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

Commit e1add581 authored by Nate Myren's avatar Nate Myren Committed by Android (Google) Code Review
Browse files

Merge "Remove R QPR attribution hacks" into sc-dev

parents 491112e2 f882feea
Loading
Loading
Loading
Loading
+3 −27
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@ import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.UserManager;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.LongSparseArray;
@@ -8114,8 +8113,8 @@ public class AppOpsManager {
                } else if (collectionMode == COLLECT_SYNC
                        // Only collect app-ops when the proxy is trusted
                        && (mContext.checkPermission(Manifest.permission.UPDATE_APP_OPS_STATS, -1,
                        myUid) == PackageManager.PERMISSION_GRANTED || isTrustedVoiceServiceProxy(
                        mContext, mContext.getOpPackageName(), op, mContext.getUserId()))) {
                        myUid) == PackageManager.PERMISSION_GRANTED ||
                        Binder.getCallingUid() == proxiedUid)) {
                    collectNotedOpSync(op, proxiedAttributionTag);
                }
            }
@@ -8126,28 +8125,6 @@ public class AppOpsManager {
        }
    }

    /**
     * Checks if the voice recognition service is a trust proxy.
     *
     * @return {@code true} if the package is a trust voice recognition service proxy
     * @hide
     */
    public static boolean isTrustedVoiceServiceProxy(Context context, String packageName,
            int code, int userId) {
        // This is a workaround for R QPR, new API change is not allowed. We only allow the current
        // voice recognizer is also the voice interactor to noteproxy op.
        if (code != OP_RECORD_AUDIO) {
            return false;
        }
        final String voiceRecognitionComponent = Settings.Secure.getStringForUser(
                context.getContentResolver(), Settings.Secure.VOICE_RECOGNITION_SERVICE, userId);

        final String voiceRecognitionServicePackageName =
                getComponentPackageNameFromString(voiceRecognitionComponent);
        return (Objects.equals(packageName, voiceRecognitionServicePackageName))
                && isPackagePreInstalled(context, packageName, userId);
    }

    private static String getComponentPackageNameFromString(String from) {
        ComponentName componentName = from != null ? ComponentName.unflattenFromString(from) : null;
        return componentName != null ? componentName.getPackageName() : "";
@@ -8522,8 +8499,7 @@ public class AppOpsManager {
                        // Only collect app-ops when the proxy is trusted
                        && (mContext.checkPermission(Manifest.permission.UPDATE_APP_OPS_STATS, -1,
                        Process.myUid()) == PackageManager.PERMISSION_GRANTED
                        || isTrustedVoiceServiceProxy(mContext, mContext.getOpPackageName(), opInt,
                        mContext.getUserId()))) {
                        || Binder.getCallingUid() == proxiedUid)) {
                    collectNotedOpSync(opInt, proxiedAttributionTag);
                }
            }
+22 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.content.pm.ParceledListSlice;
import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
import android.content.pm.permission.SplitPermissionInfoParcelable;
import android.location.LocationManager;
import android.media.AudioManager;
import android.os.Build;
import android.os.Handler;
@@ -50,12 +51,14 @@ import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.DebugUtils;
import android.util.Log;
import android.util.Slog;

import com.android.internal.R;
import com.android.internal.annotations.Immutable;
import com.android.internal.util.CollectionUtils;

@@ -82,6 +85,8 @@ public final class PermissionManager {
    public static final String KILL_APP_REASON_GIDS_CHANGED =
            "permission grant or revoke changed gids";

    private static final String SYSTEM_PKG = "android";

    /**
     * Refuse to install package if groups of permissions are bad
     * - Permission groups should only be shared between apps sharing a certificate
@@ -856,6 +861,23 @@ public final class PermissionManager {
        return mUsageHelper.getOpUsageData(new AudioManager().isMicrophoneMute());
    }

    /**
     * Check if this package/op combination is exempted from indicators
     * @return
     * @hide
     */
    public static boolean isSpecialCaseShownIndicator(@NonNull Context context,
            @NonNull String packageName) {

        if (packageName.equals(SYSTEM_PKG)) {
            return false;
        }

        return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY, "permissions_hub_2_enabled",
                false)
                || packageName.equals(context.getString(R.string.config_systemSpeechRecognizer))
                || context.getSystemService(LocationManager.class).isProviderPackage(packageName);
    }
    /**
     * Gets the list of packages that have permissions that specified
     * {@code requestDontAutoRevokePermissions=true} in their
+104 −430

File changed.

Preview size limit exceeded, changes collapsed.

+2 −10
Original line number Diff line number Diff line
@@ -3091,14 +3091,10 @@ public class AppOpsService extends IAppOpsService.Stub {
            return AppOpsManager.MODE_IGNORED;
        }

        // This is a workaround for R QPR, new API change is not allowed. We only allow the current
        // voice recognizer is also the voice interactor to noteproxy op.
        final boolean isTrustVoiceServiceProxy = AppOpsManager.isTrustedVoiceServiceProxy(mContext,
                proxyPackageName, code, UserHandle.getUserId(proxyUid));
        final boolean isSelfBlame = Binder.getCallingUid() == proxiedUid;
        final boolean isProxyTrusted = mContext.checkPermission(
                Manifest.permission.UPDATE_APP_OPS_STATS, -1, proxyUid)
                == PackageManager.PERMISSION_GRANTED || isTrustVoiceServiceProxy || isSelfBlame;
                == PackageManager.PERMISSION_GRANTED || isSelfBlame;

        final int proxyFlags = isProxyTrusted ? AppOpsManager.OP_FLAG_TRUSTED_PROXY
                : AppOpsManager.OP_FLAG_UNTRUSTED_PROXY;
@@ -3576,14 +3572,10 @@ public class AppOpsService extends IAppOpsService.Stub {
            return AppOpsManager.MODE_IGNORED;
        }

        // This is a workaround for R QPR, new API change is not allowed. We only allow the current
        // voice recognizer is also the voice interactor to noteproxy op.
        final boolean isTrustVoiceServiceProxy = AppOpsManager.isTrustedVoiceServiceProxy(mContext,
                proxyPackageName, code, UserHandle.getUserId(proxyUid));
        final boolean isSelfBlame = Binder.getCallingUid() == proxiedUid;
        final boolean isProxyTrusted = mContext.checkPermission(
                Manifest.permission.UPDATE_APP_OPS_STATS, -1, proxyUid)
                == PackageManager.PERMISSION_GRANTED || isTrustVoiceServiceProxy || isSelfBlame;
                == PackageManager.PERMISSION_GRANTED || isSelfBlame;

        final int proxyFlags = isProxyTrusted ? AppOpsManager.OP_FLAG_TRUSTED_PROXY
                : AppOpsManager.OP_FLAG_UNTRUSTED_PROXY;