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

Commit a8440fe3 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Clean UserHandle / UserManager hidden api call"

parents 802b930d 5d03facb
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Binder;
@@ -332,9 +331,10 @@ public final class Utils {
    }

    public static boolean checkCaller() {
        int callingUser = UserHandle.getCallingUserId();
        int callingUid = Binder.getCallingUid();
        return (sForegroundUserId == callingUser)
        UserHandle callingUser = UserHandle.getUserHandleForUid(callingUid);

        return (sForegroundUserId == callingUser.getIdentifier())
                || (UserHandle.getAppId(sSystemUiUid) == UserHandle.getAppId(callingUid))
                || (UserHandle.getAppId(Process.SYSTEM_UID) == UserHandle.getAppId(callingUid));
    }
@@ -343,18 +343,19 @@ public final class Utils {
        if (mContext == null) {
            return checkCaller();
        }
        int callingUser = UserHandle.getCallingUserId();
        int callingUid = Binder.getCallingUid();
        UserHandle callingUser = UserHandle.getUserHandleForUid(callingUid);

        // Use the Bluetooth process identity when making call to get parent user
        final long ident = Binder.clearCallingIdentity();
        try {
            UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
            UserInfo ui = um.getProfileParent(callingUser);
            int parentUser = (ui != null) ? ui.id : UserHandle.USER_NULL;
            UserHandle uh = um.getProfileParent(callingUser);
            int parentUser = (uh != null) ? uh.getIdentifier() : UserHandle.USER_NULL;

            // Always allow SystemUI/System access.
            return (sForegroundUserId == callingUser) || (sForegroundUserId == parentUser)
            return (sForegroundUserId == callingUser.getIdentifier())
                    || (sForegroundUserId == parentUser)
                    || (UserHandle.getAppId(sSystemUiUid) == UserHandle.getAppId(callingUid))
                    || (UserHandle.getAppId(Process.SYSTEM_UID) == UserHandle.getAppId(callingUid));
        } catch (Exception ex) {
+1 −1
Original line number Diff line number Diff line
@@ -2390,7 +2390,7 @@ public class AdapterService extends Service {
    }

    boolean startDiscovery(String callingPackage, @Nullable String callingFeatureId) {
        UserHandle callingUser = UserHandle.of(UserHandle.getCallingUserId());
        UserHandle callingUser = Binder.getCallingUserHandle();
        debugLog("startDiscovery");
        mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
        boolean isQApp = Utils.isQApp(this, callingPackage);
+1 −1
Original line number Diff line number Diff line
@@ -261,7 +261,7 @@ public abstract class ProfileService extends Service {
        int currentUserId = ActivityManager.getCurrentUser();
        setCurrentUser(currentUserId);
        UserManager userManager = UserManager.get(getApplicationContext());
        if (userManager.isUserUnlocked(currentUserId)) {
        if (userManager.isUserUnlocked(UserHandle.of(currentUserId))) {
            setUserUnlocked(currentUserId);
        }
        mProfileStarted = start();
+3 −3
Original line number Diff line number Diff line
@@ -2141,7 +2141,7 @@ public class GattService extends ProfileService {
        if (DBG) {
            Log.d(TAG, "start scan with filters");
        }
        UserHandle callingUser = UserHandle.of(UserHandle.getCallingUserId());

        enforceAdminPermission();
        if (needsPrivilegedPermissionForScan(settings)) {
            enforcePrivilegedPermission();
@@ -2149,7 +2149,7 @@ public class GattService extends ProfileService {
        settings = enforceReportDelayFloor(settings);
        enforcePrivilegedPermissionIfNeeded(filters);
        final ScanClient scanClient = new ScanClient(scannerId, settings, filters, storages);
        scanClient.userHandle = UserHandle.of(UserHandle.getCallingUserId());
        scanClient.userHandle = Binder.getCallingUserHandle();
        mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
        scanClient.eligibleForSanitizedExposureNotification =
                callingPackage.equals(mExposureNotificationPackage);
@@ -2216,7 +2216,7 @@ public class GattService extends ProfileService {

        pendingIntent.registerCancelListener(mScanIntentCancelListener);

        app.mUserHandle = UserHandle.of(UserHandle.getCallingUserId());
        app.mUserHandle = UserHandle.getUserHandleForUid(Binder.getCallingUid());
        mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
        app.mEligibleForSanitizedExposureNotification =
                callingPackage.equals(mExposureNotificationPackage);
+2 −2
Original line number Diff line number Diff line
@@ -15,8 +15,8 @@
 */
package com.android.bluetooth.mapclient;

import android.os.Binder;
import android.os.SystemProperties;
import android.os.UserHandle;

import com.android.bluetooth.Utils;
import com.android.internal.annotations.VisibleForTesting;
@@ -34,7 +34,7 @@ class MapUtils {
    }

    static boolean isSystemUser() {
        return UserHandle.getCallingUserId() == UserHandle.USER_SYSTEM;
        return Binder.getCallingUserHandle().isSystem();
    }

    static MnsService newMnsServiceInstance(MapClientService mapClientService) {
Loading