Merge "Get ApplicationInfo using usr id" into rvc-qpr-dev am: 19e9f00346

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13274693

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I8e65f3622eec6e15ea5266b81092de6be862038d
This commit is contained in:
Joanne Chung
2021-01-15 08:40:21 +00:00
committed by Automerger Merge Worker
2 changed files with 8 additions and 8 deletions

View File

@@ -7614,8 +7614,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))) {
myUid) == PackageManager.PERMISSION_GRANTED || isTrustedVoiceServiceProxy(
mContext, mContext.getOpPackageName(), op, mContext.getUserId()))) {
collectNotedOpSync(op, proxiedAttributionTag);
}
}
@@ -7633,7 +7633,7 @@ public class AppOpsManager {
* @hide
*/
public static boolean isTrustedVoiceServiceProxy(Context context, String packageName,
int code) {
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) {
@@ -7645,7 +7645,7 @@ public class AppOpsManager {
final String voiceRecognitionServicePackageName =
getComponentPackageNameFromString(voiceRecognitionComponent);
return (Objects.equals(packageName, voiceRecognitionServicePackageName))
&& isPackagePreInstalled(context, packageName);
&& isPackagePreInstalled(context, packageName, userId);
}
private static String getComponentPackageNameFromString(String from) {
@@ -7653,10 +7653,10 @@ public class AppOpsManager {
return componentName != null ? componentName.getPackageName() : "";
}
private static boolean isPackagePreInstalled(Context context, String packageName) {
private static boolean isPackagePreInstalled(Context context, String packageName, int userId) {
try {
final PackageManager pm = context.getPackageManager();
final ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
final ApplicationInfo info = pm.getApplicationInfoAsUser(packageName, 0, userId);
return ((info.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
} catch (PackageManager.NameNotFoundException e) {
return false;

View File

@@ -3014,8 +3014,8 @@ public class AppOpsService extends IAppOpsService.Stub {
// 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);
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)