Merge "Mark apexd session as successful before marking staged session applied"
This commit is contained in:
committed by
Android (Google) Code Review
commit
623a9c6dc7
@@ -166,6 +166,27 @@ class ApexManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks a staged session as successful.
|
||||
*
|
||||
* <p>Only activated session can be marked as successful.
|
||||
*
|
||||
* @param sessionId the identifier of the {@link PackageInstallerSession} being marked as
|
||||
* successful.
|
||||
*/
|
||||
void markStagedSessionSuccessful(int sessionId) {
|
||||
try {
|
||||
mApexService.markStagedSessionSuccessful(sessionId);
|
||||
} catch (RemoteException re) {
|
||||
Slog.e(TAG, "Unable to contact apexservice", re);
|
||||
throw new RuntimeException(re);
|
||||
} catch (Exception e) {
|
||||
// It is fine to just log an exception in this case. APEXd will be able to recover in
|
||||
// case markStagedSessionSuccessful fails.
|
||||
Slog.e(TAG, "Failed to mark session " + sessionId + " as successful", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps various state information to the provided {@link PrintWriter} object.
|
||||
*
|
||||
@@ -196,7 +217,7 @@ class ApexManager {
|
||||
ipw.increaseIndent();
|
||||
final ApexSessionInfo[] sessions = mApexService.getSessions();
|
||||
for (ApexSessionInfo si : sessions) {
|
||||
ipw.println("Session ID: " + Integer.toString(si.sessionId));
|
||||
ipw.println("Session ID: " + si.sessionId);
|
||||
ipw.increaseIndent();
|
||||
if (si.isUnknown) {
|
||||
ipw.println("State: UNKNOWN");
|
||||
|
||||
@@ -247,7 +247,8 @@ public class StagingManager {
|
||||
}
|
||||
|
||||
private void resumeSession(@NonNull PackageInstallerSession session) {
|
||||
if (sessionContainsApex(session)) {
|
||||
boolean hasApex = sessionContainsApex(session);
|
||||
if (hasApex) {
|
||||
// Check with apexservice whether the apex packages have been activated.
|
||||
ApexSessionInfo apexSessionInfo = mApexManager.getStagedSessionInfo(session.sessionId);
|
||||
if (apexSessionInfo == null) {
|
||||
@@ -271,7 +272,7 @@ public class StagingManager {
|
||||
mBgHandler.post(() -> preRebootVerification(session));
|
||||
return;
|
||||
}
|
||||
if (!apexSessionInfo.isActivated) {
|
||||
if (!apexSessionInfo.isActivated && !apexSessionInfo.isSuccess) {
|
||||
// In all the remaining cases apexd will try to apply the session again at next
|
||||
// boot. Nothing to do here for now.
|
||||
Slog.w(TAG, "Staged session " + session.sessionId + " scheduled to be applied "
|
||||
@@ -287,7 +288,11 @@ public class StagingManager {
|
||||
+ "more information.");
|
||||
return;
|
||||
}
|
||||
|
||||
session.setStagedSessionApplied();
|
||||
if (hasApex) {
|
||||
mApexManager.markStagedSessionSuccessful(session.sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
private String findFirstAPKInDir(File stageDir) {
|
||||
|
||||
Reference in New Issue
Block a user