Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 4db95cc

Browse files
nioffeAndroid (Google) Code Review
authored andcommitted
Merge "allocateSpaceForUpdate: clear calling identity before calling into apexd." into sc-dev
2 parents 410dd5b + 8f0fa02 commit 4db95cc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

services/core/java/com/android/server/recoverysystem/RecoverySystemService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,11 +961,13 @@ private static CompressedApexInfoList getCompressedApexInfoList(String packageFi
961961

962962
@Override
963963
public boolean allocateSpaceForUpdate(String packageFile) {
964+
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.RECOVERY, null);
964965
if (!isUpdatableApexSupported()) {
965966
Log.i(TAG, "Updatable Apex not supported, "
966967
+ "allocateSpaceForUpdate does nothing.");
967968
return true;
968969
}
970+
final long token = Binder.clearCallingIdentity();
969971
try {
970972
CompressedApexInfoList apexInfoList = getCompressedApexInfoList(packageFile);
971973
ApexManager apexManager = ApexManager.getInstance();
@@ -975,6 +977,8 @@ public boolean allocateSpaceForUpdate(String packageFile) {
975977
e.rethrowAsRuntimeException();
976978
} catch (IOException | UnsupportedOperationException e) {
977979
Slog.e(TAG, "Failed to reserve space for compressed apex: ", e);
980+
} finally {
981+
Binder.restoreCallingIdentity(token);
978982
}
979983
return false;
980984
}

0 commit comments

Comments
 (0)