Loading services/core/java/com/android/server/pm/PackageInstallerSession.java +24 −8 Original line number Original line Diff line number Diff line Loading @@ -1168,9 +1168,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { // as appropriate once all children have been processed // as appropriate once all children have been processed try { try { PackageInstallerSession session = mSessionProvider.getSession(childSessionId); PackageInstallerSession session = mSessionProvider.getSession(childSessionId); if (!session.streamValidateAndCommit()) { allSessionsReady &= session.streamValidateAndCommit(); allSessionsReady = false; } nonFailingSessions.add(session); nonFailingSessions.add(session); } catch (PackageManagerException e) { } catch (PackageManagerException e) { allSessionsReady = false; allSessionsReady = false; Loading @@ -1179,10 +1177,14 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { } } } } } } // If we encountered any unrecoverable failures, destroy all // If we encountered any unrecoverable failures, destroy all other sessions including // other impacted sessions besides the parent; that will be cleaned up by the // the parent // ChildStatusIntentReceiver. if (unrecoverableFailure != null) { if (unrecoverableFailure != null) { // {@link #streamValidateAndCommit()} calls // {@link #onSessionVerificationFailure(PackageManagerException)}, but we don't // expect it to ever do so for parent sessions. Call that on this parent to clean // it up and notify listeners of the error. onSessionVerificationFailure(unrecoverableFailure); // fail other child sessions that did not already fail // fail other child sessions that did not already fail for (int i = nonFailingSessions.size() - 1; i >= 0; --i) { for (int i = nonFailingSessions.size() - 1; i >= 0; --i) { PackageInstallerSession session = nonFailingSessions.get(i); PackageInstallerSession session = nonFailingSessions.get(i); Loading Loading @@ -1249,6 +1251,15 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { public void statusUpdate(Intent intent) { public void statusUpdate(Intent intent) { mHandler.post(() -> { mHandler.post(() -> { if (mChildSessionsRemaining.size() == 0) { if (mChildSessionsRemaining.size() == 0) { // no children to deal with, ignore. return; } final boolean destroyed; synchronized (mLock) { destroyed = mDestroyed; } if (destroyed) { // the parent has already been terminated, ignore. return; return; } } final int sessionId = intent.getIntExtra( final int sessionId = intent.getIntExtra( Loading @@ -1275,8 +1286,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { intent.putExtra(PackageInstaller.EXTRA_SESSION_ID, intent.putExtra(PackageInstaller.EXTRA_SESSION_ID, PackageInstallerSession.this.sessionId); PackageInstallerSession.this.sessionId); mChildSessionsRemaining.clear(); // we're done. Don't send any more. mChildSessionsRemaining.clear(); // we're done. Don't send any more. onSessionVerificationFailure(status, try { intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE)); mStatusReceiver.sendIntent(mContext, 0, intent, null, null); } catch (IntentSender.SendIntentException ignore) { } } } }); }); } } Loading Loading @@ -1389,6 +1402,9 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { * @throws PackageManagerException on an unrecoverable error. * @throws PackageManagerException on an unrecoverable error. */ */ private boolean streamValidateAndCommit() throws PackageManagerException { private boolean streamValidateAndCommit() throws PackageManagerException { // TODO(patb): since the work done here for a parent session in a multi-package install is // mostly superficial, consider splitting this method for the parent and // single / child sessions. synchronized (mLock) { synchronized (mLock) { if (mCommitted) { if (mCommitted) { return true; return true; Loading Loading
services/core/java/com/android/server/pm/PackageInstallerSession.java +24 −8 Original line number Original line Diff line number Diff line Loading @@ -1168,9 +1168,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { // as appropriate once all children have been processed // as appropriate once all children have been processed try { try { PackageInstallerSession session = mSessionProvider.getSession(childSessionId); PackageInstallerSession session = mSessionProvider.getSession(childSessionId); if (!session.streamValidateAndCommit()) { allSessionsReady &= session.streamValidateAndCommit(); allSessionsReady = false; } nonFailingSessions.add(session); nonFailingSessions.add(session); } catch (PackageManagerException e) { } catch (PackageManagerException e) { allSessionsReady = false; allSessionsReady = false; Loading @@ -1179,10 +1177,14 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { } } } } } } // If we encountered any unrecoverable failures, destroy all // If we encountered any unrecoverable failures, destroy all other sessions including // other impacted sessions besides the parent; that will be cleaned up by the // the parent // ChildStatusIntentReceiver. if (unrecoverableFailure != null) { if (unrecoverableFailure != null) { // {@link #streamValidateAndCommit()} calls // {@link #onSessionVerificationFailure(PackageManagerException)}, but we don't // expect it to ever do so for parent sessions. Call that on this parent to clean // it up and notify listeners of the error. onSessionVerificationFailure(unrecoverableFailure); // fail other child sessions that did not already fail // fail other child sessions that did not already fail for (int i = nonFailingSessions.size() - 1; i >= 0; --i) { for (int i = nonFailingSessions.size() - 1; i >= 0; --i) { PackageInstallerSession session = nonFailingSessions.get(i); PackageInstallerSession session = nonFailingSessions.get(i); Loading Loading @@ -1249,6 +1251,15 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { public void statusUpdate(Intent intent) { public void statusUpdate(Intent intent) { mHandler.post(() -> { mHandler.post(() -> { if (mChildSessionsRemaining.size() == 0) { if (mChildSessionsRemaining.size() == 0) { // no children to deal with, ignore. return; } final boolean destroyed; synchronized (mLock) { destroyed = mDestroyed; } if (destroyed) { // the parent has already been terminated, ignore. return; return; } } final int sessionId = intent.getIntExtra( final int sessionId = intent.getIntExtra( Loading @@ -1275,8 +1286,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { intent.putExtra(PackageInstaller.EXTRA_SESSION_ID, intent.putExtra(PackageInstaller.EXTRA_SESSION_ID, PackageInstallerSession.this.sessionId); PackageInstallerSession.this.sessionId); mChildSessionsRemaining.clear(); // we're done. Don't send any more. mChildSessionsRemaining.clear(); // we're done. Don't send any more. onSessionVerificationFailure(status, try { intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE)); mStatusReceiver.sendIntent(mContext, 0, intent, null, null); } catch (IntentSender.SendIntentException ignore) { } } } }); }); } } Loading Loading @@ -1389,6 +1402,9 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { * @throws PackageManagerException on an unrecoverable error. * @throws PackageManagerException on an unrecoverable error. */ */ private boolean streamValidateAndCommit() throws PackageManagerException { private boolean streamValidateAndCommit() throws PackageManagerException { // TODO(patb): since the work done here for a parent session in a multi-package install is // mostly superficial, consider splitting this method for the parent and // single / child sessions. synchronized (mLock) { synchronized (mLock) { if (mCommitted) { if (mCommitted) { return true; return true; Loading