Ensure the calling identity is restored
To follow the security checker guideline, go/android-security-checker
Bug: 304519474
Test: wm presubmit
Change-Id: Id4aeeec7d9ff4d347c15f6f714ad1917c3513fd6
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index 27315bb..7cccf6b 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -707,7 +707,7 @@
}
}
- int res;
+ int res = START_CANCELED;
synchronized (mService.mGlobalLock) {
final boolean globalConfigWillChange = mRequest.globalConfig != null
&& mService.getGlobalConfiguration().diff(mRequest.globalConfig) != 0;
@@ -719,22 +719,20 @@
+ "will change = %b", globalConfigWillChange);
final long origId = Binder.clearCallingIdentity();
-
- res = resolveToHeavyWeightSwitcherIfNeeded();
- if (res != START_SUCCESS) {
- return res;
- }
-
try {
+ res = resolveToHeavyWeightSwitcherIfNeeded();
+ if (res != START_SUCCESS) {
+ return res;
+ }
+
res = executeRequest(mRequest);
} finally {
+ Binder.restoreCallingIdentity(origId);
mRequest.logMessage.append(" result code=").append(res);
Slog.i(TAG, mRequest.logMessage.toString());
mRequest.logMessage.setLength(0);
}
- Binder.restoreCallingIdentity(origId);
-
if (globalConfigWillChange) {
// If the caller also wants to switch to a new configuration, do so now.
// This allows a clean switch, as we are waiting for the current activity