diff options
| author | 2017-04-04 15:16:36 -0700 | |
|---|---|---|
| committer | 2017-04-06 10:40:22 -0700 | |
| commit | c33cbb21e8cc3d3501fc53c45e9263274c524d85 (patch) | |
| tree | 51e2135c6eed4ae1457a905c2252f357ce6fc348 | |
| parent | 0b47e289c86a271d1cddd8267178f788bfb2ef06 (diff) | |
change how instant app installer is updated
. only pay attention to package changes if there's no
installer or the changed package is the installer
. always update the installer component, even if the
resolved component is identical [the install paths
might have updated]
Change-Id: I16eba07ccdb55f5cb61ba6172e71ce1698445fa5
Fixes: 36740490
Test: Manually install/remove/update the installer and see that the component is updated
| -rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 01847aeb919b..ce4d7ee7a523 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -849,8 +849,7 @@ public class PackageManagerService extends IPackageManager.Stub { /** Component used to show resolver settings for Instant Apps */ final ComponentName mInstantAppResolverSettingsComponent; - /** Component used to install ephemeral applications */ - ComponentName mInstantAppInstallerComponent; + /** Activity used to install instant applications */ ActivityInfo mInstantAppInstallerActivity; final ResolveInfo mInstantAppInstallerInfo = new ResolveInfo(); @@ -2829,7 +2828,7 @@ public class PackageManagerService extends IPackageManager.Stub { mInstantAppResolverConnection = null; mInstantAppResolverSettingsComponent = null; } - updateInstantAppInstallerLocked(); + updateInstantAppInstallerLocked(null); // Read and update the usage of dex files. // Do this at the end of PM init so that all the packages have their @@ -2869,22 +2868,15 @@ public class PackageManagerService extends IPackageManager.Stub { Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); } - private void updateInstantAppInstallerLocked() { - final ComponentName oldInstantAppInstallerComponent = mInstantAppInstallerComponent; - final ActivityInfo newInstantAppInstaller = getInstantAppInstallerLPr(); - ComponentName newInstantAppInstallerComponent = newInstantAppInstaller == null - ? null : newInstantAppInstaller.getComponentName(); - - if (newInstantAppInstallerComponent != null - && !newInstantAppInstallerComponent.equals(oldInstantAppInstallerComponent)) { - if (DEBUG_EPHEMERAL) { - Slog.d(TAG, "Set ephemeral installer: " + newInstantAppInstallerComponent); - } - setUpInstantAppInstallerActivityLP(newInstantAppInstaller); - } else if (DEBUG_EPHEMERAL && newInstantAppInstallerComponent == null) { - Slog.d(TAG, "Unset ephemeral installer; none available"); + private void updateInstantAppInstallerLocked(String modifiedPackage) { + // we're only interested in updating the installer appliction when 1) it's not + // already set or 2) the modified package is the installer + if (mInstantAppInstallerActivity != null + && !mInstantAppInstallerActivity.getComponentName().getPackageName() + .equals(modifiedPackage)) { + return; } - mInstantAppInstallerComponent = newInstantAppInstallerComponent; + setUpInstantAppInstallerActivityLP(getInstantAppInstallerLPr()); } private static File preparePackageParserCache(boolean isUpgrade) { @@ -5737,7 +5729,7 @@ public class PackageManagerService extends IPackageManager.Stub { if (mInstantAppResolverConnection == null) { return false; } - if (mInstantAppInstallerComponent == null) { + if (mInstantAppInstallerActivity == null) { return false; } if (intent.getComponent() != null) { @@ -17092,7 +17084,7 @@ public class PackageManagerService extends IPackageManager.Stub { if (res.returnCode == PackageManager.INSTALL_SUCCEEDED) { updateSequenceNumberLP(pkgName, res.newUsers); - updateInstantAppInstallerLocked(); + updateInstantAppInstallerLocked(pkgName); } } } @@ -17668,7 +17660,7 @@ public class PackageManagerService extends IPackageManager.Stub { mInstantAppRegistry.onPackageUninstalledLPw(pkg, info.removedUsers); } updateSequenceNumberLP(packageName, info.removedUsers); - updateInstantAppInstallerLocked(); + updateInstantAppInstallerLocked(packageName); } } } @@ -20031,7 +20023,7 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName()); updateSequenceNumberLP(packageName, new int[] { userId }); final long callingId = Binder.clearCallingIdentity(); try { - updateInstantAppInstallerLocked(); + updateInstantAppInstallerLocked(packageName); } finally { Binder.restoreCallingIdentity(callingId); } @@ -23223,7 +23215,8 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName()); @Override public boolean isInstantAppInstallerComponent(ComponentName component) { synchronized (mPackages) { - return component != null && component.equals(mInstantAppInstallerComponent); + return mInstantAppInstallerActivity != null + && mInstantAppInstallerActivity.getComponentName().equals(component); } } |