Merge "Initial Binder interface for installd."

This commit is contained in:
Jeff Sharkey
2016-12-06 00:14:53 +00:00
committed by Gerrit Code Review
2 changed files with 23 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ LOCAL_SRC_FILES += \
java/com/android/server/am/EventLogTags.logtags \ java/com/android/server/am/EventLogTags.logtags \
../../../../system/netd/server/binder/android/net/INetd.aidl \ ../../../../system/netd/server/binder/android/net/INetd.aidl \
../../../../system/netd/server/binder/android/net/metrics/INetdEventListener.aidl \ ../../../../system/netd/server/binder/android/net/metrics/INetdEventListener.aidl \
../../../native/cmds/installd/binder/android/os/IInstalld.aidl \
LOCAL_AIDL_INCLUDES += \ LOCAL_AIDL_INCLUDES += \
system/netd/server/binder system/netd/server/binder

View File

@@ -20,6 +20,10 @@ import android.annotation.Nullable;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageStats; import android.content.pm.PackageStats;
import android.os.Build; import android.os.Build;
import android.os.IInstalld;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceSpecificException;
import android.util.Slog; import android.util.Slog;
import com.android.internal.os.InstallerConnection; import com.android.internal.os.InstallerConnection;
@@ -33,6 +37,8 @@ import java.util.Arrays;
public final class Installer extends SystemService { public final class Installer extends SystemService {
private static final String TAG = "Installer"; private static final String TAG = "Installer";
private static final boolean USE_BINDER = true;
/* *************************************************************************** /* ***************************************************************************
* IMPORTANT: These values are passed to native code. Keep them in sync with * IMPORTANT: These values are passed to native code. Keep them in sync with
* frameworks/native/cmds/installd/installd.h * frameworks/native/cmds/installd/installd.h
@@ -55,10 +61,13 @@ public final class Installer extends SystemService {
public static final int FLAG_CLEAR_CODE_CACHE_ONLY = 1 << 9; public static final int FLAG_CLEAR_CODE_CACHE_ONLY = 1 << 9;
private final InstallerConnection mInstaller; private final InstallerConnection mInstaller;
private final IInstalld mInstalld;
public Installer(Context context) { public Installer(Context context) {
super(context); super(context);
mInstaller = new InstallerConnection(); mInstaller = new InstallerConnection();
// TODO: reconnect if installd restarts
mInstalld = IInstalld.Stub.asInterface(ServiceManager.getService("installd"));
} }
// Package-private installer that accepts a custom InstallerConnection. Used for // Package-private installer that accepts a custom InstallerConnection. Used for
@@ -66,6 +75,8 @@ public final class Installer extends SystemService {
Installer(Context context, InstallerConnection connection) { Installer(Context context, InstallerConnection connection) {
super(context); super(context);
mInstaller = connection; mInstaller = connection;
// TODO: reconnect if installd restarts
mInstalld = IInstalld.Stub.asInterface(ServiceManager.getService("installd"));
} }
/** /**
@@ -84,8 +95,17 @@ public final class Installer extends SystemService {
public void createAppData(String uuid, String pkgname, int userid, int flags, int appid, public void createAppData(String uuid, String pkgname, int userid, int flags, int appid,
String seinfo, int targetSdkVersion) throws InstallerException { String seinfo, int targetSdkVersion) throws InstallerException {
mInstaller.execute("create_app_data", uuid, pkgname, userid, flags, appid, seinfo, if (USE_BINDER) {
targetSdkVersion); try {
mInstalld.createAppData(uuid, pkgname, userid, flags, appid, seinfo,
targetSdkVersion);
} catch (RemoteException | ServiceSpecificException e) {
throw new InstallerException(e.getMessage());
}
} else {
mInstaller.execute("create_app_data", uuid, pkgname, userid, flags, appid, seinfo,
targetSdkVersion);
}
} }
public void restoreconAppData(String uuid, String pkgname, int userid, int flags, int appid, public void restoreconAppData(String uuid, String pkgname, int userid, int flags, int appid,