Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 855254eb authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by android-build-merger
Browse files

Merge "Drop uses-feature requirement for system process" into oc-dev am: 8ba6fdb3

am: fd991c42

Change-Id: I5c88fc5bb941ede9d30853b182a7bd5bf58a8f84
parents fc92b9ff fd991c42
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -244,7 +244,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
        }

        private void checkCallerIsSystemOr(String pkg, int userId) throws RemoteException {
            if (getCallingUserId() == UserHandle.USER_SYSTEM) {
            if (isCallerSystem()) {
                return;
            }

@@ -294,6 +294,11 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
        }

        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);
@@ -306,10 +311,14 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
        }
    }

    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,