Merge "TEMP add app ops debug logs" into sc-dev
This commit is contained in:
@@ -3351,10 +3351,21 @@ public class AppOpsService extends IAppOpsService.Stub {
|
|||||||
boolean shouldCollectMessage) {
|
boolean shouldCollectMessage) {
|
||||||
RestrictionBypass bypass;
|
RestrictionBypass bypass;
|
||||||
try {
|
try {
|
||||||
bypass = verifyAndGetBypass(uid, packageName, attributionTag, proxyPackageName);
|
boolean isLocOrActivity = code == AppOpsManager.OP_FINE_LOCATION
|
||||||
|
|| code == AppOpsManager.OP_FINE_LOCATION_SOURCE
|
||||||
|
|| code == AppOpsManager.OP_ACTIVITY_RECOGNITION
|
||||||
|
|| code == AppOpsManager.OP_ACTIVITY_RECOGNITION_SOURCE;
|
||||||
|
bypass = verifyAndGetBypass(uid, packageName, attributionTag, proxyPackageName,
|
||||||
|
isLocOrActivity);
|
||||||
|
boolean wasNull = attributionTag == null;
|
||||||
if (bypass != null && bypass.getIsAttributionTagNotFound()) {
|
if (bypass != null && bypass.getIsAttributionTagNotFound()) {
|
||||||
attributionTag = null;
|
attributionTag = null;
|
||||||
}
|
}
|
||||||
|
if (attributionTag == null && isLocOrActivity
|
||||||
|
&& packageName.equals("com.google.android.gms")) {
|
||||||
|
Slog.i("AppOpsDebug", "null tag on location or activity op " + code
|
||||||
|
+ " for " + packageName + ", was overridden: " + !wasNull, new Exception());
|
||||||
|
}
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
Slog.e(TAG, "noteOperation", e);
|
Slog.e(TAG, "noteOperation", e);
|
||||||
return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag,
|
return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag,
|
||||||
@@ -3861,10 +3872,20 @@ public class AppOpsService extends IAppOpsService.Stub {
|
|||||||
int attributionChainId, boolean dryRun) {
|
int attributionChainId, boolean dryRun) {
|
||||||
RestrictionBypass bypass;
|
RestrictionBypass bypass;
|
||||||
try {
|
try {
|
||||||
bypass = verifyAndGetBypass(uid, packageName, attributionTag, proxyPackageName);
|
boolean isLocOrActivity = code == AppOpsManager.OP_FINE_LOCATION
|
||||||
|
|| code == AppOpsManager.OP_FINE_LOCATION_SOURCE
|
||||||
|
|| code == AppOpsManager.OP_ACTIVITY_RECOGNITION
|
||||||
|
|| code == AppOpsManager.OP_ACTIVITY_RECOGNITION_SOURCE;
|
||||||
|
bypass = verifyAndGetBypass(uid, packageName, attributionTag, proxyPackageName,
|
||||||
|
isLocOrActivity);
|
||||||
if (bypass != null && bypass.getIsAttributionTagNotFound()) {
|
if (bypass != null && bypass.getIsAttributionTagNotFound()) {
|
||||||
attributionTag = null;
|
attributionTag = null;
|
||||||
}
|
}
|
||||||
|
if (attributionTag == null && isLocOrActivity
|
||||||
|
&& packageName.equals("com.google.android.gms")) {
|
||||||
|
Slog.i("AppOpsDebug", "null tag on location or activity op "
|
||||||
|
+ code + " for " + packageName, new Exception());
|
||||||
|
}
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
Slog.e(TAG, "startOperation", e);
|
Slog.e(TAG, "startOperation", e);
|
||||||
return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag,
|
return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag,
|
||||||
@@ -4418,7 +4439,7 @@ public class AppOpsService extends IAppOpsService.Stub {
|
|||||||
*/
|
*/
|
||||||
private @Nullable RestrictionBypass verifyAndGetBypass(int uid, String packageName,
|
private @Nullable RestrictionBypass verifyAndGetBypass(int uid, String packageName,
|
||||||
@Nullable String attributionTag) {
|
@Nullable String attributionTag) {
|
||||||
return verifyAndGetBypass(uid, packageName, attributionTag, null);
|
return verifyAndGetBypass(uid, packageName, attributionTag, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -4433,7 +4454,7 @@ public class AppOpsService extends IAppOpsService.Stub {
|
|||||||
* @return {@code true} iff the package is privileged
|
* @return {@code true} iff the package is privileged
|
||||||
*/
|
*/
|
||||||
private @Nullable RestrictionBypass verifyAndGetBypass(int uid, String packageName,
|
private @Nullable RestrictionBypass verifyAndGetBypass(int uid, String packageName,
|
||||||
@Nullable String attributionTag, @Nullable String proxyPackageName) {
|
@Nullable String attributionTag, @Nullable String proxyPackageName, boolean extraLog) {
|
||||||
if (uid == Process.ROOT_UID) {
|
if (uid == Process.ROOT_UID) {
|
||||||
// For backwards compatibility, don't check package name for root UID.
|
// For backwards compatibility, don't check package name for root UID.
|
||||||
return null;
|
return null;
|
||||||
@@ -4475,6 +4496,15 @@ public class AppOpsService extends IAppOpsService.Stub {
|
|||||||
AndroidPackage pkg = pmInt.getPackage(packageName);
|
AndroidPackage pkg = pmInt.getPackage(packageName);
|
||||||
if (pkg != null) {
|
if (pkg != null) {
|
||||||
isAttributionTagValid = isAttributionInPackage(pkg, attributionTag);
|
isAttributionTagValid = isAttributionInPackage(pkg, attributionTag);
|
||||||
|
if (packageName.equals("com.google.android.gms") && extraLog) {
|
||||||
|
if (isAttributionTagValid && attributionTag != null) {
|
||||||
|
Slog.i("AppOpsDebug", "tag " + attributionTag + " found in "
|
||||||
|
+ packageName);
|
||||||
|
} else {
|
||||||
|
Slog.i("AppOpsDebug", "tag " + attributionTag + " missing from "
|
||||||
|
+ packageName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pkgUid = UserHandle.getUid(userId, UserHandle.getAppId(pkg.getUid()));
|
pkgUid = UserHandle.getUid(userId, UserHandle.getAppId(pkg.getUid()));
|
||||||
bypass = getBypassforPackage(pkg);
|
bypass = getBypassforPackage(pkg);
|
||||||
|
|||||||
@@ -225,13 +225,21 @@ public final class AppOpsPolicy implements AppOpsManagerInternal.CheckOpsDelegat
|
|||||||
if (isDatasourceAttributionTag(uid, packageName, attributionTag,
|
if (isDatasourceAttributionTag(uid, packageName, attributionTag,
|
||||||
mLocationTags)) {
|
mLocationTags)) {
|
||||||
return resolvedCode;
|
return resolvedCode;
|
||||||
|
} else if (packageName.equals("com.google.android.gms")) {
|
||||||
|
Log.i("AppOpsDebugRemapping", "NOT remapping " + packageName + " code "
|
||||||
|
+ code + " for tag " + attributionTag);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resolvedCode = resolveArOp(code);
|
resolvedCode = resolveArOp(code);
|
||||||
if (resolvedCode != code) {
|
if (resolvedCode != code) {
|
||||||
if (isDatasourceAttributionTag(uid, packageName, attributionTag,
|
if (isDatasourceAttributionTag(uid, packageName, attributionTag,
|
||||||
mActivityRecognitionTags)) {
|
mActivityRecognitionTags)) {
|
||||||
|
Log.i("AppOpsDebugRemapping", "remapping " + packageName + " code "
|
||||||
|
+ code + " to " + resolvedCode + " for tag " + attributionTag);
|
||||||
return resolvedCode;
|
return resolvedCode;
|
||||||
|
} else if (packageName.equals("com.google.android.gms")) {
|
||||||
|
Log.i("AppOpsDebugRemapping", "NOT remapping " + packageName
|
||||||
|
+ " code " + code + " for tag " + attributionTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -334,8 +342,22 @@ public final class AppOpsPolicy implements AppOpsManagerInternal.CheckOpsDelegat
|
|||||||
if (appIdTags != null) {
|
if (appIdTags != null) {
|
||||||
final ArraySet<String> packageTags = appIdTags.get(packageName);
|
final ArraySet<String> packageTags = appIdTags.get(packageName);
|
||||||
if (packageTags != null && packageTags.contains(attributionTag)) {
|
if (packageTags != null && packageTags.contains(attributionTag)) {
|
||||||
|
if (packageName.equals("com.google.android.gms")) {
|
||||||
|
Log.i("AppOpsDebugRemapping", packageName + " tag "
|
||||||
|
+ attributionTag + " in " + packageTags);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (packageName.equals("com.google.android.gms")) {
|
||||||
|
Log.i("AppOpsDebugRemapping", packageName + " tag " + attributionTag
|
||||||
|
+ " NOT in " + packageTags);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (packageName.equals("com.google.android.gms")) {
|
||||||
|
Log.i("AppOpsDebugRemapping", "no package tags for uid " + uid
|
||||||
|
+ " package " + packageName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user