Merge "Camera: Clear identity before access device policy manager" into main

This commit is contained in:
Austin Borger
2023-07-10 20:26:19 +00:00
committed by Gerrit Code Review

View File

@@ -595,6 +595,13 @@ public class CameraServiceProxy extends SystemService
@Override @Override
public boolean isCameraDisabled(int userId) { public boolean isCameraDisabled(int userId) {
if (Binder.getCallingUid() != Process.CAMERASERVER_UID) {
Slog.e(TAG, "Calling UID: " + Binder.getCallingUid()
+ " doesn't match expected camera service UID!");
return false;
}
final long ident = Binder.clearCallingIdentity();
try {
DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class); DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class);
if (dpm == null) { if (dpm == null) {
Slog.e(TAG, "Failed to get the device policy manager service"); Slog.e(TAG, "Failed to get the device policy manager service");
@@ -606,6 +613,9 @@ public class CameraServiceProxy extends SystemService
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }
} finally {
Binder.restoreCallingIdentity(ident);
}
} }
}; };