Merge "allocateSpaceForUpdate: clear calling identity before calling into apexd." into sc-dev

This commit is contained in:
Nikita Ioffe 2021-06-22 11:55:55 +00:00 committed by Android (Google) Code Review
commit 4db95cceb9

View File

@ -961,11 +961,13 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
@Override
public boolean allocateSpaceForUpdate(String packageFile) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.RECOVERY, null);
if (!isUpdatableApexSupported()) {
Log.i(TAG, "Updatable Apex not supported, "
+ "allocateSpaceForUpdate does nothing.");
return true;
}
final long token = Binder.clearCallingIdentity();
try {
CompressedApexInfoList apexInfoList = getCompressedApexInfoList(packageFile);
ApexManager apexManager = ApexManager.getInstance();
@ -975,6 +977,8 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
e.rethrowAsRuntimeException();
} catch (IOException | UnsupportedOperationException e) {
Slog.e(TAG, "Failed to reserve space for compressed apex: ", e);
} finally {
Binder.restoreCallingIdentity(token);
}
return false;
}