Merge "Bind to DefaultContainerService early for AIA" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
68e89707f4
@@ -122,8 +122,9 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
private static final boolean LOGD = true;
|
||||
private static final String REMOVE_SPLIT_MARKER_EXTENSION = ".removed";
|
||||
|
||||
private static final int MSG_COMMIT = 0;
|
||||
private static final int MSG_ON_PACKAGE_INSTALLED = 1;
|
||||
private static final int MSG_EARLY_BIND = 0;
|
||||
private static final int MSG_COMMIT = 1;
|
||||
private static final int MSG_ON_PACKAGE_INSTALLED = 2;
|
||||
|
||||
/** XML constants used for persisting a session */
|
||||
static final String TAG_SESSION = "session";
|
||||
@@ -280,6 +281,9 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_EARLY_BIND:
|
||||
earlyBindToDefContainer();
|
||||
break;
|
||||
case MSG_COMMIT:
|
||||
synchronized (mLock) {
|
||||
try {
|
||||
@@ -315,6 +319,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
}
|
||||
};
|
||||
|
||||
private void earlyBindToDefContainer() {
|
||||
mPm.earlyBindToDefContainer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} iff the installing is app an device owner or affiliated profile owner.
|
||||
*/
|
||||
@@ -410,6 +418,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
// attempt to bind to the DefContainer as early as possible
|
||||
if ((params.installFlags & PackageManager.INSTALL_INSTANT_APP) != 0) {
|
||||
mHandler.sendMessage(mHandler.obtainMessage(MSG_EARLY_BIND));
|
||||
}
|
||||
}
|
||||
|
||||
public SessionInfo generateInfo() {
|
||||
|
||||
@@ -1326,6 +1326,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
static final int INTENT_FILTER_VERIFIED = 18;
|
||||
static final int WRITE_PACKAGE_LIST = 19;
|
||||
static final int INSTANT_APP_RESOLUTION_PHASE_TWO = 20;
|
||||
static final int DEF_CONTAINER_BIND = 21;
|
||||
|
||||
static final int WRITE_SETTINGS_DELAY = 10*1000; // 10 seconds
|
||||
|
||||
@@ -1417,8 +1418,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
new ArrayList<HandlerParams>();
|
||||
|
||||
private boolean connectToService() {
|
||||
if (DEBUG_SD_INSTALL) Log.i(TAG, "Trying to bind to" +
|
||||
" DefaultContainerService");
|
||||
if (DEBUG_INSTALL) Log.i(TAG, "Trying to bind to DefaultContainerService");
|
||||
Intent service = new Intent().setComponent(DEFAULT_CONTAINER_COMPONENT);
|
||||
Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
|
||||
if (mContext.bindServiceAsUser(service, mDefContainerConn,
|
||||
@@ -1453,6 +1453,17 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
|
||||
void doHandleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case DEF_CONTAINER_BIND:
|
||||
if (!mBound) {
|
||||
Trace.asyncTraceBegin(TRACE_TAG_PACKAGE_MANAGER, "earlyBindingMCS",
|
||||
System.identityHashCode(mHandler));
|
||||
if (!connectToService()) {
|
||||
Slog.e(TAG, "Failed to bind to media container service");
|
||||
}
|
||||
Trace.asyncTraceEnd(TRACE_TAG_PACKAGE_MANAGER, "earlyBindingMCS",
|
||||
System.identityHashCode(mHandler));
|
||||
}
|
||||
break;
|
||||
case INIT_COPY: {
|
||||
HandlerParams params = (HandlerParams) msg.obj;
|
||||
int idx = mPendingInstalls.size();
|
||||
@@ -13621,6 +13632,14 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
return installReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to bind to the default container service explicitly instead of doing so lazily on
|
||||
* install commit.
|
||||
*/
|
||||
void earlyBindToDefContainer() {
|
||||
mHandler.sendMessage(mHandler.obtainMessage(DEF_CONTAINER_BIND));
|
||||
}
|
||||
|
||||
void installStage(String packageName, File stagedDir,
|
||||
IPackageInstallObserver2 observer, PackageInstaller.SessionParams sessionParams,
|
||||
String installerPackageName, int installerUid, UserHandle user,
|
||||
|
||||
Reference in New Issue
Block a user