diff options
| author | 2022-05-07 17:46:15 +0000 | |
|---|---|---|
| committer | 2022-05-07 17:46:15 +0000 | |
| commit | cd9d42c59a8a1db4f7762b0d2ea84ded7c40a50f (patch) | |
| tree | 1656182a3f2c8c7bfb53107b64dc7900f6ba77bb | |
| parent | 0ccbe274452319b4e242d82f7c76211fea0e1c51 (diff) | |
| parent | bf7fddee01c116d2619535a1bca7d2cc3f163a62 (diff) | |
Merge "Making it possible to call setFirstBoot when mInstallD is available" into tm-dev am: bf7fddee01
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18029278
Change-Id: Ic01a0c63b88fecd26dac3862d80a159076b84a88
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | services/core/java/com/android/server/pm/Installer.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/pm/Installer.java b/services/core/java/com/android/server/pm/Installer.java index 320b06f6dc3e..32f0f109821d 100644 --- a/services/core/java/com/android/server/pm/Installer.java +++ b/services/core/java/com/android/server/pm/Installer.java @@ -119,7 +119,7 @@ public class Installer extends SystemService { IInstalld.FLAG_CLEAR_APP_DATA_KEEP_ART_PROFILES; private final boolean mIsolated; - + private volatile boolean mDeferSetFirstBoot; private volatile IInstalld mInstalld; private volatile Object mWarnIfHeld; @@ -171,6 +171,7 @@ public class Installer extends SystemService { mInstalld = IInstalld.Stub.asInterface(binder); try { invalidateMounts(); + executeDeferredActions(); } catch (InstallerException ignored) { } } else { @@ -180,6 +181,15 @@ public class Installer extends SystemService { } /** + * Perform any deferred actions on mInstalld while the connection could not be made. + */ + private void executeDeferredActions() throws InstallerException { + if (mDeferSetFirstBoot) { + setFirstBoot(); + } + } + + /** * Do several pre-flight checks before making a remote call. * * @return if the remote call should continue. @@ -291,8 +301,15 @@ public class Installer extends SystemService { return; } try { - mInstalld.setFirstBoot(); - } catch (RemoteException e) { + // mInstalld might be null if the connection could not be established. + if (mInstalld != null) { + mInstalld.setFirstBoot(); + } else { + // if it is null while trying to set the first boot, set a flag to try and set the + // first boot when the connection is eventually established + mDeferSetFirstBoot = true; + } + } catch (Exception e) { throw InstallerException.from(e); } } |