}
private void checkCallerIsSystemOr(String pkg, int userId) throws RemoteException {
- if (getCallingUserId() == UserHandle.USER_SYSTEM) {
+ if (isCallerSystem()) {
return;
}
}
private void checkUsesFeature(String pkg, int userId) {
+ if (isCallerSystem()) {
+ // Drop the requirement for calls from system process
+ return;
+ }
+
FeatureInfo[] reqFeatures = getPackageInfo(pkg, userId).reqFeatures;
String requiredFeature = PackageManager.FEATURE_COMPANION_DEVICE_SETUP;
int numFeatures = ArrayUtils.size(reqFeatures);
}
}
- private int getCallingUserId() {
+ private static int getCallingUserId() {
return UserHandle.getUserId(Binder.getCallingUid());
}
+ private static boolean isCallerSystem() {
+ return getCallingUserId() == UserHandle.USER_SYSTEM;
+ }
+
private ServiceConnection createServiceConnection(
final AssociationRequest request,
final IFindDeviceCallback findDeviceCallback,