diff options
author | Philip P. Moltmann <moltmann@google.com> | 2020-03-05 15:01:29 -0800 |
---|---|---|
committer | Philip P. Moltmann <moltmann@google.com> | 2020-03-11 23:52:32 +0000 |
commit | 8a06c2870e098efcdb24c8bcfb3b5c819ad3fcb0 (patch) | |
tree | 3260827b205512d8ea8cce78ee4dca2b057b0966 | |
parent | 7e22a40a614da198f24bfadf4f9549bc5b9ecb8b (diff) |
Rename featureId -> attributionTag
In the core functionality this changes everything including aidl's and
field names:
- Context
- ContentProvider
- AppOps*
- Package parsing
For the rest, this is a shallow change to only change to the changed
APIs. This keeps the change small-ish
Exempt-From-Owner-Approval: Rename
Fixes: 148792795
Test: TH
Change-Id: I2a2245fe76e09e62cb13d5785d2efb4a304ba54a
78 files changed, 1566 insertions, 1454 deletions
diff --git a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java index c458d1190e51..e042782af366 100644 --- a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java +++ b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java @@ -670,7 +670,7 @@ public class UserLifecycleTests { private void startApp(int userId, String packageName) throws RemoteException { final Context context = InstrumentationRegistry.getContext(); final WaitResult result = ActivityTaskManager.getService().startActivityAndWait(null, - context.getPackageName(), context.getFeatureId(), + context.getPackageName(), context.getAttributionTag(), context.getPackageManager().getLaunchIntentForPackage(packageName), null, null, null, 0, 0, null, null, userId); attestTrue("User " + userId + " failed to start " + packageName, diff --git a/api/current.txt b/api/current.txt index 5a01f7ab1fa9..1b6e998ff74a 100644 --- a/api/current.txt +++ b/api/current.txt @@ -623,7 +623,6 @@ package android { field public static final int fastScrollTextColor = 16843609; // 0x1010359 field public static final int fastScrollThumbDrawable = 16843574; // 0x1010336 field public static final int fastScrollTrackDrawable = 16843577; // 0x1010339 - field public static final int featureId = 16844301; // 0x101060d field public static final int fillAfter = 16843197; // 0x10101bd field public static final int fillAlpha = 16843980; // 0x10104cc field public static final int fillBefore = 16843196; // 0x10101bc @@ -4589,7 +4588,7 @@ package android.app { public final class AsyncNotedAppOp implements android.os.Parcelable { method public int describeContents(); - method @Nullable public String getFeatureId(); + method @Nullable public String getAttributionTag(); method @NonNull public String getMessage(); method @IntRange(from=0) public int getNotingUid(); method @NonNull public String getOp(); @@ -6433,7 +6432,7 @@ package android.app { public final class SyncNotedAppOp implements android.os.Parcelable { ctor public SyncNotedAppOp(@IntRange(from=0L) int, @Nullable String); method public int describeContents(); - method @Nullable public String getFeatureId(); + method @Nullable public String getAttributionTag(); method @NonNull public String getOp(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.app.SyncNotedAppOp> CREATOR; @@ -9699,7 +9698,7 @@ package android.content { method public abstract int delete(@NonNull android.net.Uri, @Nullable String, @Nullable String[]); method public int delete(@NonNull android.net.Uri, @Nullable android.os.Bundle); method public void dump(java.io.FileDescriptor, java.io.PrintWriter, String[]); - method @Nullable public final String getCallingFeatureId(); + method @Nullable public final String getCallingAttributionTag(); method @Nullable public final String getCallingPackage(); method @Nullable public final String getCallingPackageUnchecked(); method @Nullable public final android.content.Context getContext(); @@ -10033,11 +10032,11 @@ package android.content { method @CheckResult(suggest="#enforceUriPermission(Uri,int,int,String)") public abstract int checkUriPermission(android.net.Uri, int, int, int); method @CheckResult(suggest="#enforceUriPermission(Uri,String,String,int,int,int,String)") public abstract int checkUriPermission(@Nullable android.net.Uri, @Nullable String, @Nullable String, int, int, int); method @Deprecated public abstract void clearWallpaper() throws java.io.IOException; + method @NonNull public android.content.Context createAttributionContext(@Nullable String); method public abstract android.content.Context createConfigurationContext(@NonNull android.content.res.Configuration); method public abstract android.content.Context createContextForSplit(String) throws android.content.pm.PackageManager.NameNotFoundException; method public abstract android.content.Context createDeviceProtectedStorageContext(); method public abstract android.content.Context createDisplayContext(@NonNull android.view.Display); - method @NonNull public android.content.Context createFeatureContext(@Nullable String); method public abstract android.content.Context createPackageContext(String, int) throws android.content.pm.PackageManager.NameNotFoundException; method @NonNull public android.content.Context createWindowContext(int, @Nullable android.os.Bundle); method public abstract String[] databaseList(); @@ -10055,6 +10054,7 @@ package android.content { method public abstract android.content.Context getApplicationContext(); method public abstract android.content.pm.ApplicationInfo getApplicationInfo(); method public abstract android.content.res.AssetManager getAssets(); + method @Nullable public String getAttributionTag(); method public abstract java.io.File getCacheDir(); method public abstract ClassLoader getClassLoader(); method public abstract java.io.File getCodeCacheDir(); @@ -10071,7 +10071,6 @@ package android.content { method @Nullable public abstract java.io.File getExternalFilesDir(@Nullable String); method public abstract java.io.File[] getExternalFilesDirs(String); method @Deprecated public abstract java.io.File[] getExternalMediaDirs(); - method @Nullable public String getFeatureId(); method public abstract java.io.File getFileStreamPath(String); method public abstract java.io.File getFilesDir(); method public java.util.concurrent.Executor getMainExecutor(); @@ -82244,3 +82243,4 @@ package org.xmlpull.v1.sax2 { } } + diff --git a/api/removed.txt b/api/removed.txt index db6aec322653..0e61911f1bff 100644 --- a/api/removed.txt +++ b/api/removed.txt @@ -1,4 +1,12 @@ // Signature format: 2.0 +package android { + + public static final class R.attr { + field public static final int featureId = 16844301; // 0x101060d + } + +} + package android.app { public class ActivityManager { @@ -69,11 +77,17 @@ package android.app.usage { package android.content { + public abstract class ContentProvider implements android.content.ComponentCallbacks2 { + method @Deprecated @Nullable public final String getCallingFeatureId(); + } + public abstract class ContentResolver { method @Deprecated public void notifyChange(@NonNull Iterable<android.net.Uri>, @Nullable android.database.ContentObserver, int); } public abstract class Context { + method @Deprecated @NonNull public android.content.Context createFeatureContext(@Nullable String); + method @Deprecated @Nullable public String getFeatureId(); method public abstract android.content.SharedPreferences getSharedPreferences(java.io.File, int); method public abstract java.io.File getSharedPreferencesPath(String); } diff --git a/api/system-current.txt b/api/system-current.txt index 3fc63627e34b..f6ac66791e65 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -448,14 +448,37 @@ package android.app { field public static final int UID_STATE_TOP = 200; // 0xc8 } - public static final class AppOpsManager.HistoricalFeatureOps implements android.os.Parcelable { + public static final class AppOpsManager.AttributedHistoricalOps implements android.os.Parcelable { method public int describeContents(); - method @Nullable public String getFeatureId(); method @Nullable public android.app.AppOpsManager.HistoricalOp getOp(@NonNull String); method @NonNull public android.app.AppOpsManager.HistoricalOp getOpAt(@IntRange(from=0) int); method @IntRange(from=0) public int getOpCount(); + method @Nullable public String getTag(); method public void writeToParcel(@NonNull android.os.Parcel, int); - field @NonNull public static final android.os.Parcelable.Creator<android.app.AppOpsManager.HistoricalFeatureOps> CREATOR; + field @NonNull public static final android.os.Parcelable.Creator<android.app.AppOpsManager.AttributedHistoricalOps> CREATOR; + } + + public static final class AppOpsManager.AttributedOpEntry implements android.os.Parcelable { + method public int describeContents(); + method public long getLastAccessBackgroundTime(int); + method public long getLastAccessForegroundTime(int); + method public long getLastAccessTime(int); + method public long getLastAccessTime(int, int, int); + method public long getLastBackgroundDuration(int); + method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastBackgroundProxyInfo(int); + method public long getLastDuration(int); + method public long getLastDuration(int, int, int); + method public long getLastForegroundDuration(int); + method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastForegroundProxyInfo(int); + method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastProxyInfo(int); + method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastProxyInfo(int, int, int); + method public long getLastRejectBackgroundTime(int); + method public long getLastRejectForegroundTime(int); + method public long getLastRejectTime(int); + method public long getLastRejectTime(int, int, int); + method public boolean isRunning(); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator<android.app.AppOpsManager.AttributedOpEntry> CREATOR; } public static final class AppOpsManager.HistoricalOp implements android.os.Parcelable { @@ -491,7 +514,7 @@ package android.app { public static final class AppOpsManager.HistoricalOpsRequest.Builder { ctor public AppOpsManager.HistoricalOpsRequest.Builder(long, long); method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest build(); - method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setFeatureId(@Nullable String); + method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setAttributionTag(@Nullable String); method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setFlags(int); method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setOpNames(@Nullable java.util.List<java.lang.String>); method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setPackageName(@Nullable String); @@ -500,9 +523,9 @@ package android.app { public static final class AppOpsManager.HistoricalPackageOps implements android.os.Parcelable { method public int describeContents(); - method @IntRange(from=0) public int getFeatureCount(); - method @Nullable public android.app.AppOpsManager.HistoricalFeatureOps getFeatureOps(@NonNull String); - method @NonNull public android.app.AppOpsManager.HistoricalFeatureOps getFeatureOpsAt(@IntRange(from=0) int); + method @Nullable public android.app.AppOpsManager.AttributedHistoricalOps getAttributedOps(@NonNull String); + method @NonNull public android.app.AppOpsManager.AttributedHistoricalOps getAttributedOpsAt(@IntRange(from=0) int); + method @IntRange(from=0) public int getAttributedOpsCount(); method @Nullable public android.app.AppOpsManager.HistoricalOp getOp(@NonNull String); method @NonNull public android.app.AppOpsManager.HistoricalOp getOpAt(@IntRange(from=0) int); method @IntRange(from=0) public int getOpCount(); @@ -523,8 +546,8 @@ package android.app { public static final class AppOpsManager.OpEntry implements android.os.Parcelable { method public int describeContents(); + method @NonNull public java.util.Map<java.lang.String,android.app.AppOpsManager.AttributedOpEntry> getAttributedOpEntries(); method @Deprecated public long getDuration(); - method @NonNull public java.util.Map<java.lang.String,android.app.AppOpsManager.OpFeatureEntry> getFeatures(); method public long getLastAccessBackgroundTime(int); method public long getLastAccessForegroundTime(int); method public long getLastAccessTime(int); @@ -554,36 +577,13 @@ package android.app { public static final class AppOpsManager.OpEventProxyInfo implements android.os.Parcelable { method public int describeContents(); - method @Nullable public String getFeatureId(); + method @Nullable public String getAttributionTag(); method @Nullable public String getPackageName(); method @IntRange(from=0) public int getUid(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.app.AppOpsManager.OpEventProxyInfo> CREATOR; } - public static final class AppOpsManager.OpFeatureEntry implements android.os.Parcelable { - method public int describeContents(); - method public long getLastAccessBackgroundTime(int); - method public long getLastAccessForegroundTime(int); - method public long getLastAccessTime(int); - method public long getLastAccessTime(int, int, int); - method public long getLastBackgroundDuration(int); - method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastBackgroundProxyInfo(int); - method public long getLastDuration(int); - method public long getLastDuration(int, int, int); - method public long getLastForegroundDuration(int); - method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastForegroundProxyInfo(int); - method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastProxyInfo(int); - method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastProxyInfo(int, int, int); - method public long getLastRejectBackgroundTime(int); - method public long getLastRejectForegroundTime(int); - method public long getLastRejectTime(int); - method public long getLastRejectTime(int, int, int); - method public boolean isRunning(); - method public void writeToParcel(@NonNull android.os.Parcel, int); - field @NonNull public static final android.os.Parcelable.Creator<android.app.AppOpsManager.OpFeatureEntry> CREATOR; - } - public static final class AppOpsManager.PackageOps implements android.os.Parcelable { method public int describeContents(); method @NonNull public java.util.List<android.app.AppOpsManager.OpEntry> getOps(); @@ -688,7 +688,7 @@ package android.app { public final class RuntimeAppOpAccessMessage implements android.os.Parcelable { ctor public RuntimeAppOpAccessMessage(@IntRange(from=0L) int, @IntRange(from=0L) int, @NonNull String, @Nullable String, @NonNull String, int); method public int describeContents(); - method @Nullable public String getFeatureId(); + method @Nullable public String getAttributionTag(); method @NonNull public String getMessage(); method @NonNull public String getOp(); method @NonNull public String getPackageName(); diff --git a/api/test-current.txt b/api/test-current.txt index 29e025f8d12d..b13b59d1489d 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -264,14 +264,37 @@ package android.app { field public static final int UID_STATE_TOP = 200; // 0xc8 } - public static final class AppOpsManager.HistoricalFeatureOps implements android.os.Parcelable { + public static final class AppOpsManager.AttributedHistoricalOps implements android.os.Parcelable { method public int describeContents(); - method @Nullable public String getFeatureId(); method @Nullable public android.app.AppOpsManager.HistoricalOp getOp(@NonNull String); method @NonNull public android.app.AppOpsManager.HistoricalOp getOpAt(@IntRange(from=0) int); method @IntRange(from=0) public int getOpCount(); + method @Nullable public String getTag(); method public void writeToParcel(@NonNull android.os.Parcel, int); - field @NonNull public static final android.os.Parcelable.Creator<android.app.AppOpsManager.HistoricalFeatureOps> CREATOR; + field @NonNull public static final android.os.Parcelable.Creator<android.app.AppOpsManager.AttributedHistoricalOps> CREATOR; + } + + public static final class AppOpsManager.AttributedOpEntry implements android.os.Parcelable { + method public int describeContents(); + method public long getLastAccessBackgroundTime(int); + method public long getLastAccessForegroundTime(int); + method public long getLastAccessTime(int); + method public long getLastAccessTime(int, int, int); + method public long getLastBackgroundDuration(int); + method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastBackgroundProxyInfo(int); + method public long getLastDuration(int); + method public long getLastDuration(int, int, int); + method public long getLastForegroundDuration(int); + method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastForegroundProxyInfo(int); + method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastProxyInfo(int); + method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastProxyInfo(int, int, int); + method public long getLastRejectBackgroundTime(int); + method public long getLastRejectForegroundTime(int); + method public long getLastRejectTime(int); + method public long getLastRejectTime(int, int, int); + method public boolean isRunning(); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator<android.app.AppOpsManager.AttributedOpEntry> CREATOR; } public static final class AppOpsManager.HistoricalOp implements android.os.Parcelable { @@ -312,7 +335,7 @@ package android.app { public static final class AppOpsManager.HistoricalOpsRequest.Builder { ctor public AppOpsManager.HistoricalOpsRequest.Builder(long, long); method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest build(); - method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setFeatureId(@Nullable String); + method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setAttributionTag(@Nullable String); method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setFlags(int); method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setOpNames(@Nullable java.util.List<java.lang.String>); method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setPackageName(@Nullable String); @@ -321,9 +344,9 @@ package android.app { public static final class AppOpsManager.HistoricalPackageOps implements android.os.Parcelable { method public int describeContents(); - method @IntRange(from=0) public int getFeatureCount(); - method @Nullable public android.app.AppOpsManager.HistoricalFeatureOps getFeatureOps(@NonNull String); - method @NonNull public android.app.AppOpsManager.HistoricalFeatureOps getFeatureOpsAt(@IntRange(from=0) int); + method @Nullable public android.app.AppOpsManager.AttributedHistoricalOps getAttributedOps(@NonNull String); + method @NonNull public android.app.AppOpsManager.AttributedHistoricalOps getAttributedOpsAt(@IntRange(from=0) int); + method @IntRange(from=0) public int getAttributedOpsCount(); method @Nullable public android.app.AppOpsManager.HistoricalOp getOp(@NonNull String); method @NonNull public android.app.AppOpsManager.HistoricalOp getOpAt(@IntRange(from=0) int); method @IntRange(from=0) public int getOpCount(); @@ -344,8 +367,8 @@ package android.app { public static final class AppOpsManager.OpEntry implements android.os.Parcelable { method public int describeContents(); + method @NonNull public java.util.Map<java.lang.String,android.app.AppOpsManager.AttributedOpEntry> getAttributedOpEntries(); method @Deprecated public long getDuration(); - method @NonNull public java.util.Map<java.lang.String,android.app.AppOpsManager.OpFeatureEntry> getFeatures(); method public long getLastAccessBackgroundTime(int); method public long getLastAccessForegroundTime(int); method public long getLastAccessTime(int); @@ -375,36 +398,13 @@ package android.app { public static final class AppOpsManager.OpEventProxyInfo implements android.os.Parcelable { method public int describeContents(); - method @Nullable public String getFeatureId(); + method @Nullable public String getAttributionTag(); method @Nullable public String getPackageName(); method @IntRange(from=0) public int getUid(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.app.AppOpsManager.OpEventProxyInfo> CREATOR; } - public static final class AppOpsManager.OpFeatureEntry implements android.os.Parcelable { - method public int describeContents(); - method public long getLastAccessBackgroundTime(int); - method public long getLastAccessForegroundTime(int); - method public long getLastAccessTime(int); - method public long getLastAccessTime(int, int, int); - method public long getLastBackgroundDuration(int); - method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastBackgroundProxyInfo(int); - method public long getLastDuration(int); - method public long getLastDuration(int, int, int); - method public long getLastForegroundDuration(int); - method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastForegroundProxyInfo(int); - method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastProxyInfo(int); - method @Nullable public android.app.AppOpsManager.OpEventProxyInfo getLastProxyInfo(int, int, int); - method public long getLastRejectBackgroundTime(int); - method public long getLastRejectForegroundTime(int); - method public long getLastRejectTime(int); - method public long getLastRejectTime(int, int, int); - method public boolean isRunning(); - method public void writeToParcel(@NonNull android.os.Parcel, int); - field @NonNull public static final android.os.Parcelable.Creator<android.app.AppOpsManager.OpFeatureEntry> CREATOR; - } - public static final class AppOpsManager.PackageOps implements android.os.Parcelable { method public int describeContents(); method @NonNull public java.util.List<android.app.AppOpsManager.OpEntry> getOps(); @@ -466,7 +466,7 @@ package android.app { public final class RuntimeAppOpAccessMessage implements android.os.Parcelable { ctor public RuntimeAppOpAccessMessage(@IntRange(from=0L) int, @IntRange(from=0L) int, @NonNull String, @Nullable String, @NonNull String, int); method public int describeContents(); - method @Nullable public String getFeatureId(); + method @Nullable public String getAttributionTag(); method @NonNull public String getMessage(); method @NonNull public String getOp(); method @NonNull public String getPackageName(); diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index 32a5243374ff..7f0b5146ad2e 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -485,7 +485,7 @@ message Atom { PackageNotificationChannelGroupPreferences package_notification_channel_group_preferences = 10073 [(module) = "framework"]; GnssStats gnss_stats = 10074 [(module) = "framework"]; - AppFeaturesOps app_features_ops = 10075 [(module) = "framework"]; + AttributedAppOps attributed_app_ops = 10075 [(module) = "framework"]; } // DO NOT USE field numbers above 100,000 in AOSP. @@ -7600,18 +7600,19 @@ message AppOps { } /** - * Historical app ops data per package and features. + * Historical app ops data per package and attribution tag. */ -message AppFeaturesOps { +message AttributedAppOps { // Uid of the package requesting the op optional int32 uid = 1 [(is_uid) = true]; // Name of the package performing the op optional string package_name = 2; - // feature id; provided by developer when accessing related API, limited at 50 chars by API. - // Features must be provided through manifest using <feature> tag available in R and above. - optional string feature_id = 3; + // tag; provided by developer when accessing related API, limited at 50 chars by API. + // Attributions must be provided through manifest using <attribution> tag available in R and + // above. + optional string tag = 3; // operation id; maps to the OPSTR_* constants in AppOpsManager.java optional string op = 4; @@ -8473,9 +8474,11 @@ message RuntimeAppOpAccess { // operation string id per OPSTR_ constants in AppOpsManager.java optional string op = 3; - // feature id; provided by developer when accessing related API, limited at 50 chars by API. - // Features must be provided through manifest using <feature> tag available in R and above. - optional string feature_id = 4; + // attribution_tag; provided by developer when accessing related API, limited at 50 chars by + // API. + // Attributions must be provided through manifest using <attribution> tag available in R and + // above. + optional string attribution_tag = 4; // message related to app op access, limited to 600 chars by API optional string message = 5; diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 8d6bc7222abd..6480a6abeb78 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -5829,7 +5829,7 @@ public class Activity extends ContextThemeWrapper intent.prepareToLeaveProcess(this); result = ActivityTaskManager.getService() .startActivity(mMainThread.getApplicationThread(), getBasePackageName(), - getFeatureId(), intent, + getAttributionTag(), intent, intent.resolveTypeIfNeeded(getContentResolver()), mToken, mEmbeddedID, requestCode, ActivityManager.START_FLAG_ONLY_IF_NEEDED, null, options); } catch (RemoteException e) { @@ -6624,12 +6624,10 @@ public class Activity extends ContextThemeWrapper String packageName = getPackageName(); try { data.prepareToLeaveProcess(this); - IIntentSender target = - ActivityManager.getService().getIntentSenderWithFeature( - ActivityManager.INTENT_SENDER_ACTIVITY_RESULT, packageName, getFeatureId(), - mParent == null ? mToken : mParent.mToken, - mEmbeddedID, requestCode, new Intent[] { data }, null, flags, null, - getUserId()); + IIntentSender target = ActivityManager.getService().getIntentSenderWithFeature( + ActivityManager.INTENT_SENDER_ACTIVITY_RESULT, packageName, getAttributionTag(), + mParent == null ? mToken : mParent.mToken, mEmbeddedID, requestCode, + new Intent[]{data}, null, flags, null, getUserId()); return target != null ? new PendingIntent(target) : null; } catch (RemoteException e) { // Empty diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 6564dc9b0840..7033645f2d35 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -159,8 +159,8 @@ import java.util.function.Supplier; * <p>Some apps are forwarding access to other apps. E.g. an app might get the location from the * system's location provider and then send the location further to a 3rd app. In this case the * app passing on the data needs to call {@link #noteProxyOp} to signal the access proxying. This - * might also make sense inside of a single app if the access is forwarded between two features of - * the app. + * might also make sense inside of a single app if the access is forwarded between two parts of + * the tagged with different attribution tags. * * <p>An app can register an {@link OnOpNotedCallback} to get informed about what accesses the * system is tracking for it. As each runtime permission has an associated app-op this API is @@ -2650,23 +2650,23 @@ public class AppOpsManager { private @IntRange(from = 0) int mUid; /** Package of the proxy that noted the op */ private @Nullable String mPackageName; - /** ID of the feature of the proxy that noted the op */ - private @Nullable String mFeatureId; + /** Attribution tag of the proxy that noted the op */ + private @Nullable String mAttributionTag; /** * Reinit existing object with new state. * * @param uid UID of the proxy app that noted the op * @param packageName Package of the proxy that noted the op - * @param featureId ID of the feature of the proxy that noted the op + * @param attributionTag attribution tag of the proxy that noted the op * * @hide */ public void reinit(@IntRange(from = 0) int uid, @Nullable String packageName, - @Nullable String featureId) { + @Nullable String attributionTag) { mUid = Preconditions.checkArgumentNonnegative(uid); mPackageName = packageName; - mFeatureId = featureId; + mAttributionTag = attributionTag; } @@ -2691,21 +2691,21 @@ public class AppOpsManager { * UID of the proxy app that noted the op * @param packageName * Package of the proxy that noted the op - * @param featureId - * ID of the feature of the proxy that noted the op + * @param attributionTag + * Attribution tag of the proxy that noted the op * @hide */ @DataClass.Generated.Member public OpEventProxyInfo( @IntRange(from = 0) int uid, @Nullable String packageName, - @Nullable String featureId) { + @Nullable String attributionTag) { this.mUid = uid; com.android.internal.util.AnnotationValidations.validate( IntRange.class, null, mUid, "from", 0); this.mPackageName = packageName; - this.mFeatureId = featureId; + this.mAttributionTag = attributionTag; // onConstructed(); // You can define this method to get a callback } @@ -2719,7 +2719,7 @@ public class AppOpsManager { public OpEventProxyInfo(@NonNull OpEventProxyInfo orig) { mUid = orig.mUid; mPackageName = orig.mPackageName; - mFeatureId = orig.mFeatureId; + mAttributionTag = orig.mAttributionTag; } /** @@ -2739,11 +2739,11 @@ public class AppOpsManager { } /** - * ID of the feature of the proxy that noted the op + * Attribution tag of the proxy that noted the op */ @DataClass.Generated.Member - public @Nullable String getFeatureId() { - return mFeatureId; + public @Nullable String getAttributionTag() { + return mAttributionTag; } @Override @@ -2754,11 +2754,11 @@ public class AppOpsManager { byte flg = 0; if (mPackageName != null) flg |= 0x2; - if (mFeatureId != null) flg |= 0x4; + if (mAttributionTag != null) flg |= 0x4; dest.writeByte(flg); dest.writeInt(mUid); if (mPackageName != null) dest.writeString(mPackageName); - if (mFeatureId != null) dest.writeString(mFeatureId); + if (mAttributionTag != null) dest.writeString(mAttributionTag); } @Override @@ -2775,14 +2775,14 @@ public class AppOpsManager { byte flg = in.readByte(); int uid = in.readInt(); String packageName = (flg & 0x2) == 0 ? null : in.readString(); - String featureId = (flg & 0x4) == 0 ? null : in.readString(); + String attributionTag = (flg & 0x4) == 0 ? null : in.readString(); this.mUid = uid; com.android.internal.util.AnnotationValidations.validate( IntRange.class, null, mUid, "from", 0); this.mPackageName = packageName; - this.mFeatureId = featureId; + this.mAttributionTag = attributionTag; // onConstructed(); // You can define this method to get a callback } @@ -2806,7 +2806,7 @@ public class AppOpsManager { time = 1576814974615L, codegenVersion = "1.0.14", sourceFile = "frameworks/base/core/java/android/app/AppOpsManager.java", - inputSignatures = "private @android.annotation.IntRange(from=0L) int mUid\nprivate @android.annotation.Nullable java.lang.String mPackageName\nprivate @android.annotation.Nullable java.lang.String mFeatureId\npublic void reinit(int,java.lang.String,java.lang.String)\nclass OpEventProxyInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genHiddenConstructor=true, genHiddenCopyConstructor=true)") + inputSignatures = "private @android.annotation.IntRange(from=0L) int mUid\nprivate @android.annotation.Nullable java.lang.String mPackageName\nprivate @android.annotation.Nullable java.lang.String mAttributionTag\npublic void reinit(int,java.lang.String,java.lang.String)\nclass OpEventProxyInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genHiddenConstructor=true, genHiddenCopyConstructor=true)") @Deprecated private void __metadata() {} */ @@ -3005,7 +3005,7 @@ public class AppOpsManager { /** * Last {@link #noteOp} and {@link #startOp} events performed for a single op and a specific - * {@link Context#createFeatureContext(String) feature} for all uidModes and opFlags. + * {@link Context#createAttributionContext(String) attribution} for all uidModes and opFlags. * * @hide */ @@ -3014,7 +3014,7 @@ public class AppOpsManager { @Immutable // @DataClass(genHiddenConstructor = true) codegen verifier is broken @DataClass.Suppress({"getAccessEvents", "getRejectEvents", "getOp"}) - public static final class OpFeatureEntry implements Parcelable { + public static final class AttributedOpEntry implements Parcelable { /** The code of the op */ private final @IntRange(from = 0, to = _NUM_OP - 1) int mOp; /** Whether the op is running */ @@ -3313,8 +3313,8 @@ public class AppOpsManager { } /** - * Gets the proxy info of the app that performed the last access on behalf of this feature - * and as a result blamed the op on this app. + * Gets the proxy info of the app that performed the last access on behalf of this + * attribution and as a result blamed the op on this attribution. * * @param flags The op flags * @@ -3331,7 +3331,7 @@ public class AppOpsManager { /** * Gets the proxy info of the app that performed the last foreground access on behalf of - * this feature and as a result blamed the op on this app. + * this attribution and as a result blamed the op on this attribution. * * @param flags The op flags * @@ -3349,7 +3349,7 @@ public class AppOpsManager { /** * Gets the proxy info of the app that performed the last background access on behalf of - * this feature and as a result blamed the op on this app. + * this attribution and as a result blamed the op on this attribution. * * @param flags The op flags * @@ -3366,8 +3366,8 @@ public class AppOpsManager { } /** - * Gets the proxy info of the app that performed the last access on behalf of this feature - * and as a result blamed the op on this app. + * Gets the proxy info of the app that performed the last access on behalf of this + * attribution and as a result blamed the op on this attribution. * * @param fromUidState The lowest UID state for which to query * @param toUidState The highest UID state for which to query (inclusive) @@ -3442,7 +3442,7 @@ public class AppOpsManager { /** - * Creates a new OpFeatureEntry. + * Creates a new OpAttributionEntry. * * @param op * The code of the op @@ -3455,7 +3455,7 @@ public class AppOpsManager { * @hide */ @DataClass.Generated.Member - public OpFeatureEntry( + public AttributedOpEntry( @IntRange(from = 0, to = _NUM_OP - 1) int op, boolean running, @Nullable LongSparseArray<NoteOpEvent> accessEvents, @@ -3525,7 +3525,7 @@ public class AppOpsManager { /** @hide */ @SuppressWarnings({"unchecked", "RedundantCast"}) @DataClass.Generated.Member - /* package-private */ OpFeatureEntry(@NonNull Parcel in) { + /* package-private */ AttributedOpEntry(@NonNull Parcel in) { // You can override field unparcelling by defining methods like: // static FieldType unparcelFieldName(Parcel in) { ... } @@ -3548,16 +3548,16 @@ public class AppOpsManager { } @DataClass.Generated.Member - public static final @NonNull Parcelable.Creator<OpFeatureEntry> CREATOR - = new Parcelable.Creator<OpFeatureEntry>() { + public static final @NonNull Parcelable.Creator<AttributedOpEntry> CREATOR + = new Parcelable.Creator<AttributedOpEntry>() { @Override - public OpFeatureEntry[] newArray(int size) { - return new OpFeatureEntry[size]; + public AttributedOpEntry[] newArray(int size) { + return new AttributedOpEntry[size]; } @Override - public OpFeatureEntry createFromParcel(@NonNull Parcel in) { - return new OpFeatureEntry(in); + public AttributedOpEntry createFromParcel(@NonNull Parcel in) { + return new AttributedOpEntry(in); } }; @@ -3566,7 +3566,7 @@ public class AppOpsManager { time = 1574809856239L, codegenVersion = "1.0.14", sourceFile = "frameworks/base/core/java/android/app/AppOpsManager.java", - inputSignatures = "private final @android.annotation.IntRange(from=0L, to=_NUM_OP - 1) int mOp\nprivate final boolean mRunning\nprivate final @com.android.internal.util.DataClass.ParcelWith(android.app.OpFeatureEntry.LongSparseArrayParceling.class) @android.annotation.Nullable android.util.LongSparseArray<android.app.NoteOpEvent> mAccessEvents\nprivate final @com.android.internal.util.DataClass.ParcelWith(android.app.OpFeatureEntry.LongSparseArrayParceling.class) @android.annotation.Nullable android.util.LongSparseArray<android.app.NoteOpEvent> mRejectEvents\npublic @android.annotation.NonNull android.util.ArraySet<java.lang.Long> collectKeys()\npublic @android.app.UidState int getLastAccessUidState(int)\npublic @android.app.UidState int getLastForegroundAccessUidState(int)\npublic @android.app.UidState int getLastBackgroundAccessUidState(int)\npublic @android.app.UidState int getLastRejectUidState(int)\npublic @android.app.UidState int getLastForegroundRejectUidState(int)\npublic @android.app.UidState int getLastBackgroundRejectUidState(int)\npublic long getAccessTime(int,int)\npublic long getRejectTime(int,int)\npublic long getDuration(int,int)\npublic int getProxyUid(int,int)\npublic @android.annotation.Nullable java.lang.String getProxyPackageName(int,int)\npublic @android.annotation.Nullable java.lang.String getProxyFeatureId(int,int)\nclass OpFeatureEntry extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genHiddenConstructor=true)") + inputSignatures = "private final @android.annotation.IntRange(from=0L, to=_NUM_OP - 1) int mOp\nprivate final boolean mRunning\nprivate final @com.android.internal.util.DataClass.ParcelWith(android.app.OpAttributionEntry.LongSparseArrayParceling.class) @android.annotation.Nullable android.util.LongSparseArray<android.app.NoteOpEvent> mAccessEvents\nprivate final @com.android.internal.util.DataClass.ParcelWith(android.app.OpAttributionEntry.LongSparseArrayParceling.class) @android.annotation.Nullable android.util.LongSparseArray<android.app.NoteOpEvent> mRejectEvents\npublic @android.annotation.NonNull android.util.ArraySet<java.lang.Long> collectKeys()\npublic @android.app.UidState int getLastAccessUidState(int)\npublic @android.app.UidState int getLastForegroundAccessUidState(int)\npublic @android.app.UidState int getLastBackgroundAccessUidState(int)\npublic @android.app.UidState int getLastRejectUidState(int)\npublic @android.app.UidState int getLastForegroundRejectUidState(int)\npublic @android.app.UidState int getLastBackgroundRejectUidState(int)\npublic long getAccessTime(int,int)\npublic long getRejectTime(int,int)\npublic long getDuration(int,int)\npublic int getProxyUid(int,int)\npublic @android.annotation.Nullable java.lang.String getProxyPackageName(int,int)\npublic @android.annotation.Nullable java.lang.String getProxyAttributionTag(int,int)\nclass OpAttributionEntry extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genHiddenConstructor=true)") @Deprecated private void __metadata() {} */ @@ -3592,8 +3592,8 @@ public class AppOpsManager { private final @IntRange(from = 0, to = _NUM_OP - 1) int mOp; /** The mode of the op */ private final @Mode int mMode; - /** The features that have been used when checking the op */ - private final @NonNull Map<String, OpFeatureEntry> mFeatures; + /** The attributed entries by attribution tag */ + private final @NonNull Map<String, AttributedOpEntry> mAttributedOpEntries; /** * @hide @@ -3634,7 +3634,7 @@ public class AppOpsManager { * @see #getLastAccessForegroundTime(int) * @see #getLastAccessBackgroundTime(int) * @see #getLastAccessTime(int, int, int) - * @see OpFeatureEntry#getLastAccessTime(int) + * @see AttributedOpEntry#getLastAccessTime(int) */ public long getLastAccessTime(@OpFlags int flags) { return getLastAccessTime(MAX_PRIORITY_UID_STATE, MIN_PRIORITY_UID_STATE, flags); @@ -3651,7 +3651,7 @@ public class AppOpsManager { * @see #getLastAccessTime(int) * @see #getLastAccessBackgroundTime(int) * @see #getLastAccessTime(int, int, int) - * @see OpFeatureEntry#getLastAccessForegroundTime(int) + * @see AttributedOpEntry#getLastAccessForegroundTime(int) */ public long getLastAccessForegroundTime(@OpFlags int flags) { return getLastAccessTime(MAX_PRIORITY_UID_STATE, resolveFirstUnrestrictedUidState(mOp), @@ -3669,7 +3669,7 @@ public class AppOpsManager { * @see #getLastAccessTime(int) * @see #getLastAccessForegroundTime(int) * @see #getLastAccessTime(int, int, int) - * @see OpFeatureEntry#getLastAccessBackgroundTime(int) + * @see AttributedOpEntry#getLastAccessBackgroundTime(int) */ public long getLastAccessBackgroundTime(@OpFlags int flags) { return getLastAccessTime(resolveLastRestrictedUidState(mOp), MIN_PRIORITY_UID_STATE, @@ -3686,13 +3686,14 @@ public class AppOpsManager { private @Nullable NoteOpEvent getLastAccessEvent(@UidState int fromUidState, @UidState int toUidState, @OpFlags int flags) { NoteOpEvent lastAccessEvent = null; - for (OpFeatureEntry featureEntry : mFeatures.values()) { - NoteOpEvent lastFeatureAccessEvent = featureEntry.getLastAccessEvent(fromUidState, - toUidState, flags); - - if (lastAccessEvent == null || (lastFeatureAccessEvent != null - && lastFeatureAccessEvent.getNoteTime() > lastAccessEvent.getNoteTime())) { - lastAccessEvent = lastFeatureAccessEvent; + for (AttributedOpEntry attributionEntry : mAttributedOpEntries.values()) { + NoteOpEvent lastAttributionAccessEvent = attributionEntry.getLastAccessEvent( + fromUidState, toUidState, flags); + + if (lastAccessEvent == null || (lastAttributionAccessEvent != null + && lastAttributionAccessEvent.getNoteTime() + > lastAccessEvent.getNoteTime())) { + lastAccessEvent = lastAttributionAccessEvent; } } @@ -3712,7 +3713,7 @@ public class AppOpsManager { * @see #getLastAccessTime(int) * @see #getLastAccessForegroundTime(int) * @see #getLastAccessBackgroundTime(int) - * @see OpFeatureEntry#getLastAccessTime(int, int, int) + * @see AttributedOpEntry#getLastAccessTime(int, int, int) */ public long getLastAccessTime(@UidState int fromUidState, @UidState int toUidState, @OpFlags int flags) { @@ -3748,7 +3749,7 @@ public class AppOpsManager { * @see #getLastRejectForegroundTime(int) * @see #getLastRejectBackgroundTime(int) * @see #getLastRejectTime(int, int, int) - * @see OpFeatureEntry#getLastRejectTime(int) + * @see AttributedOpEntry#getLastRejectTime(int) */ public long getLastRejectTime(@OpFlags int flags) { return getLastRejectTime(MAX_PRIORITY_UID_STATE, MIN_PRIORITY_UID_STATE, flags); @@ -3765,7 +3766,7 @@ public class AppOpsManager { * @see #getLastRejectTime(int) * @see #getLastRejectBackgroundTime(int) * @see #getLastRejectTime(int, int, int) - * @see OpFeatureEntry#getLastRejectForegroundTime(int) + * @see AttributedOpEntry#getLastRejectForegroundTime(int) */ public long getLastRejectForegroundTime(@OpFlags int flags) { return getLastRejectTime(MAX_PRIORITY_UID_STATE, resolveFirstUnrestrictedUidState(mOp), @@ -3783,7 +3784,7 @@ public class AppOpsManager { * @see #getLastRejectTime(int) * @see #getLastRejectForegroundTime(int) * @see #getLastRejectTime(int, int, int) - * @see OpFeatureEntry#getLastRejectBackgroundTime(int) + * @see AttributedOpEntry#getLastRejectBackgroundTime(int) */ public long getLastRejectBackgroundTime(@OpFlags int flags) { return getLastRejectTime(resolveLastRestrictedUidState(mOp), MIN_PRIORITY_UID_STATE, @@ -3800,13 +3801,14 @@ public class AppOpsManager { private @Nullable NoteOpEvent getLastRejectEvent(@UidState int fromUidState, @UidState int toUidState, @OpFlags int flags) { NoteOpEvent lastAccessEvent = null; - for (OpFeatureEntry featureEntry : mFeatures.values()) { - NoteOpEvent lastFeatureAccessEvent = featureEntry.getLastRejectEvent(fromUidState, - toUidState, flags); - - if (lastAccessEvent == null || (lastFeatureAccessEvent != null - && lastFeatureAccessEvent.getNoteTime() > lastAccessEvent.getNoteTime())) { - lastAccessEvent = lastFeatureAccessEvent; + for (AttributedOpEntry attributionEntry : mAttributedOpEntries.values()) { + NoteOpEvent lastAttributionAccessEvent = attributionEntry.getLastRejectEvent( + fromUidState, toUidState, flags); + + if (lastAccessEvent == null || (lastAttributionAccessEvent != null + && lastAttributionAccessEvent.getNoteTime() + > lastAccessEvent.getNoteTime())) { + lastAccessEvent = lastAttributionAccessEvent; } } @@ -3827,7 +3829,7 @@ public class AppOpsManager { * @see #getLastRejectForegroundTime(int) * @see #getLastRejectBackgroundTime(int) * @see #getLastRejectTime(int, int, int) - * @see OpFeatureEntry#getLastRejectTime(int, int, int) + * @see AttributedOpEntry#getLastRejectTime(int, int, int) */ public long getLastRejectTime(@UidState int fromUidState, @UidState int toUidState, @OpFlags int flags) { @@ -3843,8 +3845,8 @@ public class AppOpsManager { * @return Whether the operation is running. */ public boolean isRunning() { - for (OpFeatureEntry opFeatureEntry : mFeatures.values()) { - if (opFeatureEntry.isRunning()) { + for (AttributedOpEntry opAttributionEntry : mAttributedOpEntries.values()) { + if (opAttributionEntry.isRunning()) { return true; } } @@ -3870,7 +3872,7 @@ public class AppOpsManager { * @see #getLastForegroundDuration(int) * @see #getLastBackgroundDuration(int) * @see #getLastDuration(int, int, int) - * @see OpFeatureEntry#getLastDuration(int) + * @see AttributedOpEntry#getLastDuration(int) */ public long getLastDuration(@OpFlags int flags) { return getLastDuration(MAX_PRIORITY_UID_STATE, MIN_PRIORITY_UID_STATE, flags); @@ -3886,7 +3888,7 @@ public class AppOpsManager { * @see #getLastDuration(int) * @see #getLastBackgroundDuration(int) * @see #getLastDuration(int, int, int) - * @see OpFeatureEntry#getLastForegroundDuration(int) + * @see AttributedOpEntry#getLastForegroundDuration(int) */ public long getLastForegroundDuration(@OpFlags int flags) { return getLastDuration(MAX_PRIORITY_UID_STATE, resolveFirstUnrestrictedUidState(mOp), @@ -3903,7 +3905,7 @@ public class AppOpsManager { * @see #getLastDuration(int) * @see #getLastForegroundDuration(int) * @see #getLastDuration(int, int, int) - * @see OpFeatureEntry#getLastBackgroundDuration(int) + * @see AttributedOpEntry#getLastBackgroundDuration(int) */ public long getLastBackgroundDuration(@OpFlags int flags) { return getLastDuration(resolveLastRestrictedUidState(mOp), MIN_PRIORITY_UID_STATE, @@ -3922,7 +3924,7 @@ public class AppOpsManager { * @see #getLastDuration(int) * @see #getLastForegroundDuration(int) * @see #getLastBackgroundDuration(int) - * @see OpFeatureEntry#getLastDuration(int, int, int) + * @see AttributedOpEntry#getLastDuration(int, int, int) */ public long getLastDuration(@UidState int fromUidState, @UidState int toUidState, @OpFlags int flags) { @@ -3997,7 +3999,7 @@ public class AppOpsManager { * @see #getLastForegroundProxyInfo(int) * @see #getLastBackgroundProxyInfo(int) * @see #getLastProxyInfo(int, int, int) - * @see OpFeatureEntry#getLastProxyInfo(int) + * @see AttributedOpEntry#getLastProxyInfo(int) */ public @Nullable OpEventProxyInfo getLastProxyInfo(@OpFlags int flags) { return getLastProxyInfo(MAX_PRIORITY_UID_STATE, MIN_PRIORITY_UID_STATE, flags); @@ -4014,7 +4016,7 @@ public class AppOpsManager { * @see #getLastProxyInfo(int) * @see #getLastBackgroundProxyInfo(int) * @see #getLastProxyInfo(int, int, int) - * @see OpFeatureEntry#getLastForegroundProxyInfo(int) + * @see AttributedOpEntry#getLastForegroundProxyInfo(int) */ public @Nullable OpEventProxyInfo getLastForegroundProxyInfo(@OpFlags int flags) { return getLastProxyInfo(MAX_PRIORITY_UID_STATE, resolveFirstUnrestrictedUidState(mOp), @@ -4032,7 +4034,7 @@ public class AppOpsManager { * @see #getLastProxyInfo(int) * @see #getLastForegroundProxyInfo(int) * @see #getLastProxyInfo(int, int, int) - * @see OpFeatureEntry#getLastBackgroundProxyInfo(int) + * @see AttributedOpEntry#getLastBackgroundProxyInfo(int) */ public @Nullable OpEventProxyInfo getLastBackgroundProxyInfo(@OpFlags int flags) { return getLastProxyInfo(resolveLastRestrictedUidState(mOp), MIN_PRIORITY_UID_STATE, @@ -4052,7 +4054,7 @@ public class AppOpsManager { * @see #getLastProxyInfo(int) * @see #getLastForegroundProxyInfo(int) * @see #getLastBackgroundProxyInfo(int) - * @see OpFeatureEntry#getLastProxyInfo(int, int, int) + * @see AttributedOpEntry#getLastProxyInfo(int, int, int) */ public @Nullable OpEventProxyInfo getLastProxyInfo(@UidState int fromUidState, @UidState int toUidState, @OpFlags int flags) { @@ -4086,15 +4088,15 @@ public class AppOpsManager { * The code of the op * @param mode * The mode of the op - * @param features - * The features that have been used when checking the op + * @param attributedOpEntries + * The attributions that have been used when noting the op * @hide */ @DataClass.Generated.Member public OpEntry( @IntRange(from = 0, to = _NUM_OP - 1) int op, @Mode int mode, - @NonNull Map<String,OpFeatureEntry> features) { + @NonNull Map<String, AttributedOpEntry> attributedOpEntries) { this.mOp = op; com.android.internal.util.AnnotationValidations.validate( IntRange.class, null, mOp, @@ -4103,9 +4105,9 @@ public class AppOpsManager { this.mMode = mode; com.android.internal.util.AnnotationValidations.validate( Mode.class, null, mMode); - this.mFeatures = features; + this.mAttributedOpEntries = attributedOpEntries; com.android.internal.util.AnnotationValidations.validate( - NonNull.class, null, mFeatures); + NonNull.class, null, mAttributedOpEntries); // onConstructed(); // You can define this method to get a callback } @@ -4119,14 +4121,14 @@ public class AppOpsManager { } /** - * The features that have been used when checking the op keyed by id of the feature. + * The attributed entries keyed by attribution tag. * - * @see Context#createFeatureContext(String) + * @see Context#createAttributionContext(String) * @see #noteOp(String, int, String, String, String) */ @DataClass.Generated.Member - public @NonNull Map<String,OpFeatureEntry> getFeatures() { - return mFeatures; + public @NonNull Map<String, AttributedOpEntry> getAttributedOpEntries() { + return mAttributedOpEntries; } @Override @@ -4137,7 +4139,7 @@ public class AppOpsManager { dest.writeInt(mOp); dest.writeInt(mMode); - dest.writeMap(mFeatures); + dest.writeMap(mAttributedOpEntries); } @Override @@ -4153,8 +4155,8 @@ public class AppOpsManager { int op = in.readInt(); int mode = in.readInt(); - Map<String,OpFeatureEntry> features = new java.util.LinkedHashMap<>(); - in.readMap(features, OpFeatureEntry.class.getClassLoader()); + Map<String, AttributedOpEntry> attributions = new java.util.LinkedHashMap<>(); + in.readMap(attributions, AttributedOpEntry.class.getClassLoader()); this.mOp = op; com.android.internal.util.AnnotationValidations.validate( @@ -4164,9 +4166,9 @@ public class AppOpsManager { this.mMode = mode; com.android.internal.util.AnnotationValidations.validate( Mode.class, null, mMode); - this.mFeatures = features; + this.mAttributedOpEntries = attributions; com.android.internal.util.AnnotationValidations.validate( - NonNull.class, null, mFeatures); + NonNull.class, null, mAttributedOpEntries); // onConstructed(); // You can define this method to get a callback } @@ -4190,7 +4192,7 @@ public class AppOpsManager { time = 1574809856259L, codegenVersion = "1.0.14", sourceFile = "frameworks/base/core/java/android/app/AppOpsManager.java", - inputSignatures = "private final @android.annotation.IntRange(from=0L, to=_NUM_OP - 1) int mOp\nprivate final @android.app.Mode int mMode\nprivate final @android.annotation.NonNull java.util.Map<java.lang.String,android.app.OpFeatureEntry> mFeatures\npublic @android.annotation.UnsupportedAppUsage(maxTargetSdk=Build.VERSION_CODES.Q, publicAlternatives=\"{@code \" + \"#getOpStr()}\") int getOp()\npublic @android.annotation.NonNull java.lang.String getOpStr()\npublic @java.lang.Deprecated @android.annotation.UnsupportedAppUsage(maxTargetSdk=Build.VERSION_CODES.Q, publicAlternatives=\"{@code \" + \"#getAccessTime(int, int)}\") long getTime()\npublic @java.lang.Deprecated long getLastAccessTime(int)\npublic @java.lang.Deprecated long getLastAccessForegroundTime(int)\npublic @java.lang.Deprecated long getLastAccessBackgroundTime(int)\npublic @java.lang.Deprecated long getLastAccessTime(int,int,int)\npublic @java.lang.Deprecated @android.annotation.UnsupportedAppUsage(maxTargetSdk=Build.VERSION_CODES.Q, publicAlternatives=\"{@code \" + \"#getLastRejectTime(int, int, int)}\") long getRejectTime()\npublic @java.lang.Deprecated long getLastRejectTime(int)\npublic @java.lang.Deprecated long getLastRejectForegroundTime(int)\npublic @java.lang.Deprecated long getLastRejectBackgroundTime(int)\npublic @java.lang.Deprecated long getLastRejectTime(int,int,int)\npublic long getAccessTime(int,int)\npublic long getRejectTime(int,int)\npublic boolean isRunning()\nprivate android.app.NoteOpEvent getLastAccessEvent(int,int,int)\npublic @java.lang.Deprecated long getDuration()\npublic @java.lang.Deprecated long getLastForegroundDuration(int)\npublic @java.lang.Deprecated long getLastBackgroundDuration(int)\npublic @java.lang.Deprecated long getLastDuration(int,int,int)\npublic @java.lang.Deprecated int getProxyUid()\npublic @java.lang.Deprecated @android.annotation.Nullable java.lang.String getProxyPackageName()\nprivate @android.app.UidState int getLastAccessUidStateForFlagsInStatesOfAllFeatures(int,int,int)\npublic @android.app.UidState int getLastAccessUidState(int)\npublic @android.app.UidState int getLastForegroundAccessUidState(int)\npublic @android.app.UidState int getLastBackgroundAccessUidState(int)\nprivate @android.app.UidState int getLastRejectUidStateForFlagsInStatesOfAllFeatures(int,int,int)\npublic @android.app.UidState int getLastRejectUidState(int)\npublic @android.app.UidState int getLastForegroundRejectUidState(int)\npublic @android.app.UidState int getLastBackgroundRejectUidState(int)\npublic long getDuration(int,int)\npublic int getProxyUid(int,int)\nprivate int getProxyUid(int,int,int)\npublic @android.annotation.Nullable java.lang.String getProxyPackageName(int,int)\nprivate @android.annotation.Nullable java.lang.String getProxyPackageName(int,int,int)\nclass OpEntry extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genHiddenConstructor=true)") + inputSignatures = "private final @android.annotation.IntRange(from=0L, to=_NUM_OP - 1) int mOp\nprivate final @android.app.Mode int mMode\nprivate final @android.annotation.NonNull java.util.Map<java.lang.String,android.app.OpAttributionEntry> mAttributions\npublic @android.annotation.UnsupportedAppUsage(maxTargetSdk=Build.VERSION_CODES.Q, publicAlternatives=\"{@code \" + \"#getOpStr()}\") int getOp()\npublic @android.annotation.NonNull java.lang.String getOpStr()\npublic @java.lang.Deprecated @android.annotation.UnsupportedAppUsage(maxTargetSdk=Build.VERSION_CODES.Q, publicAlternatives=\"{@code \" + \"#getAccessTime(int, int)}\") long getTime()\npublic @java.lang.Deprecated long getLastAccessTime(int)\npublic @java.lang.Deprecated long getLastAccessForegroundTime(int)\npublic @java.lang.Deprecated long getLastAccessBackgroundTime(int)\npublic @java.lang.Deprecated long getLastAccessTime(int,int,int)\npublic @java.lang.Deprecated @android.annotation.UnsupportedAppUsage(maxTargetSdk=Build.VERSION_CODES.Q, publicAlternatives=\"{@code \" + \"#getLastRejectTime(int, int, int)}\") long getRejectTime()\npublic @java.lang.Deprecated long getLastRejectTime(int)\npublic @java.lang.Deprecated long getLastRejectForegroundTime(int)\npublic @java.lang.Deprecated long getLastRejectBackgroundTime(int)\npublic @java.lang.Deprecated long getLastRejectTime(int,int,int)\npublic long getAccessTime(int,int)\npublic long getRejectTime(int,int)\npublic boolean isRunning()\nprivate android.app.NoteOpEvent getLastAccessEvent(int,int,int)\npublic @java.lang.Deprecated long getDuration()\npublic @java.lang.Deprecated long getLastForegroundDuration(int)\npublic @java.lang.Deprecated long getLastBackgroundDuration(int)\npublic @java.lang.Deprecated long getLastDuration(int,int,int)\npublic @java.lang.Deprecated int getProxyUid()\npublic @java.lang.Deprecated @android.annotation.Nullable java.lang.String getProxyPackageName()\nprivate @android.app.UidState int getLastAccessUidStateForFlagsInStatesOfAllAttributions(int,int,int)\npublic @android.app.UidState int getLastAccessUidState(int)\npublic @android.app.UidState int getLastForegroundAccessUidState(int)\npublic @android.app.UidState int getLastBackgroundAccessUidState(int)\nprivate @android.app.UidState int getLastRejectUidStateForFlagsInStatesOfAllAttributions(int,int,int)\npublic @android.app.UidState int getLastRejectUidState(int)\npublic @android.app.UidState int getLastForegroundRejectUidState(int)\npublic @android.app.UidState int getLastBackgroundRejectUidState(int)\npublic long getDuration(int,int)\npublic int getProxyUid(int,int)\nprivate int getProxyUid(int,int,int)\npublic @android.annotation.Nullable java.lang.String getProxyPackageName(int,int)\nprivate @android.annotation.Nullable java.lang.String getProxyPackageName(int,int,int)\nclass OpEntry extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genHiddenConstructor=true)") @Deprecated private void __metadata() {} */ @@ -4206,7 +4208,7 @@ public class AppOpsManager { void visitHistoricalOps(@NonNull HistoricalOps ops); void visitHistoricalUidOps(@NonNull HistoricalUidOps ops); void visitHistoricalPackageOps(@NonNull HistoricalPackageOps ops); - void visitHistoricalFeatureOps(@NonNull HistoricalFeatureOps ops); + void visitHistoricalAttributionOps(@NonNull AttributedHistoricalOps ops); void visitHistoricalOp(@NonNull HistoricalOp ops); } @@ -4219,7 +4221,7 @@ public class AppOpsManager { @IntDef(flag = true, prefix = { "FILTER_BY_" }, value = { FILTER_BY_UID, FILTER_BY_PACKAGE_NAME, - FILTER_BY_FEATURE_ID, + FILTER_BY_ATTRIBUTION_TAG, FILTER_BY_OP_NAMES }) public @interface HistoricalOpsRequestFilter {} @@ -4239,11 +4241,11 @@ public class AppOpsManager { public static final int FILTER_BY_PACKAGE_NAME = 1<<1; /** - * Filter historical appop request by feature id. + * Filter historical appop request by attribution tag. * * @hide */ - public static final int FILTER_BY_FEATURE_ID = 1<<2; + public static final int FILTER_BY_ATTRIBUTION_TAG = 1<<2; /** * Filter historical appop request by op names. @@ -4264,7 +4266,7 @@ public class AppOpsManager { public static final class HistoricalOpsRequest { private final int mUid; private final @Nullable String mPackageName; - private final @Nullable String mFeatureId; + private final @Nullable String mAttributionTag; private final @Nullable List<String> mOpNames; private final @HistoricalOpsRequestFilter int mFilter; private final long mBeginTimeMillis; @@ -4272,12 +4274,12 @@ public class AppOpsManager { private final @OpFlags int mFlags; private HistoricalOpsRequest(int uid, @Nullable String packageName, - @Nullable String featureId, @Nullable List<String> opNames, + @Nullable String attributionTag, @Nullable List<String> opNames, @HistoricalOpsRequestFilter int filter, long beginTimeMillis, long endTimeMillis, @OpFlags int flags) { mUid = uid; mPackageName = packageName; - mFeatureId = featureId; + mAttributionTag = attributionTag; mOpNames = opNames; mFilter = filter; mBeginTimeMillis = beginTimeMillis; @@ -4295,7 +4297,7 @@ public class AppOpsManager { public static final class Builder { private int mUid = Process.INVALID_UID; private @Nullable String mPackageName; - private @Nullable String mFeatureId; + private @Nullable String mAttributionTag; private @Nullable List<String> mOpNames; private @HistoricalOpsRequestFilter int mFilter; private final long mBeginTimeMillis; @@ -4359,14 +4361,14 @@ public class AppOpsManager { } /** - * Sets the feature id to query for. + * Sets the attribution tag to query for. * - * @param featureId The id of the feature. + * @param attributionTag attribution tag * @return This builder. */ - public @NonNull Builder setFeatureId(@Nullable String featureId) { - mFeatureId = featureId; - mFilter |= FILTER_BY_FEATURE_ID; + public @NonNull Builder setAttributionTag(@Nullable String attributionTag) { + mAttributionTag = attributionTag; + mFilter |= FILTER_BY_ATTRIBUTION_TAG; return this; } @@ -4417,7 +4419,7 @@ public class AppOpsManager { * @return a new {@link HistoricalOpsRequest}. */ public @NonNull HistoricalOpsRequest build() { - return new HistoricalOpsRequest(mUid, mPackageName, mFeatureId, mOpNames, + return new HistoricalOpsRequest(mUid, mPackageName, mAttributionTag, mOpNames, mFilter, mBeginTimeMillis, mEndTimeMillis, mFlags); } } @@ -4577,7 +4579,7 @@ public class AppOpsManager { * * @param uid Uid to filter for. * @param packageName Package to filter for. - * @param featureId Package to filter for. + * @param attributionTag attribution tag to filter for * @param opNames Ops to filter for. * @param filter Which parameters to filter on. * @param beginTimeMillis The begin time to filter for or {@link Long#MIN_VALUE} for all. @@ -4585,7 +4587,7 @@ public class AppOpsManager { * * @hide */ - public void filter(int uid, @Nullable String packageName, @Nullable String featureId, + public void filter(int uid, @Nullable String packageName, @Nullable String attributionTag, @Nullable String[] opNames, @HistoricalOpsRequestFilter int filter, long beginTimeMillis, long endTimeMillis) { final long durationMillis = getDurationMillis(); @@ -4599,7 +4601,7 @@ public class AppOpsManager { if ((filter & FILTER_BY_UID) != 0 && uid != uidOp.getUid()) { mHistoricalUidOps.removeAt(i); } else { - uidOp.filter(packageName, featureId, opNames, filter, scaleFactor); + uidOp.filter(packageName, attributionTag, opNames, filter, scaleFactor); if (uidOp.getPackageCount() == 0) { mHistoricalUidOps.removeAt(i); } @@ -4630,28 +4632,28 @@ public class AppOpsManager { /** @hide */ @TestApi public void increaseAccessCount(int opCode, int uid, @NonNull String packageName, - @Nullable String featureId, @UidState int uidState, @OpFlags int flags, + @Nullable String attributionTag, @UidState int uidState, @OpFlags int flags, long increment) { getOrCreateHistoricalUidOps(uid).increaseAccessCount(opCode, - packageName, featureId, uidState, flags, increment); + packageName, attributionTag, uidState, flags, increment); } /** @hide */ @TestApi public void increaseRejectCount(int opCode, int uid, @NonNull String packageName, - @Nullable String featureId, @UidState int uidState, @OpFlags int flags, + @Nullable String attributionTag, @UidState int uidState, @OpFlags int flags, long increment) { getOrCreateHistoricalUidOps(uid).increaseRejectCount(opCode, - packageName, featureId, uidState, flags, increment); + packageName, attributionTag, uidState, flags, increment); } /** @hide */ @TestApi public void increaseAccessDuration(int opCode, int uid, @NonNull String packageName, - @Nullable String featureId, @UidState int uidState, @OpFlags int flags, + @Nullable String attributionTag, @UidState int uidState, @OpFlags int flags, long increment) { getOrCreateHistoricalUidOps(uid).increaseAccessDuration(opCode, - packageName, featureId, uidState, flags, increment); + packageName, attributionTag, uidState, flags, increment); } /** @hide */ @@ -4931,7 +4933,7 @@ public class AppOpsManager { } } - private void filter(@Nullable String packageName, @Nullable String featureId, + private void filter(@Nullable String packageName, @Nullable String attributionTag, @Nullable String[] opNames, @HistoricalOpsRequestFilter int filter, double fractionToRemove) { final int packageCount = getPackageCount(); @@ -4941,8 +4943,8 @@ public class AppOpsManager { packageOps.getPackageName())) { mHistoricalPackageOps.removeAt(i); } else { - packageOps.filter(featureId, opNames, filter, fractionToRemove); - if (packageOps.getFeatureCount() == 0) { + packageOps.filter(attributionTag, opNames, filter, fractionToRemove); + if (packageOps.getAttributedOpsCount() == 0) { mHistoricalPackageOps.removeAt(i); } } @@ -4961,24 +4963,24 @@ public class AppOpsManager { } private void increaseAccessCount(int opCode, @NonNull String packageName, - @Nullable String featureId, @UidState int uidState, @OpFlags int flags, + @Nullable String attributionTag, @UidState int uidState, @OpFlags int flags, long increment) { getOrCreateHistoricalPackageOps(packageName).increaseAccessCount( - opCode, featureId, uidState, flags, increment); + opCode, attributionTag, uidState, flags, increment); } private void increaseRejectCount(int opCode, @NonNull String packageName, - @Nullable String featureId, @UidState int uidState, @OpFlags int flags, + @Nullable String attributionTag, @UidState int uidState, @OpFlags int flags, long increment) { getOrCreateHistoricalPackageOps(packageName).increaseRejectCount( - opCode, featureId, uidState, flags, increment); + opCode, attributionTag, uidState, flags, increment); } private void increaseAccessDuration(int opCode, @NonNull String packageName, - @Nullable String featureId, @UidState int uidState, @OpFlags int flags, + @Nullable String attributionTag, @UidState int uidState, @OpFlags int flags, long increment) { getOrCreateHistoricalPackageOps(packageName).increaseAccessDuration( - opCode, featureId, uidState, flags, increment); + opCode, attributionTag, uidState, flags, increment); } /** @@ -5123,7 +5125,7 @@ public class AppOpsManager { @SystemApi public static final class HistoricalPackageOps implements Parcelable { private final @NonNull String mPackageName; - private @Nullable ArrayMap<String, HistoricalFeatureOps> mHistoricalFeatureOps; + private @Nullable ArrayMap<String, AttributedHistoricalOps> mAttributedHistoricalOps; /** @hide */ public HistoricalPackageOps(@NonNull String packageName) { @@ -5132,70 +5134,71 @@ public class AppOpsManager { private HistoricalPackageOps(@NonNull HistoricalPackageOps other) { mPackageName = other.mPackageName; - final int opCount = other.getFeatureCount(); + final int opCount = other.getAttributedOpsCount(); for (int i = 0; i < opCount; i++) { - final HistoricalFeatureOps origOps = other.getFeatureOpsAt(i); - final HistoricalFeatureOps cloneOps = new HistoricalFeatureOps(origOps); - if (mHistoricalFeatureOps == null) { - mHistoricalFeatureOps = new ArrayMap<>(opCount); + final AttributedHistoricalOps origOps = other.getAttributedOpsAt(i); + final AttributedHistoricalOps cloneOps = new AttributedHistoricalOps(origOps); + if (mAttributedHistoricalOps == null) { + mAttributedHistoricalOps = new ArrayMap<>(opCount); } - mHistoricalFeatureOps.put(cloneOps.getFeatureId(), cloneOps); + mAttributedHistoricalOps.put(cloneOps.getTag(), cloneOps); } } private HistoricalPackageOps(@NonNull Parcel parcel) { mPackageName = parcel.readString(); - mHistoricalFeatureOps = parcel.createTypedArrayMap(HistoricalFeatureOps.CREATOR); + mAttributedHistoricalOps = parcel.createTypedArrayMap(AttributedHistoricalOps.CREATOR); } private @Nullable HistoricalPackageOps splice(double fractionToRemove) { HistoricalPackageOps splice = null; - final int featureCount = getFeatureCount(); - for (int i = 0; i < featureCount; i++) { - final HistoricalFeatureOps origOps = getFeatureOpsAt(i); - final HistoricalFeatureOps spliceOps = origOps.splice(fractionToRemove); + final int attributionCount = getAttributedOpsCount(); + for (int i = 0; i < attributionCount; i++) { + final AttributedHistoricalOps origOps = getAttributedOpsAt(i); + final AttributedHistoricalOps spliceOps = origOps.splice(fractionToRemove); if (spliceOps != null) { if (splice == null) { splice = new HistoricalPackageOps(mPackageName); } - if (splice.mHistoricalFeatureOps == null) { - splice.mHistoricalFeatureOps = new ArrayMap<>(); + if (splice.mAttributedHistoricalOps == null) { + splice.mAttributedHistoricalOps = new ArrayMap<>(); } - splice.mHistoricalFeatureOps.put(spliceOps.getFeatureId(), spliceOps); + splice.mAttributedHistoricalOps.put(spliceOps.getTag(), spliceOps); } } return splice; } private void merge(@NonNull HistoricalPackageOps other) { - final int featureCount = other.getFeatureCount(); - for (int i = 0; i < featureCount; i++) { - final HistoricalFeatureOps otherFeatureOps = other.getFeatureOpsAt(i); - final HistoricalFeatureOps thisFeatureOps = getFeatureOps( - otherFeatureOps.getFeatureId()); - if (thisFeatureOps != null) { - thisFeatureOps.merge(otherFeatureOps); + final int attributionCount = other.getAttributedOpsCount(); + for (int i = 0; i < attributionCount; i++) { + final AttributedHistoricalOps otherAttributionOps = other.getAttributedOpsAt(i); + final AttributedHistoricalOps thisAttributionOps = getAttributedOps( + otherAttributionOps.getTag()); + if (thisAttributionOps != null) { + thisAttributionOps.merge(otherAttributionOps); } else { - if (mHistoricalFeatureOps == null) { - mHistoricalFeatureOps = new ArrayMap<>(); + if (mAttributedHistoricalOps == null) { + mAttributedHistoricalOps = new ArrayMap<>(); } - mHistoricalFeatureOps.put(otherFeatureOps.getFeatureId(), otherFeatureOps); + mAttributedHistoricalOps.put(otherAttributionOps.getTag(), + otherAttributionOps); } } } - private void filter(@Nullable String featureId, @Nullable String[] opNames, + private void filter(@Nullable String attributionTag, @Nullable String[] opNames, @HistoricalOpsRequestFilter int filter, double fractionToRemove) { - final int featureCount = getFeatureCount(); - for (int i = featureCount - 1; i >= 0; i--) { - final HistoricalFeatureOps featureOps = getFeatureOpsAt(i); - if ((filter & FILTER_BY_FEATURE_ID) != 0 && !Objects.equals(featureId, - featureOps.getFeatureId())) { - mHistoricalFeatureOps.removeAt(i); + final int attributionCount = getAttributedOpsCount(); + for (int i = attributionCount - 1; i >= 0; i--) { + final AttributedHistoricalOps attributionOps = getAttributedOpsAt(i); + if ((filter & FILTER_BY_ATTRIBUTION_TAG) != 0 && !Objects.equals(attributionTag, + attributionOps.getTag())) { + mAttributedHistoricalOps.removeAt(i); } else { - featureOps.filter(opNames, filter, fractionToRemove); - if (featureOps.getOpCount() == 0) { - mHistoricalFeatureOps.removeAt(i); + attributionOps.filter(opNames, filter, fractionToRemove); + if (attributionOps.getOpCount() == 0) { + mAttributedHistoricalOps.removeAt(i); } } } @@ -5203,38 +5206,38 @@ public class AppOpsManager { private void accept(@NonNull HistoricalOpsVisitor visitor) { visitor.visitHistoricalPackageOps(this); - final int featureCount = getFeatureCount(); - for (int i = 0; i < featureCount; i++) { - getFeatureOpsAt(i).accept(visitor); + final int attributionCount = getAttributedOpsCount(); + for (int i = 0; i < attributionCount; i++) { + getAttributedOpsAt(i).accept(visitor); } } private boolean isEmpty() { - final int featureCount = getFeatureCount(); - for (int i = featureCount - 1; i >= 0; i--) { - final HistoricalFeatureOps featureOps = mHistoricalFeatureOps.valueAt(i); - if (!featureOps.isEmpty()) { + final int attributionCount = getAttributedOpsCount(); + for (int i = attributionCount - 1; i >= 0; i--) { + final AttributedHistoricalOps attributionOps = mAttributedHistoricalOps.valueAt(i); + if (!attributionOps.isEmpty()) { return false; } } return true; } - private void increaseAccessCount(int opCode, @Nullable String featureId, + private void increaseAccessCount(int opCode, @Nullable String attributionTag, @UidState int uidState, @OpFlags int flags, long increment) { - getOrCreateHistoricalFeatureOps(featureId).increaseAccessCount( + getOrCreateAttributedHistoricalOps(attributionTag).increaseAccessCount( opCode, uidState, flags, increment); } - private void increaseRejectCount(int opCode, @Nullable String featureId, + private void increaseRejectCount(int opCode, @Nullable String attributionTag, @UidState int uidState, @OpFlags int flags, long increment) { - getOrCreateHistoricalFeatureOps(featureId).increaseRejectCount( + getOrCreateAttributedHistoricalOps(attributionTag).increaseRejectCount( opCode, uidState, flags, increment); } - private void increaseAccessDuration(int opCode, @Nullable String featureId, + private void increaseAccessDuration(int opCode, @Nullable String attributionTag, @UidState int uidState, @OpFlags int flags, long increment) { - getOrCreateHistoricalFeatureOps(featureId).increaseAccessDuration( + getOrCreateAttributedHistoricalOps(attributionTag).increaseAccessDuration( opCode, uidState, flags, increment); } @@ -5247,17 +5250,18 @@ public class AppOpsManager { return mPackageName; } - private @NonNull HistoricalFeatureOps getOrCreateHistoricalFeatureOps( - @Nullable String featureId) { - if (mHistoricalFeatureOps == null) { - mHistoricalFeatureOps = new ArrayMap<>(); + private @NonNull AttributedHistoricalOps getOrCreateAttributedHistoricalOps( + @Nullable String attributionTag) { + if (mAttributedHistoricalOps == null) { + mAttributedHistoricalOps = new ArrayMap<>(); } - HistoricalFeatureOps historicalFeatureOp = mHistoricalFeatureOps.get(featureId); - if (historicalFeatureOp == null) { - historicalFeatureOp = new HistoricalFeatureOps(featureId); - mHistoricalFeatureOps.put(featureId, historicalFeatureOp); + AttributedHistoricalOps historicalAttributionOp = mAttributedHistoricalOps.get( + attributionTag); + if (historicalAttributionOp == null) { + historicalAttributionOp = new AttributedHistoricalOps(attributionTag); + mAttributedHistoricalOps.put(attributionTag, historicalAttributionOp); } - return historicalFeatureOp; + return historicalAttributionOp; } /** @@ -5268,13 +5272,13 @@ public class AppOpsManager { */ public @IntRange(from = 0) int getOpCount() { int numOps = 0; - int numFeatures = getFeatureCount(); + int numAttributions = getAttributedOpsCount(); for (int code = 0; code < _NUM_OP; code++) { String opName = opToPublicName(code); - for (int featureNum = 0; featureNum < numFeatures; featureNum++) { - if (getFeatureOpsAt(featureNum).getOp(opName) != null) { + for (int attributionNum = 0; attributionNum < numAttributions; attributionNum++) { + if (getAttributedOpsAt(attributionNum).getOp(opName) != null) { numOps++; break; } @@ -5287,7 +5291,7 @@ public class AppOpsManager { /** * Gets the historical op at a given index. * - * <p>This combines the counts from all features. + * <p>This combines the counts from all attributions. * * @param index The index to lookup. * @return The op at the given index. @@ -5295,13 +5299,13 @@ public class AppOpsManager { */ public @NonNull HistoricalOp getOpAt(@IntRange(from = 0) int index) { int numOpsFound = 0; - int numFeatures = getFeatureCount(); + int numAttributions = getAttributedOpsCount(); for (int code = 0; code < _NUM_OP; code++) { String opName = opToPublicName(code); - for (int featureNum = 0; featureNum < numFeatures; featureNum++) { - if (getFeatureOpsAt(featureNum).getOp(opName) != null) { + for (int attributionNum = 0; attributionNum < numAttributions; attributionNum++) { + if (getAttributedOpsAt(attributionNum).getOp(opName) != null) { if (numOpsFound == index) { return getOp(opName); } else { @@ -5318,25 +5322,25 @@ public class AppOpsManager { /** * Gets the historical entry for a given op name. * - * <p>This combines the counts from all features. + * <p>This combines the counts from all attributions. * * @param opName The op name. * @return The historical entry for that op name. */ public @Nullable HistoricalOp getOp(@NonNull String opName) { - if (mHistoricalFeatureOps == null) { + if (mAttributedHistoricalOps == null) { return null; } HistoricalOp combinedOp = null; - int numFeatures = getFeatureCount(); - for (int i = 0; i < numFeatures; i++) { - HistoricalOp featureOp = getFeatureOpsAt(i).getOp(opName); - if (featureOp != null) { + int numAttributions = getAttributedOpsCount(); + for (int i = 0; i < numAttributions; i++) { + HistoricalOp attributionOp = getAttributedOpsAt(i).getOp(opName); + if (attributionOp != null) { if (combinedOp == null) { - combinedOp = new HistoricalOp(featureOp); + combinedOp = new HistoricalOp(attributionOp); } else { - combinedOp.merge(featureOp); + combinedOp.merge(attributionOp); } } } @@ -5352,7 +5356,7 @@ public class AppOpsManager { @Override public void writeToParcel(@NonNull Parcel parcel, int flags) { parcel.writeString(mPackageName); - parcel.writeTypedArrayMap(mHistoricalFeatureOps, flags); + parcel.writeTypedArrayMap(mAttributedHistoricalOps, flags); } public static final @android.annotation.NonNull Creator<HistoricalPackageOps> CREATOR = @@ -5380,11 +5384,11 @@ public class AppOpsManager { if (!mPackageName.equals(other.mPackageName)) { return false; } - if (mHistoricalFeatureOps == null) { - if (other.mHistoricalFeatureOps != null) { + if (mAttributedHistoricalOps == null) { + if (other.mAttributedHistoricalOps != null) { return false; } - } else if (!mHistoricalFeatureOps.equals(other.mHistoricalFeatureOps)) { + } else if (!mAttributedHistoricalOps.equals(other.mAttributedHistoricalOps)) { return false; } return true; @@ -5393,58 +5397,58 @@ public class AppOpsManager { @Override public int hashCode() { int result = mPackageName != null ? mPackageName.hashCode() : 0; - result = 31 * result + (mHistoricalFeatureOps != null ? mHistoricalFeatureOps.hashCode() - : 0); + result = 31 * result + (mAttributedHistoricalOps != null + ? mAttributedHistoricalOps.hashCode() : 0); return result; } /** - * Gets number of feature with historical ops. + * Gets number of attributed historical ops. * - * @return The number of feature with historical ops. + * @return The number of attribution with historical ops. * - * @see #getFeatureOpsAt(int) + * @see #getAttributedOpsAt(int) */ - public @IntRange(from = 0) int getFeatureCount() { - if (mHistoricalFeatureOps == null) { + public @IntRange(from = 0) int getAttributedOpsCount() { + if (mAttributedHistoricalOps == null) { return 0; } - return mHistoricalFeatureOps.size(); + return mAttributedHistoricalOps.size(); } /** - * Gets the historical feature ops at a given index. + * Gets the attributed historical ops at a given index. * * @param index The index. * - * @return The historical feature ops at the given index. + * @return The historical attribution ops at the given index. * - * @see #getFeatureCount() + * @see #getAttributedOpsCount() */ - public @NonNull HistoricalFeatureOps getFeatureOpsAt(@IntRange(from = 0) int index) { - if (mHistoricalFeatureOps == null) { + public @NonNull AttributedHistoricalOps getAttributedOpsAt(@IntRange(from = 0) int index) { + if (mAttributedHistoricalOps == null) { throw new IndexOutOfBoundsException(); } - return mHistoricalFeatureOps.valueAt(index); + return mAttributedHistoricalOps.valueAt(index); } /** - * Gets the historical feature ops for a given feature. + * Gets the attributed historical ops for a given attribution tag. * - * @param featureId The feature id. + * @param attributionTag The attribution tag. * - * @return The historical ops for the feature. + * @return The historical ops for the attribution. */ - public @Nullable HistoricalFeatureOps getFeatureOps(@NonNull String featureId) { - if (mHistoricalFeatureOps == null) { + public @Nullable AttributedHistoricalOps getAttributedOps(@NonNull String attributionTag) { + if (mAttributedHistoricalOps == null) { return null; } - return mHistoricalFeatureOps.get(featureId); + return mAttributedHistoricalOps.get(attributionTag); } } /** - * This class represents historical app op information about a feature in a package. + * This class represents historical app op information about a attribution in a package. * * @hide */ @@ -5454,20 +5458,20 @@ public class AppOpsManager { @DataClass(genHiddenConstructor = true, genEqualsHashCode = true, genHiddenCopyConstructor = true) */ @DataClass.Suppress("getHistoricalOps") - public static final class HistoricalFeatureOps implements Parcelable { - /** Id of the {@link Context#createFeatureContext feature} in the package */ - private final @Nullable String mFeatureId; + public static final class AttributedHistoricalOps implements Parcelable { + /** {@link Context#createAttributionContext attribution} tag */ + private final @Nullable String mTag; - /** Ops for this feature */ + /** Ops for this attribution */ private @Nullable ArrayMap<String, HistoricalOp> mHistoricalOps; /** @hide */ - public HistoricalFeatureOps(@NonNull String featureId) { - mFeatureId = featureId; + public AttributedHistoricalOps(@NonNull String tag) { + mTag = tag; } - private HistoricalFeatureOps(@NonNull HistoricalFeatureOps other) { - mFeatureId = other.mFeatureId; + private AttributedHistoricalOps(@NonNull AttributedHistoricalOps other) { + mTag = other.mTag; final int opCount = other.getOpCount(); for (int i = 0; i < opCount; i++) { final HistoricalOp origOp = other.getOpAt(i); @@ -5479,15 +5483,15 @@ public class AppOpsManager { } } - private @Nullable HistoricalFeatureOps splice(double fractionToRemove) { - HistoricalFeatureOps splice = null; + private @Nullable AttributedHistoricalOps splice(double fractionToRemove) { + AttributedHistoricalOps splice = null; final int opCount = getOpCount(); for (int i = 0; i < opCount; i++) { final HistoricalOp origOps = getOpAt(i); final HistoricalOp spliceOps = origOps.splice(fractionToRemove); if (spliceOps != null) { if (splice == null) { - splice = new HistoricalFeatureOps(mFeatureId, null); + splice = new AttributedHistoricalOps(mTag, null); } if (splice.mHistoricalOps == null) { splice.mHistoricalOps = new ArrayMap<>(); @@ -5498,7 +5502,7 @@ public class AppOpsManager { return splice; } - private void merge(@NonNull HistoricalFeatureOps other) { + private void merge(@NonNull AttributedHistoricalOps other) { final int opCount = other.getOpCount(); for (int i = 0; i < opCount; i++) { final HistoricalOp otherOp = other.getOpAt(i); @@ -5595,7 +5599,7 @@ public class AppOpsManager { } private void accept(@NonNull HistoricalOpsVisitor visitor) { - visitor.visitHistoricalFeatureOps(this); + visitor.visitHistoricalAttributionOps(this); final int opCount = getOpCount(); for (int i = 0; i < opCount; i++) { getOpAt(i).accept(visitor); @@ -5631,46 +5635,46 @@ public class AppOpsManager { /** - * Creates a new HistoricalFeatureOps. + * Creates a new HistoricalAttributionOps. * - * @param featureId - * Id of the {@link Context#createFeatureContext feature} in the package + * @param tag + * {@link Context#createAttributionContext attribution} tag * @param historicalOps - * Ops for this feature + * Ops for this attribution * @hide */ @DataClass.Generated.Member - public HistoricalFeatureOps( - @Nullable String featureId, + public AttributedHistoricalOps( + @Nullable String tag, @Nullable ArrayMap<String,HistoricalOp> historicalOps) { - this.mFeatureId = featureId; + this.mTag = tag; this.mHistoricalOps = historicalOps; // onConstructed(); // You can define this method to get a callback } /** - * Id of the {@link Context#createFeatureContext feature} in the package + * {@link Context#createAttributionContext attribution} tag */ @DataClass.Generated.Member - public @Nullable String getFeatureId() { - return mFeatureId; + public @Nullable String getTag() { + return mTag; } @Override @DataClass.Generated.Member public boolean equals(@Nullable Object o) { // You can override field equality logic by defining either of the methods like: - // boolean fieldNameEquals(HistoricalFeatureOps other) { ... } + // boolean fieldNameEquals(HistoricalAttributionOps other) { ... } // boolean fieldNameEquals(FieldType otherValue) { ... } if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; @SuppressWarnings("unchecked") - HistoricalFeatureOps that = (HistoricalFeatureOps) o; + AttributedHistoricalOps that = (AttributedHistoricalOps) o; //noinspection PointlessBooleanExpression return true - && Objects.equals(mFeatureId, that.mFeatureId) + && Objects.equals(mTag, that.mTag) && Objects.equals(mHistoricalOps, that.mHistoricalOps); } @@ -5681,7 +5685,7 @@ public class AppOpsManager { // int fieldNameHashCode() { ... } int _hash = 1; - _hash = 31 * _hash + Objects.hashCode(mFeatureId); + _hash = 31 * _hash + Objects.hashCode(mTag); _hash = 31 * _hash + Objects.hashCode(mHistoricalOps); return _hash; } @@ -5693,10 +5697,10 @@ public class AppOpsManager { // void parcelFieldName(Parcel dest, int flags) { ... } byte flg = 0; - if (mFeatureId != null) flg |= 0x1; + if (mTag != null) flg |= 0x1; if (mHistoricalOps != null) flg |= 0x2; dest.writeByte(flg); - if (mFeatureId != null) dest.writeString(mFeatureId); + if (mTag != null) dest.writeString(mTag); if (mHistoricalOps != null) dest.writeMap(mHistoricalOps); } @@ -5707,35 +5711,35 @@ public class AppOpsManager { /** @hide */ @SuppressWarnings({"unchecked", "RedundantCast"}) @DataClass.Generated.Member - /* package-private */ HistoricalFeatureOps(@NonNull Parcel in) { + /* package-private */ AttributedHistoricalOps(@NonNull Parcel in) { // You can override field unparcelling by defining methods like: // static FieldType unparcelFieldName(Parcel in) { ... } byte flg = in.readByte(); - String featureId = (flg & 0x1) == 0 ? null : in.readString(); + String attributionTag = (flg & 0x1) == 0 ? null : in.readString(); ArrayMap<String,HistoricalOp> historicalOps = null; if ((flg & 0x2) != 0) { historicalOps = new ArrayMap(); in.readMap(historicalOps, HistoricalOp.class.getClassLoader()); } - this.mFeatureId = featureId; + this.mTag = attributionTag; this.mHistoricalOps = historicalOps; // onConstructed(); // You can define this method to get a callback } @DataClass.Generated.Member - public static final @NonNull Parcelable.Creator<HistoricalFeatureOps> CREATOR - = new Parcelable.Creator<HistoricalFeatureOps>() { + public static final @NonNull Parcelable.Creator<AttributedHistoricalOps> CREATOR + = new Parcelable.Creator<AttributedHistoricalOps>() { @Override - public HistoricalFeatureOps[] newArray(int size) { - return new HistoricalFeatureOps[size]; + public AttributedHistoricalOps[] newArray(int size) { + return new AttributedHistoricalOps[size]; } @Override - public HistoricalFeatureOps createFromParcel(@NonNull Parcel in) { - return new HistoricalFeatureOps(in); + public AttributedHistoricalOps createFromParcel(@NonNull Parcel in) { + return new AttributedHistoricalOps(in); } }; @@ -5744,7 +5748,7 @@ public class AppOpsManager { time = 1578113234821L, codegenVersion = "1.0.14", sourceFile = "frameworks/base/core/java/android/app/AppOpsManager.java", - inputSignatures = "private final @android.annotation.Nullable java.lang.String mFeatureId\nprivate @android.annotation.Nullable android.util.ArrayMap<java.lang.String,android.app.HistoricalOp> mHistoricalOps\nprivate @android.annotation.Nullable android.app.HistoricalFeatureOps splice(double)\nprivate void merge(android.app.HistoricalFeatureOps)\nprivate void filter(java.lang.String[],int,double)\nprivate boolean isEmpty()\nprivate void increaseAccessCount(int,int,int,long)\nprivate void increaseRejectCount(int,int,int,long)\nprivate void increaseAccessDuration(int,int,int,long)\npublic @android.annotation.IntRange(from=0L) int getOpCount()\npublic @android.annotation.NonNull android.app.HistoricalOp getOpAt(int)\npublic @android.annotation.Nullable android.app.HistoricalOp getOp(java.lang.String)\nprivate void accept(android.app.HistoricalOpsVisitor)\nprivate @android.annotation.NonNull android.app.HistoricalOp getOrCreateHistoricalOp(int)\nclass HistoricalFeatureOps extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genHiddenConstructor=true, genEqualsHashCode=true, genHiddenCopyConstructor=true)") + inputSignatures = "private final @android.annotation.Nullable java.lang.String mAttributionTag\nprivate @android.annotation.Nullable android.util.ArrayMap<java.lang.String,android.app.HistoricalOp> mHistoricalOps\nprivate @android.annotation.Nullable android.app.HistoricalAttributionOps splice(double)\nprivate void merge(android.app.HistoricalAttributionOps)\nprivate void filter(java.lang.String[],int,double)\nprivate boolean isEmpty()\nprivate void increaseAccessCount(int,int,int,long)\nprivate void increaseRejectCount(int,int,int,long)\nprivate void increaseAccessDuration(int,int,int,long)\npublic @android.annotation.IntRange(from=0L) int getOpCount()\npublic @android.annotation.NonNull android.app.HistoricalOp getOpAt(int)\npublic @android.annotation.Nullable android.app.HistoricalOp getOp(java.lang.String)\nprivate void accept(android.app.HistoricalOpsVisitor)\nprivate @android.annotation.NonNull android.app.HistoricalOp getOrCreateHistoricalOp(int)\nclass HistoricalAttributionOps extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genHiddenConstructor=true, genEqualsHashCode=true, genHiddenCopyConstructor=true)") @Deprecated private void __metadata() {} */ @@ -6420,7 +6424,7 @@ public class AppOpsManager { Objects.requireNonNull(executor, "executor cannot be null"); Objects.requireNonNull(callback, "callback cannot be null"); try { - mService.getHistoricalOps(request.mUid, request.mPackageName, request.mFeatureId, + mService.getHistoricalOps(request.mUid, request.mPackageName, request.mAttributionTag, request.mOpNames, request.mFilter, request.mBeginTimeMillis, request.mEndTimeMillis, request.mFlags, new RemoteCallback((result) -> { final HistoricalOps ops = result.getParcelable(KEY_HISTORICAL_OPS); @@ -6460,8 +6464,9 @@ public class AppOpsManager { Objects.requireNonNull(callback, "callback cannot be null"); try { mService.getHistoricalOpsFromDiskRaw(request.mUid, request.mPackageName, - request.mFeatureId, request.mOpNames, request.mFilter, request.mBeginTimeMillis, - request.mEndTimeMillis, request.mFlags, new RemoteCallback((result) -> { + request.mAttributionTag, request.mOpNames, request.mFilter, + request.mBeginTimeMillis, request.mEndTimeMillis, request.mFlags, + new RemoteCallback((result) -> { final HistoricalOps ops = result.getParcelable(KEY_HISTORICAL_OPS); final long identity = Binder.clearCallingIdentity(); try { @@ -7044,8 +7049,8 @@ public class AppOpsManager { * @param op The operation to note. One of the OPSTR_* constants. * @param uid The user id of the application attempting to perform the operation. * @param packageName The name of the application attempting to perform the operation. - * @param featureId The {@link Context#createFeatureContext feature} in the package or {@code - * null} for default feature + * @param attributionTag The {@link Context#createAttributionContext attribution tag} or {@code + * null} for default attribution * @param message A message describing the reason the op was noted * * @return Returns {@link #MODE_ALLOWED} if the operation is allowed, or @@ -7055,8 +7060,8 @@ public class AppOpsManager { * @throws SecurityException If the app has been configured to crash on this op. */ public int noteOp(@NonNull String op, int uid, @Nullable String packageName, - @Nullable String featureId, @Nullable String message) { - return noteOp(strOpToOp(op), uid, packageName, featureId, message); + @Nullable String attributionTag, @Nullable String message) { + return noteOp(strOpToOp(op), uid, packageName, attributionTag, message); } /** @@ -7072,7 +7077,8 @@ public class AppOpsManager { * @param op The operation to note. One of the OP_* constants. * @param uid The user id of the application attempting to perform the operation. * @param packageName The name of the application attempting to perform the operation. - * @param featureId The feature in the app or {@code null} for default feature + * @param attributionTag The {@link Context#createAttributionContext attribution tag} or {@code + * null} for default attribution * @param message A message describing the reason the op was noted * * @return Returns {@link #MODE_ALLOWED} if the operation is allowed, or @@ -7083,9 +7089,9 @@ public class AppOpsManager { * * @hide */ - public int noteOp(int op, int uid, @Nullable String packageName, @Nullable String featureId, - @Nullable String message) { - final int mode = noteOpNoThrow(op, uid, packageName, featureId, message); + public int noteOp(int op, int uid, @Nullable String packageName, + @Nullable String attributionTag, @Nullable String message) { + final int mode = noteOpNoThrow(op, uid, packageName, attributionTag, message); if (mode == MODE_ERRORED) { throw new SecurityException(buildSecurityExceptionMsg(op, uid, packageName)); } @@ -7120,8 +7126,8 @@ public class AppOpsManager { * @param op The operation to note. One of the OPSTR_* constants. * @param uid The user id of the application attempting to perform the operation. * @param packageName The name of the application attempting to perform the operation. - * @param featureId The {@link Context#createFeatureContext feature} in the package or {@code - * null} for default feature + * @param attributionTag The {@link Context#createAttributionContext attribution tag} or {@code + * null} for default attribution * @param message A message describing the reason the op was noted * * @return Returns {@link #MODE_ALLOWED} if the operation is allowed, or @@ -7129,8 +7135,8 @@ public class AppOpsManager { * causing the app to crash). */ public int noteOpNoThrow(@NonNull String op, int uid, @NonNull String packageName, - @Nullable String featureId, @Nullable String message) { - return noteOpNoThrow(strOpToOp(op), uid, packageName, featureId, message); + @Nullable String attributionTag, @Nullable String message) { + return noteOpNoThrow(strOpToOp(op), uid, packageName, attributionTag, message); } /** @@ -7140,7 +7146,8 @@ public class AppOpsManager { * @param op The operation to note. One of the OP_* constants. * @param uid The user id of the application attempting to perform the operation. * @param packageName The name of the application attempting to perform the operation. - * @param featureId The feature in the app or {@code null} for default feature + * @param attributionTag The {@link Context#createAttributionContext attribution tag} or {@code + * null} for default attribution * @param message A message describing the reason the op was noted * * @return Returns {@link #MODE_ALLOWED} if the operation is allowed, or @@ -7150,7 +7157,7 @@ public class AppOpsManager { * @hide */ public int noteOpNoThrow(int op, int uid, @Nullable String packageName, - @Nullable String featureId, @Nullable String message) { + @Nullable String attributionTag, @Nullable String message) { try { collectNoteOpCallsForValidation(op); int collectionMode = getNotedOpCollectionMode(uid, packageName, op); @@ -7161,14 +7168,14 @@ public class AppOpsManager { } } - int mode = mService.noteOperation(op, uid, packageName, featureId, + int mode = mService.noteOperation(op, uid, packageName, attributionTag, collectionMode == COLLECT_ASYNC, message); if (mode == MODE_ALLOWED) { if (collectionMode == COLLECT_SELF) { - collectNotedOpForSelf(op, featureId); + collectNotedOpForSelf(op, attributionTag); } else if (collectionMode == COLLECT_SYNC) { - collectNotedOpSync(op, featureId); + collectNotedOpSync(op, attributionTag); } } @@ -7208,8 +7215,8 @@ public class AppOpsManager { * @param op The operation to note. One of the OP_* constants. * @param proxiedPackageName The name of the application calling into the proxy application. * @param proxiedUid The uid of the proxied application - * @param proxiedFeatureId The feature in the proxied app or {@code null} for default - * feature + * @param proxiedAttributionTag The proxied {@link Context#createAttributionContext + * attribution tag} or {@code null} for default attribution * @param message A message describing the reason the op was noted * * @return Returns {@link #MODE_ALLOWED} if the operation is allowed, or {@link #MODE_IGNORED} @@ -7221,8 +7228,8 @@ public class AppOpsManager { * @hide */ public int noteProxyOp(int op, @Nullable String proxiedPackageName, int proxiedUid, - @Nullable String proxiedFeatureId, @Nullable String message) { - int mode = noteProxyOpNoThrow(op, proxiedPackageName, proxiedUid, proxiedFeatureId, + @Nullable String proxiedAttributionTag, @Nullable String message) { + int mode = noteProxyOpNoThrow(op, proxiedPackageName, proxiedUid, proxiedAttributionTag, message); if (mode == MODE_ERRORED) { throw new SecurityException("Proxy package " + mContext.getOpPackageName() @@ -7241,8 +7248,8 @@ public class AppOpsManager { * @param op The operation to note. One of the OPSTR_* constants. * @param proxiedPackageName The name of the application calling into the proxy application. * @param proxiedUid The uid of the proxied application - * @param proxiedFeatureId The feature in the proxied app or {@code null} for default - * feature + * @param proxiedAttributionTag The proxied {@link Context#createAttributionContext + * attribution tag} or {@code null} for default attribution * @param message A message describing the reason the op was noted * * @return Returns {@link #MODE_ALLOWED} if the operation is allowed, or {@link #MODE_IGNORED} @@ -7252,8 +7259,8 @@ public class AppOpsManager { * op. */ public int noteProxyOp(@NonNull String op, @Nullable String proxiedPackageName, int proxiedUid, - @Nullable String proxiedFeatureId, @Nullable String message) { - return noteProxyOp(strOpToOp(op), proxiedPackageName, proxiedUid, proxiedFeatureId, + @Nullable String proxiedAttributionTag, @Nullable String message) { + return noteProxyOp(strOpToOp(op), proxiedPackageName, proxiedUid, proxiedAttributionTag, message); } @@ -7284,14 +7291,14 @@ public class AppOpsManager { * @param op The op to note * @param proxiedPackageName The package to note the op for * @param proxiedUid The uid the package belongs to - * @param proxiedFeatureId The feature in the proxied app or {@code null} for default - * feature + * @param proxiedAttributionTag The proxied {@link Context#createAttributionContext + * attribution tag} or {@code null} for default attribution * @param message A message describing the reason the op was noted */ public int noteProxyOpNoThrow(@NonNull String op, @Nullable String proxiedPackageName, - int proxiedUid, @Nullable String proxiedFeatureId, @Nullable String message) { + int proxiedUid, @Nullable String proxiedAttributionTag, @Nullable String message) { return noteProxyOpNoThrow(strOpToOp(op), proxiedPackageName, proxiedUid, - proxiedFeatureId, message); + proxiedAttributionTag, message); } /** @@ -7302,14 +7309,14 @@ public class AppOpsManager { * @param proxiedPackageName The package to note the op for or {@code null} if the op should be * noted for the "android" package * @param proxiedUid The uid the package belongs to - * @param proxiedFeatureId The feature in the proxied app or {@code null} for default - * feature + * @param proxiedAttributionTag The proxied {@link Context#createAttributionContext + * attribution tag} or {@code null} for default attribution * @param message A message describing the reason the op was noted * * @hide */ public int noteProxyOpNoThrow(int op, @Nullable String proxiedPackageName, int proxiedUid, - @Nullable String proxiedFeatureId, @Nullable String message) { + @Nullable String proxiedAttributionTag, @Nullable String message) { int myUid = Process.myUid(); try { @@ -7323,17 +7330,17 @@ public class AppOpsManager { } int mode = mService.noteProxyOperation(op, proxiedUid, proxiedPackageName, - proxiedFeatureId, myUid, mContext.getOpPackageName(), - mContext.getFeatureId(), collectionMode == COLLECT_ASYNC, message); + proxiedAttributionTag, myUid, mContext.getOpPackageName(), + mContext.getAttributionTag(), collectionMode == COLLECT_ASYNC, message); if (mode == MODE_ALLOWED) { if (collectionMode == COLLECT_SELF) { - collectNotedOpForSelf(op, proxiedFeatureId); + collectNotedOpForSelf(op, proxiedAttributionTag); } 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) { - collectNotedOpSync(op, proxiedFeatureId); + collectNotedOpSync(op, proxiedAttributionTag); } } @@ -7522,8 +7529,8 @@ public class AppOpsManager { * @param op The operation to start. One of the OPSTR_* constants. * @param uid The user id of the application attempting to perform the operation. * @param packageName The name of the application attempting to perform the operation. - * @param featureId The {@link Context#createFeatureContext feature} in the package or {@code - * null} for default feature + * @param attributionTag The {@link Context#createAttributionContext attribution tag} or + * {@code null} for default attribution * @param message Description why op was started * * @return Returns {@link #MODE_ALLOWED} if the operation is allowed, or @@ -7534,8 +7541,8 @@ public class AppOpsManager { * the package is not in the passed in UID. */ public int startOp(@NonNull String op, int uid, @Nullable String packageName, - @Nullable String featureId, @Nullable String message) { - return startOp(strOpToOp(op), uid, packageName, false, featureId, message); + @Nullable String attributionTag, @Nullable String message) { + return startOp(strOpToOp(op), uid, packageName, false, attributionTag, message); } /** @@ -7544,7 +7551,8 @@ public class AppOpsManager { * @param op The operation to start. One of the OP_* constants. * @param uid The user id of the application attempting to perform the operation. * @param packageName The name of the application attempting to perform the operation. - * @param featureId The feature in the app or {@code null} for default feature + * @param attributionTag The {@link Context#createAttributionContext attribution tag} or + * {@code null} for default attribution * @param startIfModeDefault Whether to start if mode is {@link #MODE_DEFAULT}. * @param message Description why op was started * @@ -7558,8 +7566,8 @@ public class AppOpsManager { * @hide */ public int startOp(int op, int uid, @Nullable String packageName, boolean startIfModeDefault, - @Nullable String featureId, @Nullable String message) { - final int mode = startOpNoThrow(op, uid, packageName, startIfModeDefault, featureId, + @Nullable String attributionTag, @Nullable String message) { + final int mode = startOpNoThrow(op, uid, packageName, startIfModeDefault, attributionTag, message); if (mode == MODE_ERRORED) { throw new SecurityException(buildSecurityExceptionMsg(op, uid, packageName)); @@ -7602,7 +7610,8 @@ public class AppOpsManager { * @param op The operation to start. One of the OP_* constants. * @param uid The user id of the application attempting to perform the operation. * @param packageName The name of the application attempting to perform the operation. - * @param featureId The feature in the app or {@code null} for default feature + * @param attributionTag The {@link Context#createAttributionContext attribution tag} or + * {@code null} for default attribution * @param message Description why op was started * * @return Returns {@link #MODE_ALLOWED} if the operation is allowed, or @@ -7610,8 +7619,8 @@ public class AppOpsManager { * causing the app to crash). */ public int startOpNoThrow(@NonNull String op, int uid, @NonNull String packageName, - @NonNull String featureId, @Nullable String message) { - return startOpNoThrow(strOpToOp(op), uid, packageName, false, featureId, message); + @NonNull String attributionTag, @Nullable String message) { + return startOpNoThrow(strOpToOp(op), uid, packageName, false, attributionTag, message); } /** @@ -7621,7 +7630,8 @@ public class AppOpsManager { * @param op The operation to start. One of the OP_* constants. * @param uid The user id of the application attempting to perform the operation. * @param packageName The name of the application attempting to perform the operation. - * @param featureId The feature in the app or {@code null} for default feature + * @param attributionTag The {@link Context#createAttributionContext attribution tag} or + * {@code null} for default attribution * @param startIfModeDefault Whether to start if mode is {@link #MODE_DEFAULT}. * @param message Description why op was started * @@ -7632,7 +7642,7 @@ public class AppOpsManager { * @hide */ public int startOpNoThrow(int op, int uid, @NonNull String packageName, - boolean startIfModeDefault, @Nullable String featureId, @Nullable String message) { + boolean startIfModeDefault, @Nullable String attributionTag, @Nullable String message) { try { collectNoteOpCallsForValidation(op); int collectionMode = getNotedOpCollectionMode(uid, packageName, op); @@ -7644,13 +7654,13 @@ public class AppOpsManager { } int mode = mService.startOperation(getClientId(), op, uid, packageName, - featureId, startIfModeDefault, collectionMode == COLLECT_ASYNC, message); + attributionTag, startIfModeDefault, collectionMode == COLLECT_ASYNC, message); if (mode == MODE_ALLOWED) { if (collectionMode == COLLECT_SELF) { - collectNotedOpForSelf(op, featureId); + collectNotedOpForSelf(op, attributionTag); } else if (collectionMode == COLLECT_SYNC) { - collectNotedOpSync(op, featureId); + collectNotedOpSync(op, attributionTag); } } @@ -7684,8 +7694,8 @@ public class AppOpsManager { * previously passed in when starting the operation. */ public void finishOp(@NonNull String op, int uid, @NonNull String packageName, - @Nullable String featureId) { - finishOp(strOpToOp(op), uid, packageName, featureId); + @Nullable String attributionTag) { + finishOp(strOpToOp(op), uid, packageName, attributionTag); } /** @@ -7706,9 +7716,9 @@ public class AppOpsManager { * @hide */ public void finishOp(int op, int uid, @NonNull String packageName, - @Nullable String featureId) { + @Nullable String attributionTag) { try { - mService.finishOperation(getClientId(), op, uid, packageName, featureId); + mService.finishOperation(getClientId(), op, uid, packageName, attributionTag); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -7819,15 +7829,15 @@ public class AppOpsManager { * Collect a noted op for the current process. * * @param op The noted op - * @param featureId The feature the op is noted for + * @param attributionTag The attribution tag the op is noted for */ - private void collectNotedOpForSelf(int op, @Nullable String featureId) { + private void collectNotedOpForSelf(int op, @Nullable String attributionTag) { synchronized (sLock) { if (sOnOpNotedCallback != null) { - sOnOpNotedCallback.onSelfNoted(new SyncNotedAppOp(op, featureId)); + sOnOpNotedCallback.onSelfNoted(new SyncNotedAppOp(op, attributionTag)); } } - sMessageCollector.onSelfNoted(new SyncNotedAppOp(op, featureId)); + sMessageCollector.onSelfNoted(new SyncNotedAppOp(op, attributionTag)); } /** @@ -7836,9 +7846,9 @@ public class AppOpsManager { * <p> Delivered to caller via {@link #prefixParcelWithAppOpsIfNeeded} * * @param op The noted op - * @param featureId The feature the op is noted for + * @param attributionTag The attribution tag the op is noted for */ - private void collectNotedOpSync(int op, @Nullable String featureId) { + private void collectNotedOpSync(int op, @Nullable String attributionTag) { // If this is inside of a two-way binder call: // We are inside of a two-way binder call. Delivered to caller via // {@link #prefixParcelWithAppOpsIfNeeded} @@ -7848,16 +7858,16 @@ public class AppOpsManager { sAppOpsNotedInThisBinderTransaction.set(appOpsNoted); } - long[] appOpsNotedForFeature = appOpsNoted.get(featureId); - if (appOpsNotedForFeature == null) { - appOpsNotedForFeature = new long[2]; - appOpsNoted.put(featureId, appOpsNotedForFeature); + long[] appOpsNotedForAttribution = appOpsNoted.get(attributionTag); + if (appOpsNotedForAttribution == null) { + appOpsNotedForAttribution = new long[2]; + appOpsNoted.put(attributionTag, appOpsNotedForAttribution); } if (op < 64) { - appOpsNotedForFeature[0] |= 1L << op; + appOpsNotedForAttribution[0] |= 1L << op; } else { - appOpsNotedForFeature[1] |= 1L << (op - 64); + appOpsNotedForAttribution[1] |= 1L << (op - 64); } } @@ -7938,10 +7948,10 @@ public class AppOpsManager { p.writeInt(Parcel.EX_HAS_NOTED_APPOPS_REPLY_HEADER); - int numFeatureWithNotesAppOps = notedAppOps.size(); - p.writeInt(numFeatureWithNotesAppOps); + int numAttributionWithNotesAppOps = notedAppOps.size(); + p.writeInt(numAttributionWithNotesAppOps); - for (int i = 0; i < numFeatureWithNotesAppOps; i++) { + for (int i = 0; i < numAttributionWithNotesAppOps; i++) { p.writeString(notedAppOps.keyAt(i)); p.writeLong(notedAppOps.valueAt(i)[0]); p.writeLong(notedAppOps.valueAt(i)[1]); @@ -7959,10 +7969,10 @@ public class AppOpsManager { * @hide */ public static void readAndLogNotedAppops(@NonNull Parcel p) { - int numFeaturesWithNotedAppOps = p.readInt(); + int numAttributionsWithNotedAppOps = p.readInt(); - for (int i = 0; i < numFeaturesWithNotedAppOps; i++) { - String featureId = p.readString(); + for (int i = 0; i < numAttributionsWithNotedAppOps; i++) { + String attributionTag = p.readString(); long[] rawNotedAppOps = new long[2]; rawNotedAppOps[0] = p.readLong(); rawNotedAppOps[1] = p.readLong(); @@ -7974,13 +7984,13 @@ public class AppOpsManager { for (int code = notedAppOps.nextSetBit(0); code != -1; code = notedAppOps.nextSetBit(code + 1)) { if (sOnOpNotedCallback != null) { - sOnOpNotedCallback.onNoted(new SyncNotedAppOp(code, featureId)); + sOnOpNotedCallback.onNoted(new SyncNotedAppOp(code, attributionTag)); } } } for (int code = notedAppOps.nextSetBit(0); code != -1; code = notedAppOps.nextSetBit(code + 1)) { - sMessageCollector.onNoted(new SyncNotedAppOp(code, featureId)); + sMessageCollector.onNoted(new SyncNotedAppOp(code, attributionTag)); } } } diff --git a/core/java/android/app/AsyncNotedAppOp.java b/core/java/android/app/AsyncNotedAppOp.java index 4d955dbe8703..b0c2762c3439 100644 --- a/core/java/android/app/AsyncNotedAppOp.java +++ b/core/java/android/app/AsyncNotedAppOp.java @@ -48,8 +48,8 @@ public final class AsyncNotedAppOp implements Parcelable { /** Uid that noted the op */ private final @IntRange(from = 0) int mNotingUid; - /** {@link android.content.Context#createFeatureContext Feature} in the app */ - private final @Nullable String mFeatureId; + /** {@link android.content.Context#createAttributionContext attribution tag} */ + private final @Nullable String mAttributionTag; /** Message associated with the noteOp. This message is set by the app noting the op */ private final @NonNull String mMessage; @@ -92,8 +92,8 @@ public final class AsyncNotedAppOp implements Parcelable { * Op that was noted * @param notingUid * Uid that noted the op - * @param featureId - * {@link android.content.Context#createFeatureContext Feature} in the app + * @param attributionTag + * {@link android.content.Context#createAttributionContext attribution tag} * @param message * Message associated with the noteOp. This message is set by the app noting the op * @param time @@ -104,7 +104,7 @@ public final class AsyncNotedAppOp implements Parcelable { public AsyncNotedAppOp( @IntRange(from = 0) int opCode, @IntRange(from = 0) int notingUid, - @Nullable String featureId, + @Nullable String attributionTag, @NonNull String message, @CurrentTimeMillisLong long time) { this.mOpCode = opCode; @@ -115,7 +115,7 @@ public final class AsyncNotedAppOp implements Parcelable { com.android.internal.util.AnnotationValidations.validate( IntRange.class, null, mNotingUid, "from", 0); - this.mFeatureId = featureId; + this.mAttributionTag = attributionTag; this.mMessage = message; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mMessage); @@ -135,11 +135,11 @@ public final class AsyncNotedAppOp implements Parcelable { } /** - * {@link android.content.Context#createFeatureContext Feature} in the app + * {@link android.content.Context#createAttributionContext attribution tag} */ @DataClass.Generated.Member - public @Nullable String getFeatureId() { - return mFeatureId; + public @Nullable String getAttributionTag() { + return mAttributionTag; } /** @@ -173,7 +173,7 @@ public final class AsyncNotedAppOp implements Parcelable { return true && mOpCode == that.mOpCode && mNotingUid == that.mNotingUid - && java.util.Objects.equals(mFeatureId, that.mFeatureId) + && java.util.Objects.equals(mAttributionTag, that.mAttributionTag) && java.util.Objects.equals(mMessage, that.mMessage) && mTime == that.mTime; } @@ -187,7 +187,7 @@ public final class AsyncNotedAppOp implements Parcelable { int _hash = 1; _hash = 31 * _hash + mOpCode; _hash = 31 * _hash + mNotingUid; - _hash = 31 * _hash + java.util.Objects.hashCode(mFeatureId); + _hash = 31 * _hash + java.util.Objects.hashCode(mAttributionTag); _hash = 31 * _hash + java.util.Objects.hashCode(mMessage); _hash = 31 * _hash + Long.hashCode(mTime); return _hash; @@ -200,11 +200,11 @@ public final class AsyncNotedAppOp implements Parcelable { // void parcelFieldName(Parcel dest, int flags) { ... } byte flg = 0; - if (mFeatureId != null) flg |= 0x4; + if (mAttributionTag != null) flg |= 0x4; dest.writeByte(flg); dest.writeInt(mOpCode); dest.writeInt(mNotingUid); - if (mFeatureId != null) dest.writeString(mFeatureId); + if (mAttributionTag != null) dest.writeString(mAttributionTag); dest.writeString(mMessage); dest.writeLong(mTime); } @@ -223,7 +223,7 @@ public final class AsyncNotedAppOp implements Parcelable { byte flg = in.readByte(); int opCode = in.readInt(); int notingUid = in.readInt(); - String featureId = (flg & 0x4) == 0 ? null : in.readString(); + String attributionTag = (flg & 0x4) == 0 ? null : in.readString(); String message = in.readString(); long time = in.readLong(); @@ -235,7 +235,7 @@ public final class AsyncNotedAppOp implements Parcelable { com.android.internal.util.AnnotationValidations.validate( IntRange.class, null, mNotingUid, "from", 0); - this.mFeatureId = featureId; + this.mAttributionTag = attributionTag; this.mMessage = message; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mMessage); @@ -261,10 +261,10 @@ public final class AsyncNotedAppOp implements Parcelable { }; @DataClass.Generated( - time = 1583866178330L, + time = 1583866239013L, codegenVersion = "1.0.15", sourceFile = "frameworks/base/core/java/android/app/AsyncNotedAppOp.java", - inputSignatures = "private final @android.annotation.IntRange(from=0L) int mOpCode\nprivate final @android.annotation.IntRange(from=0L) int mNotingUid\nprivate final @android.annotation.Nullable java.lang.String mFeatureId\nprivate final @android.annotation.NonNull java.lang.String mMessage\nprivate final @android.annotation.CurrentTimeMillisLong long mTime\npublic @android.annotation.NonNull java.lang.String getOp()\nprivate void onConstructed()\nclass AsyncNotedAppOp extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genAidl=true, genHiddenConstructor=true)") + inputSignatures = "private final @android.annotation.IntRange(from=0L) int mOpCode\nprivate final @android.annotation.IntRange(from=0L) int mNotingUid\nprivate final @android.annotation.Nullable java.lang.String mAttributionTag\nprivate final @android.annotation.NonNull java.lang.String mMessage\nprivate final @android.annotation.CurrentTimeMillisLong long mTime\npublic @android.annotation.NonNull java.lang.String getOp()\nprivate void onConstructed()\nclass AsyncNotedAppOp extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genAidl=true, genHiddenConstructor=true)") @Deprecated private void __metadata() {} diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 2873b10e60c8..56e6aee83a44 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -219,8 +219,8 @@ class ContextImpl extends Context { @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) private final String mOpPackageName; - /** If of feature this context is for */ - private final @Nullable String mFeatureId; + /** Attribution tag of this context */ + private final @Nullable String mAttributionTag; private final @NonNull ResourcesManager mResourcesManager; @UnsupportedAppUsage @@ -421,8 +421,8 @@ class ContextImpl extends Context { /** @hide */ @Override - public @Nullable String getFeatureId() { - return mFeatureId; + public @Nullable String getAttributionTag() { + return mAttributionTag; } @Override @@ -1026,10 +1026,10 @@ class ContextImpl extends Context { public void startActivityAsUser(Intent intent, Bundle options, UserHandle user) { try { ActivityTaskManager.getService().startActivityAsUser( - mMainThread.getApplicationThread(), getBasePackageName(), getFeatureId(), intent, - intent.resolveTypeIfNeeded(getContentResolver()), - null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, options, - user.getIdentifier()); + mMainThread.getApplicationThread(), getBasePackageName(), getAttributionTag(), + intent, intent.resolveTypeIfNeeded(getContentResolver()), + null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, options, + user.getIdentifier()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1109,9 +1109,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null, - Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, false, - getUserId()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + null, Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, + false, getUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1126,9 +1126,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null, - Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, - null, false, false, getUserId()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + null, Activity.RESULT_OK, null, null, receiverPermissions, + AppOpsManager.OP_NONE, null, false, false, getUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1141,9 +1141,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null, - Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, - null, false, false, getUserId()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + null, Activity.RESULT_OK, null, null, receiverPermissions, + AppOpsManager.OP_NONE, null, false, false, getUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1156,9 +1156,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null, - Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, - null, false, false, user.getIdentifier()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + null, Activity.RESULT_OK, null, null, receiverPermissions, + AppOpsManager.OP_NONE, null, false, false, user.getIdentifier()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1173,9 +1173,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null, - Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, - options, false, false, getUserId()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + null, Activity.RESULT_OK, null, null, receiverPermissions, + AppOpsManager.OP_NONE, options, false, false, getUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1190,9 +1190,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null, - Activity.RESULT_OK, null, null, receiverPermissions, appOp, null, false, false, - getUserId()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + null, Activity.RESULT_OK, null, null, receiverPermissions, appOp, null, false, + false, getUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1207,9 +1207,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null, - Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, - null, true, false, getUserId()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + null, Activity.RESULT_OK, null, null, receiverPermissions, + AppOpsManager.OP_NONE, null, true, false, getUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1270,8 +1270,8 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, rd, - initialCode, initialData, initialExtras, receiverPermissions, appOp, + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + rd, initialCode, initialData, initialExtras, receiverPermissions, appOp, options, true, false, getUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); @@ -1284,9 +1284,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null, - Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, false, - user.getIdentifier()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + null, Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, + false, user.getIdentifier()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1307,9 +1307,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null, - Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, - options, false, false, user.getIdentifier()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + null, Activity.RESULT_OK, null, null, receiverPermissions, + AppOpsManager.OP_NONE, options, false, false, user.getIdentifier()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1324,9 +1324,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null, - Activity.RESULT_OK, null, null, receiverPermissions, appOp, null, false, false, - user.getIdentifier()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + null, Activity.RESULT_OK, null, null, receiverPermissions, appOp, null, false, + false, user.getIdentifier()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1375,9 +1375,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, rd, - initialCode, initialData, initialExtras, receiverPermissions, - appOp, options, true, false, user.getIdentifier()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + rd, initialCode, initialData, initialExtras, receiverPermissions, appOp, + options, true, false, user.getIdentifier()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1416,9 +1416,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null, - Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, true, - getUserId()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + null, Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, + true, getUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1452,9 +1452,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, rd, - initialCode, initialData, initialExtras, null, - AppOpsManager.OP_NONE, null, true, true, getUserId()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + rd, initialCode, initialData, initialExtras, null, AppOpsManager.OP_NONE, null, + true, true, getUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1484,9 +1484,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null, - Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, true, - user.getIdentifier()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + null, Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, null, false, + true, user.getIdentifier()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1499,9 +1499,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, null, - Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, options, false, true, - user.getIdentifier()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + null, Activity.RESULT_OK, null, null, null, AppOpsManager.OP_NONE, options, + false, true, user.getIdentifier()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1534,9 +1534,9 @@ class ContextImpl extends Context { try { intent.prepareToLeaveProcess(this); ActivityManager.getService().broadcastIntentWithFeature( - mMainThread.getApplicationThread(), getFeatureId(), intent, resolvedType, rd, - initialCode, initialData, initialExtras, null, - AppOpsManager.OP_NONE, null, true, true, user.getIdentifier()); + mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType, + rd, initialCode, initialData, initialExtras, null, AppOpsManager.OP_NONE, null, + true, true, user.getIdentifier()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1620,7 +1620,7 @@ class ContextImpl extends Context { } try { final Intent intent = ActivityManager.getService().registerReceiverWithFeature( - mMainThread.getApplicationThread(), mBasePackageName, getFeatureId(), rd, + mMainThread.getApplicationThread(), mBasePackageName, getAttributionTag(), rd, filter, broadcastPermission, userId, flags); if (intent != null) { intent.setExtrasClassLoader(getClassLoader()); @@ -1696,7 +1696,7 @@ class ContextImpl extends Context { ComponentName cn = ActivityManager.getService().startService( mMainThread.getApplicationThread(), service, service.resolveTypeIfNeeded(getContentResolver()), requireForeground, - getOpPackageName(), getFeatureId(), user.getIdentifier()); + getOpPackageName(), getAttributionTag(), user.getIdentifier()); if (cn != null) { if (cn.getPackageName().equals("!")) { throw new SecurityException( @@ -2285,14 +2285,14 @@ class ContextImpl extends Context { if (packageName.equals("system") || packageName.equals("android")) { // The system resources are loaded in every application, so we can safely copy // the context without reloading Resources. - return new ContextImpl(this, mMainThread, mPackageInfo, mFeatureId, null, + return new ContextImpl(this, mMainThread, mPackageInfo, mAttributionTag, null, mToken, user, flags, null, null); } LoadedApk pi = mMainThread.getPackageInfo(packageName, mResources.getCompatibilityInfo(), flags | CONTEXT_REGISTER_PACKAGE, user.getIdentifier()); if (pi != null) { - ContextImpl c = new ContextImpl(this, mMainThread, pi, mFeatureId, null, + ContextImpl c = new ContextImpl(this, mMainThread, pi, mAttributionTag, null, mToken, user, flags, null, null); final int displayId = getDisplayId(); @@ -2329,7 +2329,7 @@ class ContextImpl extends Context { final String[] paths = mPackageInfo.getSplitPaths(splitName); final ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, - mFeatureId, splitName, mToken, mUser, mFlags, classLoader, null); + mAttributionTag, splitName, mToken, mUser, mFlags, classLoader, null); final int displayId = getDisplayId(); @@ -2353,7 +2353,7 @@ class ContextImpl extends Context { throw new IllegalArgumentException("overrideConfiguration must not be null"); } - ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, mFeatureId, + ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, mAttributionTag, mSplitName, mToken, mUser, mFlags, mClassLoader, null); final int displayId = getDisplayId(); @@ -2370,7 +2370,7 @@ class ContextImpl extends Context { throw new IllegalArgumentException("display must not be null"); } - ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, mFeatureId, + ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, mAttributionTag, mSplitName, mToken, mUser, mFlags, mClassLoader, null); final int displayId = display.getDisplayId(); @@ -2394,7 +2394,7 @@ class ContextImpl extends Context { } ContextImpl createBaseWindowContext(IBinder token) { - ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, mFeatureId, + ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, mAttributionTag, mSplitName, token, mUser, mFlags, mClassLoader, null); context.mIsUiContext = true; @@ -2420,8 +2420,8 @@ class ContextImpl extends Context { } @Override - public @NonNull Context createFeatureContext(@Nullable String featureId) { - return new ContextImpl(this, mMainThread, mPackageInfo, featureId, mSplitName, + public @NonNull Context createAttributionContext(@Nullable String attributionTag) { + return new ContextImpl(this, mMainThread, mPackageInfo, attributionTag, mSplitName, mToken, mUser, mFlags, mClassLoader, null); } @@ -2429,7 +2429,7 @@ class ContextImpl extends Context { public Context createDeviceProtectedStorageContext() { final int flags = (mFlags & ~Context.CONTEXT_CREDENTIAL_PROTECTED_STORAGE) | Context.CONTEXT_DEVICE_PROTECTED_STORAGE; - return new ContextImpl(this, mMainThread, mPackageInfo, mFeatureId, mSplitName, + return new ContextImpl(this, mMainThread, mPackageInfo, mAttributionTag, mSplitName, mToken, mUser, flags, mClassLoader, null); } @@ -2437,7 +2437,7 @@ class ContextImpl extends Context { public Context createCredentialProtectedStorageContext() { final int flags = (mFlags & ~Context.CONTEXT_DEVICE_PROTECTED_STORAGE) | Context.CONTEXT_CREDENTIAL_PROTECTED_STORAGE; - return new ContextImpl(this, mMainThread, mPackageInfo, mFeatureId, mSplitName, + return new ContextImpl(this, mMainThread, mPackageInfo, mAttributionTag, mSplitName, mToken, mUser, flags, mClassLoader, null); } @@ -2700,7 +2700,7 @@ class ContextImpl extends Context { } private ContextImpl(@Nullable ContextImpl container, @NonNull ActivityThread mainThread, - @NonNull LoadedApk packageInfo, @Nullable String featureId, + @NonNull LoadedApk packageInfo, @Nullable String attributionTag, @Nullable String splitName, @Nullable IBinder activityToken, @Nullable UserHandle user, int flags, @Nullable ClassLoader classLoader, @Nullable String overrideOpPackageName) { mOuterContext = this; @@ -2754,7 +2754,7 @@ class ContextImpl extends Context { } mOpPackageName = overrideOpPackageName != null ? overrideOpPackageName : opPackageName; - mFeatureId = featureId; + mAttributionTag = attributionTag; mContentResolver = new ApplicationContentResolver(this, mainThread); } diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java index 18932c6b0784..818a12145932 100644 --- a/core/java/android/app/Instrumentation.java +++ b/core/java/android/app/Instrumentation.java @@ -1720,11 +1720,10 @@ public class Instrumentation { try { intent.migrateExtraStreamToClipData(); intent.prepareToLeaveProcess(who); - int result = ActivityTaskManager.getService() - .startActivity(whoThread, who.getBasePackageName(), who.getFeatureId(), intent, - intent.resolveTypeIfNeeded(who.getContentResolver()), - token, target != null ? target.mEmbeddedID : null, - requestCode, 0, null, options); + int result = ActivityTaskManager.getService().startActivity(whoThread, + who.getBasePackageName(), who.getAttributionTag(), intent, + intent.resolveTypeIfNeeded(who.getContentResolver()), token, + target != null ? target.mEmbeddedID : null, requestCode, 0, null, options); checkStartActivityResult(result, intent); } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); @@ -1793,9 +1792,9 @@ public class Instrumentation { intents[i].prepareToLeaveProcess(who); resolvedTypes[i] = intents[i].resolveTypeIfNeeded(who.getContentResolver()); } - int result = ActivityTaskManager.getService() - .startActivities(whoThread, who.getBasePackageName(), who.getFeatureId(), intents, - resolvedTypes, token, options, userId); + int result = ActivityTaskManager.getService().startActivities(whoThread, + who.getBasePackageName(), who.getAttributionTag(), intents, resolvedTypes, + token, options, userId); checkStartActivityResult(result, intents[0]); return result; } catch (RemoteException e) { @@ -1860,10 +1859,10 @@ public class Instrumentation { try { intent.migrateExtraStreamToClipData(); intent.prepareToLeaveProcess(who); - int result = ActivityTaskManager.getService() - .startActivity(whoThread, who.getBasePackageName(), who.getFeatureId(), intent, - intent.resolveTypeIfNeeded(who.getContentResolver()), - token, target, requestCode, 0, null, options); + int result = ActivityTaskManager.getService().startActivity(whoThread, + who.getBasePackageName(), who.getAttributionTag(), intent, + intent.resolveTypeIfNeeded(who.getContentResolver()), token, target, + requestCode, 0, null, options); checkStartActivityResult(result, intent); } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); @@ -1927,11 +1926,10 @@ public class Instrumentation { try { intent.migrateExtraStreamToClipData(); intent.prepareToLeaveProcess(who); - int result = ActivityTaskManager.getService() - .startActivityAsUser(whoThread, who.getBasePackageName(), who.getFeatureId(), - intent, intent.resolveTypeIfNeeded(who.getContentResolver()), - token, resultWho, - requestCode, 0, null, options, user.getIdentifier()); + int result = ActivityTaskManager.getService().startActivityAsUser(whoThread, + who.getBasePackageName(), who.getAttributionTag(), intent, + intent.resolveTypeIfNeeded(who.getContentResolver()), token, resultWho, + requestCode, 0, null, options, user.getIdentifier()); checkStartActivityResult(result, intent); } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); @@ -2022,7 +2020,7 @@ public class Instrumentation { intent.migrateExtraStreamToClipData(); intent.prepareToLeaveProcess(who); int result = appTask.startActivity(whoThread.asBinder(), who.getBasePackageName(), - who.getFeatureId(), intent, + who.getAttributionTag(), intent, intent.resolveTypeIfNeeded(who.getContentResolver()), options); checkStartActivityResult(result, intent); } catch (RemoteException e) { diff --git a/core/java/android/app/PendingIntent.java b/core/java/android/app/PendingIntent.java index f68c929144c8..792f840638a9 100644 --- a/core/java/android/app/PendingIntent.java +++ b/core/java/android/app/PendingIntent.java @@ -355,8 +355,8 @@ public final class PendingIntent implements Parcelable { intent.prepareToLeaveProcess(context); IIntentSender target = ActivityManager.getService().getIntentSenderWithFeature( - ActivityManager.INTENT_SENDER_ACTIVITY, packageName, context.getFeatureId(), - null, null, requestCode, new Intent[] { intent }, + ActivityManager.INTENT_SENDER_ACTIVITY, packageName, + context.getAttributionTag(), null, null, requestCode, new Intent[] { intent }, resolvedType != null ? new String[] { resolvedType } : null, flags, options, context.getUserId()); return target != null ? new PendingIntent(target) : null; @@ -381,8 +381,8 @@ public final class PendingIntent implements Parcelable { intent.prepareToLeaveProcess(context); IIntentSender target = ActivityManager.getService().getIntentSenderWithFeature( - ActivityManager.INTENT_SENDER_ACTIVITY, packageName, context.getFeatureId(), - null, null, requestCode, new Intent[] { intent }, + ActivityManager.INTENT_SENDER_ACTIVITY, packageName, + context.getAttributionTag(), null, null, requestCode, new Intent[] { intent }, resolvedType != null ? new String[] { resolvedType } : null, flags, options, user.getIdentifier()); return target != null ? new PendingIntent(target) : null; @@ -498,9 +498,9 @@ public final class PendingIntent implements Parcelable { try { IIntentSender target = ActivityManager.getService().getIntentSenderWithFeature( - ActivityManager.INTENT_SENDER_ACTIVITY, packageName, context.getFeatureId(), - null, null, requestCode, intents, resolvedTypes, flags, options, - context.getUserId()); + ActivityManager.INTENT_SENDER_ACTIVITY, packageName, + context.getAttributionTag(), null, null, requestCode, intents, resolvedTypes, + flags, options, context.getUserId()); return target != null ? new PendingIntent(target) : null; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); @@ -524,8 +524,8 @@ public final class PendingIntent implements Parcelable { try { IIntentSender target = ActivityManager.getService().getIntentSenderWithFeature( - ActivityManager.INTENT_SENDER_ACTIVITY, packageName, context.getFeatureId(), - null, null, requestCode, intents, resolvedTypes, + ActivityManager.INTENT_SENDER_ACTIVITY, packageName, + context.getAttributionTag(), null, null, requestCode, intents, resolvedTypes, flags, options, user.getIdentifier()); return target != null ? new PendingIntent(target) : null; } catch (RemoteException e) { @@ -576,8 +576,8 @@ public final class PendingIntent implements Parcelable { intent.prepareToLeaveProcess(context); IIntentSender target = ActivityManager.getService().getIntentSenderWithFeature( - ActivityManager.INTENT_SENDER_BROADCAST, packageName, context.getFeatureId(), - null, null, requestCode, new Intent[] { intent }, + ActivityManager.INTENT_SENDER_BROADCAST, packageName, + context.getAttributionTag(), null, null, requestCode, new Intent[] { intent }, resolvedType != null ? new String[] { resolvedType } : null, flags, null, userHandle.getIdentifier()); return target != null ? new PendingIntent(target) : null; @@ -655,7 +655,7 @@ public final class PendingIntent implements Parcelable { intent.prepareToLeaveProcess(context); IIntentSender target = ActivityManager.getService().getIntentSenderWithFeature( - serviceKind, packageName, context.getFeatureId(), + serviceKind, packageName, context.getAttributionTag(), null, null, requestCode, new Intent[] { intent }, resolvedType != null ? new String[] { resolvedType } : null, flags, null, context.getUserId()); diff --git a/core/java/android/app/RuntimeAppOpAccessMessage.java b/core/java/android/app/RuntimeAppOpAccessMessage.java index a81b8e7ab13c..a19f815c4298 100644 --- a/core/java/android/app/RuntimeAppOpAccessMessage.java +++ b/core/java/android/app/RuntimeAppOpAccessMessage.java @@ -44,7 +44,7 @@ public final class RuntimeAppOpAccessMessage implements Parcelable { /** Name of package for which runtime app op access message was collected */ private final @NonNull String mPackageName; /** Feature of package for which runtime app op access message was collected */ - private final @Nullable String mFeatureId; + private final @Nullable String mAttributionTag; /** Message collected (including stacktrace for synchronous ops) */ private final @NonNull String mMessage; /** Sampling strategy used to collect this message. */ @@ -63,8 +63,8 @@ public final class RuntimeAppOpAccessMessage implements Parcelable { * Op code of operation access which was collected * @param packageName * Name of package for which runtime app op access message was collected - * @param featureId - * Feature of package for which runtime app op access message was collected + * @param attributionTag + * Attribution tag for which runtime app op access message was collected * @param message * Message collected (including stacktrace for synchronous ops) * @param samplingStrategy @@ -75,7 +75,7 @@ public final class RuntimeAppOpAccessMessage implements Parcelable { @IntRange(from = 0L) int uid, @IntRange(from = 0L) int opCode, @NonNull String packageName, - @Nullable String featureId, + @Nullable String attributionTag, @NonNull String message, @AppOpsManager.SamplingStrategy int samplingStrategy) { this.mUid = uid; @@ -90,7 +90,7 @@ public final class RuntimeAppOpAccessMessage implements Parcelable { this.mPackageName = packageName; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mPackageName); - this.mFeatureId = featureId; + this.mAttributionTag = attributionTag; this.mMessage = message; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mMessage); @@ -134,11 +134,11 @@ public final class RuntimeAppOpAccessMessage implements Parcelable { } /** - * Feature of package for which runtime app op access message was collected + * Attribution tag for which runtime app op access message was collected */ @DataClass.Generated.Member - public @Nullable String getFeatureId() { - return mFeatureId; + public @Nullable String getAttributionTag() { + return mAttributionTag; } /** @@ -164,12 +164,12 @@ public final class RuntimeAppOpAccessMessage implements Parcelable { // void parcelFieldName(Parcel dest, int flags) { ... } byte flg = 0; - if (mFeatureId != null) flg |= 0x8; + if (mAttributionTag != null) flg |= 0x8; dest.writeByte(flg); dest.writeInt(mUid); dest.writeInt(mOpCode); dest.writeString(mPackageName); - if (mFeatureId != null) dest.writeString(mFeatureId); + if (mAttributionTag != null) dest.writeString(mAttributionTag); dest.writeString(mMessage); dest.writeInt(mSamplingStrategy); } @@ -189,7 +189,7 @@ public final class RuntimeAppOpAccessMessage implements Parcelable { int uid = in.readInt(); int opCode = in.readInt(); String packageName = in.readString(); - String featureId = (flg & 0x8) == 0 ? null : in.readString(); + String attributionTag = (flg & 0x8) == 0 ? null : in.readString(); String message = in.readString(); int samplingStrategy = in.readInt(); @@ -205,7 +205,7 @@ public final class RuntimeAppOpAccessMessage implements Parcelable { this.mPackageName = packageName; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mPackageName); - this.mFeatureId = featureId; + this.mAttributionTag = attributionTag; this.mMessage = message; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mMessage); @@ -234,7 +234,7 @@ public final class RuntimeAppOpAccessMessage implements Parcelable { time = 1581517099127L, codegenVersion = "1.0.14", sourceFile = "frameworks/base/core/java/android/app/RuntimeAppOpAccessMessage.java", - inputSignatures = "private final @android.annotation.IntRange(from=0L) int mUid\nprivate final @android.annotation.IntRange(from=0L, to=AppOpsManager._NUM_OP - 1) int mOpCode\nprivate final @android.annotation.NonNull java.lang.String mPackageName\nprivate final @android.annotation.Nullable java.lang.String mFeatureId\nprivate final @android.annotation.NonNull java.lang.String mMessage\nprivate final @android.app.AppOpsManager.SamplingStrategy int mSamplingStrategy\npublic @android.annotation.NonNull java.lang.String getOp()\nclass RuntimeAppOpAccessMessage extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genConstructor=false)")*/ + inputSignatures = "private final @android.annotation.IntRange(from=0L) int mUid\nprivate final @android.annotation.IntRange(from=0L, to=AppOpsManager._NUM_OP - 1) int mOpCode\nprivate final @android.annotation.NonNull java.lang.String mPackageName\nprivate final @android.annotation.Nullable java.lang.String mAttributionTag\nprivate final @android.annotation.NonNull java.lang.String mMessage\nprivate final @android.app.AppOpsManager.SamplingStrategy int mSamplingStrategy\npublic @android.annotation.NonNull java.lang.String getOp()\nclass RuntimeAppOpAccessMessage extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genConstructor=false)")*/ @Deprecated private void __metadata() {} diff --git a/core/java/android/app/SyncNotedAppOp.java b/core/java/android/app/SyncNotedAppOp.java index 13b90ca6ced1..0a880dc0cbb7 100644 --- a/core/java/android/app/SyncNotedAppOp.java +++ b/core/java/android/app/SyncNotedAppOp.java @@ -43,24 +43,24 @@ public final class SyncNotedAppOp implements Parcelable { /** op code of synchronous appop noted */ private final @IntRange(from = 0L, to = AppOpsManager._NUM_OP - 1) int mOpCode; - /** featureId of synchronous appop noted */ - private final @Nullable String mFeatureId; + /** attributionTag of synchronous appop noted */ + private final @Nullable String mAttributionTag; /** * Creates a new SyncNotedAppOp. * * @param opCode * op code of synchronous appop noted - * @param featureId - * featureId of synchronous appop noted + * @param attributionTag + * attributionTag of synchronous appop noted */ - public SyncNotedAppOp(@IntRange(from = 0L) int opCode, @Nullable String featureId) { + public SyncNotedAppOp(@IntRange(from = 0L) int opCode, @Nullable String attributionTag) { this.mOpCode = opCode; com.android.internal.util.AnnotationValidations.validate( IntRange.class, null, mOpCode, "from", 0, "to", AppOpsManager._NUM_OP - 1); - this.mFeatureId = featureId; + this.mAttributionTag = attributionTag; } /** @@ -84,11 +84,11 @@ public final class SyncNotedAppOp implements Parcelable { /** - * featureId of synchronous appop noted + * attributionTag of synchronous appop noted */ @DataClass.Generated.Member - public @Nullable String getFeatureId() { - return mFeatureId; + public @Nullable String getAttributionTag() { + return mAttributionTag; } @Override @@ -105,7 +105,7 @@ public final class SyncNotedAppOp implements Parcelable { //noinspection PointlessBooleanExpression return true && mOpCode == that.mOpCode - && java.util.Objects.equals(mFeatureId, that.mFeatureId); + && java.util.Objects.equals(mAttributionTag, that.mAttributionTag); } @Override @@ -116,7 +116,7 @@ public final class SyncNotedAppOp implements Parcelable { int _hash = 1; _hash = 31 * _hash + mOpCode; - _hash = 31 * _hash + java.util.Objects.hashCode(mFeatureId); + _hash = 31 * _hash + java.util.Objects.hashCode(mAttributionTag); return _hash; } @@ -127,10 +127,10 @@ public final class SyncNotedAppOp implements Parcelable { // void parcelFieldName(Parcel dest, int flags) { ... } byte flg = 0; - if (mFeatureId != null) flg |= 0x2; + if (mAttributionTag != null) flg |= 0x2; dest.writeByte(flg); dest.writeInt(mOpCode); - if (mFeatureId != null) dest.writeString(mFeatureId); + if (mAttributionTag != null) dest.writeString(mAttributionTag); } @Override @@ -146,14 +146,14 @@ public final class SyncNotedAppOp implements Parcelable { byte flg = in.readByte(); int opCode = in.readInt(); - String featureId = (flg & 0x2) == 0 ? null : in.readString(); + String attributionTag = (flg & 0x2) == 0 ? null : in.readString(); this.mOpCode = opCode; com.android.internal.util.AnnotationValidations.validate( IntRange.class, null, mOpCode, "from", 0, "to", AppOpsManager._NUM_OP - 1); - this.mFeatureId = featureId; + this.mAttributionTag = attributionTag; // onConstructed(); // You can define this method to get a callback } @@ -176,7 +176,7 @@ public final class SyncNotedAppOp implements Parcelable { time = 1579188889960L, codegenVersion = "1.0.14", sourceFile = "frameworks/base/core/java/android/app/SyncNotedAppOp.java", - inputSignatures = "private final @android.annotation.IntRange(from=0L, to=AppOpsManager._NUM_OP - 1) int mOpCode\nprivate final @android.annotation.Nullable java.lang.String mFeatureId\npublic @android.annotation.NonNull java.lang.String getOp()\npublic @android.annotation.SystemApi int getOpCode()\nclass SyncNotedAppOp extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genConstructor=false)")*/ + inputSignatures = "private final @android.annotation.IntRange(from=0L, to=AppOpsManager._NUM_OP - 1) int mOpCode\nprivate final @android.annotation.Nullable java.lang.String mAttributionTag\npublic @android.annotation.NonNull java.lang.String getOp()\npublic @android.annotation.SystemApi int getOpCode()\nclass SyncNotedAppOp extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genConstructor=false)")*/ @Deprecated private void __metadata() {} diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java index d9405e18a162..1deeda3c6a3b 100644 --- a/core/java/android/app/WallpaperManager.java +++ b/core/java/android/app/WallpaperManager.java @@ -478,7 +478,7 @@ public class WallpaperManager { try { Bundle params = new Bundle(); ParcelFileDescriptor pfd = mService.getWallpaperWithFeature( - context.getOpPackageName(), context.getFeatureId(), this, FLAG_SYSTEM, + context.getOpPackageName(), context.getAttributionTag(), this, FLAG_SYSTEM, params, userId); if (pfd != null) { @@ -1069,7 +1069,7 @@ public class WallpaperManager { try { Bundle outParams = new Bundle(); return sGlobals.mService.getWallpaperWithFeature(mContext.getOpPackageName(), - mContext.getFeatureId(), null, which, outParams, userId); + mContext.getAttributionTag(), null, which, outParams, userId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } catch (SecurityException e) { diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index 6ae68fcad6f4..608b563bfc76 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -849,7 +849,7 @@ public final class BluetoothAdapter { synchronized (mLock) { if (sBluetoothLeScanner == null) { sBluetoothLeScanner = new BluetoothLeScanner(mManagerService, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } } return sBluetoothLeScanner; @@ -1663,11 +1663,11 @@ public final class BluetoothAdapter { return ActivityThread.currentOpPackageName(); } - private String getFeatureId() { + private String getAttributionTag() { // Workaround for legacy API for getting a BluetoothAdapter not // passing a context if (mContext != null) { - return mContext.getFeatureId(); + return mContext.getAttributionTag(); } return null; } @@ -1709,7 +1709,7 @@ public final class BluetoothAdapter { try { mServiceLock.readLock().lock(); if (mService != null) { - return mService.startDiscovery(getOpPackageName(), getFeatureId()); + return mService.startDiscovery(getOpPackageName(), getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "", e); diff --git a/core/java/android/bluetooth/BluetoothManager.java b/core/java/android/bluetooth/BluetoothManager.java index 7ff64663349b..3b4fe0a30b80 100644 --- a/core/java/android/bluetooth/BluetoothManager.java +++ b/core/java/android/bluetooth/BluetoothManager.java @@ -62,7 +62,7 @@ public final class BluetoothManager { * @hide */ public BluetoothManager(Context context) { - if (context.getFeatureId() == null) { + if (context.getAttributionTag() == null) { context = context.getApplicationContext(); if (context == null) { throw new IllegalArgumentException( diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java index bd3298c79fff..d8e8b27d0621 100644 --- a/core/java/android/content/ContentProvider.java +++ b/core/java/android/content/ContentProvider.java @@ -230,12 +230,12 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } @Override - public Cursor query(String callingPkg, @Nullable String featureId, Uri uri, + public Cursor query(String callingPkg, @Nullable String attributionTag, Uri uri, @Nullable String[] projection, @Nullable Bundle queryArgs, @Nullable ICancellationSignal cancellationSignal) { uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); - if (enforceReadPermission(callingPkg, featureId, uri, null) + if (enforceReadPermission(callingPkg, attributionTag, uri, null) != AppOpsManager.MODE_ALLOWED) { // The caller has no access to the data, so return an empty cursor with // the columns in the requested order. The caller may ask for an invalid @@ -253,7 +253,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall // columns. We then use the column names to return an empty cursor. Cursor cursor; final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { cursor = mInterface.query( uri, projection, queryArgs, @@ -272,7 +272,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } Trace.traceBegin(TRACE_TAG_DATABASE, "query"); final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { return mInterface.query( uri, projection, queryArgs, @@ -308,15 +308,15 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } @Override - public Uri insert(String callingPkg, @Nullable String featureId, Uri uri, + public Uri insert(String callingPkg, @Nullable String attributionTag, Uri uri, ContentValues initialValues, Bundle extras) { uri = validateIncomingUri(uri); int userId = getUserIdFromUri(uri); uri = maybeGetUriWithoutUserId(uri); - if (enforceWritePermission(callingPkg, featureId, uri, null) + if (enforceWritePermission(callingPkg, attributionTag, uri, null) != AppOpsManager.MODE_ALLOWED) { final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { return rejectInsert(uri, initialValues); } finally { @@ -325,7 +325,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } Trace.traceBegin(TRACE_TAG_DATABASE, "insert"); final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { return maybeAddUserId(mInterface.insert(uri, initialValues, extras), userId); } catch (RemoteException e) { @@ -337,17 +337,17 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } @Override - public int bulkInsert(String callingPkg, @Nullable String featureId, Uri uri, + public int bulkInsert(String callingPkg, @Nullable String attributionTag, Uri uri, ContentValues[] initialValues) { uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); - if (enforceWritePermission(callingPkg, featureId, uri, null) + if (enforceWritePermission(callingPkg, attributionTag, uri, null) != AppOpsManager.MODE_ALLOWED) { return 0; } Trace.traceBegin(TRACE_TAG_DATABASE, "bulkInsert"); final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { return mInterface.bulkInsert(uri, initialValues); } catch (RemoteException e) { @@ -359,8 +359,9 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } @Override - public ContentProviderResult[] applyBatch(String callingPkg, @Nullable String featureId, - String authority, ArrayList<ContentProviderOperation> operations) + public ContentProviderResult[] applyBatch(String callingPkg, + @Nullable String attributionTag, String authority, + ArrayList<ContentProviderOperation> operations) throws OperationApplicationException { validateIncomingAuthority(authority); int numOperations = operations.size(); @@ -377,13 +378,13 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall operations.set(i, operation); } if (operation.isReadOperation()) { - if (enforceReadPermission(callingPkg, featureId, uri, null) + if (enforceReadPermission(callingPkg, attributionTag, uri, null) != AppOpsManager.MODE_ALLOWED) { throw new OperationApplicationException("App op not allowed", 0); } } if (operation.isWriteOperation()) { - if (enforceWritePermission(callingPkg, featureId, uri, null) + if (enforceWritePermission(callingPkg, attributionTag, uri, null) != AppOpsManager.MODE_ALLOWED) { throw new OperationApplicationException("App op not allowed", 0); } @@ -391,7 +392,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } Trace.traceBegin(TRACE_TAG_DATABASE, "applyBatch"); final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { ContentProviderResult[] results = mInterface.applyBatch(authority, operations); @@ -413,16 +414,17 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } @Override - public int delete(String callingPkg, @Nullable String featureId, Uri uri, Bundle extras) { + public int delete(String callingPkg, @Nullable String attributionTag, Uri uri, + Bundle extras) { uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); - if (enforceWritePermission(callingPkg, featureId, uri, null) + if (enforceWritePermission(callingPkg, attributionTag, uri, null) != AppOpsManager.MODE_ALLOWED) { return 0; } Trace.traceBegin(TRACE_TAG_DATABASE, "delete"); final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { return mInterface.delete(uri, extras); } catch (RemoteException e) { @@ -434,17 +436,17 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } @Override - public int update(String callingPkg, @Nullable String featureId, Uri uri, + public int update(String callingPkg, @Nullable String attributionTag, Uri uri, ContentValues values, Bundle extras) { uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); - if (enforceWritePermission(callingPkg, featureId, uri, null) + if (enforceWritePermission(callingPkg, attributionTag, uri, null) != AppOpsManager.MODE_ALLOWED) { return 0; } Trace.traceBegin(TRACE_TAG_DATABASE, "update"); final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { return mInterface.update(uri, values, extras); } catch (RemoteException e) { @@ -456,15 +458,15 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } @Override - public ParcelFileDescriptor openFile(String callingPkg, @Nullable String featureId, + public ParcelFileDescriptor openFile(String callingPkg, @Nullable String attributionTag, Uri uri, String mode, ICancellationSignal cancellationSignal, IBinder callerToken) throws FileNotFoundException { uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); - enforceFilePermission(callingPkg, featureId, uri, mode, callerToken); + enforceFilePermission(callingPkg, attributionTag, uri, mode, callerToken); Trace.traceBegin(TRACE_TAG_DATABASE, "openFile"); final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { return mInterface.openFile( uri, mode, CancellationSignal.fromTransport(cancellationSignal)); @@ -477,15 +479,15 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } @Override - public AssetFileDescriptor openAssetFile(String callingPkg, @Nullable String featureId, + public AssetFileDescriptor openAssetFile(String callingPkg, @Nullable String attributionTag, Uri uri, String mode, ICancellationSignal cancellationSignal) throws FileNotFoundException { uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); - enforceFilePermission(callingPkg, featureId, uri, mode, null); + enforceFilePermission(callingPkg, attributionTag, uri, mode, null); Trace.traceBegin(TRACE_TAG_DATABASE, "openAssetFile"); final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { return mInterface.openAssetFile( uri, mode, CancellationSignal.fromTransport(cancellationSignal)); @@ -498,13 +500,13 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } @Override - public Bundle call(String callingPkg, @Nullable String featureId, String authority, + public Bundle call(String callingPkg, @Nullable String attributionTag, String authority, String method, @Nullable String arg, @Nullable Bundle extras) { validateIncomingAuthority(authority); Bundle.setDefusable(extras, true); Trace.traceBegin(TRACE_TAG_DATABASE, "call"); final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { return mInterface.call(authority, method, arg, extras); } catch (RemoteException e) { @@ -532,15 +534,15 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall @Override public AssetFileDescriptor openTypedAssetFile(String callingPkg, - @Nullable String featureId, Uri uri, String mimeType, Bundle opts, + @Nullable String attributionTag, Uri uri, String mimeType, Bundle opts, ICancellationSignal cancellationSignal) throws FileNotFoundException { Bundle.setDefusable(opts, true); uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); - enforceFilePermission(callingPkg, featureId, uri, "r", null); + enforceFilePermission(callingPkg, attributionTag, uri, "r", null); Trace.traceBegin(TRACE_TAG_DATABASE, "openTypedAssetFile"); final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { return mInterface.openTypedAssetFile( uri, mimeType, opts, CancellationSignal.fromTransport(cancellationSignal)); @@ -558,17 +560,17 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } @Override - public Uri canonicalize(String callingPkg, @Nullable String featureId, Uri uri) { + public Uri canonicalize(String callingPkg, @Nullable String attributionTag, Uri uri) { uri = validateIncomingUri(uri); int userId = getUserIdFromUri(uri); uri = getUriWithoutUserId(uri); - if (enforceReadPermission(callingPkg, featureId, uri, null) + if (enforceReadPermission(callingPkg, attributionTag, uri, null) != AppOpsManager.MODE_ALLOWED) { return null; } Trace.traceBegin(TRACE_TAG_DATABASE, "canonicalize"); final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { return maybeAddUserId(mInterface.canonicalize(uri), userId); } catch (RemoteException e) { @@ -580,26 +582,26 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } @Override - public void canonicalizeAsync(String callingPkg, @Nullable String featureId, Uri uri, + public void canonicalizeAsync(String callingPkg, @Nullable String attributionTag, Uri uri, RemoteCallback callback) { final Bundle result = new Bundle(); result.putParcelable(ContentResolver.REMOTE_CALLBACK_RESULT, - canonicalize(callingPkg, featureId, uri)); + canonicalize(callingPkg, attributionTag, uri)); callback.sendResult(result); } @Override - public Uri uncanonicalize(String callingPkg, String featureId, Uri uri) { + public Uri uncanonicalize(String callingPkg, String attributionTag, Uri uri) { uri = validateIncomingUri(uri); int userId = getUserIdFromUri(uri); uri = getUriWithoutUserId(uri); - if (enforceReadPermission(callingPkg, featureId, uri, null) + if (enforceReadPermission(callingPkg, attributionTag, uri, null) != AppOpsManager.MODE_ALLOWED) { return null; } Trace.traceBegin(TRACE_TAG_DATABASE, "uncanonicalize"); final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { return maybeAddUserId(mInterface.uncanonicalize(uri), userId); } catch (RemoteException e) { @@ -611,17 +613,17 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } @Override - public boolean refresh(String callingPkg, String featureId, Uri uri, Bundle extras, + public boolean refresh(String callingPkg, String attributionTag, Uri uri, Bundle extras, ICancellationSignal cancellationSignal) throws RemoteException { uri = validateIncomingUri(uri); uri = getUriWithoutUserId(uri); - if (enforceReadPermission(callingPkg, featureId, uri, null) + if (enforceReadPermission(callingPkg, attributionTag, uri, null) != AppOpsManager.MODE_ALLOWED) { return false; } Trace.traceBegin(TRACE_TAG_DATABASE, "refresh"); final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { return mInterface.refresh(uri, extras, CancellationSignal.fromTransport(cancellationSignal)); @@ -632,13 +634,13 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } @Override - public int checkUriPermission(String callingPkg, @Nullable String featureId, Uri uri, + public int checkUriPermission(String callingPkg, @Nullable String attributionTag, Uri uri, int uid, int modeFlags) { uri = validateIncomingUri(uri); uri = maybeGetUriWithoutUserId(uri); Trace.traceBegin(TRACE_TAG_DATABASE, "checkUriPermission"); final Pair<String, String> original = setCallingPackage( - new Pair<>(callingPkg, featureId)); + new Pair<>(callingPkg, attributionTag)); try { return mInterface.checkUriPermission(uri, uid, modeFlags); } catch (RemoteException e) { @@ -649,47 +651,50 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } } - private void enforceFilePermission(String callingPkg, @Nullable String featureId, Uri uri, - String mode, IBinder callerToken) throws FileNotFoundException, SecurityException { + private void enforceFilePermission(String callingPkg, @Nullable String attributionTag, + Uri uri, String mode, IBinder callerToken) + throws FileNotFoundException, SecurityException { if (mode != null && mode.indexOf('w') != -1) { - if (enforceWritePermission(callingPkg, featureId, uri, callerToken) + if (enforceWritePermission(callingPkg, attributionTag, uri, callerToken) != AppOpsManager.MODE_ALLOWED) { throw new FileNotFoundException("App op not allowed"); } } else { - if (enforceReadPermission(callingPkg, featureId, uri, callerToken) + if (enforceReadPermission(callingPkg, attributionTag, uri, callerToken) != AppOpsManager.MODE_ALLOWED) { throw new FileNotFoundException("App op not allowed"); } } } - private int enforceReadPermission(String callingPkg, @Nullable String featureId, Uri uri, - IBinder callerToken) + private int enforceReadPermission(String callingPkg, @Nullable String attributionTag, + Uri uri, IBinder callerToken) throws SecurityException { - final int mode = enforceReadPermissionInner(uri, callingPkg, featureId, callerToken); + final int mode = enforceReadPermissionInner(uri, callingPkg, attributionTag, + callerToken); if (mode != MODE_ALLOWED) { return mode; } - return noteProxyOp(callingPkg, featureId, mReadOp); + return noteProxyOp(callingPkg, attributionTag, mReadOp); } - private int enforceWritePermission(String callingPkg, String featureId, Uri uri, + private int enforceWritePermission(String callingPkg, String attributionTag, Uri uri, IBinder callerToken) throws SecurityException { - final int mode = enforceWritePermissionInner(uri, callingPkg, featureId, callerToken); + final int mode = enforceWritePermissionInner(uri, callingPkg, attributionTag, + callerToken); if (mode != MODE_ALLOWED) { return mode; } - return noteProxyOp(callingPkg, featureId, mWriteOp); + return noteProxyOp(callingPkg, attributionTag, mWriteOp); } - private int noteProxyOp(String callingPkg, String featureId, int op) { + private int noteProxyOp(String callingPkg, String attributionTag, int op) { if (op != AppOpsManager.OP_NONE) { int mode = mAppOpsManager.noteProxyOp(op, callingPkg, Binder.getCallingUid(), - featureId, null); + attributionTag, null); return mode == MODE_DEFAULT ? MODE_IGNORED : mode; } @@ -711,19 +716,19 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall * associated with that permission. */ private int checkPermissionAndAppOp(String permission, String callingPkg, - @Nullable String featureId, IBinder callerToken) { + @Nullable String attributionTag, IBinder callerToken) { if (getContext().checkPermission(permission, Binder.getCallingPid(), Binder.getCallingUid(), callerToken) != PERMISSION_GRANTED) { return MODE_ERRORED; } - return mTransport.noteProxyOp(callingPkg, featureId, + return mTransport.noteProxyOp(callingPkg, attributionTag, AppOpsManager.permissionToOpCode(permission)); } /** {@hide} */ protected int enforceReadPermissionInner(Uri uri, String callingPkg, - @Nullable String featureId, IBinder callerToken) throws SecurityException { + @Nullable String attributionTag, IBinder callerToken) throws SecurityException { final Context context = getContext(); final int pid = Binder.getCallingPid(); final int uid = Binder.getCallingUid(); @@ -737,7 +742,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall if (mExported && checkUser(pid, uid, context)) { final String componentPerm = getReadPermission(); if (componentPerm != null) { - final int mode = checkPermissionAndAppOp(componentPerm, callingPkg, featureId, + final int mode = checkPermissionAndAppOp(componentPerm, callingPkg, attributionTag, callerToken); if (mode == MODE_ALLOWED) { return MODE_ALLOWED; @@ -757,8 +762,8 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall for (PathPermission pp : pps) { final String pathPerm = pp.getReadPermission(); if (pathPerm != null && pp.match(path)) { - final int mode = checkPermissionAndAppOp(pathPerm, callingPkg, featureId, - callerToken); + final int mode = checkPermissionAndAppOp(pathPerm, callingPkg, + attributionTag, callerToken); if (mode == MODE_ALLOWED) { return MODE_ALLOWED; } else { @@ -807,7 +812,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall /** {@hide} */ protected int enforceWritePermissionInner(Uri uri, String callingPkg, - @Nullable String featureId, IBinder callerToken) throws SecurityException { + @Nullable String attributionTag, IBinder callerToken) throws SecurityException { final Context context = getContext(); final int pid = Binder.getCallingPid(); final int uid = Binder.getCallingUid(); @@ -821,8 +826,8 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall if (mExported && checkUser(pid, uid, context)) { final String componentPerm = getWritePermission(); if (componentPerm != null) { - final int mode = checkPermissionAndAppOp(componentPerm, callingPkg, featureId, - callerToken); + final int mode = checkPermissionAndAppOp(componentPerm, callingPkg, + attributionTag, callerToken); if (mode == MODE_ALLOWED) { return MODE_ALLOWED; } else { @@ -841,8 +846,8 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall for (PathPermission pp : pps) { final String pathPerm = pp.getWritePermission(); if (pathPerm != null && pp.match(path)) { - final int mode = checkPermissionAndAppOp(pathPerm, callingPkg, featureId, - callerToken); + final int mode = checkPermissionAndAppOp(pathPerm, callingPkg, + attributionTag, callerToken); if (mode == MODE_ALLOWED) { return MODE_ALLOWED; } else { @@ -943,16 +948,16 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } /** - * Return the feature in the package of the caller that initiated the request being + * Return the attribution tag of the caller that initiated the request being * processed on the current thread. Returns {@code null} if not currently processing - * a request of the request is for the default feature. + * a request of the request is for the default attribution. * <p> * This will always return {@code null} when processing * {@link #getType(Uri)} or {@link #getStreamTypes(Uri, String)} requests. * * @see #getCallingPackage */ - public final @Nullable String getCallingFeatureId() { + public final @Nullable String getCallingAttributionTag() { final Pair<String, String> pkg = mCallingPackage.get(); if (pkg != null) { return pkg.second; @@ -962,6 +967,14 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall } /** + * @removed + */ + @Deprecated + public final @Nullable String getCallingFeatureId() { + return getCallingAttributionTag(); + } + + /** * Return the package name of the caller that initiated the request being * processed on the current thread. The returned package will have * <em>not</em> been verified to belong to the calling UID. Returns diff --git a/core/java/android/content/ContentProviderClient.java b/core/java/android/content/ContentProviderClient.java index a9b786217eef..d0f5ec467458 100644 --- a/core/java/android/content/ContentProviderClient.java +++ b/core/java/android/content/ContentProviderClient.java @@ -80,7 +80,7 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { private final IContentProvider mContentProvider; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) private final String mPackageName; - private final @Nullable String mFeatureId; + private final @Nullable String mAttributionTag; private final String mAuthority; private final boolean mStable; @@ -104,7 +104,7 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { mContentResolver = contentResolver; mContentProvider = contentProvider; mPackageName = contentResolver.mPackageName; - mFeatureId = contentResolver.mFeatureId; + mAttributionTag = contentResolver.mAttributionTag; mAuthority = authority; mStable = stable; @@ -195,7 +195,8 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { cancellationSignal.setRemote(remoteCancellationSignal); } final Cursor cursor = mContentProvider.query( - mPackageName, mFeatureId, uri, projection, queryArgs, remoteCancellationSignal); + mPackageName, mAttributionTag, uri, projection, queryArgs, + remoteCancellationSignal); if (cursor == null) { return null; } @@ -255,7 +256,7 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { beforeRemote(); try { - return mContentProvider.canonicalize(mPackageName, mFeatureId, url); + return mContentProvider.canonicalize(mPackageName, mAttributionTag, url); } catch (DeadObjectException e) { if (!mStable) { mContentResolver.unstableProviderDied(mContentProvider); @@ -273,7 +274,7 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { beforeRemote(); try { - return mContentProvider.uncanonicalize(mPackageName, mFeatureId, url); + return mContentProvider.uncanonicalize(mPackageName, mAttributionTag, url); } catch (DeadObjectException e) { if (!mStable) { mContentResolver.unstableProviderDied(mContentProvider); @@ -298,7 +299,7 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { remoteCancellationSignal = mContentProvider.createCancellationSignal(); cancellationSignal.setRemote(remoteCancellationSignal); } - return mContentProvider.refresh(mPackageName, mFeatureId, url, extras, + return mContentProvider.refresh(mPackageName, mAttributionTag, url, extras, remoteCancellationSignal); } catch (DeadObjectException e) { if (!mStable) { @@ -318,7 +319,7 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { beforeRemote(); try { - return mContentProvider.checkUriPermission(mPackageName, mFeatureId, uri, uid, + return mContentProvider.checkUriPermission(mPackageName, mAttributionTag, uri, uid, modeFlags); } catch (DeadObjectException e) { if (!mStable) { @@ -344,7 +345,8 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { beforeRemote(); try { - return mContentProvider.insert(mPackageName, mFeatureId, url, initialValues, extras); + return mContentProvider.insert(mPackageName, mAttributionTag, url, initialValues, + extras); } catch (DeadObjectException e) { if (!mStable) { mContentResolver.unstableProviderDied(mContentProvider); @@ -364,7 +366,7 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { beforeRemote(); try { - return mContentProvider.bulkInsert(mPackageName, mFeatureId, url, initialValues); + return mContentProvider.bulkInsert(mPackageName, mAttributionTag, url, initialValues); } catch (DeadObjectException e) { if (!mStable) { mContentResolver.unstableProviderDied(mContentProvider); @@ -388,7 +390,7 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { beforeRemote(); try { - return mContentProvider.delete(mPackageName, mFeatureId, url, extras); + return mContentProvider.delete(mPackageName, mAttributionTag, url, extras); } catch (DeadObjectException e) { if (!mStable) { mContentResolver.unstableProviderDied(mContentProvider); @@ -413,7 +415,7 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { beforeRemote(); try { - return mContentProvider.update(mPackageName, mFeatureId, url, values, extras); + return mContentProvider.update(mPackageName, mAttributionTag, url, values, extras); } catch (DeadObjectException e) { if (!mStable) { mContentResolver.unstableProviderDied(mContentProvider); @@ -457,8 +459,8 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { remoteSignal = mContentProvider.createCancellationSignal(); signal.setRemote(remoteSignal); } - return mContentProvider.openFile(mPackageName, mFeatureId, url, mode, remoteSignal, - null); + return mContentProvider.openFile(mPackageName, mAttributionTag, url, mode, + remoteSignal, null); } catch (DeadObjectException e) { if (!mStable) { mContentResolver.unstableProviderDied(mContentProvider); @@ -502,7 +504,7 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { remoteSignal = mContentProvider.createCancellationSignal(); signal.setRemote(remoteSignal); } - return mContentProvider.openAssetFile(mPackageName, mFeatureId, url, mode, + return mContentProvider.openAssetFile(mPackageName, mAttributionTag, url, mode, remoteSignal); } catch (DeadObjectException e) { if (!mStable) { @@ -544,7 +546,7 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { signal.setRemote(remoteSignal); } return mContentProvider.openTypedAssetFile( - mPackageName, mFeatureId, uri, mimeTypeFilter, opts, remoteSignal); + mPackageName, mAttributionTag, uri, mimeTypeFilter, opts, remoteSignal); } catch (DeadObjectException e) { if (!mStable) { mContentResolver.unstableProviderDied(mContentProvider); @@ -571,7 +573,8 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { beforeRemote(); try { - return mContentProvider.applyBatch(mPackageName, mFeatureId, authority, operations); + return mContentProvider.applyBatch(mPackageName, mAttributionTag, authority, + operations); } catch (DeadObjectException e) { if (!mStable) { mContentResolver.unstableProviderDied(mContentProvider); @@ -597,7 +600,8 @@ public class ContentProviderClient implements ContentInterface, AutoCloseable { beforeRemote(); try { - return mContentProvider.call(mPackageName, mFeatureId, authority, method, arg, extras); + return mContentProvider.call(mPackageName, mAttributionTag, authority, method, arg, + extras); } catch (DeadObjectException e) { if (!mStable) { mContentResolver.unstableProviderDied(mContentProvider); diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java index 31e1fc824ed2..b134c3796b40 100644 --- a/core/java/android/content/ContentResolver.java +++ b/core/java/android/content/ContentResolver.java @@ -767,7 +767,7 @@ public abstract class ContentResolver implements ContentInterface { public ContentResolver(@Nullable Context context, @Nullable ContentInterface wrapped) { mContext = context != null ? context : ActivityThread.currentApplication(); mPackageName = mContext.getOpPackageName(); - mFeatureId = mContext.getFeatureId(); + mAttributionTag = mContext.getAttributionTag(); mTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion; mWrapped = wrapped; } @@ -1144,7 +1144,7 @@ public abstract class ContentResolver implements ContentInterface { cancellationSignal.setRemote(remoteCancellationSignal); } try { - qCursor = unstableProvider.query(mPackageName, mFeatureId, uri, projection, + qCursor = unstableProvider.query(mPackageName, mAttributionTag, uri, projection, queryArgs, remoteCancellationSignal); } catch (DeadObjectException e) { // The remote process has died... but we only hold an unstable @@ -1155,7 +1155,7 @@ public abstract class ContentResolver implements ContentInterface { if (stableProvider == null) { return null; } - qCursor = stableProvider.query(mPackageName, mFeatureId, uri, projection, + qCursor = stableProvider.query(mPackageName, mAttributionTag, uri, projection, queryArgs, remoteCancellationSignal); } if (qCursor == null) { @@ -1247,7 +1247,7 @@ public abstract class ContentResolver implements ContentInterface { try { final UriResultListener resultListener = new UriResultListener(); - provider.canonicalizeAsync(mPackageName, mFeatureId, url, + provider.canonicalizeAsync(mPackageName, mAttributionTag, url, new RemoteCallback(resultListener)); resultListener.waitForResult(CONTENT_PROVIDER_TIMEOUT_MILLIS); return resultListener.result; @@ -1294,7 +1294,7 @@ public abstract class ContentResolver implements ContentInterface { } try { - return provider.uncanonicalize(mPackageName, mFeatureId, url); + return provider.uncanonicalize(mPackageName, mAttributionTag, url); } catch (RemoteException e) { // Arbitrary and not worth documenting, as Activity // Manager will kill this process shortly anyway. @@ -1346,7 +1346,7 @@ public abstract class ContentResolver implements ContentInterface { remoteCancellationSignal = provider.createCancellationSignal(); cancellationSignal.setRemote(remoteCancellationSignal); } - return provider.refresh(mPackageName, mFeatureId, url, extras, + return provider.refresh(mPackageName, mAttributionTag, url, extras, remoteCancellationSignal); } catch (RemoteException e) { // Arbitrary and not worth documenting, as Activity @@ -1748,7 +1748,8 @@ public abstract class ContentResolver implements ContentInterface { try { fd = unstableProvider.openAssetFile( - mPackageName, mFeatureId, uri, mode, remoteCancellationSignal); + mPackageName, mAttributionTag, uri, mode, + remoteCancellationSignal); if (fd == null) { // The provider will be released by the finally{} clause return null; @@ -1763,7 +1764,7 @@ public abstract class ContentResolver implements ContentInterface { throw new FileNotFoundException("No content provider: " + uri); } fd = stableProvider.openAssetFile( - mPackageName, mFeatureId, uri, mode, remoteCancellationSignal); + mPackageName, mAttributionTag, uri, mode, remoteCancellationSignal); if (fd == null) { // The provider will be released by the finally{} clause return null; @@ -1914,7 +1915,8 @@ public abstract class ContentResolver implements ContentInterface { try { fd = unstableProvider.openTypedAssetFile( - mPackageName, mFeatureId, uri, mimeType, opts, remoteCancellationSignal); + mPackageName, mAttributionTag, uri, mimeType, opts, + remoteCancellationSignal); if (fd == null) { // The provider will be released by the finally{} clause return null; @@ -1929,7 +1931,8 @@ public abstract class ContentResolver implements ContentInterface { throw new FileNotFoundException("No content provider: " + uri); } fd = stableProvider.openTypedAssetFile( - mPackageName, mFeatureId, uri, mimeType, opts, remoteCancellationSignal); + mPackageName, mAttributionTag, uri, mimeType, opts, + remoteCancellationSignal); if (fd == null) { // The provider will be released by the finally{} clause return null; @@ -2077,7 +2080,7 @@ public abstract class ContentResolver implements ContentInterface { } try { long startTime = SystemClock.uptimeMillis(); - Uri createdRow = provider.insert(mPackageName, mFeatureId, url, values, extras); + Uri createdRow = provider.insert(mPackageName, mAttributionTag, url, values, extras); long durationMillis = SystemClock.uptimeMillis() - startTime; maybeLogUpdateToEventLog(durationMillis, url, "insert", null /* where */); return createdRow; @@ -2158,7 +2161,7 @@ public abstract class ContentResolver implements ContentInterface { } try { long startTime = SystemClock.uptimeMillis(); - int rowsCreated = provider.bulkInsert(mPackageName, mFeatureId, url, values); + int rowsCreated = provider.bulkInsert(mPackageName, mAttributionTag, url, values); long durationMillis = SystemClock.uptimeMillis() - startTime; maybeLogUpdateToEventLog(durationMillis, url, "bulkinsert", null /* where */); return rowsCreated; @@ -2217,7 +2220,7 @@ public abstract class ContentResolver implements ContentInterface { } try { long startTime = SystemClock.uptimeMillis(); - int rowsDeleted = provider.delete(mPackageName, mFeatureId, url, extras); + int rowsDeleted = provider.delete(mPackageName, mAttributionTag, url, extras); long durationMillis = SystemClock.uptimeMillis() - startTime; maybeLogUpdateToEventLog(durationMillis, url, "delete", null); return rowsDeleted; @@ -2284,7 +2287,7 @@ public abstract class ContentResolver implements ContentInterface { } try { long startTime = SystemClock.uptimeMillis(); - int rowsUpdated = provider.update(mPackageName, mFeatureId, uri, values, extras); + int rowsUpdated = provider.update(mPackageName, mAttributionTag, uri, values, extras); long durationMillis = SystemClock.uptimeMillis() - startTime; maybeLogUpdateToEventLog(durationMillis, uri, "update", null); return rowsUpdated; @@ -2333,7 +2336,7 @@ public abstract class ContentResolver implements ContentInterface { throw new IllegalArgumentException("Unknown authority " + authority); } try { - final Bundle res = provider.call(mPackageName, mFeatureId, authority, method, arg, + final Bundle res = provider.call(mPackageName, mAttributionTag, authority, method, arg, extras); Bundle.setDefusable(res, true); return res; @@ -3746,8 +3749,8 @@ public abstract class ContentResolver implements ContentInterface { } /** @hide */ - public @Nullable String getFeatureId() { - return mFeatureId; + public @Nullable String getAttributionTag() { + return mAttributionTag; } @UnsupportedAppUsage @@ -3757,7 +3760,7 @@ public abstract class ContentResolver implements ContentInterface { @UnsupportedAppUsage final String mPackageName; - final @Nullable String mFeatureId; + final @Nullable String mAttributionTag; final int mTargetSdkVersion; final ContentInterface mWrapped; diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index e2adc4a1a273..85bdfab2cd3e 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -815,16 +815,25 @@ public abstract class Context { } /** - * <p>Features are used in complex apps to logically separate parts of the app. E.g. a - * blogging app might also have a instant messaging app built in. + * <p>Attribution can be used in complex apps to logically separate parts of the app. E.g. a + * blogging app might also have a instant messaging app built in. In this case two separate tags + * can for used each sub-feature. * - * @return the feature id this context is for or {@code null} if this is the default - * feature. + * @return the attribution tag this context is for or {@code null} if this is the default. */ - public @Nullable String getFeatureId() { + public @Nullable String getAttributionTag() { return null; } + // TODO moltmann: Remove + /** + * @removed + */ + @Deprecated + public @Nullable String getFeatureId() { + return getAttributionTag(); + } + /** Return the full application info for this context's package. */ public abstract ApplicationInfo getApplicationInfo(); @@ -5836,19 +5845,29 @@ public abstract class Context { } /** - * Return a new Context object for the current Context but for a different feature in the app. - * Features can be used by complex apps to separate logical parts. + * Return a new Context object for the current Context but attribute to a different tag. + * In complex apps attribution tagging can be used to distinguish between separate logical + * parts. * - * @param featureId The feature id or {@code null} to create a context for the default feature. + * @param attributionTag The tag or {@code null} to create a context for the default. * - * @return A {@link Context} for the feature + * @return A {@link Context} that is tagged for the new attribution * - * @see #getFeatureId() + * @see #getAttributionTag() */ - public @NonNull Context createFeatureContext(@Nullable String featureId) { + public @NonNull Context createAttributionContext(@Nullable String attributionTag) { throw new RuntimeException("Not implemented. Must override in a subclass."); } + // TODO moltmann: remove + /** + * @removed + */ + @Deprecated + public @NonNull Context createFeatureContext(@Nullable String featureId) { + return createAttributionContext(featureId); + } + /** * Return a new Context object for the current Context but whose storage * APIs are backed by device-protected storage. diff --git a/core/java/android/content/ContextWrapper.java b/core/java/android/content/ContextWrapper.java index b7e04cf74c4a..d389d2a4ae09 100644 --- a/core/java/android/content/ContextWrapper.java +++ b/core/java/android/content/ContextWrapper.java @@ -164,8 +164,8 @@ public class ContextWrapper extends Context { /** @hide */ @Override - public @Nullable String getFeatureId() { - return mBase.getFeatureId(); + public @Nullable String getAttributionTag() { + return mBase.getAttributionTag(); } @Override @@ -984,8 +984,8 @@ public class ContextWrapper extends Context { } @Override - public @NonNull Context createFeatureContext(@Nullable String featureId) { - return mBase.createFeatureContext(featureId); + public @NonNull Context createAttributionContext(@Nullable String attributionTag) { + return mBase.createAttributionContext(attributionTag); } @Override diff --git a/core/java/android/content/IContentProvider.java b/core/java/android/content/IContentProvider.java index 37643da375df..84b0f0e80bab 100644 --- a/core/java/android/content/IContentProvider.java +++ b/core/java/android/content/IContentProvider.java @@ -38,7 +38,7 @@ import java.util.ArrayList; * @hide */ public interface IContentProvider extends IInterface { - public Cursor query(String callingPkg, @Nullable String featureId, Uri url, + public Cursor query(String callingPkg, @Nullable String attributionTag, Uri url, @Nullable String[] projection, @Nullable Bundle queryArgs, @Nullable ICancellationSignal cancellationSignal) throws RemoteException; @@ -59,8 +59,8 @@ public interface IContentProvider extends IInterface { throws RemoteException { return insert(callingPkg, null, url, initialValues, null); } - public Uri insert(String callingPkg, String featureId, Uri url, ContentValues initialValues, - Bundle extras) throws RemoteException; + public Uri insert(String callingPkg, String attributionTag, Uri url, + ContentValues initialValues, Bundle extras) throws RemoteException; @Deprecated @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "Use {@link " + "ContentProviderClient#bulkInsert(android.net.Uri, android.content.ContentValues[])" @@ -69,7 +69,7 @@ public interface IContentProvider extends IInterface { throws RemoteException { return bulkInsert(callingPkg, null, url, initialValues); } - public int bulkInsert(String callingPkg, String featureId, Uri url, + public int bulkInsert(String callingPkg, String attributionTag, Uri url, ContentValues[] initialValues) throws RemoteException; @Deprecated @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "Use {@link " @@ -80,7 +80,7 @@ public interface IContentProvider extends IInterface { return delete(callingPkg, null, url, ContentResolver.createSqlQueryBundle(selection, selectionArgs)); } - public int delete(String callingPkg, String featureId, Uri url, Bundle extras) + public int delete(String callingPkg, String attributionTag, Uri url, Bundle extras) throws RemoteException; @Deprecated @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, publicAlternatives = "Use {@link " @@ -91,18 +91,18 @@ public interface IContentProvider extends IInterface { return update(callingPkg, null, url, values, ContentResolver.createSqlQueryBundle(selection, selectionArgs)); } - public int update(String callingPkg, String featureId, Uri url, ContentValues values, + public int update(String callingPkg, String attributionTag, Uri url, ContentValues values, Bundle extras) throws RemoteException; - public ParcelFileDescriptor openFile(String callingPkg, @Nullable String featureId, Uri url, - String mode, ICancellationSignal signal, IBinder callerToken) + public ParcelFileDescriptor openFile(String callingPkg, @Nullable String attributionTag, + Uri url, String mode, ICancellationSignal signal, IBinder callerToken) throws RemoteException, FileNotFoundException; - public AssetFileDescriptor openAssetFile(String callingPkg, @Nullable String featureId, + public AssetFileDescriptor openAssetFile(String callingPkg, @Nullable String attributionTag, Uri url, String mode, ICancellationSignal signal) throws RemoteException, FileNotFoundException; - public ContentProviderResult[] applyBatch(String callingPkg, @Nullable String featureId, + public ContentProviderResult[] applyBatch(String callingPkg, @Nullable String attributionTag, String authority, ArrayList<ContentProviderOperation> operations) throws RemoteException, OperationApplicationException; @@ -115,15 +115,15 @@ public interface IContentProvider extends IInterface { return call(callingPkg, null, "unknown", method, arg, extras); } - public Bundle call(String callingPkg, @Nullable String featureId, String authority, + public Bundle call(String callingPkg, @Nullable String attributionTag, String authority, String method, @Nullable String arg, @Nullable Bundle extras) throws RemoteException; - public int checkUriPermission(String callingPkg, @Nullable String featureId, Uri uri, int uid, - int modeFlags) throws RemoteException; + public int checkUriPermission(String callingPkg, @Nullable String attributionTag, Uri uri, + int uid, int modeFlags) throws RemoteException; public ICancellationSignal createCancellationSignal() throws RemoteException; - public Uri canonicalize(String callingPkg, @Nullable String featureId, Uri uri) + public Uri canonicalize(String callingPkg, @Nullable String attributionTag, Uri uri) throws RemoteException; /** @@ -131,20 +131,21 @@ public interface IContentProvider extends IInterface { * call returns immediately, and the resulting type is returned when available via * a binder callback. */ - void canonicalizeAsync(String callingPkg, @Nullable String featureId, Uri uri, + void canonicalizeAsync(String callingPkg, @Nullable String attributionTag, Uri uri, RemoteCallback callback) throws RemoteException; - public Uri uncanonicalize(String callingPkg, @Nullable String featureId, Uri uri) + public Uri uncanonicalize(String callingPkg, @Nullable String attributionTag, Uri uri) throws RemoteException; - public boolean refresh(String callingPkg, @Nullable String featureId, Uri url, + public boolean refresh(String callingPkg, @Nullable String attributionTag, Uri url, @Nullable Bundle extras, ICancellationSignal cancellationSignal) throws RemoteException; // Data interchange. public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException; - public AssetFileDescriptor openTypedAssetFile(String callingPkg, @Nullable String featureId, - Uri url, String mimeType, Bundle opts, ICancellationSignal signal) + public AssetFileDescriptor openTypedAssetFile(String callingPkg, + @Nullable String attributionTag, Uri url, String mimeType, Bundle opts, + ICancellationSignal signal) throws RemoteException, FileNotFoundException; /* IPC constants */ diff --git a/core/java/android/content/PermissionChecker.java b/core/java/android/content/PermissionChecker.java index 33bd839a53f6..052c9209f6f7 100644 --- a/core/java/android/content/PermissionChecker.java +++ b/core/java/android/content/PermissionChecker.java @@ -123,7 +123,7 @@ public final class PermissionChecker { * @param uid The uid for which to check. * @param packageName The package name for which to check. If null the * the first package for the calling UID will be used. - * @param featureId Feature in the package + * @param attributionTag attribution tag * @return The permission check result which is either {@link #PERMISSION_GRANTED} * or {@link #PERMISSION_SOFT_DENIED} or {@link #PERMISSION_HARD_DENIED}. * @param message A message describing the reason the permission was checked @@ -133,9 +133,9 @@ public final class PermissionChecker { @PermissionResult public static int checkPermissionForDataDelivery(@NonNull Context context, @NonNull String permission, int pid, int uid, @Nullable String packageName, - @Nullable String featureId, @Nullable String message) { - return checkPermissionCommon(context, permission, pid, uid, packageName, featureId, message, - true /*forDataDelivery*/); + @Nullable String attributionTag, @Nullable String message) { + return checkPermissionCommon(context, permission, pid, uid, packageName, attributionTag, + message, true /*forDataDelivery*/); } /** @@ -171,8 +171,8 @@ public final class PermissionChecker { @PermissionResult public static int checkPermissionForPreflight(@NonNull Context context, @NonNull String permission, int pid, int uid, @Nullable String packageName) { - return checkPermissionCommon(context, permission, pid, uid, packageName, null /*featureId*/, - null /*message*/, false /*forDataDelivery*/); + return checkPermissionCommon(context, permission, pid, uid, packageName, + null /*attributionTag*/, null /*message*/, false /*forDataDelivery*/); } /** @@ -207,7 +207,7 @@ public final class PermissionChecker { public static int checkSelfPermissionForDataDelivery(@NonNull Context context, @NonNull String permission, @Nullable String message) { return checkPermissionForDataDelivery(context, permission, Process.myPid(), - Process.myUid(), context.getPackageName(), context.getFeatureId(), message); + Process.myUid(), context.getPackageName(), context.getAttributionTag(), message); } /** @@ -266,7 +266,7 @@ public final class PermissionChecker { * @param permission The permission to check. * @param packageName The package name making the IPC. If null the * the first package for the calling UID will be used. - * @param featureId The feature inside of the app + * @param attributionTag attribution tag * @return The permission check result which is either {@link #PERMISSION_GRANTED} * or {@link #PERMISSION_SOFT_DENIED} or {@link #PERMISSION_HARD_DENIED}. * @param message A message describing the reason the permission was checked @@ -276,12 +276,12 @@ public final class PermissionChecker { @PermissionResult public static int checkCallingPermissionForDataDelivery(@NonNull Context context, @NonNull String permission, @Nullable String packageName, - @Nullable String featureId, @Nullable String message) { + @Nullable String attributionTag, @Nullable String message) { if (Binder.getCallingPid() == Process.myPid()) { return PERMISSION_HARD_DENIED; } return checkPermissionForDataDelivery(context, permission, Binder.getCallingPid(), - Binder.getCallingUid(), packageName, featureId, message); + Binder.getCallingUid(), packageName, attributionTag, message); } /** @@ -343,20 +343,20 @@ public final class PermissionChecker { * @param permission The permission to check. * @return The permission check result which is either {@link #PERMISSION_GRANTED} * or {@link #PERMISSION_SOFT_DENIED} or {@link #PERMISSION_HARD_DENIED}. - * @param featureId feature Id of caller (if not self) + * @param attributionTag attribution tag of caller (if not self) * @param message A message describing the reason the permission was checked * * @see #checkCallingOrSelfPermissionForPreflight(Context, String) */ @PermissionResult public static int checkCallingOrSelfPermissionForDataDelivery(@NonNull Context context, - @NonNull String permission, @Nullable String featureId, @Nullable String message) { + @NonNull String permission, @Nullable String attributionTag, @Nullable String message) { String packageName = (Binder.getCallingPid() == Process.myPid()) ? context.getPackageName() : null; - featureId = (Binder.getCallingPid() == Process.myPid()) - ? context.getFeatureId() : featureId; + attributionTag = (Binder.getCallingPid() == Process.myPid()) + ? context.getAttributionTag() : attributionTag; return checkPermissionForDataDelivery(context, permission, Binder.getCallingPid(), - Binder.getCallingUid(), packageName, featureId, message); + Binder.getCallingUid(), packageName, attributionTag, message); } /** @@ -395,7 +395,7 @@ public final class PermissionChecker { } static int checkPermissionCommon(@NonNull Context context, @NonNull String permission, - int pid, int uid, @Nullable String packageName, @Nullable String featureId, + int pid, int uid, @Nullable String packageName, @Nullable String attributionTag, @Nullable String message, boolean forDataDelivery) { final PermissionInfo permissionInfo; try { @@ -414,18 +414,18 @@ public final class PermissionChecker { } if (permissionInfo.isAppOp()) { - return checkAppOpPermission(context, permission, pid, uid, packageName, featureId, + return checkAppOpPermission(context, permission, pid, uid, packageName, attributionTag, message, forDataDelivery); } if (permissionInfo.isRuntime()) { - return checkRuntimePermission(context, permission, pid, uid, packageName, featureId, - message, forDataDelivery); + return checkRuntimePermission(context, permission, pid, uid, packageName, + attributionTag, message, forDataDelivery); } return context.checkPermission(permission, pid, uid); } private static int checkAppOpPermission(@NonNull Context context, @NonNull String permission, - int pid, int uid, @Nullable String packageName, @Nullable String featureId, + int pid, int uid, @Nullable String packageName, @Nullable String attributionTag, @Nullable String message, boolean forDataDelivery) { final String op = AppOpsManager.permissionToOp(permission); if (op == null || packageName == null) { @@ -434,7 +434,7 @@ public final class PermissionChecker { final AppOpsManager appOpsManager = context.getSystemService(AppOpsManager.class); final int opMode = (forDataDelivery) - ? appOpsManager.noteProxyOpNoThrow(op, packageName, uid, featureId, message) + ? appOpsManager.noteProxyOpNoThrow(op, packageName, uid, attributionTag, message) : appOpsManager.unsafeCheckOpNoThrow(op, uid, packageName); switch (opMode) { @@ -453,7 +453,7 @@ public final class PermissionChecker { } private static int checkRuntimePermission(@NonNull Context context, @NonNull String permission, - int pid, int uid, @Nullable String packageName, @Nullable String featureId, + int pid, int uid, @Nullable String packageName, @Nullable String attributionTag, @Nullable String message, boolean forDataDelivery) { if (context.checkPermission(permission, pid, uid) == PackageManager.PERMISSION_DENIED) { return PERMISSION_HARD_DENIED; @@ -466,7 +466,7 @@ public final class PermissionChecker { final AppOpsManager appOpsManager = context.getSystemService(AppOpsManager.class); final int opMode = (forDataDelivery) - ? appOpsManager.noteProxyOpNoThrow(op, packageName, uid, featureId, message) + ? appOpsManager.noteProxyOpNoThrow(op, packageName, uid, attributionTag, message) : appOpsManager.unsafeCheckOpNoThrow(op, uid, packageName); if (opMode == AppOpsManager.MODE_ALLOWED) { diff --git a/core/java/android/content/pm/CrossProfileApps.java b/core/java/android/content/pm/CrossProfileApps.java index 3261cb124e00..e6b9fda5709a 100644 --- a/core/java/android/content/pm/CrossProfileApps.java +++ b/core/java/android/content/pm/CrossProfileApps.java @@ -95,7 +95,7 @@ public class CrossProfileApps { mService.startActivityAsUser( mContext.getIApplicationThread(), mContext.getPackageName(), - mContext.getFeatureId(), + mContext.getAttributionTag(), component, targetUser.getIdentifier(), true); @@ -132,7 +132,7 @@ public class CrossProfileApps { mService.startActivityAsUserByIntent( mContext.getIApplicationThread(), mContext.getPackageName(), - mContext.getFeatureId(), + mContext.getAttributionTag(), intent, targetUser.getIdentifier(), callingActivity != null ? callingActivity.getActivityToken() : null); @@ -159,7 +159,7 @@ public class CrossProfileApps { public void startActivity(@NonNull ComponentName component, @NonNull UserHandle targetUser) { try { mService.startActivityAsUser(mContext.getIApplicationThread(), - mContext.getPackageName(), mContext.getFeatureId(), component, + mContext.getPackageName(), mContext.getAttributionTag(), component, targetUser.getIdentifier(), false); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java index 86242fd6f82f..4e4897f59ad3 100644 --- a/core/java/android/content/pm/LauncherApps.java +++ b/core/java/android/content/pm/LauncherApps.java @@ -721,7 +721,7 @@ public class LauncherApps { } try { mService.startActivityAsUser(mContext.getIApplicationThread(), - mContext.getPackageName(), mContext.getFeatureId(), + mContext.getPackageName(), mContext.getAttributionTag(), component, sourceBounds, opts, user); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); @@ -739,8 +739,8 @@ public class LauncherApps { @Nullable Rect sourceBounds, @Nullable Bundle opts) { try { mService.startSessionDetailsActivityAsUser(mContext.getIApplicationThread(), - mContext.getPackageName(), mContext.getFeatureId(), sessionInfo, sourceBounds, - opts, sessionInfo.getUser()); + mContext.getPackageName(), mContext.getAttributionTag(), sessionInfo, + sourceBounds, opts, sessionInfo.getUser()); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } @@ -760,7 +760,7 @@ public class LauncherApps { logErrorForInvalidProfileAccess(user); try { mService.showAppDetailsAsUser(mContext.getIApplicationThread(), - mContext.getPackageName(), mContext.getFeatureId(), + mContext.getPackageName(), mContext.getAttributionTag(), component, sourceBounds, opts, user); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index c6875a4b3443..edf313467b76 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -190,7 +190,7 @@ public class PackageParser { public static final String TAG_OVERLAY = "overlay"; public static final String TAG_PACKAGE = "package"; public static final String TAG_PACKAGE_VERIFIER = "package-verifier"; - public static final String TAG_FEATURE = "feature"; + public static final String TAG_ATTRIBUTION = "attribution"; public static final String TAG_PERMISSION = "permission"; public static final String TAG_PERMISSION_GROUP = "permission-group"; public static final String TAG_PERMISSION_TREE = "permission-tree"; diff --git a/core/java/android/content/pm/parsing/ParsingPackage.java b/core/java/android/content/pm/parsing/ParsingPackage.java index 75f234d5a38b..9215dca2c185 100644 --- a/core/java/android/content/pm/parsing/ParsingPackage.java +++ b/core/java/android/content/pm/parsing/ParsingPackage.java @@ -24,7 +24,7 @@ import android.content.pm.FeatureGroupInfo; import android.content.pm.FeatureInfo; import android.content.pm.PackageParser; import android.content.pm.parsing.component.ParsedActivity; -import android.content.pm.parsing.component.ParsedFeature; +import android.content.pm.parsing.component.ParsedAttribution; import android.content.pm.parsing.component.ParsedInstrumentation; import android.content.pm.parsing.component.ParsedIntentInfo; import android.content.pm.parsing.component.ParsedPermission; @@ -77,7 +77,7 @@ public interface ParsingPackage extends ParsingPackageRead { ParsingPackage addProvider(ParsedProvider parsedProvider); - ParsingPackage addFeature(ParsedFeature permission); + ParsingPackage addAttribution(ParsedAttribution attribution); ParsingPackage addReceiver(ParsedActivity parsedReceiver); diff --git a/core/java/android/content/pm/parsing/ParsingPackageImpl.java b/core/java/android/content/pm/parsing/ParsingPackageImpl.java index cf0455b95162..e038592fd516 100644 --- a/core/java/android/content/pm/parsing/ParsingPackageImpl.java +++ b/core/java/android/content/pm/parsing/ParsingPackageImpl.java @@ -32,8 +32,8 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageParser; import android.content.pm.ProcessInfo; import android.content.pm.parsing.component.ParsedActivity; +import android.content.pm.parsing.component.ParsedAttribution; import android.content.pm.parsing.component.ParsedComponent; -import android.content.pm.parsing.component.ParsedFeature; import android.content.pm.parsing.component.ParsedInstrumentation; import android.content.pm.parsing.component.ParsedIntentInfo; import android.content.pm.parsing.component.ParsedMainComponent; @@ -253,7 +253,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable { protected List<ParsedProvider> providers = emptyList(); @NonNull - private List<ParsedFeature> features = emptyList(); + private List<ParsedAttribution> attributions = emptyList(); @NonNull protected List<ParsedPermission> permissions = emptyList(); @@ -648,8 +648,8 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable { } @Override - public ParsingPackageImpl addFeature(ParsedFeature feature) { - this.features = CollectionUtils.add(this.features, feature); + public ParsingPackageImpl addAttribution(ParsedAttribution attribution) { + this.attributions = CollectionUtils.add(this.attributions, attribution); return this; } @@ -1018,7 +1018,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable { dest.writeTypedList(this.receivers); dest.writeTypedList(this.services); dest.writeTypedList(this.providers); - dest.writeTypedList(this.features); + dest.writeTypedList(this.attributions); dest.writeTypedList(this.permissions); dest.writeTypedList(this.permissionGroups); dest.writeTypedList(this.instrumentations); @@ -1178,7 +1178,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable { this.receivers = in.createTypedArrayList(ParsedActivity.CREATOR); this.services = in.createTypedArrayList(ParsedService.CREATOR); this.providers = in.createTypedArrayList(ParsedProvider.CREATOR); - this.features = in.createTypedArrayList(ParsedFeature.CREATOR); + this.attributions = in.createTypedArrayList(ParsedAttribution.CREATOR); this.permissions = in.createTypedArrayList(ParsedPermission.CREATOR); this.permissionGroups = in.createTypedArrayList(ParsedPermissionGroup.CREATOR); this.instrumentations = in.createTypedArrayList(ParsedInstrumentation.CREATOR); @@ -1548,8 +1548,8 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable { @NonNull @Override - public List<ParsedFeature> getFeatures() { - return features; + public List<ParsedAttribution> getAttributions() { + return attributions; } @NonNull diff --git a/core/java/android/content/pm/parsing/ParsingPackageRead.java b/core/java/android/content/pm/parsing/ParsingPackageRead.java index 49765c782ab2..277c82dd1d13 100644 --- a/core/java/android/content/pm/parsing/ParsingPackageRead.java +++ b/core/java/android/content/pm/parsing/ParsingPackageRead.java @@ -28,7 +28,7 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageParser; import android.content.pm.ServiceInfo; import android.content.pm.parsing.component.ParsedActivity; -import android.content.pm.parsing.component.ParsedFeature; +import android.content.pm.parsing.component.ParsedAttribution; import android.content.pm.parsing.component.ParsedInstrumentation; import android.content.pm.parsing.component.ParsedIntentInfo; import android.content.pm.parsing.component.ParsedPermission; @@ -80,7 +80,7 @@ public interface ParsingPackageRead extends Parcelable { List<ConfigurationInfo> getConfigPreferences(); @NonNull - List<ParsedFeature> getFeatures(); + List<ParsedAttribution> getAttributions(); /** * @see PackageInfo#featureGroups diff --git a/core/java/android/content/pm/parsing/ParsingPackageUtils.java b/core/java/android/content/pm/parsing/ParsingPackageUtils.java index 29c8b6504870..b433b0b778a8 100644 --- a/core/java/android/content/pm/parsing/ParsingPackageUtils.java +++ b/core/java/android/content/pm/parsing/ParsingPackageUtils.java @@ -49,8 +49,8 @@ import android.content.pm.Signature; import android.content.pm.parsing.component.ComponentParseUtils; import android.content.pm.parsing.component.ParsedActivity; import android.content.pm.parsing.component.ParsedActivityUtils; -import android.content.pm.parsing.component.ParsedFeature; -import android.content.pm.parsing.component.ParsedFeatureUtils; +import android.content.pm.parsing.component.ParsedAttribution; +import android.content.pm.parsing.component.ParsedAttributionUtils; import android.content.pm.parsing.component.ParsedInstrumentation; import android.content.pm.parsing.component.ParsedInstrumentationUtils; import android.content.pm.parsing.component.ParsedIntentInfo; @@ -673,7 +673,7 @@ public class ParsingPackageUtils { ); } - if (!ParsedFeature.isCombinationValid(pkg.getFeatures())) { + if (!ParsedAttribution.isCombinationValid(pkg.getAttributions())) { return input.error( INSTALL_PARSE_FAILED_BAD_MANIFEST, "Combination <feature> tags are not valid" @@ -708,8 +708,9 @@ public class ParsingPackageUtils { return parseOverlay(input, pkg, res, parser); case PackageParser.TAG_KEY_SETS: return parseKeySets(input, pkg, res, parser); - case PackageParser.TAG_FEATURE: - return parseFeature(input, pkg, res, parser); + case "feature": // TODO moltmann: Remove + case PackageParser.TAG_ATTRIBUTION: + return parseAttribution(input, pkg, res, parser); case PackageParser.TAG_PERMISSION_GROUP: return parsePermissionGroup(input, pkg, res, parser); case PackageParser.TAG_PERMISSION: @@ -918,13 +919,15 @@ public class ParsingPackageUtils { return input.success(pkg); } - private static ParseResult<ParsingPackage> parseFeature(ParseInput input, ParsingPackage pkg, - Resources res, XmlResourceParser parser) throws IOException, XmlPullParserException { - ParseResult<ParsedFeature> result = ParsedFeatureUtils.parseFeature(res, parser, input); + private static ParseResult<ParsingPackage> parseAttribution(ParseInput input, + ParsingPackage pkg, Resources res, XmlResourceParser parser) + throws IOException, XmlPullParserException { + ParseResult<ParsedAttribution> result = ParsedAttributionUtils.parseAttribution(res, + parser, input); if (result.isError()) { return input.error(result); } - return input.success(pkg.addFeature(result.getResult())); + return input.success(pkg.addAttribution(result.getResult())); } private static ParseResult<ParsingPackage> parsePermissionGroup(ParseInput input, diff --git a/core/java/android/content/pm/parsing/component/ParsedFeature.java b/core/java/android/content/pm/parsing/component/ParsedAttribution.java index b8a9098cfa0e..02b3c7d9c909 100644 --- a/core/java/android/content/pm/parsing/component/ParsedFeature.java +++ b/core/java/android/content/pm/parsing/component/ParsedAttribution.java @@ -29,65 +29,65 @@ import java.util.ArrayList; import java.util.List; /** - * A {@link android.R.styleable#AndroidManifestFeature <feature>} tag parsed from the + * A {@link android.R.styleable#AndroidManifestAttribution <attribution>} tag parsed from the * manifest. * * @hide */ @DataClass(genAidl = false) -public class ParsedFeature implements Parcelable { - /** Maximum length of featureId */ - public static final int MAX_FEATURE_ID_LEN = 50; +public class ParsedAttribution implements Parcelable { + /** Maximum length of attribution tag */ + public static final int MAX_ATTRIBUTION_TAG_LEN = 50; - /** Maximum amount of features per package */ - private static final int MAX_NUM_FEATURES = 1000; + /** Maximum amount of attributions per package */ + private static final int MAX_NUM_ATTRIBUTIONS = 1000; - /** Id of the feature */ - public final @NonNull String id; + /** Tag of the attribution */ + public final @NonNull String tag; - /** User visible label fo the feature */ + /** User visible label fo the attribution */ public final @StringRes int label; - /** Ids of previously declared features this feature inherits from */ + /** Ids of previously declared attributions this attribution inherits from */ public final @NonNull List<String> inheritFrom; /** - * @return Is this set of features a valid combination for a single package? + * @return Is this set of attributions a valid combination for a single package? */ - public static boolean isCombinationValid(@Nullable List<ParsedFeature> features) { - if (features == null) { + public static boolean isCombinationValid(@Nullable List<ParsedAttribution> attributions) { + if (attributions == null) { return true; } - ArraySet<String> featureIds = new ArraySet<>(features.size()); - ArraySet<String> inheritFromFeatureIds = new ArraySet<>(); + ArraySet<String> attributionTags = new ArraySet<>(attributions.size()); + ArraySet<String> inheritFromAttributionTags = new ArraySet<>(); - int numFeatures = features.size(); - if (numFeatures > MAX_NUM_FEATURES) { + int numAttributions = attributions.size(); + if (numAttributions > MAX_NUM_ATTRIBUTIONS) { return false; } - for (int featureNum = 0; featureNum < numFeatures; featureNum++) { - boolean wasAdded = featureIds.add(features.get(featureNum).id); + for (int attributionNum = 0; attributionNum < numAttributions; attributionNum++) { + boolean wasAdded = attributionTags.add(attributions.get(attributionNum).tag); if (!wasAdded) { // feature id is not unique return false; } } - for (int featureNum = 0; featureNum < numFeatures; featureNum++) { - ParsedFeature feature = features.get(featureNum); + for (int attributionNum = 0; attributionNum < numAttributions; attributionNum++) { + ParsedAttribution feature = attributions.get(attributionNum); int numInheritFrom = feature.inheritFrom.size(); for (int inheritFromNum = 0; inheritFromNum < numInheritFrom; inheritFromNum++) { String inheritFrom = feature.inheritFrom.get(inheritFromNum); - if (featureIds.contains(inheritFrom)) { - // Cannot inherit from a feature that is still defined + if (attributionTags.contains(inheritFrom)) { + // Cannot inherit from a attribution that is still defined return false; } - boolean wasAdded = inheritFromFeatureIds.add(inheritFrom); + boolean wasAdded = inheritFromAttributionTags.add(inheritFrom); if (!wasAdded) { // inheritFrom is not unique return false; @@ -106,7 +106,7 @@ public class ParsedFeature implements Parcelable { // CHECKSTYLE:OFF Generated code // // To regenerate run: - // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/parsing/component/ParsedFeature.java + // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/parsing/component/ParsedAttribution.java // // To exclude the generated code from IntelliJ auto-formatting enable (one-time): // Settings > Editor > Code Style > Formatter Control @@ -114,8 +114,8 @@ public class ParsedFeature implements Parcelable { @android.annotation.IntDef(prefix = "MAX_", value = { - MAX_FEATURE_ID_LEN, - MAX_NUM_FEATURES + MAX_ATTRIBUTION_TAG_LEN, + MAX_NUM_ATTRIBUTIONS }) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @DataClass.Generated.Member @@ -124,32 +124,32 @@ public class ParsedFeature implements Parcelable { @DataClass.Generated.Member public static String maxToString(@Max int value) { switch (value) { - case MAX_FEATURE_ID_LEN: - return "MAX_FEATURE_ID_LEN"; - case MAX_NUM_FEATURES: - return "MAX_NUM_FEATURES"; + case MAX_ATTRIBUTION_TAG_LEN: + return "MAX_ATTRIBUTION_TAG_LEN"; + case MAX_NUM_ATTRIBUTIONS: + return "MAX_NUM_ATTRIBUTIONS"; default: return Integer.toHexString(value); } } /** - * Creates a new ParsedFeature. + * Creates a new ParsedAttribution. * - * @param id - * Id of the feature + * @param tag + * Tag of the attribution * @param label - * User visible label fo the feature + * User visible label fo the attribution * @param inheritFrom - * Ids of previously declared features this feature inherits from + * Ids of previously declared attributions this attribution inherits from */ @DataClass.Generated.Member - public ParsedFeature( - @NonNull String id, + public ParsedAttribution( + @NonNull String tag, @StringRes int label, @NonNull List<String> inheritFrom) { - this.id = id; + this.tag = tag; com.android.internal.util.AnnotationValidations.validate( - NonNull.class, null, id); + NonNull.class, null, tag); this.label = label; com.android.internal.util.AnnotationValidations.validate( StringRes.class, null, label); @@ -166,7 +166,7 @@ public class ParsedFeature implements Parcelable { // You can override field parcelling by defining methods like: // void parcelFieldName(Parcel dest, int flags) { ... } - dest.writeString(id); + dest.writeString(tag); dest.writeInt(label); dest.writeStringList(inheritFrom); } @@ -178,18 +178,18 @@ public class ParsedFeature implements Parcelable { /** @hide */ @SuppressWarnings({"unchecked", "RedundantCast"}) @DataClass.Generated.Member - protected ParsedFeature(@NonNull Parcel in) { + protected ParsedAttribution(@NonNull Parcel in) { // You can override field unparcelling by defining methods like: // static FieldType unparcelFieldName(Parcel in) { ... } - String _id = in.readString(); + String _tag = in.readString(); int _label = in.readInt(); List<String> _inheritFrom = new ArrayList<>(); in.readStringList(_inheritFrom); - this.id = _id; + this.tag = _tag; com.android.internal.util.AnnotationValidations.validate( - NonNull.class, null, id); + NonNull.class, null, tag); this.label = _label; com.android.internal.util.AnnotationValidations.validate( StringRes.class, null, label); @@ -201,24 +201,24 @@ public class ParsedFeature implements Parcelable { } @DataClass.Generated.Member - public static final @NonNull Parcelable.Creator<ParsedFeature> CREATOR - = new Parcelable.Creator<ParsedFeature>() { + public static final @NonNull Parcelable.Creator<ParsedAttribution> CREATOR + = new Parcelable.Creator<ParsedAttribution>() { @Override - public ParsedFeature[] newArray(int size) { - return new ParsedFeature[size]; + public ParsedAttribution[] newArray(int size) { + return new ParsedAttribution[size]; } @Override - public ParsedFeature createFromParcel(@NonNull Parcel in) { - return new ParsedFeature(in); + public ParsedAttribution createFromParcel(@NonNull Parcel in) { + return new ParsedAttribution(in); } }; @DataClass.Generated( - time = 1581379861853L, + time = 1583436566499L, codegenVersion = "1.0.14", - sourceFile = "frameworks/base/core/java/android/content/pm/parsing/component/ParsedFeature.java", - inputSignatures = "public static final int MAX_FEATURE_ID_LEN\nprivate static final int MAX_NUM_FEATURES\npublic final @android.annotation.NonNull java.lang.String id\npublic final @android.annotation.StringRes int label\npublic final @android.annotation.NonNull java.util.List<java.lang.String> inheritFrom\npublic static boolean isCombinationValid(java.util.List<android.content.pm.parsing.component.ParsedFeature>)\nclass ParsedFeature extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genAidl=false)") + sourceFile = "frameworks/base/core/java/android/content/pm/parsing/component/ParsedAttribution.java", + inputSignatures = "public static final int MAX_ATTRIBUTION_TAG_LEN\nprivate static final int MAX_NUM_ATTRIBUTIONS\npublic final @android.annotation.NonNull java.lang.String tag\npublic final @android.annotation.StringRes int label\npublic final @android.annotation.NonNull java.util.List<java.lang.String> inheritFrom\npublic static boolean isCombinationValid(java.util.List<android.content.pm.parsing.component.ParsedAttribution>)\nclass ParsedAttribution extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genAidl=false)") @Deprecated private void __metadata() {} diff --git a/core/java/android/content/pm/parsing/component/ParsedFeatureUtils.java b/core/java/android/content/pm/parsing/component/ParsedAttributionUtils.java index fb5280175d1a..c4b1a0eb90a0 100644 --- a/core/java/android/content/pm/parsing/component/ParsedFeatureUtils.java +++ b/core/java/android/content/pm/parsing/component/ParsedAttributionUtils.java @@ -34,34 +34,40 @@ import java.util.Collections; import java.util.List; /** @hide */ -public class ParsedFeatureUtils { +public class ParsedAttributionUtils { @NonNull - public static ParseResult<ParsedFeature> parseFeature(Resources res, XmlResourceParser parser, - ParseInput input) throws IOException, XmlPullParserException { - String featureId; + public static ParseResult<ParsedAttribution> parseAttribution(Resources res, + XmlResourceParser parser, ParseInput input) + throws IOException, XmlPullParserException { + String attributionTag; int label; List<String> inheritFrom = null; - TypedArray sa = res.obtainAttributes(parser, R.styleable.AndroidManifestFeature); + TypedArray sa = res.obtainAttributes(parser, R.styleable.AndroidManifestAttribution); if (sa == null) { - return input.error("<feature> could not be parsed"); + return input.error("<attribution> could not be parsed"); } try { - featureId = sa.getNonConfigurationString(R.styleable.AndroidManifestFeature_featureId, - 0); - if (featureId == null) { - return input.error("<featureId> does not specify android:featureId"); + attributionTag = sa.getNonConfigurationString( + R.styleable.AndroidManifestAttribution_tag, 0); + if (attributionTag == null) { + // TODO moltmann: Remove handling of featureId + attributionTag = sa.getNonConfigurationString( + R.styleable.AndroidManifestAttribution_featureId, 0); + if (attributionTag == null) { + return input.error("<attribution> does not specify android:tag"); + } } - if (featureId.length() > ParsedFeature.MAX_FEATURE_ID_LEN) { - return input.error("<featureId> is too long. Max length is " - + ParsedFeature.MAX_FEATURE_ID_LEN); + if (attributionTag.length() > ParsedAttribution.MAX_ATTRIBUTION_TAG_LEN) { + return input.error("android:tag is too long. Max length is " + + ParsedAttribution.MAX_ATTRIBUTION_TAG_LEN); } - label = sa.getResourceId(R.styleable.AndroidManifestFeature_label, 0); + label = sa.getResourceId(R.styleable.AndroidManifestAttribution_label, 0); if (label == Resources.ID_NULL) { - return input.error("<featureId> does not specify android:label"); + return input.error("<attribution> does not specify android:label"); } } finally { sa.recycle(); @@ -77,14 +83,15 @@ public class ParsedFeatureUtils { String tagName = parser.getName(); if (tagName.equals("inherit-from")) { - sa = res.obtainAttributes(parser, R.styleable.AndroidManifestFeatureInheritFrom); + sa = res.obtainAttributes(parser, + R.styleable.AndroidManifestAttributionInheritFrom); if (sa == null) { return input.error("<inherit-from> could not be parsed"); } try { String inheritFromId = sa.getNonConfigurationString( - R.styleable.AndroidManifestFeatureInheritFrom_featureId,0); + R.styleable.AndroidManifestAttributionInheritFrom_tag, 0); if (inheritFrom == null) { inheritFrom = new ArrayList<>(); @@ -94,7 +101,7 @@ public class ParsedFeatureUtils { sa.recycle(); } } else { - return input.error("Bad element under <feature>: " + tagName); + return input.error("Bad element under <attribution>: " + tagName); } } @@ -104,6 +111,6 @@ public class ParsedFeatureUtils { ((ArrayList) inheritFrom).trimToSize(); } - return input.success(new ParsedFeature(featureId, label, inheritFrom)); + return input.success(new ParsedAttribution(attributionTag, label, inheritFrom)); } } diff --git a/core/java/android/hardware/camera2/CameraManager.java b/core/java/android/hardware/camera2/CameraManager.java index a091f84fe463..972b0f55acef 100644 --- a/core/java/android/hardware/camera2/CameraManager.java +++ b/core/java/android/hardware/camera2/CameraManager.java @@ -486,7 +486,7 @@ public final class CameraManager { "Camera service is currently unavailable"); } cameraUser = cameraService.connectDevice(callbacks, cameraId, - mContext.getOpPackageName(), mContext.getFeatureId(), uid); + mContext.getOpPackageName(), mContext.getAttributionTag(), uid); } else { // Use legacy camera implementation for HAL1 devices int id; diff --git a/core/java/android/provider/DocumentsProvider.java b/core/java/android/provider/DocumentsProvider.java index a80153d691f0..327bca268a7b 100644 --- a/core/java/android/provider/DocumentsProvider.java +++ b/core/java/android/provider/DocumentsProvider.java @@ -1081,7 +1081,7 @@ public abstract class DocumentsProvider extends ContentProvider { // signed with platform signature can hold MANAGE_DOCUMENTS, we are going to check for // MANAGE_DOCUMENTS or associated URI permission here instead final Uri rootUri = extras.getParcelable(DocumentsContract.EXTRA_URI); - enforceWritePermissionInner(rootUri, getCallingPackage(), getCallingFeatureId(), + enforceWritePermissionInner(rootUri, getCallingPackage(), getCallingAttributionTag(), null); final String rootId = DocumentsContract.getRootId(rootUri); @@ -1103,8 +1103,8 @@ public abstract class DocumentsProvider extends ContentProvider { enforceTree(documentUri); if (METHOD_IS_CHILD_DOCUMENT.equals(method)) { - enforceReadPermissionInner(documentUri, getCallingPackage(), getCallingFeatureId(), - null); + enforceReadPermissionInner(documentUri, getCallingPackage(), + getCallingAttributionTag(), null); final Uri childUri = extras.getParcelable(DocumentsContract.EXTRA_TARGET_URI); final String childAuthority = childUri.getAuthority(); @@ -1116,8 +1116,8 @@ public abstract class DocumentsProvider extends ContentProvider { && isChildDocument(documentId, childId)); } else if (METHOD_CREATE_DOCUMENT.equals(method)) { - enforceWritePermissionInner(documentUri, getCallingPackage(), getCallingFeatureId(), - null); + enforceWritePermissionInner(documentUri, getCallingPackage(), + getCallingAttributionTag(), null); final String mimeType = extras.getString(Document.COLUMN_MIME_TYPE); final String displayName = extras.getString(Document.COLUMN_DISPLAY_NAME); @@ -1131,8 +1131,8 @@ public abstract class DocumentsProvider extends ContentProvider { out.putParcelable(DocumentsContract.EXTRA_URI, newDocumentUri); } else if (METHOD_CREATE_WEB_LINK_INTENT.equals(method)) { - enforceWritePermissionInner(documentUri, getCallingPackage(), getCallingFeatureId(), - null); + enforceWritePermissionInner(documentUri, getCallingPackage(), + getCallingAttributionTag(), null); final Bundle options = extras.getBundle(DocumentsContract.EXTRA_OPTIONS); final IntentSender intentSender = createWebLinkIntent(documentId, options); @@ -1140,8 +1140,8 @@ public abstract class DocumentsProvider extends ContentProvider { out.putParcelable(DocumentsContract.EXTRA_RESULT, intentSender); } else if (METHOD_RENAME_DOCUMENT.equals(method)) { - enforceWritePermissionInner(documentUri, getCallingPackage(), getCallingFeatureId(), - null); + enforceWritePermissionInner(documentUri, getCallingPackage(), + getCallingAttributionTag(), null); final String displayName = extras.getString(Document.COLUMN_DISPLAY_NAME); final String newDocumentId = renameDocument(documentId, displayName); @@ -1165,8 +1165,8 @@ public abstract class DocumentsProvider extends ContentProvider { } } else if (METHOD_DELETE_DOCUMENT.equals(method)) { - enforceWritePermissionInner(documentUri, getCallingPackage(), getCallingFeatureId(), - null); + enforceWritePermissionInner(documentUri, getCallingPackage(), + getCallingAttributionTag(), null); deleteDocument(documentId); // Document no longer exists, clean up any grants. @@ -1176,9 +1176,9 @@ public abstract class DocumentsProvider extends ContentProvider { final Uri targetUri = extras.getParcelable(DocumentsContract.EXTRA_TARGET_URI); final String targetId = DocumentsContract.getDocumentId(targetUri); - enforceReadPermissionInner(documentUri, getCallingPackage(), getCallingFeatureId(), - null); - enforceWritePermissionInner(targetUri, getCallingPackage(), getCallingFeatureId(), + enforceReadPermissionInner(documentUri, getCallingPackage(), + getCallingAttributionTag(), null); + enforceWritePermissionInner(targetUri, getCallingPackage(), getCallingAttributionTag(), null); final String newDocumentId = copyDocument(documentId, targetId); @@ -1202,11 +1202,11 @@ public abstract class DocumentsProvider extends ContentProvider { final Uri targetUri = extras.getParcelable(DocumentsContract.EXTRA_TARGET_URI); final String targetId = DocumentsContract.getDocumentId(targetUri); - enforceWritePermissionInner(documentUri, getCallingPackage(), getCallingFeatureId(), - null); - enforceReadPermissionInner(parentSourceUri, getCallingPackage(), getCallingFeatureId(), - null); - enforceWritePermissionInner(targetUri, getCallingPackage(), getCallingFeatureId(), + enforceWritePermissionInner(documentUri, getCallingPackage(), + getCallingAttributionTag(), null); + enforceReadPermissionInner(parentSourceUri, getCallingPackage(), + getCallingAttributionTag(), null); + enforceWritePermissionInner(targetUri, getCallingPackage(), getCallingAttributionTag(), null); final String newDocumentId = moveDocument(documentId, parentSourceId, targetId); @@ -1228,10 +1228,10 @@ public abstract class DocumentsProvider extends ContentProvider { final Uri parentSourceUri = extras.getParcelable(DocumentsContract.EXTRA_PARENT_URI); final String parentSourceId = DocumentsContract.getDocumentId(parentSourceUri); - enforceReadPermissionInner(parentSourceUri, getCallingPackage(), getCallingFeatureId(), - null); - enforceWritePermissionInner(documentUri, getCallingPackage(), getCallingFeatureId(), - null); + enforceReadPermissionInner(parentSourceUri, getCallingPackage(), + getCallingAttributionTag(), null); + enforceWritePermissionInner(documentUri, getCallingPackage(), + getCallingAttributionTag(), null); removeDocument(documentId, parentSourceId); // It's responsibility of the provider to revoke any grants, as the document may be @@ -1240,8 +1240,8 @@ public abstract class DocumentsProvider extends ContentProvider { final boolean isTreeUri = isTreeUri(documentUri); if (isTreeUri) { - enforceReadPermissionInner(documentUri, getCallingPackage(), getCallingFeatureId(), - null); + enforceReadPermissionInner(documentUri, getCallingPackage(), + getCallingAttributionTag(), null); } else { getContext().enforceCallingPermission(Manifest.permission.MANAGE_DOCUMENTS, null); } diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 91b0f5bff83f..042d06201b15 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -2626,7 +2626,7 @@ public final class Settings { arg.putBoolean(CALL_METHOD_OVERRIDEABLE_BY_RESTORE_KEY, true); } IContentProvider cp = mProviderHolder.getProvider(cr); - cp.call(cr.getPackageName(), cr.getFeatureId(), + cp.call(cr.getPackageName(), cr.getAttributionTag(), mProviderHolder.mUri.getAuthority(), mCallSetCommand, name, arg); } catch (RemoteException e) { Log.w(TAG, "Can't set key " + name + " in " + mUri, e); @@ -2646,7 +2646,7 @@ public final class Settings { args.putString(CALL_METHOD_PREFIX_KEY, prefix); args.putSerializable(CALL_METHOD_FLAGS_KEY, keyValues); IContentProvider cp = mProviderHolder.getProvider(cr); - Bundle bundle = cp.call(cr.getPackageName(), cr.getFeatureId(), + Bundle bundle = cp.call(cr.getPackageName(), cr.getAttributionTag(), mProviderHolder.mUri.getAuthority(), mCallSetAllCommand, null, args); return bundle.getBoolean(KEY_CONFIG_SET_RETURN); @@ -2721,14 +2721,14 @@ public final class Settings { if (Settings.isInSystemServer() && Binder.getCallingUid() != Process.myUid()) { final long token = Binder.clearCallingIdentity(); try { - b = cp.call(cr.getPackageName(), cr.getFeatureId(), + b = cp.call(cr.getPackageName(), cr.getAttributionTag(), mProviderHolder.mUri.getAuthority(), mCallGetCommand, name, args); } finally { Binder.restoreCallingIdentity(token); } } else { - b = cp.call(cr.getPackageName(), cr.getFeatureId(), + b = cp.call(cr.getPackageName(), cr.getAttributionTag(), mProviderHolder.mUri.getAuthority(), mCallGetCommand, name, args); } if (b != null) { @@ -2798,13 +2798,13 @@ public final class Settings { if (Settings.isInSystemServer() && Binder.getCallingUid() != Process.myUid()) { final long token = Binder.clearCallingIdentity(); try { - c = cp.query(cr.getPackageName(), cr.getFeatureId(), mUri, + c = cp.query(cr.getPackageName(), cr.getAttributionTag(), mUri, SELECT_VALUE_PROJECTION, queryArgs, null); } finally { Binder.restoreCallingIdentity(token); } } else { - c = cp.query(cr.getPackageName(), cr.getFeatureId(), mUri, + c = cp.query(cr.getPackageName(), cr.getAttributionTag(), mUri, SELECT_VALUE_PROJECTION, queryArgs, null); } if (c == null) { @@ -2897,7 +2897,7 @@ public final class Settings { } // Fetch all flags for the namespace at once for caching purposes - Bundle b = cp.call(cr.getPackageName(), cr.getFeatureId(), + Bundle b = cp.call(cr.getPackageName(), cr.getAttributionTag(), mProviderHolder.mUri.getAuthority(), mCallListCommand, null, args); if (b == null) { // Invalid response, return an empty map @@ -5542,7 +5542,7 @@ public final class Settings { } arg.putInt(CALL_METHOD_RESET_MODE_KEY, mode); IContentProvider cp = sProviderHolder.getProvider(resolver); - cp.call(resolver.getPackageName(), resolver.getFeatureId(), + cp.call(resolver.getPackageName(), resolver.getAttributionTag(), sProviderHolder.mUri.getAuthority(), CALL_METHOD_RESET_SECURE, null, arg); } catch (RemoteException e) { Log.w(TAG, "Can't reset do defaults for " + CONTENT_URI, e); @@ -13383,7 +13383,7 @@ public final class Settings { } arg.putInt(CALL_METHOD_RESET_MODE_KEY, mode); IContentProvider cp = sProviderHolder.getProvider(resolver); - cp.call(resolver.getPackageName(), resolver.getFeatureId(), + cp.call(resolver.getPackageName(), resolver.getAttributionTag(), sProviderHolder.mUri.getAuthority(), CALL_METHOD_RESET_GLOBAL, null, arg); } catch (RemoteException e) { Log.w(TAG, "Can't reset do defaults for " + CONTENT_URI, e); @@ -14358,7 +14358,7 @@ public final class Settings { arg.putString(Settings.CALL_METHOD_PREFIX_KEY, createPrefix(namespace)); } IContentProvider cp = sProviderHolder.getProvider(resolver); - cp.call(resolver.getPackageName(), resolver.getFeatureId(), + cp.call(resolver.getPackageName(), resolver.getAttributionTag(), sProviderHolder.mUri.getAuthority(), CALL_METHOD_RESET_CONFIG, null, arg); } catch (RemoteException e) { Log.w(TAG, "Can't reset to defaults for " + DeviceConfig.CONTENT_URI, e); @@ -14387,7 +14387,7 @@ public final class Settings { arg.putInt(CALL_METHOD_USER_KEY, userHandle); arg.putParcelable(CALL_METHOD_MONITOR_CALLBACK_KEY, callback); IContentProvider cp = sProviderHolder.getProvider(resolver); - cp.call(resolver.getPackageName(), resolver.getFeatureId(), + cp.call(resolver.getPackageName(), resolver.getAttributionTag(), sProviderHolder.mUri.getAuthority(), CALL_METHOD_REGISTER_MONITOR_CALLBACK_CONFIG, null, arg); } catch (RemoteException e) { diff --git a/core/java/android/service/voice/VoiceInteractionSession.java b/core/java/android/service/voice/VoiceInteractionSession.java index 8e6f77b2fd0c..4a0dd870f797 100644 --- a/core/java/android/service/voice/VoiceInteractionSession.java +++ b/core/java/android/service/voice/VoiceInteractionSession.java @@ -1314,7 +1314,8 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall intent.migrateExtraStreamToClipData(); intent.prepareToLeaveProcess(mContext); int res = mSystemService.startVoiceActivity(mToken, intent, - intent.resolveType(mContext.getContentResolver()), mContext.getFeatureId()); + intent.resolveType(mContext.getContentResolver()), + mContext.getAttributionTag()); Instrumentation.checkStartActivityResult(res, intent); } catch (RemoteException e) { } @@ -1342,7 +1343,8 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall intent.migrateExtraStreamToClipData(); intent.prepareToLeaveProcess(mContext); int res = mSystemService.startAssistantActivity(mToken, intent, - intent.resolveType(mContext.getContentResolver()), mContext.getFeatureId()); + intent.resolveType(mContext.getContentResolver()), + mContext.getAttributionTag()); Instrumentation.checkStartActivityResult(res, intent); } catch (RemoteException e) { } diff --git a/core/java/android/speech/SpeechRecognizer.java b/core/java/android/speech/SpeechRecognizer.java index e93ba16fa594..92f3538a48de 100644 --- a/core/java/android/speech/SpeechRecognizer.java +++ b/core/java/android/speech/SpeechRecognizer.java @@ -342,7 +342,7 @@ public class SpeechRecognizer { } try { mService.startListening(recognizerIntent, mListener, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); if (DBG) Log.d(TAG, "service start listening command succeded"); } catch (final RemoteException e) { Log.e(TAG, "startListening() failed", e); @@ -357,7 +357,7 @@ public class SpeechRecognizer { } try { mService.stopListening(mListener, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); if (DBG) Log.d(TAG, "service stop listening command succeded"); } catch (final RemoteException e) { Log.e(TAG, "stopListening() failed", e); @@ -371,7 +371,7 @@ public class SpeechRecognizer { return; } try { - mService.cancel(mListener, mContext.getOpPackageName(), mContext.getFeatureId()); + mService.cancel(mListener, mContext.getOpPackageName(), mContext.getAttributionTag()); if (DBG) Log.d(TAG, "service cancel command succeded"); } catch (final RemoteException e) { Log.e(TAG, "cancel() failed", e); @@ -400,7 +400,8 @@ public class SpeechRecognizer { public void destroy() { if (mService != null) { try { - mService.cancel(mListener, mContext.getOpPackageName(), mContext.getFeatureId()); + mService.cancel(mListener, mContext.getOpPackageName(), + mContext.getAttributionTag()); } catch (final RemoteException e) { // Not important } diff --git a/core/java/android/telephony/TelephonyRegistryManager.java b/core/java/android/telephony/TelephonyRegistryManager.java index 7238b1244eb3..ab9df56560b3 100644 --- a/core/java/android/telephony/TelephonyRegistryManager.java +++ b/core/java/android/telephony/TelephonyRegistryManager.java @@ -116,7 +116,7 @@ public class TelephonyRegistryManager { mSubscriptionChangedListenerMap.put(listener, callback); try { sRegistry.addOnSubscriptionsChangedListener(mContext.getOpPackageName(), - mContext.getFeatureId(), callback); + mContext.getAttributionTag(), callback); } catch (RemoteException ex) { // system server crash } @@ -175,7 +175,7 @@ public class TelephonyRegistryManager { mOpportunisticSubscriptionChangedListenerMap.put(listener, callback); try { sRegistry.addOnOpportunisticSubscriptionsChangedListener(mContext.getOpPackageName(), - mContext.getFeatureId(), callback); + mContext.getAttributionTag(), callback); } catch (RemoteException ex) { // system server crash } diff --git a/core/java/com/android/internal/app/IAppOpsService.aidl b/core/java/com/android/internal/app/IAppOpsService.aidl index 907ea55d52a0..921882348328 100644 --- a/core/java/com/android/internal/app/IAppOpsService.aidl +++ b/core/java/com/android/internal/app/IAppOpsService.aidl @@ -34,14 +34,14 @@ interface IAppOpsService { // be kept in sync with frameworks/native/libs/binder/include/binder/IAppOpsService.h // and not be reordered int checkOperation(int code, int uid, String packageName); - int noteOperation(int code, int uid, String packageName, @nullable String featureId, + int noteOperation(int code, int uid, String packageName, @nullable String attributionTag, boolean shouldCollectAsyncNotedOp, String message); int startOperation(IBinder clientId, int code, int uid, String packageName, - @nullable String featureId, boolean startIfModeDefault, + @nullable String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message); @UnsupportedAppUsage void finishOperation(IBinder clientId, int code, int uid, String packageName, - @nullable String featureId); + @nullable String attributionTag); void startWatchingMode(int op, String packageName, IAppOpsCallback callback); void stopWatchingMode(IAppOpsCallback callback); int permissionToOpCode(String permission); @@ -52,8 +52,8 @@ interface IAppOpsService { // Any new method exposed to native must be added after the last one, do not reorder int noteProxyOperation(int code, int proxiedUid, String proxiedPackageName, - String proxiedFeatureId, int proxyUid, String proxyPackageName, - String proxyFeatureId, boolean shouldCollectAsyncNotedOp, String message); + String proxiedAttributionTag, int proxyUid, String proxyPackageName, + String proxyAttributionTag, boolean shouldCollectAsyncNotedOp, String message); // Remaining methods are only used in Java. int checkPackage(int uid, String packageName); @@ -64,10 +64,10 @@ interface IAppOpsService { List<AppOpsManager.PackageOps> getPackagesForOps(in int[] ops); @UnsupportedAppUsage List<AppOpsManager.PackageOps> getOpsForPackage(int uid, String packageName, in int[] ops); - void getHistoricalOps(int uid, String packageName, String featureId, in List<String> ops, + void getHistoricalOps(int uid, String packageName, String attributionTag, in List<String> ops, int filter, long beginTimeMillis, long endTimeMillis, int flags, in RemoteCallback callback); - void getHistoricalOpsFromDiskRaw(int uid, String packageName, String featureId, + void getHistoricalOpsFromDiskRaw(int uid, String packageName, String attributionTag, in List<String> ops, int filter, long beginTimeMillis, long endTimeMillis, int flags, in RemoteCallback callback); void offsetHistory(long duration); diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index b67753914248..a2957cf747e5 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -5003,16 +5003,17 @@ <permission android:name="android.permission.ACCESS_LOCUS_ID_USAGE_STATS" android:protectionLevel="signature|appPredictor" /> - <!-- Feature Id for Country Detector. --> - <feature android:featureId="CountryDetector" android:label="@string/country_detector"/> - <!-- Feature Id for Location service. --> - <feature android:featureId="LocationService" android:label="@string/location_service"/> - <!-- Feature Id for Gnss service. --> - <feature android:featureId="GnssService" android:label="@string/gnss_service"/> - <!-- Feature Id for Sensor Notification service. --> - <feature android:featureId="SensorNotificationService" android:label="@string/sensor_notification_service"/> - <!-- Feature Id for Twilight service. --> - <feature android:featureId="TwilightService" android:label="@string/twilight_service"/> + <!-- Attribution for Country Detector. --> + <attribution android:tag="CountryDetector" android:label="@string/country_detector"/> + <!-- Attribution for Location service. --> + <attribution android:tag="LocationService" android:label="@string/location_service"/> + <!-- Attribution for Gnss service. --> + <attribution android:tag="GnssService" android:label="@string/gnss_service"/> + <!-- Attribution for Sensor Notification service. --> + <attribution android:tag="SensorNotificationService" + android:label="@string/sensor_notification_service"/> + <!-- Attribution for Twilight service. --> + <attribution android:tag="TwilightService" android:label="@string/twilight_service"/> <application android:process="system" android:persistent="true" diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index b563cd301ed4..664f781a7d46 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -1574,7 +1574,7 @@ <code>com.google.app.<em>appname</em></code> <p>Inside of the manifest tag, may appear the following tags - in any order: {@link #AndroidManifestFeature feature}, + in any order: {@link #AndroidManifestAttribution attribution}, {@link #AndroidManifestPermission permission}, {@link #AndroidManifestPermissionGroup permission-group}, {@link #AndroidManifestPermissionTree permission-tree}, @@ -1833,29 +1833,33 @@ </declare-styleable> - <!-- The <code>feature</code> tag declares a feature. A feature is a logical part of an app. - E.g. photo sharing app might include a direct messaging component. To tag certain code as - belonging to a feature, use a context created via - {@link android.content.Context#createFeatureContext(String)} for any interaction with the + <!-- An attribution is a logical part of an app and is identified by a tag. + E.g. a photo sharing app might include a direct messaging component. To tag certain code as + belonging to an attribution, use a context created via + {@link android.content.Context#createAttributionContext(String)} for any interaction with the system. <p>This appears as a child tag of the root {@link #AndroidManifest manifest} tag. - <p>In case this feature inherits from another feature, this tag can contain one or multiple - {@link #AndroidManifestFeatureInheritFrom inherit-from} tags. --> - <declare-styleable name="AndroidManifestFeature" parent="AndroidManifest"> - <!-- Required identifier for a feature. Can be passed to - {@link android.content.Context#createFeatureContext} to create a context for this feature - --> + <p>In case this attribution inherits from another attribution, this tag can contain one or + multiple {@link #AndroidManifestAttributionInheritFrom inherit-from} tags. --> + <declare-styleable name="AndroidManifestAttribution" parent="AndroidManifest"> + <!-- TODO moltmann: Remove --> <attr name="featureId" format="string" /> - <!-- Required user visible label for a feature. --> + <!-- Required identifier for a attribution. Can be passed to + {@link android.content.Context#createAttributionContext} to create a context tagged with + this attribution + --> + <attr name="tag" format="string" /> + <!-- Required user visible label for a attribution. --> <attr name="label" format="string" /> </declare-styleable> <!-- Declares previously declared features this feature inherits from. --> - <declare-styleable name="AndroidManifestFeatureInheritFrom" parent="AndroidManifestFeature"> - <!-- Identifier of the feature this feature inherits from --> - <attr name="featureId" format="string" /> + <declare-styleable name="AndroidManifestAttributionInheritFrom" + parent="AndroidManifestAttribution"> + <!-- Identifier of the attribution this attribution inherits from --> + <attr name="tag" format="string" /> </declare-styleable> <!-- The <code>permission</code> tag declares a security permission that can be diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 2fdd98f10350..3e119b96a73c 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -3004,6 +3004,7 @@ <public name="animatedImageDrawable"/> <public name="htmlDescription"/> <public name="preferMinimalPostProcessing"/> + <!-- @removed --> <public name="featureId" /> <public name="supportsInlineSuggestions" /> <public name="crossProfile" /> diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index bd721d569c10..c8a6a1a8c865 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -606,7 +606,7 @@ public class LocationManager { public Location getLastLocation() { try { return mService.getLastLocation(null, mContext.getPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -639,7 +639,7 @@ public class LocationManager { try { return mService.getLastLocation(request, mContext.getPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -723,7 +723,7 @@ public class LocationManager { try { if (mService.getCurrentLocation(currentLocationRequest, remoteCancellationSignal, - listenerTransport, mContext.getPackageName(), mContext.getFeatureId())) { + listenerTransport, mContext.getPackageName(), mContext.getAttributionTag())) { listenerTransport.register(mContext.getSystemService(AlarmManager.class), remoteCancellationSignal); if (cancellationSignal != null) { @@ -1169,7 +1169,7 @@ public class LocationManager { boolean registered = false; try { mService.requestLocationUpdates(locationRequest, transport, null, - mContext.getPackageName(), mContext.getFeatureId()); + mContext.getPackageName(), mContext.getAttributionTag()); registered = true; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); @@ -1214,7 +1214,7 @@ public class LocationManager { try { mService.requestLocationUpdates(locationRequest, null, pendingIntent, - mContext.getPackageName(), mContext.getFeatureId()); + mContext.getPackageName(), mContext.getAttributionTag()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1714,7 +1714,7 @@ public class LocationManager { LocationRequest request = new LocationRequest().setExpireIn(expiration); try { mService.requestGeofence(request, fence, intent, mContext.getPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1801,7 +1801,7 @@ public class LocationManager { try { mService.requestGeofence(request, fence, intent, mContext.getPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -2883,7 +2883,7 @@ public class LocationManager { GnssStatusListener transport = new GnssStatusListener(); try { mService.registerGnssStatusCallback(transport, mContext.getPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); mListenerTransport = transport; return true; } catch (RemoteException e) { @@ -2961,7 +2961,7 @@ public class LocationManager { GnssMeasurementsListener transport = new GnssMeasurementsListener(); try { mService.addGnssMeasurementsListener(request, transport, mContext.getPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); mListenerTransport = transport; return true; } catch (RemoteException e) { @@ -3027,7 +3027,7 @@ public class LocationManager { GnssNavigationMessageListener transport = new GnssNavigationMessageListener(); try { mService.addGnssNavigationMessageListener(transport, mContext.getPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); mListenerTransport = transport; return true; } catch (RemoteException e) { @@ -3080,7 +3080,7 @@ public class LocationManager { GnssAntennaInfoListener transport = new GnssAntennaInfoListener(); try { mService.addGnssAntennaInfoListener(transport, mContext.getPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); mListenerTransport = transport; return true; } catch (RemoteException e) { @@ -3129,7 +3129,7 @@ public class LocationManager { BatchedLocationCallback transport = new BatchedLocationCallback(); try { mService.addGnssBatchingCallback(transport, mContext.getPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); mListenerTransport = transport; return true; } catch (RemoteException e) { diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java index 6354ccd7b3b0..ebd7658381ee 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTest.java @@ -284,12 +284,12 @@ public class CameraBinderTest extends AndroidTestCase { ICameraDeviceCallbacks dummyCallbacks = new DummyCameraDeviceCallbacks(); String clientPackageName = getContext().getPackageName(); - String clientFeatureId = getContext().getFeatureId(); + String clientAttributionTag = getContext().getAttributionTag(); ICameraDeviceUser cameraUser = mUtils.getCameraService().connectDevice( dummyCallbacks, String.valueOf(cameraId), - clientPackageName, clientFeatureId, + clientPackageName, clientAttributionTag, ICameraService.USE_CALLING_UID); assertNotNull(String.format("Camera %s was null", cameraId), cameraUser); diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraDeviceBinderTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraDeviceBinderTest.java index 466c5f4ba980..bf3e74602dbe 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraDeviceBinderTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraDeviceBinderTest.java @@ -238,12 +238,12 @@ public class CameraDeviceBinderTest extends AndroidTestCase { ICameraDeviceCallbacks.Stub dummyCallbacks = new DummyCameraDeviceCallbacks(); String clientPackageName = getContext().getPackageName(); - String clientFeatureId = getContext().getFeatureId(); + String clientAttributionTag = getContext().getAttributionTag(); mMockCb = spy(dummyCallbacks); mCameraUser = mUtils.getCameraService().connectDevice(mMockCb, mCameraId, - clientPackageName, clientFeatureId, ICameraService.USE_CALLING_UID); + clientPackageName, clientAttributionTag, ICameraService.USE_CALLING_UID); assertNotNull(String.format("Camera %s was null", mCameraId), mCameraUser); mHandlerThread = new HandlerThread(TAG); mHandlerThread.start(); diff --git a/packages/SettingsLib/Tile/src/com/android/settingslib/drawer/TileUtils.java b/packages/SettingsLib/Tile/src/com/android/settingslib/drawer/TileUtils.java index f93faeb0c7ae..ace50f30663d 100644 --- a/packages/SettingsLib/Tile/src/com/android/settingslib/drawer/TileUtils.java +++ b/packages/SettingsLib/Tile/src/com/android/settingslib/drawer/TileUtils.java @@ -545,7 +545,7 @@ public class TileUtils { bundle.putString(META_DATA_PREFERENCE_KEYHINT, key); } try { - return provider.call(context.getPackageName(), context.getFeatureId(), + return provider.call(context.getPackageName(), context.getAttributionTag(), uri.getAuthority(), method, uri.toString(), bundle); } catch (RemoteException e) { return null; diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAccessesTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAccessesTest.java index 68a3729432d8..245b7843110b 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAccessesTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAccessesTest.java @@ -8,7 +8,6 @@ import static org.mockito.Mockito.when; import android.app.AppOpsManager; import android.app.AppOpsManager.OpEntry; -import android.app.AppOpsManager.OpFeatureEntry; import android.app.AppOpsManager.PackageOps; import android.content.Context; import android.content.pm.ApplicationInfo; @@ -163,6 +162,6 @@ public class RecentLocationAccessesTest { AppOpsManager.OP_FLAG_SELF), new AppOpsManager.NoteOpEvent(time, -1, null)); return new OpEntry(op, AppOpsManager.MODE_ALLOWED, Collections.singletonMap(null, - new OpFeatureEntry(op, false, accessEvents, null))); + new AppOpsManager.AttributedOpEntry(op, false, accessEvents, null))); } } diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAppsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAppsTest.java index 3f8d758ae64f..cc9b93141d45 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAppsTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/location/RecentLocationAppsTest.java @@ -7,7 +7,7 @@ import static org.mockito.Mockito.when; import android.app.AppOpsManager; import android.app.AppOpsManager.OpEntry; -import android.app.AppOpsManager.OpFeatureEntry; +import android.app.AppOpsManager.AttributedOpEntry; import android.app.AppOpsManager.PackageOps; import android.content.Context; import android.content.pm.ApplicationInfo; @@ -18,8 +18,6 @@ import android.os.Process; import android.os.UserHandle; import android.os.UserManager; import android.util.LongSparseArray; -import android.util.LongSparseLongArray; -import android.util.Pair; import org.junit.Before; import org.junit.Test; @@ -164,6 +162,6 @@ public class RecentLocationAppsTest { AppOpsManager.OP_FLAG_SELF), new AppOpsManager.NoteOpEvent(time, duration, null)); return new OpEntry(op, AppOpsManager.MODE_ALLOWED, Collections.singletonMap(null, - new OpFeatureEntry(op, false, accessEvents, null))); + new AttributedOpEntry(op, false, accessEvents, null))); } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java b/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java index ae380b72f5e0..c281ece59c5a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java @@ -93,7 +93,7 @@ public class WorkLockActivityController { return mIatm.startActivityAsUser( mContext.getIApplicationThread() /*caller*/, mContext.getBasePackageName() /*callingPackage*/, - mContext.getFeatureId() /*callingFeatureId*/, + mContext.getAttributionTag() /*callingAttributionTag*/, intent /*intent*/, intent.resolveTypeIfNeeded(mContext.getContentResolver()) /*resolvedType*/, null /*resultTo*/, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index ee313001bfc4..90bc075b399d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -492,7 +492,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL try { result = ActivityTaskManager.getService().startActivityAsUser( null, getContext().getBasePackageName(), - getContext().getFeatureId(), intent, + getContext().getAttributionTag(), intent, intent.resolveTypeIfNeeded(getContext().getContentResolver()), null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, o.toBundle(), UserHandle.CURRENT.getIdentifier()); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index b3a62d8a4753..e30144f78844 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -2599,7 +2599,7 @@ public class StatusBar extends SystemUI implements DemoMode, } try { result = ActivityTaskManager.getService().startActivityAsUser( - null, mContext.getBasePackageName(), mContext.getFeatureId(), + null, mContext.getBasePackageName(), mContext.getAttributionTag(), intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, diff --git a/services/core/java/com/android/server/SensorNotificationService.java b/services/core/java/com/android/server/SensorNotificationService.java index 9082dca1022c..db3db0c80e3c 100644 --- a/services/core/java/com/android/server/SensorNotificationService.java +++ b/services/core/java/com/android/server/SensorNotificationService.java @@ -48,7 +48,7 @@ public class SensorNotificationService extends SystemService private static final long MILLIS_2010_1_1 = 1262358000000l; - private static final String FEATURE_ID = "SensorNotificationService"; + private static final String ATTRIBUTION_TAG = "SensorNotificationService"; private Context mContext; private SensorManager mSensorManager; @@ -59,7 +59,7 @@ public class SensorNotificationService extends SystemService private long mLocalGeomagneticFieldUpdateTime = -LOCATION_MIN_TIME; public SensorNotificationService(Context context) { - super(context.createFeatureContext(FEATURE_ID)); + super(context.createAttributionContext(ATTRIBUTION_TAG)); mContext = getContext(); } diff --git a/services/core/java/com/android/server/UiModeManagerService.java b/services/core/java/com/android/server/UiModeManagerService.java index 7c833faee1bd..36cc770115b4 100644 --- a/services/core/java/com/android/server/UiModeManagerService.java +++ b/services/core/java/com/android/server/UiModeManagerService.java @@ -1297,9 +1297,9 @@ final class UiModeManagerService extends SystemService { if (Sandman.shouldStartDockApp(getContext(), homeIntent)) { try { int result = ActivityTaskManager.getService().startActivityWithConfig( - null, getContext().getBasePackageName(), getContext().getFeatureId(), - homeIntent, null, null, null, 0, 0, mConfiguration, null, - UserHandle.USER_CURRENT); + null, getContext().getBasePackageName(), + getContext().getAttributionTag(), homeIntent, null, null, null, 0, 0, + mConfiguration, null, UserHandle.USER_CURRENT); if (ActivityManager.isStartResultSuccessful(result)) { dockAppStarted = true; } else if (result != ActivityManager.START_INTENT_NOT_RESOLVED) { diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java index 471c97b0e7c6..08f916f77988 100644 --- a/services/core/java/com/android/server/appop/AppOpsService.java +++ b/services/core/java/com/android/server/appop/AppOpsService.java @@ -20,7 +20,7 @@ import static android.app.ActivityManager.PROCESS_CAPABILITY_FOREGROUND_CAMERA; import static android.app.ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION; import static android.app.ActivityManager.PROCESS_CAPABILITY_FOREGROUND_MICROPHONE; import static android.app.AppOpsManager.CALL_BACK_ON_CHANGED_LISTENER_WITH_SWITCHED_OP_CHANGE; -import static android.app.AppOpsManager.FILTER_BY_FEATURE_ID; +import static android.app.AppOpsManager.FILTER_BY_ATTRIBUTION_TAG; import static android.app.AppOpsManager.FILTER_BY_OP_NAMES; import static android.app.AppOpsManager.FILTER_BY_PACKAGE_NAME; import static android.app.AppOpsManager.FILTER_BY_UID; @@ -80,7 +80,7 @@ import android.app.AppOpsManager; import android.app.AppOpsManager.HistoricalOps; import android.app.AppOpsManager.Mode; import android.app.AppOpsManager.OpEntry; -import android.app.AppOpsManager.OpFeatureEntry; +import android.app.AppOpsManager.AttributedOpEntry; import android.app.AppOpsManager.OpFlags; import android.app.AppOpsManagerInternal; import android.app.AppOpsManagerInternal.CheckOpsDelegate; @@ -98,7 +98,7 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; import android.content.pm.PermissionInfo; import android.content.pm.UserInfo; -import android.content.pm.parsing.component.ParsedFeature; +import android.content.pm.parsing.component.ParsedAttribution; import android.database.ContentObserver; import android.hardware.camera2.CameraDevice.CAMERA_AUDIO_RESTRICTION; import android.net.Uri; @@ -372,14 +372,14 @@ public class AppOpsService extends IAppOpsService.Stub { } OpEventProxyInfo acquire(@IntRange(from = 0) int uid, @Nullable String packageName, - @Nullable String featureId) { + @Nullable String attributionTag) { OpEventProxyInfo recycled = acquire(); if (recycled != null) { - recycled.reinit(uid, packageName, featureId); + recycled.reinit(uid, packageName, attributionTag); return recycled; } - return new OpEventProxyInfo(uid, packageName, featureId); + return new OpEventProxyInfo(uid, packageName, attributionTag); } } @@ -672,8 +672,8 @@ public class AppOpsService extends IAppOpsService.Stub { */ @Nullable RestrictionBypass bypass; - /** Lazily populated cache of featureIds of this package */ - final @NonNull ArraySet<String> knownFeatureIds = new ArraySet<>(); + /** Lazily populated cache of attributionTags of this package */ + final @NonNull ArraySet<String> knownAttributionTags = new ArraySet<>(); Ops(String _packageName, UidState _uidState) { packageName = _packageName; @@ -777,8 +777,8 @@ public class AppOpsService extends IAppOpsService.Stub { } } - private final class FeatureOp { - public final @Nullable String featureId; + private final class AttributedOp { + public final @Nullable String tag; public final @NonNull Op parent; /** @@ -805,8 +805,8 @@ public class AppOpsService extends IAppOpsService.Stub { @GuardedBy("AppOpsService.this") private @Nullable ArrayMap<IBinder, InProgressStartOpEvent> mInProgressEvents; - FeatureOp(@Nullable String featureId, @NonNull Op parent) { - this.featureId = featureId; + AttributedOp(@Nullable String tag, @NonNull Op parent) { + this.tag = tag; this.parent = parent; } @@ -815,18 +815,18 @@ public class AppOpsService extends IAppOpsService.Stub { * * @param proxyUid The uid of the proxy * @param proxyPackageName The package name of the proxy - * @param proxyFeatureId the featureId in the proxies package + * @param proxyAttributionTag the attributionTag in the proxies package * @param uidState UID state of the app noteOp/startOp was called for * @param flags OpFlags of the call */ public void accessed(int proxyUid, @Nullable String proxyPackageName, - @Nullable String proxyFeatureId, @AppOpsManager.UidState int uidState, + @Nullable String proxyAttributionTag, @AppOpsManager.UidState int uidState, @OpFlags int flags) { accessed(System.currentTimeMillis(), -1, proxyUid, proxyPackageName, - proxyFeatureId, uidState, flags); + proxyAttributionTag, uidState, flags); mHistoricalRegistry.incrementOpAccessedCount(parent.op, parent.uid, parent.packageName, - featureId, uidState, flags); + tag, uidState, flags); } /** @@ -836,12 +836,12 @@ public class AppOpsService extends IAppOpsService.Stub { * @param duration The duration of the event * @param proxyUid The uid of the proxy * @param proxyPackageName The package name of the proxy - * @param proxyFeatureId the featureId in the proxies package + * @param proxyAttributionTag the attributionTag in the proxies package * @param uidState UID state of the app noteOp/startOp was called for * @param flags OpFlags of the call */ public void accessed(long noteTime, long duration, int proxyUid, - @Nullable String proxyPackageName, @Nullable String proxyFeatureId, + @Nullable String proxyPackageName, @Nullable String proxyAttributionTag, @AppOpsManager.UidState int uidState, @OpFlags int flags) { long key = makeKey(uidState, flags); @@ -852,7 +852,7 @@ public class AppOpsService extends IAppOpsService.Stub { OpEventProxyInfo proxyInfo = null; if (proxyUid != Process.INVALID_UID) { proxyInfo = mOpEventProxyInfoPool.acquire(proxyUid, proxyPackageName, - proxyFeatureId); + proxyAttributionTag); } NoteOpEvent existingEvent = mAccessEvents.get(key); @@ -873,7 +873,7 @@ public class AppOpsService extends IAppOpsService.Stub { rejected(System.currentTimeMillis(), uidState, flags); mHistoricalRegistry.incrementOpRejected(parent.op, parent.uid, parent.packageName, - featureId, uidState, flags); + tag, uidState, flags); } /** @@ -939,7 +939,7 @@ public class AppOpsService extends IAppOpsService.Stub { // startOp events don't support proxy, hence use flags==SELF mHistoricalRegistry.incrementOpAccessedCount(parent.op, parent.uid, parent.packageName, - featureId, uidState, OP_FLAG_SELF); + tag, uidState, OP_FLAG_SELF); } /** @@ -979,7 +979,7 @@ public class AppOpsService extends IAppOpsService.Stub { mAccessEvents.put(makeKey(event.getUidState(), OP_FLAG_SELF), finishedEvent); mHistoricalRegistry.increaseOpAccessDuration(parent.op, parent.uid, - parent.packageName, featureId, event.getUidState(), + parent.packageName, tag, event.getUidState(), AppOpsManager.OP_FLAG_SELF, finishedEvent.getDuration()); mInProgressStartOpEventPool.release(event); @@ -987,7 +987,7 @@ public class AppOpsService extends IAppOpsService.Stub { if (mInProgressEvents.isEmpty()) { mInProgressEvents = null; - // TODO moltmann: Also callback for single feature activity changes + // TODO moltmann: Also callback for single attribution tag activity changes if (triggerCallbackIfNeeded && !parent.isRunning()) { scheduleOpActiveChangedIfNeededLocked(parent.op, parent.uid, parent.packageName, false); @@ -1078,14 +1078,14 @@ public class AppOpsService extends IAppOpsService.Stub { } /** - * Add all data from the {@code featureToAdd} to this op. + * Add all data from the {@code opToAdd} to this op. * * <p>If there is an event for the same key in both the later event is retained. * <p>{@code opToAdd} should not be used after this method is called. * * @param opToAdd The op to add */ - public void add(@NonNull FeatureOp opToAdd) { + public void add(@NonNull AttributedOp opToAdd) { if (opToAdd.mInProgressEvents != null) { Slog.w(TAG, "Ignoring " + opToAdd.mInProgressEvents.size() + " running app-ops"); @@ -1129,7 +1129,7 @@ public class AppOpsService extends IAppOpsService.Stub { return clone; } - @NonNull OpFeatureEntry createFeatureEntryLocked() { + @NonNull AttributedOpEntry createAttributedOpEntryLocked() { LongSparseArray<NoteOpEvent> accessEvents = deepClone(mAccessEvents); // Add in progress events as access events @@ -1153,7 +1153,7 @@ public class AppOpsService extends IAppOpsService.Stub { LongSparseArray<NoteOpEvent> rejectEvents = deepClone(mRejectEvents); - return new OpFeatureEntry(parent.op, isRunning(), accessEvents, rejectEvents); + return new AttributedOpEntry(parent.op, isRunning(), accessEvents, rejectEvents); } } @@ -1165,8 +1165,8 @@ public class AppOpsService extends IAppOpsService.Stub { private @Mode int mode; - /** featureId -> FeatureOp */ - final ArrayMap<String, FeatureOp> mFeatures = new ArrayMap<>(1); + /** attributionTag -> AttributedOp */ + final ArrayMap<String, AttributedOp> mAttributions = new ArrayMap<>(1); Op(UidState uidState, String packageName, int op, int uid) { this.op = op; @@ -1184,58 +1184,59 @@ public class AppOpsService extends IAppOpsService.Stub { return uidState.evalMode(op, mode); } - void removeFeaturesWithNoTime() { - for (int i = mFeatures.size() - 1; i >= 0; i--) { - if (!mFeatures.valueAt(i).hasAnyTime()) { - mFeatures.removeAt(i); + void removeAttributionsWithNoTime() { + for (int i = mAttributions.size() - 1; i >= 0; i--) { + if (!mAttributions.valueAt(i).hasAnyTime()) { + mAttributions.removeAt(i); } } } - private @NonNull FeatureOp getOrCreateFeature(@NonNull Op parent, - @Nullable String featureId) { - FeatureOp featureOp; + private @NonNull AttributedOp getOrCreateAttribution(@NonNull Op parent, + @Nullable String attributionTag) { + AttributedOp attributedOp; - featureOp = mFeatures.get(featureId); - if (featureOp == null) { - featureOp = new FeatureOp(featureId, parent); - mFeatures.put(featureId, featureOp); + attributedOp = mAttributions.get(attributionTag); + if (attributedOp == null) { + attributedOp = new AttributedOp(attributionTag, parent); + mAttributions.put(attributionTag, attributedOp); } - return featureOp; + return attributedOp; } @NonNull OpEntry createEntryLocked() { - final int numFeatures = mFeatures.size(); + final int numAttributions = mAttributions.size(); - final ArrayMap<String, OpFeatureEntry> featureEntries = new ArrayMap<>(numFeatures); - for (int i = 0; i < numFeatures; i++) { - featureEntries.put(mFeatures.keyAt(i), - mFeatures.valueAt(i).createFeatureEntryLocked()); + final ArrayMap<String, AppOpsManager.AttributedOpEntry> attributionEntries = + new ArrayMap<>(numAttributions); + for (int i = 0; i < numAttributions; i++) { + attributionEntries.put(mAttributions.keyAt(i), + mAttributions.valueAt(i).createAttributedOpEntryLocked()); } - return new OpEntry(op, mode, featureEntries); + return new OpEntry(op, mode, attributionEntries); } - @NonNull OpEntry createSingleFeatureEntryLocked(@Nullable String featureId) { - final int numFeatures = mFeatures.size(); + @NonNull OpEntry createSingleAttributionEntryLocked(@Nullable String attributionTag) { + final int numAttributions = mAttributions.size(); - final ArrayMap<String, OpFeatureEntry> featureEntries = new ArrayMap<>(1); - for (int i = 0; i < numFeatures; i++) { - if (Objects.equals(mFeatures.keyAt(i), featureId)) { - featureEntries.put(mFeatures.keyAt(i), - mFeatures.valueAt(i).createFeatureEntryLocked()); + final ArrayMap<String, AttributedOpEntry> attributionEntries = new ArrayMap<>(1); + for (int i = 0; i < numAttributions; i++) { + if (Objects.equals(mAttributions.keyAt(i), attributionTag)) { + attributionEntries.put(mAttributions.keyAt(i), + mAttributions.valueAt(i).createAttributedOpEntryLocked()); break; } } - return new OpEntry(op, mode, featureEntries); + return new OpEntry(op, mode, attributionEntries); } boolean isRunning() { - final int numFeatures = mFeatures.size(); - for (int i = 0; i < numFeatures; i++) { - if (mFeatures.valueAt(i).isRunning()) { + final int numAttributions = mAttributions.size(); + for (int i = 0; i < numAttributions; i++) { + if (mAttributions.valueAt(i).isRunning()) { return true; } } @@ -1408,10 +1409,11 @@ public class AppOpsService extends IAppOpsService.Stub { } /** - * Call {@link FeatureOp#onClientDeath featureOp.onClientDeath(clientId)}. + * Call {@link AttributedOp#onClientDeath attributedOp.onClientDeath(clientId)}. */ - private static void onClientDeath(@NonNull FeatureOp featureOp, @NonNull IBinder clientId) { - featureOp.onClientDeath(clientId); + private static void onClientDeath(@NonNull AttributedOp attributedOp, + @NonNull IBinder clientId) { + attributedOp.onClientDeath(clientId); } @@ -1493,20 +1495,21 @@ public class AppOpsService extends IAppOpsService.Stub { return; } - ArrayMap<String, String> dstFeatureIds = new ArrayMap<>(); - ArraySet<String> featureIds = new ArraySet<>(); - featureIds.add(null); - if (pkg.getFeatures() != null) { - int numFeatures = pkg.getFeatures().size(); - for (int featureNum = 0; featureNum < numFeatures; featureNum++) { - ParsedFeature feature = pkg.getFeatures().get(featureNum); - featureIds.add(feature.id); + ArrayMap<String, String> dstAttributionTags = new ArrayMap<>(); + ArraySet<String> attributionTags = new ArraySet<>(); + attributionTags.add(null); + if (pkg.getAttributions() != null) { + int numAttributions = pkg.getAttributions().size(); + for (int attributionNum = 0; attributionNum < numAttributions; + attributionNum++) { + ParsedAttribution attribution = pkg.getAttributions().get(attributionNum); + attributionTags.add(attribution.tag); - int numInheritFrom = feature.inheritFrom.size(); + int numInheritFrom = attribution.inheritFrom.size(); for (int inheritFromNum = 0; inheritFromNum < numInheritFrom; inheritFromNum++) { - dstFeatureIds.put(feature.inheritFrom.get(inheritFromNum), - feature.id); + dstAttributionTags.put(attribution.inheritFrom.get(inheritFromNum), + attribution.tag); } } } @@ -1524,27 +1527,30 @@ public class AppOpsService extends IAppOpsService.Stub { // Reset cached package properties to re-initialize when needed ops.bypass = null; - ops.knownFeatureIds.clear(); + ops.knownAttributionTags.clear(); - // Merge data collected for removed features into their successor features + // Merge data collected for removed attributions into their successor + // attributions int numOps = ops.size(); for (int opNum = 0; opNum < numOps; opNum++) { Op op = ops.valueAt(opNum); - int numFeatures = op.mFeatures.size(); - for (int featureNum = numFeatures - 1; featureNum >= 0; featureNum--) { - String featureId = op.mFeatures.keyAt(featureNum); + int numAttributions = op.mAttributions.size(); + for (int attributionNum = numAttributions - 1; attributionNum >= 0; + attributionNum--) { + String attributionTag = op.mAttributions.keyAt(attributionNum); - if (featureIds.contains(featureId)) { - // feature still exist after upgrade + if (attributionTags.contains(attributionTag)) { + // attribution still exist after upgrade continue; } - String newFeatureId = dstFeatureIds.get(featureId); + String newAttributionTag = dstAttributionTags.get(attributionTag); - FeatureOp newFeatureOp = op.getOrCreateFeature(op, newFeatureId); - newFeatureOp.add(op.mFeatures.valueAt(featureNum)); - op.mFeatures.removeAt(featureNum); + AttributedOp newAttributedOp = op.getOrCreateAttribution(op, + newAttributionTag); + newAttributedOp.add(op.mAttributions.valueAt(attributionNum)); + op.mAttributions.removeAt(attributionNum); scheduleFastWriteLocked(); } @@ -1744,12 +1750,13 @@ public class AppOpsService extends IAppOpsService.Stub { for (int opNum = 0; opNum < numOps; opNum++) { final Op op = ops.valueAt(opNum); - final int numFeatures = op.mFeatures.size(); - for (int featureNum = 0; featureNum < numFeatures; featureNum++) { - FeatureOp featureOp = op.mFeatures.valueAt(featureNum); + final int numAttributions = op.mAttributions.size(); + for (int attributionNum = 0; attributionNum < numAttributions; + attributionNum++) { + AttributedOp attributedOp = op.mAttributions.valueAt(attributionNum); - while (featureOp.mInProgressEvents != null) { - featureOp.finished(featureOp.mInProgressEvents.keyAt(0)); + while (attributedOp.mInProgressEvents != null) { + attributedOp.finished(attributedOp.mInProgressEvents.keyAt(0)); } } } @@ -1829,11 +1836,13 @@ public class AppOpsService extends IAppOpsService.Stub { for (int opNum = 0; opNum < numOps; opNum++) { Op op = ops.valueAt(opNum); - int numFeatures = op.mFeatures.size(); - for (int featureNum = 0; featureNum < numFeatures; featureNum++) { - FeatureOp featureOp = op.mFeatures.valueAt(featureNum); + int numAttributions = op.mAttributions.size(); + for (int attributionNum = 0; attributionNum < numAttributions; + attributionNum++) { + AttributedOp attributedOp = op.mAttributions.valueAt( + attributionNum); - featureOp.onUidStateChanged(newState); + attributedOp.onUidStateChanged(newState); } } } @@ -1979,9 +1988,9 @@ public class AppOpsService extends IAppOpsService.Stub { /** * Verify that historical appop request arguments are valid. */ - private void ensureHistoricalOpRequestIsValid(int uid, String packageName, String featureId, - List<String> opNames, int filter, long beginTimeMillis, long endTimeMillis, - int flags) { + private void ensureHistoricalOpRequestIsValid(int uid, String packageName, + String attributionTag, List<String> opNames, int filter, long beginTimeMillis, + long endTimeMillis, int flags) { if ((filter & FILTER_BY_UID) != 0) { Preconditions.checkArgument(uid != Process.INVALID_UID); } else { @@ -1994,8 +2003,8 @@ public class AppOpsService extends IAppOpsService.Stub { Preconditions.checkArgument(packageName == null); } - if ((filter & FILTER_BY_FEATURE_ID) == 0) { - Preconditions.checkArgument(featureId == null); + if ((filter & FILTER_BY_ATTRIBUTION_TAG) == 0) { + Preconditions.checkArgument(attributionTag == null); } if ((filter & FILTER_BY_OP_NAMES) != 0) { @@ -2005,17 +2014,18 @@ public class AppOpsService extends IAppOpsService.Stub { } Preconditions.checkFlagsArgument(filter, - FILTER_BY_UID | FILTER_BY_PACKAGE_NAME | FILTER_BY_FEATURE_ID | FILTER_BY_OP_NAMES); + FILTER_BY_UID | FILTER_BY_PACKAGE_NAME | FILTER_BY_ATTRIBUTION_TAG + | FILTER_BY_OP_NAMES); Preconditions.checkArgumentNonnegative(beginTimeMillis); Preconditions.checkArgument(endTimeMillis > beginTimeMillis); Preconditions.checkFlagsArgument(flags, OP_FLAGS_ALL); } @Override - public void getHistoricalOps(int uid, String packageName, String featureId, + public void getHistoricalOps(int uid, String packageName, String attributionTag, List<String> opNames, int filter, long beginTimeMillis, long endTimeMillis, int flags, RemoteCallback callback) { - ensureHistoricalOpRequestIsValid(uid, packageName, featureId, opNames, filter, + ensureHistoricalOpRequestIsValid(uid, packageName, attributionTag, opNames, filter, beginTimeMillis, endTimeMillis, flags); Objects.requireNonNull(callback, "callback cannot be null"); @@ -2036,15 +2046,15 @@ public class AppOpsService extends IAppOpsService.Stub { // Must not hold the appops lock mHandler.post(PooledLambda.obtainRunnable(HistoricalRegistry::getHistoricalOps, - mHistoricalRegistry, uid, packageName, featureId, opNamesArray, filter, + mHistoricalRegistry, uid, packageName, attributionTag, opNamesArray, filter, beginTimeMillis, endTimeMillis, flags, callback).recycleOnUse()); } @Override - public void getHistoricalOpsFromDiskRaw(int uid, String packageName, String featureId, + public void getHistoricalOpsFromDiskRaw(int uid, String packageName, String attributionTag, List<String> opNames, int filter, long beginTimeMillis, long endTimeMillis, int flags, RemoteCallback callback) { - ensureHistoricalOpRequestIsValid(uid, packageName, featureId, opNames, filter, + ensureHistoricalOpRequestIsValid(uid, packageName, attributionTag, opNames, filter, beginTimeMillis, endTimeMillis, flags); Objects.requireNonNull(callback, "callback cannot be null"); @@ -2056,7 +2066,7 @@ public class AppOpsService extends IAppOpsService.Stub { // Must not hold the appops lock mHandler.post(PooledLambda.obtainRunnable(HistoricalRegistry::getHistoricalOpsFromDiskRaw, - mHistoricalRegistry, uid, packageName, featureId, opNamesArray, + mHistoricalRegistry, uid, packageName, attributionTag, opNamesArray, filter, beginTimeMillis, endTimeMillis, flags, callback).recycleOnUse()); } @@ -2090,9 +2100,9 @@ public class AppOpsService extends IAppOpsService.Stub { } private void pruneOpLocked(Op op, int uid, String packageName) { - op.removeFeaturesWithNoTime(); + op.removeAttributionsWithNoTime(); - if (op.mFeatures.size() == 0) { + if (op.mAttributions.isEmpty()) { Ops ops = getOpsLocked(uid, packageName, null, null, false /* edit */); if (ops != null) { ops.remove(op.op); @@ -2611,8 +2621,8 @@ public class AppOpsService extends IAppOpsService.Stub { callbacks = addCallbacks(callbacks, curOp.op, uid, packageName, mPackageModeWatchers.get(packageName)); - curOp.removeFeaturesWithNoTime(); - if (curOp.mFeatures.size() == 0) { + curOp.removeAttributionsWithNoTime(); + if (curOp.mAttributions.isEmpty()) { pkgOps.removeAt(j); } } @@ -2898,8 +2908,8 @@ public class AppOpsService extends IAppOpsService.Stub { @Override public int noteProxyOperation(int code, int proxiedUid, String proxiedPackageName, - String proxiedFeatureId, int proxyUid, String proxyPackageName, - String proxyFeatureId, boolean shouldCollectAsyncNotedOp, String message) { + String proxiedAttributionTag, int proxyUid, String proxyPackageName, + String proxyAttributionTag, boolean shouldCollectAsyncNotedOp, String message) { verifyIncomingUid(proxyUid); verifyIncomingOp(code); @@ -2915,7 +2925,7 @@ public class AppOpsService extends IAppOpsService.Stub { final int proxyFlags = isProxyTrusted ? AppOpsManager.OP_FLAG_TRUSTED_PROXY : AppOpsManager.OP_FLAG_UNTRUSTED_PROXY; final int proxyMode = noteOperationUnchecked(code, proxyUid, resolveProxyPackageName, - proxyFeatureId, Process.INVALID_UID, null, null, proxyFlags, + proxyAttributionTag, Process.INVALID_UID, null, null, proxyFlags, !isProxyTrusted, "proxy " + message); if (proxyMode != AppOpsManager.MODE_ALLOWED || Binder.getCallingUid() == proxiedUid) { return proxyMode; @@ -2928,27 +2938,27 @@ public class AppOpsService extends IAppOpsService.Stub { final int proxiedFlags = isProxyTrusted ? AppOpsManager.OP_FLAG_TRUSTED_PROXIED : AppOpsManager.OP_FLAG_UNTRUSTED_PROXIED; return noteOperationUnchecked(code, proxiedUid, resolveProxiedPackageName, - proxiedFeatureId, proxyUid, resolveProxyPackageName, proxyFeatureId, + proxiedAttributionTag, proxyUid, resolveProxyPackageName, proxyAttributionTag, proxiedFlags, shouldCollectAsyncNotedOp, message); } @Override - public int noteOperation(int code, int uid, String packageName, String featureId, + public int noteOperation(int code, int uid, String packageName, String attributionTag, boolean shouldCollectAsyncNotedOp, String message) { final CheckOpsDelegate delegate; synchronized (this) { delegate = mCheckOpsDelegate; } if (delegate == null) { - return noteOperationImpl(code, uid, packageName, featureId, shouldCollectAsyncNotedOp, - message); + return noteOperationImpl(code, uid, packageName, attributionTag, + shouldCollectAsyncNotedOp, message); } - return delegate.noteOperation(code, uid, packageName, featureId, shouldCollectAsyncNotedOp, - message, AppOpsService.this::noteOperationImpl); + return delegate.noteOperation(code, uid, packageName, attributionTag, + shouldCollectAsyncNotedOp, message, AppOpsService.this::noteOperationImpl); } private int noteOperationImpl(int code, int uid, @Nullable String packageName, - @Nullable String featureId, boolean shouldCollectAsyncNotedOp, + @Nullable String attributionTag, boolean shouldCollectAsyncNotedOp, @Nullable String message) { verifyIncomingUid(uid); verifyIncomingOp(code); @@ -2956,25 +2966,26 @@ public class AppOpsService extends IAppOpsService.Stub { if (resolvedPackageName == null) { return AppOpsManager.MODE_IGNORED; } - return noteOperationUnchecked(code, uid, resolvedPackageName, featureId, + return noteOperationUnchecked(code, uid, resolvedPackageName, attributionTag, Process.INVALID_UID, null, null, AppOpsManager.OP_FLAG_SELF, shouldCollectAsyncNotedOp, message); } private int noteOperationUnchecked(int code, int uid, @NonNull String packageName, - @Nullable String featureId, int proxyUid, String proxyPackageName, - @Nullable String proxyFeatureId, @OpFlags int flags, boolean shouldCollectAsyncNotedOp, - @Nullable String message) { + @Nullable String attributionTag, int proxyUid, String proxyPackageName, + @Nullable String proxyAttributionTag, @OpFlags int flags, + boolean shouldCollectAsyncNotedOp, @Nullable String message) { RestrictionBypass bypass; try { - bypass = verifyAndGetBypass(uid, packageName, featureId); + bypass = verifyAndGetBypass(uid, packageName, attributionTag); } catch (SecurityException e) { Slog.e(TAG, "noteOperation", e); return AppOpsManager.MODE_ERRORED; } synchronized (this) { - final Ops ops = getOpsLocked(uid, packageName, featureId, bypass, true /* edit */); + final Ops ops = getOpsLocked(uid, packageName, attributionTag, bypass, + true /* edit */); if (ops == null) { scheduleOpNotedIfNeededLocked(code, uid, packageName, AppOpsManager.MODE_IGNORED); @@ -2983,17 +2994,17 @@ public class AppOpsService extends IAppOpsService.Stub { return AppOpsManager.MODE_ERRORED; } final Op op = getOpLocked(ops, code, uid, true); - final FeatureOp featureOp = op.getOrCreateFeature(op, featureId); + final AttributedOp attributedOp = op.getOrCreateAttribution(op, attributionTag); if (isOpRestrictedLocked(uid, code, packageName, bypass)) { scheduleOpNotedIfNeededLocked(code, uid, packageName, AppOpsManager.MODE_IGNORED); return AppOpsManager.MODE_IGNORED; } final UidState uidState = ops.uidState; - if (featureOp.isRunning()) { + if (attributedOp.isRunning()) { Slog.w(TAG, "Noting op not finished: uid " + uid + " pkg " + packageName + " code " + code + " startTime of in progress event=" - + featureOp.mInProgressEvents.valueAt(0).getStartTime()); + + attributedOp.mInProgressEvents.valueAt(0).getStartTime()); } final int switchCode = AppOpsManager.opToSwitch(code); @@ -3005,7 +3016,7 @@ public class AppOpsService extends IAppOpsService.Stub { if (DEBUG) Slog.d(TAG, "noteOperation: uid reject #" + uidMode + " for code " + switchCode + " (" + code + ") uid " + uid + " package " + packageName); - featureOp.rejected(uidState.state, flags); + attributedOp.rejected(uidState.state, flags); scheduleOpNotedIfNeededLocked(code, uid, packageName, uidMode); return uidMode; } @@ -3017,26 +3028,31 @@ public class AppOpsService extends IAppOpsService.Stub { if (DEBUG) Slog.d(TAG, "noteOperation: reject #" + mode + " for code " + switchCode + " (" + code + ") uid " + uid + " package " + packageName); - featureOp.rejected(uidState.state, flags); + attributedOp.rejected(uidState.state, flags); scheduleOpNotedIfNeededLocked(code, uid, packageName, mode); return mode; } } - if (DEBUG) Slog.d(TAG, "noteOperation: allowing code " + code + " uid " + uid - + " package " + packageName + (featureId == null ? "" : "." + featureId)); - featureOp.accessed(proxyUid, proxyPackageName, proxyFeatureId, uidState.state, flags); + if (DEBUG) { + Slog.d(TAG, + "noteOperation: allowing code " + code + " uid " + uid + " package " + + packageName + (attributionTag == null ? "" + : "." + attributionTag)); + } + attributedOp.accessed(proxyUid, proxyPackageName, proxyAttributionTag, uidState.state, + flags); scheduleOpNotedIfNeededLocked(code, uid, packageName, AppOpsManager.MODE_ALLOWED); if (shouldCollectAsyncNotedOp) { - collectAsyncNotedOp(uid, packageName, code, featureId, message); + collectAsyncNotedOp(uid, packageName, code, attributionTag, message); } return AppOpsManager.MODE_ALLOWED; } } - // TODO moltmann: Allow watching for feature ops + // TODO moltmann: Allow watching for attribution ops @Override public void startWatchingActive(int[] ops, IAppOpsActiveCallback callback) { int watchedUid = -1; @@ -3134,11 +3150,11 @@ public class AppOpsService extends IAppOpsService.Stub { * @param uid The uid the op was noted for * @param packageName The package the op was noted for * @param opCode The code of the op noted - * @param featureId The id of the feature to op was noted for + * @param attributionTag attribution tag the op was noted for * @param message The message for the op noting */ private void collectAsyncNotedOp(int uid, @NonNull String packageName, int opCode, - @Nullable String featureId, @NonNull String message) { + @Nullable String attributionTag, @NonNull String message) { Objects.requireNonNull(message); int callingUid = Binder.getCallingUid(); @@ -3150,10 +3166,10 @@ public class AppOpsService extends IAppOpsService.Stub { RemoteCallbackList<IAppOpsAsyncNotedCallback> callbacks = mAsyncOpWatchers.get(key); AsyncNotedAppOp asyncNotedOp = new AsyncNotedAppOp(opCode, callingUid, - featureId, message, System.currentTimeMillis()); + attributionTag, message, System.currentTimeMillis()); final boolean[] wasNoteForwarded = {false}; - reportRuntimeAppOpAccessMessageAsyncLocked(uid, packageName, opCode, featureId, + reportRuntimeAppOpAccessMessageAsyncLocked(uid, packageName, opCode, attributionTag, message); if (callbacks != null) { @@ -3164,7 +3180,7 @@ public class AppOpsService extends IAppOpsService.Stub { } catch (RemoteException e) { Slog.e(TAG, "Could not forward noteOp of " + opCode + " to " + packageName - + "/" + uid + "(" + featureId + ")", e); + + "/" + uid + "(" + attributionTag + ")", e); } }); } @@ -3266,7 +3282,7 @@ public class AppOpsService extends IAppOpsService.Stub { @Override public int startOperation(IBinder clientId, int code, int uid, String packageName, - String featureId, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, + String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message) { verifyIncomingUid(uid); verifyIncomingOp(code); @@ -3277,14 +3293,14 @@ public class AppOpsService extends IAppOpsService.Stub { RestrictionBypass bypass; try { - bypass = verifyAndGetBypass(uid, packageName, featureId); + bypass = verifyAndGetBypass(uid, packageName, attributionTag); } catch (SecurityException e) { Slog.e(TAG, "startOperation", e); return AppOpsManager.MODE_ERRORED; } synchronized (this) { - final Ops ops = getOpsLocked(uid, resolvedPackageName, featureId, bypass, + final Ops ops = getOpsLocked(uid, resolvedPackageName, attributionTag, bypass, true /* edit */); if (ops == null) { if (DEBUG) Slog.d(TAG, "startOperation: no op for code " + code + " uid " + uid @@ -3295,7 +3311,7 @@ public class AppOpsService extends IAppOpsService.Stub { if (isOpRestrictedLocked(uid, code, resolvedPackageName, bypass)) { return AppOpsManager.MODE_IGNORED; } - final FeatureOp featureOp = op.getOrCreateFeature(op, featureId); + final AttributedOp attributedOp = op.getOrCreateAttribution(op, attributionTag); final int switchCode = AppOpsManager.opToSwitch(code); final UidState uidState = ops.uidState; // If there is a non-default per UID policy (we set UID op mode only if @@ -3308,7 +3324,7 @@ public class AppOpsService extends IAppOpsService.Stub { if (DEBUG) Slog.d(TAG, "noteOperation: uid reject #" + uidMode + " for code " + switchCode + " (" + code + ") uid " + uid + " package " + resolvedPackageName); - featureOp.rejected(uidState.state, AppOpsManager.OP_FLAG_SELF); + attributedOp.rejected(uidState.state, AppOpsManager.OP_FLAG_SELF); return uidMode; } } else { @@ -3320,21 +3336,21 @@ public class AppOpsService extends IAppOpsService.Stub { if (DEBUG) Slog.d(TAG, "startOperation: reject #" + mode + " for code " + switchCode + " (" + code + ") uid " + uid + " package " + resolvedPackageName); - featureOp.rejected(uidState.state, AppOpsManager.OP_FLAG_SELF); + attributedOp.rejected(uidState.state, AppOpsManager.OP_FLAG_SELF); return mode; } } if (DEBUG) Slog.d(TAG, "startOperation: allowing code " + code + " uid " + uid + " package " + resolvedPackageName); try { - featureOp.started(clientId, uidState.state); + attributedOp.started(clientId, uidState.state); } catch (RemoteException e) { throw new RuntimeException(e); } } if (shouldCollectAsyncNotedOp) { - collectAsyncNotedOp(uid, packageName, code, featureId, message); + collectAsyncNotedOp(uid, packageName, code, attributionTag, message); } return AppOpsManager.MODE_ALLOWED; @@ -3342,7 +3358,7 @@ public class AppOpsService extends IAppOpsService.Stub { @Override public void finishOperation(IBinder clientId, int code, int uid, String packageName, - String featureId) { + String attributionTag) { verifyIncomingUid(uid); verifyIncomingOp(code); String resolvedPackageName = resolvePackageName(uid, packageName); @@ -3352,24 +3368,24 @@ public class AppOpsService extends IAppOpsService.Stub { RestrictionBypass bypass; try { - bypass = verifyAndGetBypass(uid, packageName, featureId); + bypass = verifyAndGetBypass(uid, packageName, attributionTag); } catch (SecurityException e) { Slog.e(TAG, "Cannot finishOperation", e); return; } synchronized (this) { - Op op = getOpLocked(code, uid, resolvedPackageName, featureId, bypass, true); + Op op = getOpLocked(code, uid, resolvedPackageName, attributionTag, bypass, true); if (op == null) { return; } - final FeatureOp featureOp = op.mFeatures.get(featureId); - if (featureOp == null) { + final AttributedOp attributedOp = op.mAttributions.get(attributionTag); + if (attributedOp == null) { return; } try { - featureOp.finished(clientId); + attributedOp.finished(clientId); } catch (IllegalStateException e) { Slog.e(TAG, "Operation not started: uid=" + uid + " pkg=" + packageName + " op=" + AppOpsManager.opToName(code), e); @@ -3639,25 +3655,25 @@ public class AppOpsService extends IAppOpsService.Stub { * * @param uid The uid the package belongs to * @param packageName The package the might belong to the uid - * @param featureId The feature in the package or {@code null} if no need to verify + * @param attributionTag attribution tag or {@code null} if no need to verify * * @return {@code true} iff the package is privileged */ private @Nullable RestrictionBypass verifyAndGetBypass(int uid, String packageName, - @Nullable String featureId) { + @Nullable String attributionTag) { if (uid == Process.ROOT_UID) { // For backwards compatibility, don't check package name for root UID. return null; } - // Do not check if uid/packageName/featureId is already known + // Do not check if uid/packageName/attributionTag is already known synchronized (this) { UidState uidState = mUidStates.get(uid); if (uidState != null && uidState.pkgOps != null) { Ops ops = uidState.pkgOps.get(packageName); - if (ops != null && (featureId == null || ops.knownFeatureIds.contains(featureId)) - && ops.bypass != null) { + if (ops != null && (attributionTag == null || ops.knownAttributionTags.contains( + attributionTag)) && ops.bypass != null) { return ops.bypass; } } @@ -3669,17 +3685,17 @@ public class AppOpsService extends IAppOpsService.Stub { int pkgUid; AndroidPackage pkg = LocalServices.getService(PackageManagerInternal.class).getPackage( packageName); - boolean isFeatureIdValid = false; + boolean isAttributionTagValid = false; if (pkg != null) { - if (featureId == null) { - isFeatureIdValid = true; + if (attributionTag == null) { + isAttributionTagValid = true; } else { - if (pkg.getFeatures() != null) { - int numFeatures = pkg.getFeatures().size(); - for (int i = 0; i < numFeatures; i++) { - if (pkg.getFeatures().get(i).id.equals(featureId)) { - isFeatureIdValid = true; + if (pkg.getAttributions() != null) { + int numAttributions = pkg.getAttributions().size(); + for (int i = 0; i < numAttributions; i++) { + if (pkg.getAttributions().get(i).tag.equals(attributionTag)) { + isAttributionTagValid = true; } } } @@ -3689,8 +3705,8 @@ public class AppOpsService extends IAppOpsService.Stub { UserHandle.getUserId(uid), UserHandle.getAppId(pkg.getUid())); bypass = getBypassforPackage(pkg); } else { - // Allow any feature id for resolvable uids - isFeatureIdValid = true; + // Allow any attribution tag for resolvable uids + isAttributionTagValid = true; pkgUid = resolveUid(packageName); if (pkgUid >= 0) { @@ -3702,9 +3718,9 @@ public class AppOpsService extends IAppOpsService.Stub { + " but it is really " + pkgUid); } - if (!isFeatureIdValid) { + if (!isAttributionTagValid) { // TODO moltmann: Switch from logging to enforcement - Slog.e(TAG, "featureId " + featureId + " not declared in manifest of " + Slog.e(TAG, "attributionTag " + attributionTag + " not declared in manifest of " + packageName); } } finally { @@ -3719,13 +3735,13 @@ public class AppOpsService extends IAppOpsService.Stub { * * @param uid The uid the package belongs to * @param packageName The name of the package - * @param featureId The feature in the package + * @param attributionTag attribution tag * @param bypass When to bypass certain op restrictions (can be null if edit == false) * @param edit If an ops does not exist, create the ops? * @return The ops */ - private Ops getOpsLocked(int uid, String packageName, @Nullable String featureId, + private Ops getOpsLocked(int uid, String packageName, @Nullable String attributionTag, @Nullable RestrictionBypass bypass, boolean edit) { UidState uidState = getUidStateLocked(uid, edit); if (uidState == null) { @@ -3753,8 +3769,8 @@ public class AppOpsService extends IAppOpsService.Stub { ops.bypass = bypass; } - if (featureId != null) { - ops.knownFeatureIds.add(featureId); + if (attributionTag != null) { + ops.knownAttributionTags.add(attributionTag); } } @@ -3783,15 +3799,15 @@ public class AppOpsService extends IAppOpsService.Stub { * @param code The code of the op * @param uid The uid the of the package * @param packageName The package name for which to get the state for - * @param featureId The feature in the package + * @param attributionTag The attribution tag * @param bypass When to bypass certain op restrictions (can be null if edit == false) * @param edit Iff {@code true} create the {@link Op} object if not yet created * * @return The {@link Op state} of the op */ private @Nullable Op getOpLocked(int code, int uid, @NonNull String packageName, - @Nullable String featureId, @Nullable RestrictionBypass bypass, boolean edit) { - Ops ops = getOpsLocked(uid, packageName, featureId, bypass, edit); + @Nullable String attributionTag, @Nullable RestrictionBypass bypass, boolean edit) { + Ops ops = getOpsLocked(uid, packageName, attributionTag, bypass, edit); if (ops == null) { return null; } @@ -4048,9 +4064,9 @@ public class AppOpsService extends IAppOpsService.Stub { uidState.evalForegroundOps(mOpModeWatchers); } - private void readFeatureOp(XmlPullParser parser, @NonNull Op parent, - @Nullable String feature) throws NumberFormatException, IOException { - final FeatureOp featureOp = parent.getOrCreateFeature(parent, feature); + private void readAttributionOp(XmlPullParser parser, @NonNull Op parent, + @Nullable String attribution) throws NumberFormatException, IOException { + final AttributedOp attributedOp = parent.getOrCreateAttribution(parent, attribution); final long key = XmlUtils.readLongAttribute(parser, "n"); final int uidState = extractUidStateFromKey(key); @@ -4061,14 +4077,14 @@ public class AppOpsService extends IAppOpsService.Stub { final long accessDuration = XmlUtils.readLongAttribute(parser, "d", -1); final String proxyPkg = XmlUtils.readStringAttribute(parser, "pp"); final int proxyUid = XmlUtils.readIntAttribute(parser, "pu", Process.INVALID_UID); - final String proxyFeatureId = XmlUtils.readStringAttribute(parser, "pc"); + final String proxyAttributionTag = XmlUtils.readStringAttribute(parser, "pc"); if (accessTime > 0) { - featureOp.accessed(accessTime, accessDuration, proxyUid, proxyPkg, proxyFeatureId, - uidState, opFlags); + attributedOp.accessed(accessTime, accessDuration, proxyUid, proxyPkg, + proxyAttributionTag, uidState, opFlags); } if (rejectTime > 0) { - featureOp.rejected(rejectTime, uidState, opFlags); + attributedOp.rejected(rejectTime, uidState, opFlags); } } @@ -4094,7 +4110,7 @@ public class AppOpsService extends IAppOpsService.Stub { } String tagName = parser.getName(); if (tagName.equals("st")) { - readFeatureOp(parser, op, XmlUtils.readStringAttribute(parser, "id")); + readAttributionOp(parser, op, XmlUtils.readStringAttribute(parser, "id")); } else { Slog.w(TAG, "Unknown element under <op>: " + parser.getName()); @@ -4208,11 +4224,11 @@ public class AppOpsService extends IAppOpsService.Stub { out.attribute(null, "m", Integer.toString(op.getMode())); } - for (String featureId : op.getFeatures().keySet()) { - final OpFeatureEntry feature = op.getFeatures().get( - featureId); + for (String attributionTag : op.getAttributedOpEntries().keySet()) { + final AttributedOpEntry attribution = + op.getAttributedOpEntries().get(attributionTag); - final ArraySet<Long> keys = feature.collectKeys(); + final ArraySet<Long> keys = attribution.collectKeys(); final int keyCount = keys.size(); for (int k = 0; k < keyCount; k++) { @@ -4221,14 +4237,14 @@ public class AppOpsService extends IAppOpsService.Stub { final int uidState = AppOpsManager.extractUidStateFromKey(key); final int flags = AppOpsManager.extractFlagsFromKey(key); - final long accessTime = feature.getLastAccessTime(uidState, + final long accessTime = attribution.getLastAccessTime(uidState, uidState, flags); - final long rejectTime = feature.getLastRejectTime(uidState, - uidState, flags); - final long accessDuration = feature.getLastDuration(uidState, + final long rejectTime = attribution.getLastRejectTime(uidState, uidState, flags); + final long accessDuration = attribution.getLastDuration( + uidState, uidState, flags); // Proxy information for rejections is not backed up - final OpEventProxyInfo proxy = feature.getLastProxyInfo( + final OpEventProxyInfo proxy = attribution.getLastProxyInfo( uidState, uidState, flags); if (accessTime <= 0 && rejectTime <= 0 && accessDuration <= 0 @@ -4237,17 +4253,17 @@ public class AppOpsService extends IAppOpsService.Stub { } String proxyPkg = null; - String proxyFeatureId = null; + String proxyAttributionTag = null; int proxyUid = Process.INVALID_UID; if (proxy != null) { proxyPkg = proxy.getPackageName(); - proxyFeatureId = proxy.getFeatureId(); + proxyAttributionTag = proxy.getAttributionTag(); proxyUid = proxy.getUid(); } out.startTag(null, "st"); - if (featureId != null) { - out.attribute(null, "id", featureId); + if (attributionTag != null) { + out.attribute(null, "id", attributionTag); } out.attribute(null, "n", Long.toString(key)); if (accessTime > 0) { @@ -4262,8 +4278,8 @@ public class AppOpsService extends IAppOpsService.Stub { if (proxyPkg != null) { out.attribute(null, "pp", proxyPkg); } - if (proxyFeatureId != null) { - out.attribute(null, "pc", proxyFeatureId); + if (proxyAttributionTag != null) { + out.attribute(null, "pc", proxyAttributionTag); } if (proxyUid >= 0) { out.attribute(null, "pu", Integer.toString(proxyUid)); @@ -4297,7 +4313,7 @@ public class AppOpsService extends IAppOpsService.Stub { int userId = UserHandle.USER_SYSTEM; String packageName; - String featureId; + String attributionTag; String opStr; String modeStr; int op; @@ -4399,8 +4415,8 @@ public class AppOpsService extends IAppOpsService.Stub { userId = UserHandle.parseUserArg(getNextArgRequired()); } else if ("--uid".equals(argument)) { targetsUid = true; - } else if ("--feature".equals(argument)) { - featureId = getNextArgRequired(); + } else if ("--attribution".equals(argument)) { + attributionTag = getNextArgRequired(); } else { if (packageName == null) { packageName = argument; @@ -4495,13 +4511,16 @@ public class AppOpsService extends IAppOpsService.Stub { pw.println("AppOps service (appops) commands:"); pw.println(" help"); pw.println(" Print this help text."); - pw.println(" start [--user <USER_ID>] [--feature <FEATURE_ID>] <PACKAGE | UID> <OP> "); + pw.println(" start [--user <USER_ID>] [--attribution <ATTRIBUTION_TAG>] <PACKAGE | UID> " + + "<OP> "); pw.println(" Starts a given operation for a particular application."); - pw.println(" stop [--user <USER_ID>] [--feature <FEATURE_ID>] <PACKAGE | UID> <OP> "); + pw.println(" stop [--user <USER_ID>] [--attribution <ATTRIBUTION_TAG>] <PACKAGE | UID> " + + "<OP> "); pw.println(" Stops a given operation for a particular application."); pw.println(" set [--user <USER_ID>] <[--uid] PACKAGE | UID> <OP> <MODE>"); pw.println(" Set the mode for a particular application and operation."); - pw.println(" get [--user <USER_ID>] [--feature <FEATURE_ID>] <PACKAGE | UID> [<OP>]"); + pw.println(" get [--user <USER_ID>] [--attribution <ATTRIBUTION_TAG>] <PACKAGE | UID> " + + "[<OP>]"); pw.println(" Return the mode for a particular application and optional operation."); pw.println(" query-op [--user <USER_ID>] <OP> [<MODE>]"); pw.println(" Print all packages that currently have the given op in the given mode."); @@ -4515,8 +4534,8 @@ public class AppOpsService extends IAppOpsService.Stub { pw.println(" <PACKAGE> an Android package name or its UID if prefixed by --uid"); pw.println(" <OP> an AppOps operation."); pw.println(" <MODE> one of allow, ignore, deny, or default"); - pw.println(" <USER_ID> the user id under which the package is installed. If --user is not"); - pw.println(" specified, the current user is assumed."); + pw.println(" <USER_ID> the user id under which the package is installed. If --user is"); + pw.println(" not specified, the current user is assumed."); } static int onShellCommand(Shell shell, String cmd) { @@ -4605,7 +4624,7 @@ public class AppOpsService extends IAppOpsService.Stub { pw.print(AppOpsManager.opToName(ent.getOp())); pw.print(": "); pw.print(AppOpsManager.modeToName(ent.getMode())); - if (shell.featureId == null) { + if (shell.attributionTag == null) { if (ent.getLastAccessTime(OP_FLAGS_ALL) != -1) { pw.print("; time="); TimeUtils.formatDuration( @@ -4625,29 +4644,30 @@ public class AppOpsService extends IAppOpsService.Stub { TimeUtils.formatDuration(ent.getLastDuration(OP_FLAGS_ALL), pw); } } else { - final OpFeatureEntry featureEnt = ent.getFeatures().get( - shell.featureId); - if (featureEnt != null) { - if (featureEnt.getLastAccessTime(OP_FLAGS_ALL) != -1) { + final AppOpsManager.AttributedOpEntry attributionEnt = + ent.getAttributedOpEntries().get(shell.attributionTag); + if (attributionEnt != null) { + if (attributionEnt.getLastAccessTime(OP_FLAGS_ALL) != -1) { pw.print("; time="); - TimeUtils.formatDuration(now - featureEnt.getLastAccessTime( - OP_FLAGS_ALL), pw); + TimeUtils.formatDuration( + now - attributionEnt.getLastAccessTime( + OP_FLAGS_ALL), pw); pw.print(" ago"); } - if (featureEnt.getLastRejectTime(OP_FLAGS_ALL) != -1) { + if (attributionEnt.getLastRejectTime(OP_FLAGS_ALL) != -1) { pw.print("; rejectTime="); TimeUtils.formatDuration( - now - featureEnt.getLastRejectTime(OP_FLAGS_ALL), - pw); + now - attributionEnt.getLastRejectTime( + OP_FLAGS_ALL), pw); pw.print(" ago"); } - if (featureEnt.isRunning()) { + if (attributionEnt.isRunning()) { pw.print(" (running)"); - } else if (featureEnt.getLastDuration(OP_FLAGS_ALL) + } else if (attributionEnt.getLastDuration(OP_FLAGS_ALL) != -1) { pw.print("; duration="); TimeUtils.formatDuration( - featureEnt.getLastDuration(OP_FLAGS_ALL), pw); + attributionEnt.getLastDuration(OP_FLAGS_ALL), pw); } } } @@ -4755,7 +4775,7 @@ public class AppOpsService extends IAppOpsService.Stub { if (shell.packageName != null) { shell.mInterface.startOperation(shell.mToken, shell.op, shell.packageUid, - shell.packageName, shell.featureId, true, true, + shell.packageName, shell.attributionTag, true, true, "appops start shell command"); } else { return -1; @@ -4769,8 +4789,8 @@ public class AppOpsService extends IAppOpsService.Stub { } if (shell.packageName != null) { - shell.mInterface.finishOperation(shell.mToken, - shell.op, shell.packageUid, shell.packageName, shell.featureId); + shell.mInterface.finishOperation(shell.mToken, shell.op, shell.packageUid, + shell.packageName, shell.attributionTag); } else { return -1; } @@ -4795,35 +4815,35 @@ public class AppOpsService extends IAppOpsService.Stub { pw.println(" Limit output to data associated with the given app op mode."); pw.println(" --package [PACKAGE]"); pw.println(" Limit output to data associated with the given package name."); - pw.println(" --featureId [featureId]"); - pw.println(" Limit output to data associated with the given feature id."); + pw.println(" --attributionTag [attributionTag]"); + pw.println(" Limit output to data associated with the given attribution tag."); pw.println(" --watchers"); pw.println(" Only output the watcher sections."); } - private void dumpStatesLocked(@NonNull PrintWriter pw, @Nullable String filterFeatureId, + private void dumpStatesLocked(@NonNull PrintWriter pw, @Nullable String filterAttributionTag, @HistoricalOpsRequestFilter int filter, long nowElapsed, @NonNull Op op, long now, @NonNull SimpleDateFormat sdf, @NonNull Date date, @NonNull String prefix) { - final int numFeatures = op.mFeatures.size(); - for (int i = 0; i < numFeatures; i++) { - if ((filter & FILTER_BY_FEATURE_ID) != 0 && !Objects.equals(op.mFeatures.keyAt(i), - filterFeatureId)) { + final int numAttributions = op.mAttributions.size(); + for (int i = 0; i < numAttributions; i++) { + if ((filter & FILTER_BY_ATTRIBUTION_TAG) != 0 && !Objects.equals( + op.mAttributions.keyAt(i), filterAttributionTag)) { continue; } - pw.print(prefix + op.mFeatures.keyAt(i) + "=[\n"); - dumpStatesLocked(pw, nowElapsed, op, op.mFeatures.keyAt(i), now, sdf, date, + pw.print(prefix + op.mAttributions.keyAt(i) + "=[\n"); + dumpStatesLocked(pw, nowElapsed, op, op.mAttributions.keyAt(i), now, sdf, date, prefix + " "); pw.print(prefix + "]\n"); } } private void dumpStatesLocked(@NonNull PrintWriter pw, long nowElapsed, @NonNull Op op, - @Nullable String featureId, long now, @NonNull SimpleDateFormat sdf, + @Nullable String attributionTag, long now, @NonNull SimpleDateFormat sdf, @NonNull Date date, @NonNull String prefix) { - final OpFeatureEntry entry = op.createSingleFeatureEntryLocked( - featureId).getFeatures().get(featureId); + final AttributedOpEntry entry = op.createSingleAttributionEntryLocked( + attributionTag).getAttributedOpEntries().get(attributionTag); final ArraySet<Long> keys = entry.collectKeys(); @@ -4840,11 +4860,11 @@ public class AppOpsService extends IAppOpsService.Stub { final OpEventProxyInfo proxy = entry.getLastProxyInfo(uidState, uidState, flags); String proxyPkg = null; - String proxyFeatureId = null; + String proxyAttributionTag = null; int proxyUid = Process.INVALID_UID; if (proxy != null) { proxyPkg = proxy.getPackageName(); - proxyFeatureId = proxy.getFeatureId(); + proxyAttributionTag = proxy.getAttributionTag(); proxyUid = proxy.getUid(); } @@ -4868,8 +4888,8 @@ public class AppOpsService extends IAppOpsService.Stub { pw.print(proxyUid); pw.print(", pkg="); pw.print(proxyPkg); - pw.print(", feature="); - pw.print(proxyFeatureId); + pw.print(", attributionTag="); + pw.print(proxyAttributionTag); pw.print("]"); } pw.println(); @@ -4890,21 +4910,21 @@ public class AppOpsService extends IAppOpsService.Stub { pw.print(proxyUid); pw.print(", pkg="); pw.print(proxyPkg); - pw.print(", feature="); - pw.print(proxyFeatureId); + pw.print(", attributionTag="); + pw.print(proxyAttributionTag); pw.print("]"); } pw.println(); } } - final FeatureOp featureOp = op.mFeatures.get(featureId); - if (featureOp.isRunning()) { + final AttributedOp attributedOp = op.mAttributions.get(attributionTag); + if (attributedOp.isRunning()) { long earliestElapsedTime = Long.MAX_VALUE; long maxNumStarts = 0; - int numInProgressEvents = featureOp.mInProgressEvents.size(); + int numInProgressEvents = attributedOp.mInProgressEvents.size(); for (int i = 0; i < numInProgressEvents; i++) { - InProgressStartOpEvent event = featureOp.mInProgressEvents.valueAt(i); + InProgressStartOpEvent event = attributedOp.mInProgressEvents.valueAt(i); earliestElapsedTime = Math.min(earliestElapsedTime, event.getStartElapsedTime()); maxNumStarts = Math.max(maxNumStarts, event.numUnfinishedStarts); @@ -4927,7 +4947,7 @@ public class AppOpsService extends IAppOpsService.Stub { int dumpOp = OP_NONE; String dumpPackage = null; - String dumpFeatureId = null; + String dumpAttributionTag = null; int dumpUid = Process.INVALID_UID; int dumpMode = -1; boolean dumpWatchers = false; @@ -4974,14 +4994,14 @@ public class AppOpsService extends IAppOpsService.Stub { } dumpUid = UserHandle.getAppId(dumpUid); dumpFilter |= FILTER_BY_UID; - } else if ("--featureId".equals(arg)) { + } else if ("--attributionTag".equals(arg)) { i++; if (i >= args.length) { - pw.println("No argument for --featureId option"); + pw.println("No argument for --attributionTag option"); return; } - dumpFeatureId = args[i]; - dumpFilter |= FILTER_BY_FEATURE_ID; + dumpAttributionTag = args[i]; + dumpFilter |= FILTER_BY_ATTRIBUTION_TAG; } else if ("--mode".equals(arg)) { i++; if (i >= args.length) { @@ -5320,8 +5340,8 @@ public class AppOpsService extends IAppOpsService.Stub { pw.print("="); pw.print(AppOpsManager.modeToName(mode)); } pw.println("): "); - dumpStatesLocked(pw, dumpFeatureId, dumpFilter, nowElapsed, op, now, sdf, - date, " "); + dumpStatesLocked(pw, dumpAttributionTag, dumpFilter, nowElapsed, op, now, + sdf, date, " "); } } } @@ -5420,7 +5440,7 @@ public class AppOpsService extends IAppOpsService.Stub { // Must not hold the appops lock if (dumpHistory && !dumpWatchers) { - mHistoricalRegistry.dump(" ", pw, dumpUid, dumpPackage, dumpFeatureId, dumpOp, + mHistoricalRegistry.dump(" ", pw, dumpUid, dumpPackage, dumpAttributionTag, dumpOp, dumpFilter); } } @@ -5525,7 +5545,7 @@ public class AppOpsService extends IAppOpsService.Stub { if (resolvedPackageName == null) { return false; } - // TODO moltmann: Allow to check for feature op activeness + // TODO moltmann: Allow to check for attribution op activeness synchronized (AppOpsService.this) { Ops pkgOps = getOpsLocked(uid, resolvedPackageName, null, null, false); if (pkgOps == null) { @@ -5586,7 +5606,7 @@ public class AppOpsService extends IAppOpsService.Stub { * Report runtime access to AppOp together with message (including stack trace) * * @param packageName The package which reported the op - * @param notedAppOp contains code of op and featureId provided by developer + * @param notedAppOp contains code of op and attributionTag provided by developer * @param message Message describing AppOp access (can be stack trace) * * @return Config for future sampling to reduce amount of reporting @@ -5608,7 +5628,7 @@ public class AppOpsService extends IAppOpsService.Stub { reportRuntimeAppOpAccessMessageInternalLocked(uid, packageName, AppOpsManager.strOpToOp(notedAppOp.getOp()), - notedAppOp.getFeatureId(), message); + notedAppOp.getAttributionTag(), message); return new MessageSamplingConfig(mSampledAppOpCode, mAcceptableLeftDistance, Instant.now().plus(1, ChronoUnit.HOURS).toEpochMilli()); @@ -5621,17 +5641,18 @@ public class AppOpsService extends IAppOpsService.Stub { * @param uid Uid of the package which reported the op * @param packageName The package which reported the op * @param opCode Code of AppOp - * @param featureId FeautreId of AppOp reported + * @param attributionTag FeautreId of AppOp reported * @param message Message describing AppOp access (can be stack trace) */ private void reportRuntimeAppOpAccessMessageAsyncLocked(int uid, - @NonNull String packageName, int opCode, @Nullable String featureId, + @NonNull String packageName, int opCode, @Nullable String attributionTag, @NonNull String message) { switchPackageIfRarelyUsedLocked(packageName); if (!Objects.equals(mSampledPackage, packageName)) { return; } - reportRuntimeAppOpAccessMessageInternalLocked(uid, packageName, opCode, featureId, message); + reportRuntimeAppOpAccessMessageInternalLocked(uid, packageName, opCode, attributionTag, + message); } /** @@ -5639,7 +5660,7 @@ public class AppOpsService extends IAppOpsService.Stub { * reporting uniformly at random across all received messages. */ private void reportRuntimeAppOpAccessMessageInternalLocked(int uid, - @NonNull String packageName, int opCode, @Nullable String featureId, + @NonNull String packageName, int opCode, @Nullable String attributionTag, @NonNull String message) { int newLeftDistance = AppOpsManager.leftCircularDistance(opCode, mSampledAppOpCode, _NUM_OP); @@ -5656,7 +5677,7 @@ public class AppOpsService extends IAppOpsService.Stub { mMessagesCollectedCount += 1.0f; if (ThreadLocalRandom.current().nextFloat() <= 1.0f / mMessagesCollectedCount) { mCollectedRuntimePermissionMessage = new RuntimeAppOpAccessMessage(uid, opCode, - packageName, featureId, message, mSamplingStrategy); + packageName, attributionTag, message, mSamplingStrategy); } return; } diff --git a/services/core/java/com/android/server/appop/HistoricalRegistry.java b/services/core/java/com/android/server/appop/HistoricalRegistry.java index cd450d421b0a..ed4506902f0a 100644 --- a/services/core/java/com/android/server/appop/HistoricalRegistry.java +++ b/services/core/java/com/android/server/appop/HistoricalRegistry.java @@ -15,7 +15,7 @@ */ package com.android.server.appop; -import static android.app.AppOpsManager.FILTER_BY_FEATURE_ID; +import static android.app.AppOpsManager.FILTER_BY_ATTRIBUTION_TAG; import static android.app.AppOpsManager.FILTER_BY_OP_NAMES; import static android.app.AppOpsManager.FILTER_BY_PACKAGE_NAME; import static android.app.AppOpsManager.FILTER_BY_UID; @@ -23,7 +23,6 @@ import static android.app.AppOpsManager.FILTER_BY_UID; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.AppOpsManager; -import android.app.AppOpsManager.HistoricalFeatureOps; import android.app.AppOpsManager.HistoricalMode; import android.app.AppOpsManager.HistoricalOp; import android.app.AppOpsManager.HistoricalOps; @@ -282,7 +281,7 @@ final class HistoricalRegistry { } void dump(String prefix, PrintWriter pw, int filterUid, @Nullable String filterPackage, - @Nullable String filterFeatureId, int filterOp, + @Nullable String filterAttributionTag, int filterOp, @HistoricalOpsRequestFilter int filter) { if (!isApiEnabled()) { return; @@ -298,7 +297,7 @@ final class HistoricalRegistry { pw.println(AppOpsManager.historicalModeToString(mMode)); final StringDumpVisitor visitor = new StringDumpVisitor(prefix + " ", - pw, filterUid, filterPackage, filterFeatureId, filterOp, filter); + pw, filterUid, filterPackage, filterAttributionTag, filterOp, filter); final long nowMillis = System.currentTimeMillis(); // Dump in memory state first @@ -338,7 +337,7 @@ final class HistoricalRegistry { } void getHistoricalOpsFromDiskRaw(int uid, @NonNull String packageName, - @Nullable String featureId, @Nullable String[] opNames, + @Nullable String attributionTag, @Nullable String[] opNames, @HistoricalOpsRequestFilter int filter, long beginTimeMillis, long endTimeMillis, @OpFlags int flags, @NonNull RemoteCallback callback) { if (!isApiEnabled()) { @@ -354,7 +353,7 @@ final class HistoricalRegistry { return; } final HistoricalOps result = new HistoricalOps(beginTimeMillis, endTimeMillis); - mPersistence.collectHistoricalOpsDLocked(result, uid, packageName, featureId, + mPersistence.collectHistoricalOpsDLocked(result, uid, packageName, attributionTag, opNames, filter, beginTimeMillis, endTimeMillis, flags); final Bundle payload = new Bundle(); payload.putParcelable(AppOpsManager.KEY_HISTORICAL_OPS, result); @@ -363,7 +362,7 @@ final class HistoricalRegistry { } } - void getHistoricalOps(int uid, @NonNull String packageName, @Nullable String featureId, + void getHistoricalOps(int uid, @NonNull String packageName, @Nullable String attributionTag, @Nullable String[] opNames, @HistoricalOpsRequestFilter int filter, long beginTimeMillis, long endTimeMillis, @OpFlags int flags, @NonNull RemoteCallback callback) { @@ -401,7 +400,7 @@ final class HistoricalRegistry { || inMemoryAdjEndTimeMillis <= currentOps.getBeginTimeMillis())) { // Some of the current batch falls into the query, so extract that. final HistoricalOps currentOpsCopy = new HistoricalOps(currentOps); - currentOpsCopy.filter(uid, packageName, featureId, opNames, filter, + currentOpsCopy.filter(uid, packageName, attributionTag, opNames, filter, inMemoryAdjBeginTimeMillis, inMemoryAdjEndTimeMillis); result.merge(currentOpsCopy); } @@ -421,7 +420,7 @@ final class HistoricalRegistry { - onDiskAndInMemoryOffsetMillis, 0); final long onDiskAdjEndTimeMillis = Math.max(inMemoryAdjEndTimeMillis - onDiskAndInMemoryOffsetMillis, 0); - mPersistence.collectHistoricalOpsDLocked(result, uid, packageName, featureId, + mPersistence.collectHistoricalOpsDLocked(result, uid, packageName, attributionTag, opNames, filter, onDiskAdjBeginTimeMillis, onDiskAdjEndTimeMillis, flags); } @@ -436,7 +435,7 @@ final class HistoricalRegistry { } void incrementOpAccessedCount(int op, int uid, @NonNull String packageName, - @Nullable String featureId, @UidState int uidState, @OpFlags int flags) { + @Nullable String attributionTag, @UidState int uidState, @OpFlags int flags) { synchronized (mInMemoryLock) { if (mMode == AppOpsManager.HISTORICAL_MODE_ENABLED_ACTIVE) { if (!isPersistenceInitializedMLocked()) { @@ -445,13 +444,13 @@ final class HistoricalRegistry { } getUpdatedPendingHistoricalOpsMLocked( System.currentTimeMillis()).increaseAccessCount(op, uid, packageName, - featureId, uidState, flags, 1); + attributionTag, uidState, flags, 1); } } } void incrementOpRejected(int op, int uid, @NonNull String packageName, - @Nullable String featureId, @UidState int uidState, @OpFlags int flags) { + @Nullable String attributionTag, @UidState int uidState, @OpFlags int flags) { synchronized (mInMemoryLock) { if (mMode == AppOpsManager.HISTORICAL_MODE_ENABLED_ACTIVE) { if (!isPersistenceInitializedMLocked()) { @@ -460,13 +459,13 @@ final class HistoricalRegistry { } getUpdatedPendingHistoricalOpsMLocked( System.currentTimeMillis()).increaseRejectCount(op, uid, packageName, - featureId, uidState, flags, 1); + attributionTag, uidState, flags, 1); } } } void increaseOpAccessDuration(int op, int uid, @NonNull String packageName, - @Nullable String featureId, @UidState int uidState, @OpFlags int flags, + @Nullable String attributionTag, @UidState int uidState, @OpFlags int flags, long increment) { synchronized (mInMemoryLock) { if (mMode == AppOpsManager.HISTORICAL_MODE_ENABLED_ACTIVE) { @@ -476,7 +475,7 @@ final class HistoricalRegistry { } getUpdatedPendingHistoricalOpsMLocked( System.currentTimeMillis()).increaseAccessDuration(op, uid, packageName, - featureId, uidState, flags, increment); + attributionTag, uidState, flags, increment); } } } @@ -728,7 +727,7 @@ final class HistoricalRegistry { private static final String TAG_OPS = "ops"; private static final String TAG_UID = "uid"; private static final String TAG_PACKAGE = "pkg"; - private static final String TAG_FEATURE = "ftr"; + private static final String TAG_ATTRIBUTION = "ftr"; private static final String TAG_OP = "op"; private static final String TAG_STATE = "st"; @@ -807,9 +806,9 @@ final class HistoricalRegistry { @Nullable List<HistoricalOps> readHistoryRawDLocked() { return collectHistoricalOpsBaseDLocked(Process.INVALID_UID /*filterUid*/, - null /*filterPackageName*/, null /*filterFeatureId*/, null /*filterOpNames*/, - 0 /*filter*/, 0 /*filterBeginTimeMills*/, Long.MAX_VALUE /*filterEndTimeMills*/, - AppOpsManager.OP_FLAGS_ALL); + null /*filterPackageName*/, null /*filterAttributionTag*/, + null /*filterOpNames*/, 0 /*filter*/, 0 /*filterBeginTimeMills*/, + Long.MAX_VALUE /*filterEndTimeMills*/, AppOpsManager.OP_FLAGS_ALL); } @Nullable List<HistoricalOps> readHistoryDLocked() { @@ -861,13 +860,13 @@ final class HistoricalRegistry { return 0; } - private void collectHistoricalOpsDLocked(@NonNull HistoricalOps currentOps, - int filterUid, @Nullable String filterPackageName, @Nullable String filterFeatureId, + private void collectHistoricalOpsDLocked(@NonNull HistoricalOps currentOps, int filterUid, + @Nullable String filterPackageName, @Nullable String filterAttributionTag, @Nullable String[] filterOpNames, @HistoricalOpsRequestFilter int filter, long filterBeingMillis, long filterEndMillis, @OpFlags int filterFlags) { final List<HistoricalOps> readOps = collectHistoricalOpsBaseDLocked(filterUid, - filterPackageName, filterFeatureId, filterOpNames, filter, filterBeingMillis, - filterEndMillis, filterFlags); + filterPackageName, filterAttributionTag, filterOpNames, filter, + filterBeingMillis, filterEndMillis, filterFlags); if (readOps != null) { final int readCount = readOps.size(); for (int i = 0; i < readCount; i++) { @@ -877,8 +876,8 @@ final class HistoricalRegistry { } } - private @Nullable LinkedList<HistoricalOps> collectHistoricalOpsBaseDLocked( - int filterUid, @Nullable String filterPackageName, @Nullable String filterFeatureId, + private @Nullable LinkedList<HistoricalOps> collectHistoricalOpsBaseDLocked(int filterUid, + @Nullable String filterPackageName, @Nullable String filterAttributionTag, @Nullable String[] filterOpNames, @HistoricalOpsRequestFilter int filter, long filterBeginTimeMillis, long filterEndTimeMillis, @OpFlags int filterFlags) { File baseDir = null; @@ -892,7 +891,7 @@ final class HistoricalRegistry { final Set<String> historyFiles = getHistoricalFileNames(baseDir); final long[] globalContentOffsetMillis = {0}; final LinkedList<HistoricalOps> ops = collectHistoricalOpsRecursiveDLocked( - baseDir, filterUid, filterPackageName, filterFeatureId, filterOpNames, + baseDir, filterUid, filterPackageName, filterAttributionTag, filterOpNames, filter, filterBeginTimeMillis, filterEndTimeMillis, filterFlags, globalContentOffsetMillis, null /*outOps*/, 0 /*depth*/, historyFiles); if (DEBUG) { @@ -909,7 +908,7 @@ final class HistoricalRegistry { private @Nullable LinkedList<HistoricalOps> collectHistoricalOpsRecursiveDLocked( @NonNull File baseDir, int filterUid, @Nullable String filterPackageName, - @Nullable String filterFeatureId, @Nullable String[] filterOpNames, + @Nullable String filterAttributionTag, @Nullable String[] filterOpNames, @HistoricalOpsRequestFilter int filter, long filterBeginTimeMillis, long filterEndTimeMillis, @OpFlags int filterFlags, @NonNull long[] globalContentOffsetMillis, @@ -927,7 +926,7 @@ final class HistoricalRegistry { // Read historical data at this level final List<HistoricalOps> readOps = readHistoricalOpsLocked(baseDir, previousIntervalEndMillis, currentIntervalEndMillis, filterUid, - filterPackageName, filterFeatureId, filterOpNames, filter, + filterPackageName, filterAttributionTag, filterOpNames, filter, filterBeginTimeMillis, filterEndTimeMillis, filterFlags, globalContentOffsetMillis, depth, historyFiles); // Empty is a special signal to stop diving @@ -937,7 +936,7 @@ final class HistoricalRegistry { // Collect older historical data from subsequent levels outOps = collectHistoricalOpsRecursiveDLocked(baseDir, filterUid, filterPackageName, - filterFeatureId, filterOpNames, filter, filterBeginTimeMillis, + filterAttributionTag, filterOpNames, filter, filterBeginTimeMillis, filterEndTimeMillis, filterFlags, globalContentOffsetMillis, outOps, depth + 1, historyFiles); @@ -1006,7 +1005,7 @@ final class HistoricalRegistry { final List<HistoricalOps> existingOps = readHistoricalOpsLocked(oldBaseDir, previousIntervalEndMillis, currentIntervalEndMillis, Process.INVALID_UID /*filterUid*/, null /*filterPackageName*/, - null /*filterFeatureId*/, null /*filterOpNames*/, 0 /*filter*/, + null /*filterAttributionTag*/, null /*filterOpNames*/, 0 /*filter*/, Long.MIN_VALUE /*filterBeginTimeMillis*/, Long.MAX_VALUE /*filterEndTimeMillis*/, AppOpsManager.OP_FLAGS_ALL, null, depth, null /*historyFiles*/); @@ -1120,7 +1119,7 @@ final class HistoricalRegistry { private @Nullable List<HistoricalOps> readHistoricalOpsLocked(File baseDir, long intervalBeginMillis, long intervalEndMillis, int filterUid, - @Nullable String filterPackageName, @Nullable String filterFeatureId, + @Nullable String filterPackageName, @Nullable String filterAttributionTag, @Nullable String[] filterOpNames, @HistoricalOpsRequestFilter int filter, long filterBeginTimeMillis, long filterEndTimeMillis, @OpFlags int filterFlags, @Nullable long[] cumulativeOverflowMillis, int depth, @@ -1147,15 +1146,16 @@ final class HistoricalRegistry { return null; } } - return readHistoricalOpsLocked(file, filterUid, filterPackageName, filterFeatureId, + return readHistoricalOpsLocked(file, filterUid, filterPackageName, filterAttributionTag, filterOpNames, filter, filterBeginTimeMillis, filterEndTimeMillis, filterFlags, cumulativeOverflowMillis); } - private @Nullable List<HistoricalOps> readHistoricalOpsLocked(@NonNull File file, - int filterUid, @Nullable String filterPackageName, @Nullable String filterFeatureId, - @Nullable String[] filterOpNames, @HistoricalOpsRequestFilter int filter, - long filterBeginTimeMillis, long filterEndTimeMillis, @OpFlags int filterFlags, + private @Nullable List<HistoricalOps> readHistoricalOpsLocked(@NonNull File file, + int filterUid, @Nullable String filterPackageName, + @Nullable String filterAttributionTag, @Nullable String[] filterOpNames, + @HistoricalOpsRequestFilter int filter, long filterBeginTimeMillis, + long filterEndTimeMillis, @OpFlags int filterFlags, @Nullable long[] cumulativeOverflowMillis) throws IOException, XmlPullParserException { if (DEBUG) { @@ -1180,7 +1180,7 @@ final class HistoricalRegistry { while (XmlUtils.nextElementWithin(parser, depth)) { if (TAG_OPS.equals(parser.getName())) { final HistoricalOps ops = readeHistoricalOpsDLocked(parser, filterUid, - filterPackageName, filterFeatureId, filterOpNames, filter, + filterPackageName, filterAttributionTag, filterOpNames, filter, filterBeginTimeMillis, filterEndTimeMillis, filterFlags, cumulativeOverflowMillis); if (ops == null) { @@ -1215,7 +1215,7 @@ final class HistoricalRegistry { private @Nullable HistoricalOps readeHistoricalOpsDLocked( @NonNull XmlPullParser parser, int filterUid, @Nullable String filterPackageName, - @Nullable String filterFeatureId, @Nullable String[] filterOpNames, + @Nullable String filterAttributionTag, @Nullable String[] filterOpNames, @HistoricalOpsRequestFilter int filter, long filterBeginTimeMillis, long filterEndTimeMillis, @OpFlags int filterFlags, @Nullable long[] cumulativeOverflowMillis) @@ -1245,8 +1245,8 @@ final class HistoricalRegistry { while (XmlUtils.nextElementWithin(parser, depth)) { if (TAG_UID.equals(parser.getName())) { final HistoricalOps returnedOps = readHistoricalUidOpsDLocked(ops, parser, - filterUid, filterPackageName, filterFeatureId, filterOpNames, filter, - filterFlags, filterScale); + filterUid, filterPackageName, filterAttributionTag, filterOpNames, + filter, filterFlags, filterScale); if (ops == null) { ops = returnedOps; } @@ -1260,7 +1260,7 @@ final class HistoricalRegistry { private @Nullable HistoricalOps readHistoricalUidOpsDLocked( @Nullable HistoricalOps ops, @NonNull XmlPullParser parser, int filterUid, - @Nullable String filterPackageName, @Nullable String filterFeatureId, + @Nullable String filterPackageName, @Nullable String filterAttributionTag, @Nullable String[] filterOpNames, @HistoricalOpsRequestFilter int filter, @OpFlags int filterFlags, double filterScale) throws IOException, XmlPullParserException { @@ -1272,8 +1272,8 @@ final class HistoricalRegistry { final int depth = parser.getDepth(); while (XmlUtils.nextElementWithin(parser, depth)) { if (TAG_PACKAGE.equals(parser.getName())) { - final HistoricalOps returnedOps = readHistoricalPackageOpsDLocked(ops, - uid, parser, filterPackageName, filterFeatureId, filterOpNames, filter, + final HistoricalOps returnedOps = readHistoricalPackageOpsDLocked(ops, uid, + parser, filterPackageName, filterAttributionTag, filterOpNames, filter, filterFlags, filterScale); if (ops == null) { ops = returnedOps; @@ -1285,7 +1285,7 @@ final class HistoricalRegistry { private @Nullable HistoricalOps readHistoricalPackageOpsDLocked( @Nullable HistoricalOps ops, int uid, @NonNull XmlPullParser parser, - @Nullable String filterPackageName, @Nullable String filterFeatureId, + @Nullable String filterPackageName, @Nullable String filterAttributionTag, @Nullable String[] filterOpNames, @HistoricalOpsRequestFilter int filter, @OpFlags int filterFlags, double filterScale) throws IOException, XmlPullParserException { @@ -1296,9 +1296,9 @@ final class HistoricalRegistry { } final int depth = parser.getDepth(); while (XmlUtils.nextElementWithin(parser, depth)) { - if (TAG_FEATURE.equals(parser.getName())) { - final HistoricalOps returnedOps = readHistoricalFeatureOpsDLocked(ops, uid, - packageName, parser, filterFeatureId, filterOpNames, filter, + if (TAG_ATTRIBUTION.equals(parser.getName())) { + final HistoricalOps returnedOps = readHistoricalAttributionOpsDLocked(ops, uid, + packageName, parser, filterAttributionTag, filterOpNames, filter, filterFlags, filterScale); if (ops == null) { ops = returnedOps; @@ -1308,15 +1308,15 @@ final class HistoricalRegistry { return ops; } - private @Nullable HistoricalOps readHistoricalFeatureOpsDLocked(@Nullable HistoricalOps ops, - int uid, String packageName, @NonNull XmlPullParser parser, - @Nullable String filterFeatureId, @Nullable String[] filterOpNames, - @HistoricalOpsRequestFilter int filter, @OpFlags int filterFlags, - double filterScale) + private @Nullable HistoricalOps readHistoricalAttributionOpsDLocked( + @Nullable HistoricalOps ops, int uid, String packageName, + @NonNull XmlPullParser parser, @Nullable String filterAttributionTag, + @Nullable String[] filterOpNames, @HistoricalOpsRequestFilter int filter, + @OpFlags int filterFlags, double filterScale) throws IOException, XmlPullParserException { - final String featureId = XmlUtils.readStringAttribute(parser, ATTR_NAME); - if ((filter & FILTER_BY_FEATURE_ID) != 0 && !Objects.equals(filterFeatureId, - featureId)) { + final String attributionTag = XmlUtils.readStringAttribute(parser, ATTR_NAME); + if ((filter & FILTER_BY_ATTRIBUTION_TAG) != 0 && !Objects.equals(filterAttributionTag, + attributionTag)) { XmlUtils.skipCurrentTag(parser); return null; } @@ -1324,7 +1324,8 @@ final class HistoricalRegistry { while (XmlUtils.nextElementWithin(parser, depth)) { if (TAG_OP.equals(parser.getName())) { final HistoricalOps returnedOps = readHistoricalOpDLocked(ops, uid, packageName, - featureId, parser, filterOpNames, filter, filterFlags, filterScale); + attributionTag, parser, filterOpNames, filter, filterFlags, + filterScale); if (ops == null) { ops = returnedOps; } @@ -1334,7 +1335,7 @@ final class HistoricalRegistry { } private @Nullable HistoricalOps readHistoricalOpDLocked(@Nullable HistoricalOps ops, - int uid, @NonNull String packageName, @Nullable String featureId, + int uid, @NonNull String packageName, @Nullable String attributionTag, @NonNull XmlPullParser parser, @Nullable String[] filterOpNames, @HistoricalOpsRequestFilter int filter, @OpFlags int filterFlags, double filterScale) @@ -1349,7 +1350,7 @@ final class HistoricalRegistry { while (XmlUtils.nextElementWithin(parser, depth)) { if (TAG_STATE.equals(parser.getName())) { final HistoricalOps returnedOps = readStateDLocked(ops, uid, - packageName, featureId, op, parser, filterFlags, filterScale); + packageName, attributionTag, op, parser, filterFlags, filterScale); if (ops == null) { ops = returnedOps; } @@ -1359,7 +1360,7 @@ final class HistoricalRegistry { } private @Nullable HistoricalOps readStateDLocked(@Nullable HistoricalOps ops, - int uid, @NonNull String packageName, @Nullable String featureId, int op, + int uid, @NonNull String packageName, @Nullable String attributionTag, int op, @NonNull XmlPullParser parser, @OpFlags int filterFlags, double filterScale) throws IOException { final long key = XmlUtils.readLongAttribute(parser, ATTR_NAME); @@ -1377,7 +1378,7 @@ final class HistoricalRegistry { if (ops == null) { ops = new HistoricalOps(0, 0); } - ops.increaseAccessCount(op, uid, packageName, featureId, uidState, flags, + ops.increaseAccessCount(op, uid, packageName, attributionTag, uidState, flags, accessCount); } long rejectCount = XmlUtils.readLongAttribute(parser, ATTR_REJECT_COUNT, 0); @@ -1389,7 +1390,7 @@ final class HistoricalRegistry { if (ops == null) { ops = new HistoricalOps(0, 0); } - ops.increaseRejectCount(op, uid, packageName, featureId, uidState, flags, + ops.increaseRejectCount(op, uid, packageName, attributionTag, uidState, flags, rejectCount); } long accessDuration = XmlUtils.readLongAttribute(parser, ATTR_ACCESS_DURATION, 0); @@ -1401,7 +1402,7 @@ final class HistoricalRegistry { if (ops == null) { ops = new HistoricalOps(0, 0); } - ops.increaseAccessDuration(op, uid, packageName, featureId, uidState, flags, + ops.increaseAccessDuration(op, uid, packageName, attributionTag, uidState, flags, accessDuration); } return ops; @@ -1467,24 +1468,25 @@ final class HistoricalRegistry { @NonNull XmlSerializer serializer) throws IOException { serializer.startTag(null, TAG_PACKAGE); serializer.attribute(null, ATTR_NAME, packageOps.getPackageName()); - final int numFeatures = packageOps.getFeatureCount(); - for (int i = 0; i < numFeatures; i++) { - final HistoricalFeatureOps op = packageOps.getFeatureOpsAt(i); - writeHistoricalFeatureOpsDLocked(op, serializer); + final int numAttributions = packageOps.getAttributedOpsCount(); + for (int i = 0; i < numAttributions; i++) { + final AppOpsManager.AttributedHistoricalOps op = packageOps.getAttributedOpsAt(i); + writeHistoricalAttributionOpsDLocked(op, serializer); } serializer.endTag(null, TAG_PACKAGE); } - private void writeHistoricalFeatureOpsDLocked(@NonNull HistoricalFeatureOps featureOps, + private void writeHistoricalAttributionOpsDLocked( + @NonNull AppOpsManager.AttributedHistoricalOps attributionOps, @NonNull XmlSerializer serializer) throws IOException { - serializer.startTag(null, TAG_FEATURE); - XmlUtils.writeStringAttribute(serializer, ATTR_NAME, featureOps.getFeatureId()); - final int opCount = featureOps.getOpCount(); + serializer.startTag(null, TAG_ATTRIBUTION); + XmlUtils.writeStringAttribute(serializer, ATTR_NAME, attributionOps.getTag()); + final int opCount = attributionOps.getOpCount(); for (int i = 0; i < opCount; i++) { - final HistoricalOp op = featureOps.getOpAt(i); + final HistoricalOp op = attributionOps.getOpAt(i); writeHistoricalOpDLocked(op, serializer); } - serializer.endTag(null, TAG_FEATURE); + serializer.endTag(null, TAG_ATTRIBUTION); } private void writeHistoricalOpDLocked(@NonNull HistoricalOp op, @@ -1718,29 +1720,29 @@ final class HistoricalRegistry { private final @NonNull String mOpsPrefix; private final @NonNull String mUidPrefix; private final @NonNull String mPackagePrefix; - private final @NonNull String mFeaturePrefix; + private final @NonNull String mAttributionPrefix; private final @NonNull String mEntryPrefix; private final @NonNull String mUidStatePrefix; private final @NonNull PrintWriter mWriter; private final int mFilterUid; private final String mFilterPackage; - private final String mFilterFeatureId; + private final String mFilterAttributionTag; private final int mFilterOp; private final @HistoricalOpsRequestFilter int mFilter; StringDumpVisitor(@NonNull String prefix, @NonNull PrintWriter writer, int filterUid, - @Nullable String filterPackage, @Nullable String filterFeatureId, int filterOp, + @Nullable String filterPackage, @Nullable String filterAttributionTag, int filterOp, @HistoricalOpsRequestFilter int filter) { mOpsPrefix = prefix + " "; mUidPrefix = mOpsPrefix + " "; mPackagePrefix = mUidPrefix + " "; - mFeaturePrefix = mPackagePrefix + " "; - mEntryPrefix = mFeaturePrefix + " "; + mAttributionPrefix = mPackagePrefix + " "; + mEntryPrefix = mAttributionPrefix + " "; mUidStatePrefix = mEntryPrefix + " "; mWriter = writer; mFilterUid = filterUid; mFilterPackage = filterPackage; - mFilterFeatureId = filterFeatureId; + mFilterAttributionTag = filterAttributionTag; mFilterOp = filterOp; mFilter = filter; } @@ -1791,14 +1793,14 @@ final class HistoricalRegistry { } @Override - public void visitHistoricalFeatureOps(HistoricalFeatureOps ops) { - if ((mFilter & FILTER_BY_FEATURE_ID) != 0 && !Objects.equals(mFilterPackage, - ops.getFeatureId())) { + public void visitHistoricalAttributionOps(AppOpsManager.AttributedHistoricalOps ops) { + if ((mFilter & FILTER_BY_ATTRIBUTION_TAG) != 0 && !Objects.equals(mFilterPackage, + ops.getTag())) { return; } - mWriter.print(mFeaturePrefix); - mWriter.print("Feature "); - mWriter.print(ops.getFeatureId()); + mWriter.print(mAttributionPrefix); + mWriter.print("Attribution "); + mWriter.print(ops.getTag()); mWriter.println(":"); } diff --git a/services/core/java/com/android/server/location/CountryDetectorBase.java b/services/core/java/com/android/server/location/CountryDetectorBase.java index b158388281d8..682b104f6d7a 100644 --- a/services/core/java/com/android/server/location/CountryDetectorBase.java +++ b/services/core/java/com/android/server/location/CountryDetectorBase.java @@ -31,7 +31,7 @@ import android.os.Handler; * @hide */ public abstract class CountryDetectorBase { - private static final String FEATURE_ID = "CountryDetector"; + private static final String ATTRIBUTION_TAG = "CountryDetector"; protected final Handler mHandler; protected final Context mContext; @@ -39,7 +39,7 @@ public abstract class CountryDetectorBase { protected Country mDetectedCountry; public CountryDetectorBase(Context context) { - mContext = context.createFeatureContext(FEATURE_ID); + mContext = context.createAttributionContext(ATTRIBUTION_TAG); mHandler = new Handler(); } diff --git a/services/core/java/com/android/server/location/LocationManagerService.java b/services/core/java/com/android/server/location/LocationManagerService.java index fe741e2b1459..6e3477fefc66 100644 --- a/services/core/java/com/android/server/location/LocationManagerService.java +++ b/services/core/java/com/android/server/location/LocationManagerService.java @@ -185,7 +185,7 @@ public class LocationManagerService extends ILocationManager.Stub { // time private static final int MAX_PROVIDER_SCHEDULING_JITTER_MS = 100; - private static final String FEATURE_ID = "LocationService"; + private static final String ATTRIBUTION_TAG = "LocationService"; private static final LocationRequest DEFAULT_LOCATION_REQUEST = new LocationRequest(); @@ -230,7 +230,7 @@ public class LocationManagerService extends ILocationManager.Stub { private int mBatterySaverMode; LocationManagerService(Context context) { - mContext = context.createFeatureContext(FEATURE_ID); + mContext = context.createAttributionContext(ATTRIBUTION_TAG); mHandler = FgThread.getHandler(); mLocalService = new LocalService(); diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 6dc2fb5bd826..59baba2231df 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -11514,8 +11514,8 @@ public class PackageManagerService extends IPackageManager.Stub "Static shared libs cannot declare permission groups"); } - // Static shared libs cannot declare features - if (!pkg.getFeatures().isEmpty()) { + // Static shared libs cannot declare attributions + if (!pkg.getAttributions().isEmpty()) { throw new PackageManagerException( "Static shared libs cannot declare features"); } diff --git a/services/core/java/com/android/server/pm/parsing/pkg/AndroidPackage.java b/services/core/java/com/android/server/pm/parsing/pkg/AndroidPackage.java index 792957935870..46b08df1a52e 100644 --- a/services/core/java/com/android/server/pm/parsing/pkg/AndroidPackage.java +++ b/services/core/java/com/android/server/pm/parsing/pkg/AndroidPackage.java @@ -25,7 +25,7 @@ import android.content.pm.PackageParser; import android.content.pm.PermissionGroupInfo; import android.content.pm.SharedLibraryInfo; import android.content.pm.parsing.ParsingPackageRead; -import android.content.pm.parsing.component.ParsedFeature; +import android.content.pm.parsing.component.ParsedAttribution; import android.content.pm.parsing.component.ParsedIntentInfo; import android.content.pm.parsing.component.ParsedPermissionGroup; import android.os.Bundle; @@ -147,7 +147,7 @@ public interface AndroidPackage extends PkgAppInfo, PkgPackageInfo, ParsingPacka List<ParsedPermissionGroup> getPermissionGroups(); @NonNull - List<ParsedFeature> getFeatures(); + List<ParsedAttribution> getAttributions(); /** * Used to determine the default preferred handler of an {@link Intent}. diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 1b5cc6a248e3..64edacd438fc 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -5202,7 +5202,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (dock != null) { int result = ActivityTaskManager.getService() .startActivityAsUser(null, mContext.getBasePackageName(), - mContext.getFeatureId(), dock, + mContext.getAttributionTag(), dock, dock.resolveTypeIfNeeded(mContext.getContentResolver()), null, null, 0, ActivityManager.START_FLAG_ONLY_IF_NEEDED, @@ -5214,7 +5214,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } int result = ActivityTaskManager.getService() .startActivityAsUser(null, mContext.getBasePackageName(), - mContext.getFeatureId(), mHomeIntent, + mContext.getAttributionTag(), mHomeIntent, mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()), null, null, 0, ActivityManager.START_FLAG_ONLY_IF_NEEDED, diff --git a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java index 98579af5835b..7f7d668ea8ac 100644 --- a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java +++ b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java @@ -406,8 +406,8 @@ public class StatsPullAtomService extends SystemService { case FrameworkStatsLog.BATTERY_VOLTAGE: case FrameworkStatsLog.BATTERY_CYCLE_COUNT: return pullHealthHal(atomTag, data); - case FrameworkStatsLog.APP_FEATURES_OPS: - return pullAppFeaturesOps(atomTag, data); + case FrameworkStatsLog.ATTRIBUTED_APP_OPS: + return pullAttributedAppOps(atomTag, data); default: throw new UnsupportedOperationException("Unknown tagId=" + atomTag); } @@ -562,7 +562,7 @@ public class StatsPullAtomService extends SystemService { registerAppsOnExternalStorageInfo(); registerFaceSettings(); registerAppOps(); - registerAppFeaturesOps(); + registerAttributedAppOps(); registerRuntimeAppOpAccessMessage(); registerNotificationRemoteViews(); registerDangerousPermissionState(); @@ -2898,8 +2898,8 @@ public class StatsPullAtomService extends SystemService { return StatsManager.PULL_SUCCESS; } - private void registerAppFeaturesOps() { - int tagId = FrameworkStatsLog.APP_FEATURES_OPS; + private void registerAttributedAppOps() { + int tagId = FrameworkStatsLog.ATTRIBUTED_APP_OPS; mStatsManager.setPullAtomCallback( tagId, null, // use default PullAtomMetadata values @@ -2908,7 +2908,7 @@ public class StatsPullAtomService extends SystemService { ); } - int pullAppFeaturesOps(int atomTag, List<StatsEvent> pulledData) { + int pullAttributedAppOps(int atomTag, List<StatsEvent> pulledData) { final long token = Binder.clearCallingIdentity(); try { AppOpsManager appOps = mContext.getSystemService(AppOpsManager.class); @@ -2946,7 +2946,7 @@ public class StatsPullAtomService extends SystemService { appOps.getHistoricalOps(histOpsRequest, mContext.getMainExecutor(), ops::complete); HistoricalOps histOps = ops.get(EXTERNAL_STATS_SYNC_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); - return processHistoricalOps(histOps, FrameworkStatsLog.APP_FEATURES_OPS, null); + return processHistoricalOps(histOps, FrameworkStatsLog.ATTRIBUTED_APP_OPS, null); } int processHistoricalOps(HistoricalOps histOps, int atomTag, List<StatsEvent> pulledData) { @@ -2956,15 +2956,15 @@ public class StatsPullAtomService extends SystemService { final int uid = uidOps.getUid(); for (int pkgIdx = 0; pkgIdx < uidOps.getPackageCount(); pkgIdx++) { final HistoricalPackageOps packageOps = uidOps.getPackageOpsAt(pkgIdx); - if (atomTag == FrameworkStatsLog.APP_FEATURES_OPS) { - for (int featureIdx = 0; featureIdx < packageOps.getFeatureCount(); - featureIdx++) { - final AppOpsManager.HistoricalFeatureOps featureOps = - packageOps.getFeatureOpsAt(featureIdx); - for (int opIdx = 0; opIdx < featureOps.getOpCount(); opIdx++) { - final AppOpsManager.HistoricalOp op = featureOps.getOpAt(opIdx); + if (atomTag == FrameworkStatsLog.ATTRIBUTED_APP_OPS) { + for (int attributionIdx = 0; + attributionIdx < packageOps.getAttributedOpsCount(); attributionIdx++) { + final AppOpsManager.AttributedHistoricalOps attributedOps = + packageOps.getAttributedOpsAt(attributionIdx); + for (int opIdx = 0; opIdx < attributedOps.getOpCount(); opIdx++) { + final AppOpsManager.HistoricalOp op = attributedOps.getOpAt(opIdx); counter += processHistoricalOp(op, atomTag, pulledData, uid, - packageOps.getPackageName(), featureOps.getFeatureId()); + packageOps.getPackageName(), attributedOps.getTag()); } } } else if (atomTag == FrameworkStatsLog.APP_OPS) { @@ -2981,18 +2981,19 @@ public class StatsPullAtomService extends SystemService { private int processHistoricalOp(AppOpsManager.HistoricalOp op, int atomTag, @Nullable List<StatsEvent> pulledData, int uid, String packageName, - @Nullable String feature) { - if (atomTag == FrameworkStatsLog.APP_FEATURES_OPS) { + @Nullable String attributionTag) { + if (atomTag == FrameworkStatsLog.ATTRIBUTED_APP_OPS) { if (pulledData == null) { // this is size estimation call if (op.getForegroundAccessCount(OP_FLAGS_PULLED) + op.getBackgroundAccessCount( OP_FLAGS_PULLED) == 0) { return 0; } else { - return 32 + packageName.length() + (feature == null ? 1 : feature.length()); + return 32 + packageName.length() + (attributionTag == null ? 1 + : attributionTag.length()); } } else { - if (abs((op.getOpCode() + feature + packageName).hashCode() + RANDOM_SEED) % 100 - >= mAppOpsSamplingRate) { + if (abs((op.getOpCode() + attributionTag + packageName).hashCode() + RANDOM_SEED) + % 100 >= mAppOpsSamplingRate) { return 0; } } @@ -3002,10 +3003,10 @@ public class StatsPullAtomService extends SystemService { e.setAtomId(atomTag); e.writeInt(uid); e.writeString(packageName); - if (atomTag == FrameworkStatsLog.APP_FEATURES_OPS) { - e.writeString(feature); + if (atomTag == FrameworkStatsLog.ATTRIBUTED_APP_OPS) { + e.writeString(attributionTag); } - if (atomTag == FrameworkStatsLog.APP_FEATURES_OPS) { + if (atomTag == FrameworkStatsLog.ATTRIBUTED_APP_OPS) { e.writeString(op.getOpName()); } else { e.writeInt(op.getOpCode()); @@ -3032,7 +3033,7 @@ public class StatsPullAtomService extends SystemService { e.writeBoolean(false); } } - if (atomTag == FrameworkStatsLog.APP_FEATURES_OPS) { + if (atomTag == FrameworkStatsLog.ATTRIBUTED_APP_OPS) { e.writeInt(mAppOpsSamplingRate); } pulledData.add(e.build()); @@ -3055,10 +3056,10 @@ public class StatsPullAtomService extends SystemService { e.writeInt(message.getUid()); e.writeString(message.getPackageName()); e.writeString(message.getOp()); - if (message.getFeatureId() == null) { + if (message.getAttributionTag() == null) { e.writeString(""); } else { - e.writeString(message.getFeatureId()); + e.writeString(message.getAttributionTag()); } e.writeString(message.getMessage()); e.writeInt(message.getSamplingStrategy()); diff --git a/services/core/java/com/android/server/twilight/TwilightService.java b/services/core/java/com/android/server/twilight/TwilightService.java index 761fbf8a0622..88a60ddc5a1e 100644 --- a/services/core/java/com/android/server/twilight/TwilightService.java +++ b/services/core/java/com/android/server/twilight/TwilightService.java @@ -50,7 +50,7 @@ public final class TwilightService extends SystemService implements AlarmManager.OnAlarmListener, Handler.Callback, LocationListener { private static final String TAG = "TwilightService"; - private static final String FEATURE_ID = "TwilightService"; + private static final String ATTRIBUTION_TAG = "TwilightService"; private static final boolean DEBUG = false; private static final int MSG_START_LISTENING = 1; @@ -74,7 +74,7 @@ public final class TwilightService extends SystemService protected TwilightState mLastTwilightState; public TwilightService(Context context) { - super(context.createFeatureContext(FEATURE_ID)); + super(context.createAttributionContext(ATTRIBUTION_TAG)); mHandler = new Handler(Looper.getMainLooper(), this); } diff --git a/services/tests/mockingservicestests/src/com/android/server/appop/AppOpsServiceTest.java b/services/tests/mockingservicestests/src/com/android/server/appop/AppOpsServiceTest.java index 959dc0525e8f..de6f55ba1053 100644 --- a/services/tests/mockingservicestests/src/com/android/server/appop/AppOpsServiceTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/appop/AppOpsServiceTest.java @@ -147,7 +147,7 @@ public class AppOpsServiceTest { AndroidPackage mockMyPkg = mock(AndroidPackage.class); when(mockMyPkg.isPrivileged()).thenReturn(false); when(mockMyPkg.getUid()).thenReturn(mMyUid); - when(mockMyPkg.getFeatures()).thenReturn(Collections.emptyList()); + when(mockMyPkg.getAttributions()).thenReturn(Collections.emptyList()); when(mockPackageManagerInternal.getPackage(sMyPackageName)).thenReturn(mockMyPkg); doReturn(mockPackageManagerInternal).when( diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index 7f4fcc0ea63c..c8432a0e4c90 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -943,8 +943,8 @@ public class TelecomManager { */ public TelecomManager(Context context, ITelecomService telecomServiceImpl) { Context appContext = context.getApplicationContext(); - if (appContext != null && Objects.equals(context.getFeatureId(), - appContext.getFeatureId())) { + if (appContext != null && Objects.equals(context.getAttributionTag(), + appContext.getAttributionTag())) { mContext = appContext; } else { mContext = context; @@ -978,7 +978,7 @@ public class TelecomManager { try { if (isServiceConnected()) { return getTelecomService().getDefaultOutgoingPhoneAccount(uriScheme, - mContext.getOpPackageName(), mContext.getFeatureId()); + mContext.getOpPackageName(), mContext.getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#getDefaultOutgoingPhoneAccount", e); @@ -1176,7 +1176,7 @@ public class TelecomManager { try { if (isServiceConnected()) { return getTelecomService().getSelfManagedPhoneAccounts(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#getSelfManagedPhoneAccounts()", e); @@ -1202,7 +1202,7 @@ public class TelecomManager { try { if (isServiceConnected()) { return getTelecomService().getCallCapablePhoneAccounts(includeDisabledAccounts, - mContext.getOpPackageName(), mContext.getFeatureId()); + mContext.getOpPackageName(), mContext.getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#getCallCapablePhoneAccounts(" + @@ -1506,7 +1506,7 @@ public class TelecomManager { try { if (isServiceConnected()) { return getTelecomService().isVoiceMailNumber(accountHandle, number, - mContext.getOpPackageName(), mContext.getFeatureId()); + mContext.getOpPackageName(), mContext.getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException calling ITelecomService#isVoiceMailNumber.", e); @@ -1528,7 +1528,7 @@ public class TelecomManager { try { if (isServiceConnected()) { return getTelecomService().getVoiceMailNumber(accountHandle, - mContext.getOpPackageName(), mContext.getFeatureId()); + mContext.getOpPackageName(), mContext.getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException calling ITelecomService#hasVoiceMailNumber.", e); @@ -1549,7 +1549,7 @@ public class TelecomManager { try { if (isServiceConnected()) { return getTelecomService().getLine1Number(accountHandle, - mContext.getOpPackageName(), mContext.getFeatureId()); + mContext.getOpPackageName(), mContext.getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException calling ITelecomService#getLine1Number.", e); @@ -1571,7 +1571,7 @@ public class TelecomManager { try { if (isServiceConnected()) { return getTelecomService().isInCall(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException calling isInCall().", e); @@ -1597,7 +1597,7 @@ public class TelecomManager { try { if (isServiceConnected()) { return getTelecomService().isInManagedCall(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException calling isInManagedCall().", e); @@ -1778,7 +1778,7 @@ public class TelecomManager { try { if (isServiceConnected()) { return getTelecomService().isTtySupported(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException attempting to get TTY supported state.", e); @@ -1803,7 +1803,7 @@ public class TelecomManager { try { if (isServiceConnected()) { return getTelecomService().getCurrentTtyMode(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "RemoteException attempting to get the current TTY mode.", e); @@ -2033,7 +2033,7 @@ public class TelecomManager { if (service != null) { try { service.showInCallScreen(showDialpad, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#showCallScreen", e); } @@ -2096,7 +2096,7 @@ public class TelecomManager { } try { service.placeCall(address, extras == null ? new Bundle() : extras, - mContext.getOpPackageName(), mContext.getFeatureId()); + mContext.getOpPackageName(), mContext.getAttributionTag()); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#placeCall", e); } diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index 667e8421f1be..6f0a96a0e1b3 100755 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -4202,7 +4202,7 @@ public class CarrierConfigManager { return null; } return loader.getConfigForSubIdWithFeature(subId, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException ex) { Rlog.e(TAG, "Error getting config for subId " + subId + ": " + ex.toString()); diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index e1fec96c03f4..0b39c63cc5a4 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -1148,7 +1148,7 @@ public class SubscriptionManager { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { subInfo = iSub.getActiveSubscriptionInfo(subId, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } } catch (RemoteException ex) { // ignore it @@ -1182,7 +1182,7 @@ public class SubscriptionManager { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { result = iSub.getActiveSubscriptionInfoForIccId(iccId, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } } catch (RemoteException ex) { // ignore it @@ -1216,7 +1216,7 @@ public class SubscriptionManager { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { result = iSub.getActiveSubscriptionInfoForSimSlotIndex(slotIndex, - mContext.getOpPackageName(), mContext.getFeatureId()); + mContext.getOpPackageName(), mContext.getAttributionTag()); } } catch (RemoteException ex) { // ignore it @@ -1240,7 +1240,7 @@ public class SubscriptionManager { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { result = iSub.getAllSubInfoList(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } } catch (RemoteException ex) { // ignore it @@ -1326,7 +1326,7 @@ public class SubscriptionManager { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { activeList = iSub.getActiveSubscriptionInfoList(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } } catch (RemoteException ex) { // ignore it @@ -1377,7 +1377,7 @@ public class SubscriptionManager { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { result = iSub.getAvailableSubscriptionInfoList(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } } catch (RemoteException ex) { // ignore it @@ -1495,7 +1495,7 @@ public class SubscriptionManager { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { result = iSub.getAllSubInfoCount(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } } catch (RemoteException ex) { // ignore it @@ -1524,7 +1524,7 @@ public class SubscriptionManager { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { result = iSub.getActiveSubInfoCount(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } } catch (RemoteException ex) { // ignore it @@ -2279,7 +2279,7 @@ public class SubscriptionManager { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { resultValue = iSub.getSubscriptionProperty(subId, propKey, - context.getOpPackageName(), context.getFeatureId()); + context.getOpPackageName(), context.getAttributionTag()); } } catch (RemoteException ex) { // ignore it @@ -2443,7 +2443,7 @@ public class SubscriptionManager { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { return iSub.isActiveSubId(subId, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } } catch (RemoteException ex) { } @@ -2706,13 +2706,14 @@ public class SubscriptionManager { @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public @NonNull List<SubscriptionInfo> getOpportunisticSubscriptions() { String contextPkg = mContext != null ? mContext.getOpPackageName() : "<unknown>"; - String contextFeature = mContext != null ? mContext.getFeatureId() : null; + String contextAttributionTag = mContext != null ? mContext.getAttributionTag() : null; List<SubscriptionInfo> subInfoList = null; try { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { - subInfoList = iSub.getOpportunisticSubscriptions(contextPkg, contextFeature); + subInfoList = iSub.getOpportunisticSubscriptions(contextPkg, + contextAttributionTag); } } catch (RemoteException ex) { // ignore it @@ -2951,7 +2952,7 @@ public class SubscriptionManager { public @NonNull List<SubscriptionInfo> getSubscriptionsInGroup(@NonNull ParcelUuid groupUuid) { Preconditions.checkNotNull(groupUuid, "groupUuid can't be null"); String contextPkg = mContext != null ? mContext.getOpPackageName() : "<unknown>"; - String contextFeature = mContext != null ? mContext.getFeatureId() : null; + String contextAttributionTag = mContext != null ? mContext.getAttributionTag() : null; if (VDBG) { logd("[getSubscriptionsInGroup]+ groupUuid:" + groupUuid); } @@ -2960,7 +2961,8 @@ public class SubscriptionManager { try { ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { - result = iSub.getSubscriptionsInGroup(groupUuid, contextPkg, contextFeature); + result = iSub.getSubscriptionsInGroup(groupUuid, contextPkg, + contextAttributionTag); } else { if (!isSystemProcess()) { throw new IllegalStateException("telephony service is null."); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index ce107d26c9fa..38838312d273 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -345,10 +345,10 @@ public class TelephonyManager { mSubId = subId; Context appContext = context.getApplicationContext(); if (appContext != null) { - if (Objects.equals(context.getFeatureId(), appContext.getFeatureId())) { + if (Objects.equals(context.getAttributionTag(), appContext.getAttributionTag())) { mContext = appContext; } else { - mContext = appContext.createFeatureContext(context.getFeatureId()); + mContext = appContext.createAttributionContext(context.getAttributionTag()); } } else { mContext = context; @@ -393,12 +393,12 @@ public class TelephonyManager { } } - private String getFeatureId() { + private String getAttributionTag() { // For legacy reasons the TelephonyManager has API for getting // a static instance with no context set preventing us from - // getting the feature Id. + // getting the attribution tag. if (mContext != null) { - return mContext.getFeatureId(); + return mContext.getAttributionTag(); } return null; } @@ -1896,7 +1896,7 @@ public class TelephonyManager { try { return telephony.getDeviceSoftwareVersionForSlot(slotIndex, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1938,7 +1938,7 @@ public class TelephonyManager { if (telephony == null) return null; return telephony.getDeviceIdWithFeature(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1983,7 +1983,7 @@ public class TelephonyManager { if (info == null) return null; return info.getDeviceIdForPhone(slotIndex, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2041,7 +2041,7 @@ public class TelephonyManager { if (telephony == null) return null; try { - return telephony.getImeiForSlot(slotIndex, getOpPackageName(), getFeatureId()); + return telephony.getImeiForSlot(slotIndex, getOpPackageName(), getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2135,7 +2135,8 @@ public class TelephonyManager { if (telephony == null) return null; try { - String meid = telephony.getMeidForSlot(slotIndex, getOpPackageName(), getFeatureId()); + String meid = telephony.getMeidForSlot(slotIndex, getOpPackageName(), + getAttributionTag()); if (TextUtils.isEmpty(meid)) { Log.d(TAG, "getMeid: return null because MEID is not available"); return null; @@ -2237,7 +2238,7 @@ public class TelephonyManager { if (info == null) return null; String nai = info.getNaiForSubscriber(subId, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); if (Log.isLoggable(TAG, Log.VERBOSE)) { Rlog.v(TAG, "Nai = " + nai); } @@ -2271,7 +2272,7 @@ public class TelephonyManager { } CellIdentity cellIdentity = telephony.getCellLocation(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); CellLocation cl = cellIdentity.asCellLocation(); if (cl == null || cl.isEmpty()) { Rlog.d(TAG, "getCellLocation returning null because CellLocation is empty or" @@ -2355,7 +2356,7 @@ public class TelephonyManager { if (telephony == null) return null; return telephony.getNeighboringCellInfo(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2957,7 +2958,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) { return telephony.getNetworkTypeForSubscriber(subId, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } else { // This can happen when the ITelephony interface is not up yet. return NETWORK_TYPE_UNKNOWN; @@ -3022,7 +3023,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) { return telephony.getDataNetworkTypeForSubscriber(subId, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } else { // This can happen when the ITelephony interface is not up yet. return NETWORK_TYPE_UNKNOWN; @@ -3059,7 +3060,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) { return telephony.getVoiceNetworkTypeForSubscriber(subId, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } else { // This can happen when the ITelephony interface is not up yet. return NETWORK_TYPE_UNKNOWN; @@ -3845,7 +3846,7 @@ public class TelephonyManager { if (info == null) return null; return info.getIccSerialNumberForSubscriber(subId, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -3889,7 +3890,7 @@ public class TelephonyManager { if (telephony == null) return PhoneConstants.LTE_ON_CDMA_UNKNOWN; return telephony.getLteOnCdmaModeForSubscriber(subId, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } catch (RemoteException ex) { // Assume no ICC card if remote exception which shouldn't happen return PhoneConstants.LTE_ON_CDMA_UNKNOWN; @@ -4118,7 +4119,7 @@ public class TelephonyManager { if (info == null) return null; return info.getSubscriberIdForSubscriber(subId, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -4286,7 +4287,7 @@ public class TelephonyManager { if (info == null) return null; return info.getGroupIdLevel1ForSubscriber(getSubId(), mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -4310,7 +4311,7 @@ public class TelephonyManager { if (info == null) return null; return info.getGroupIdLevel1ForSubscriber(subId, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -4361,7 +4362,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) number = telephony.getLine1NumberForDisplay(subId, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -4373,7 +4374,7 @@ public class TelephonyManager { if (info == null) return null; return info.getLine1NumberForSubscriber(subId, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -4452,7 +4453,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) alphaTag = telephony.getLine1AlphaTagForDisplay(subId, - getOpPackageName(), getFeatureId()); + getOpPackageName(), getAttributionTag()); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -4464,7 +4465,7 @@ public class TelephonyManager { if (info == null) return null; return info.getLine1AlphaTagForSubscriber(subId, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -4494,7 +4495,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) return telephony.getMergedSubscriberIds(getSubId(), getOpPackageName(), - getFeatureId()); + getAttributionTag()); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -4551,7 +4552,7 @@ public class TelephonyManager { IPhoneSubInfo info = getSubscriberInfoService(); if (info == null) return null; - return info.getMsisdnForSubscriber(subId, getOpPackageName(), getFeatureId()); + return info.getMsisdnForSubscriber(subId, getOpPackageName(), getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -4586,7 +4587,7 @@ public class TelephonyManager { if (info == null) return null; return info.getVoiceMailNumberForSubscriber(subId, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -4711,7 +4712,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) { return telephony.getVisualVoicemailPackageName(mContext.getOpPackageName(), - getFeatureId(), getSubId()); + getAttributionTag(), getSubId()); } } catch (RemoteException ex) { } catch (NullPointerException ex) { @@ -5148,7 +5149,7 @@ public class TelephonyManager { if (telephony == null) return 0; return telephony.getVoiceMessageCountForSubscriber(subId, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } catch (RemoteException ex) { return 0; } catch (NullPointerException ex) { @@ -5185,7 +5186,7 @@ public class TelephonyManager { if (info == null) return null; return info.getVoiceMailAlphaTagForSubscriber(subId, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -5551,7 +5552,7 @@ public class TelephonyManager { (TelephonyRegistryManager) mContext.getSystemService(Context.TELEPHONY_REGISTRY_SERVICE); if (telephonyRegistry != null) { - telephonyRegistry.listenForSubscriber(mSubId, getOpPackageName(), getFeatureId(), + telephonyRegistry.listenForSubscriber(mSubId, getOpPackageName(), getAttributionTag(), listener, events, notifyNow); } else { Rlog.w(TAG, "telephony registry not ready."); @@ -5584,7 +5585,7 @@ public class TelephonyManager { if (telephony == null) return -1; return telephony.getCdmaEriIconIndexForSubscriber(subId, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } catch (RemoteException ex) { // the phone process is restarting. return -1; @@ -5608,7 +5609,7 @@ public class TelephonyManager { if (telephony == null) return -1; return telephony.getCdmaEriIconModeForSubscriber(subId, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } catch (RemoteException ex) { // the phone process is restarting. return -1; @@ -5640,7 +5641,7 @@ public class TelephonyManager { if (telephony == null) return null; return telephony.getCdmaEriTextForSubscriber(subId, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } catch (RemoteException ex) { // the phone process is restarting. return null; @@ -5732,7 +5733,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony == null) return null; - return telephony.getAllCellInfo(getOpPackageName(), getFeatureId()); + return telephony.getAllCellInfo(getOpPackageName(), getAttributionTag()); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -5832,7 +5833,7 @@ public class TelephonyManager { Binder.restoreCallingIdentity(identity); } } - }, getOpPackageName(), getFeatureId()); + }, getOpPackageName(), getAttributionTag()); } catch (RemoteException ex) { } } @@ -5883,7 +5884,7 @@ public class TelephonyManager { Binder.restoreCallingIdentity(identity); } } - }, getOpPackageName(), getFeatureId(), workSource); + }, getOpPackageName(), getAttributionTag(), workSource); } catch (RemoteException ex) { } } @@ -7169,7 +7170,7 @@ public class TelephonyManager { if (telephony == null) return null; return telephony.getForbiddenPlmns(subId, appType, mContext.getOpPackageName(), - getFeatureId()); + getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -7203,7 +7204,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony == null) return -1; return telephony.setForbiddenPlmns( - getSubId(), APPTYPE_USIM, fplmns, getOpPackageName(), getFeatureId()); + getSubId(), APPTYPE_USIM, fplmns, getOpPackageName(), getAttributionTag()); } catch (RemoteException ex) { Rlog.e(TAG, "setForbiddenPlmns RemoteException: " + ex.getMessage()); } catch (NullPointerException ex) { @@ -7224,7 +7225,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony == null) return new String[0]; - return telephony.getPcscfAddress(apnType, getOpPackageName(), getFeatureId()); + return telephony.getPcscfAddress(apnType, getOpPackageName(), getAttributionTag()); } catch (RemoteException e) { return new String[0]; } @@ -7797,7 +7798,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) { return telephony.getCellNetworkScanResults(getSubId(), getOpPackageName(), - getFeatureId()); + getAttributionTag()); } } catch (RemoteException ex) { Rlog.e(TAG, "getAvailableNetworks RemoteException", ex); @@ -7852,7 +7853,7 @@ public class TelephonyManager { } } return mTelephonyScanManager.requestNetworkScan(getSubId(), request, executor, callback, - getOpPackageName(), getFeatureId()); + getOpPackageName(), getAttributionTag()); } /** @@ -8606,7 +8607,7 @@ public class TelephonyManager { try { ITelephony telephony = getITelephony(); if (telephony != null) - return telephony.isRadioOnWithFeature(getOpPackageName(), getFeatureId()); + return telephony.isRadioOnWithFeature(getOpPackageName(), getAttributionTag()); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isRadioOn", e); } @@ -8980,7 +8981,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) { return telephony.getRadioPowerState(getSlotIndex(), mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } } catch (RemoteException ex) { // This could happen if binder process crashes. @@ -9371,7 +9372,7 @@ public class TelephonyManager { try { ITelephony telephony = getITelephony(); if (telephony != null) - return telephony.isVideoCallingEnabled(getOpPackageName(), getFeatureId()); + return telephony.isVideoCallingEnabled(getOpPackageName(), getAttributionTag()); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isVideoCallingEnabled", e); } @@ -9388,7 +9389,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) { return telephony.canChangeDtmfToneLength(mSubId, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#canChangeDtmfToneLength", e); @@ -9407,7 +9408,7 @@ public class TelephonyManager { try { ITelephony telephony = getITelephony(); if (telephony != null) { - return telephony.isWorldPhone(mSubId, getOpPackageName(), getFeatureId()); + return telephony.isWorldPhone(mSubId, getOpPackageName(), getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isWorldPhone", e); @@ -10135,7 +10136,8 @@ public class TelephonyManager { ITelephony service = getITelephony(); if (service != null) { retval = service.getSubIdForPhoneAccountHandle( - phoneAccountHandle, mContext.getOpPackageName(), mContext.getFeatureId()); + phoneAccountHandle, mContext.getOpPackageName(), + mContext.getAttributionTag()); } } catch (RemoteException ex) { Log.e(TAG, "getSubscriptionId RemoteException", ex); @@ -10276,7 +10278,7 @@ public class TelephonyManager { ITelephony service = getITelephony(); if (service != null) { return service.getServiceStateForSubscriber(subId, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#getServiceStateForSubscriber", e); @@ -10997,7 +10999,8 @@ public class TelephonyManager { try { ITelephony service = getITelephony(); if (service != null) { - return service.getClientRequestStats(getOpPackageName(), getFeatureId(), subId); + return service.getClientRequestStats(getOpPackageName(), getAttributionTag(), + subId); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#getClientRequestStats", e); @@ -11283,7 +11286,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) { return telephony.getNumberOfModemsWithSimultaneousDataConnections( - getSubId(), getOpPackageName(), getFeatureId()); + getSubId(), getOpPackageName(), getAttributionTag()); } } catch (RemoteException ex) { // This could happen if binder process crashes. @@ -11713,7 +11716,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) { return telephony.getEmergencyNumberList(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } else { throw new IllegalStateException("telephony service is null."); } @@ -11769,7 +11772,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) { emergencyNumberList = telephony.getEmergencyNumberList( - mContext.getOpPackageName(), mContext.getFeatureId()); + mContext.getOpPackageName(), mContext.getAttributionTag()); if (emergencyNumberList != null) { for (Integer subscriptionId : emergencyNumberList.keySet()) { List<EmergencyNumber> numberList = emergencyNumberList.get(subscriptionId); @@ -12079,13 +12082,13 @@ public class TelephonyManager { }) public int getPreferredOpportunisticDataSubscription() { String packageName = mContext != null ? mContext.getOpPackageName() : "<unknown>"; - String featureId = mContext != null ? mContext.getFeatureId() : null; + String attributionTag = mContext != null ? mContext.getAttributionTag() : null; int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; try { IOns iOpportunisticNetworkService = getIOns(); if (iOpportunisticNetworkService != null) { subId = iOpportunisticNetworkService.getPreferredDataSubscriptionId( - packageName, featureId); + packageName, attributionTag); } } catch (RemoteException ex) { Rlog.e(TAG, "getPreferredDataSubscriptionId RemoteException", ex); @@ -12215,7 +12218,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) { return telephony.isModemEnabledForSlot(slotIndex, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } } catch (RemoteException ex) { Log.e(TAG, "enableModem RemoteException", ex); @@ -12320,7 +12323,7 @@ public class TelephonyManager { try { ITelephony service = getITelephony(); if (service != null) { - return service.isMultiSimSupported(getOpPackageName(), getFeatureId()); + return service.isMultiSimSupported(getOpPackageName(), getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "isMultiSimSupported RemoteException", e); @@ -12372,7 +12375,7 @@ public class TelephonyManager { ITelephony service = getITelephony(); if (service != null) { return service.doesSwitchMultiSimConfigTriggerReboot(getSubId(), - getOpPackageName(), getFeatureId()); + getOpPackageName(), getAttributionTag()); } } catch (RemoteException e) { Log.e(TAG, "doesSwitchMultiSimConfigTriggerReboot RemoteException", e); diff --git a/telephony/java/android/telephony/ims/RcsUceAdapter.java b/telephony/java/android/telephony/ims/RcsUceAdapter.java index 30306c7f9dea..05ab6bd75878 100644 --- a/telephony/java/android/telephony/ims/RcsUceAdapter.java +++ b/telephony/java/android/telephony/ims/RcsUceAdapter.java @@ -291,7 +291,7 @@ public class RcsUceAdapter { try { imsRcsController.requestCapabilities(mSubId, mContext.getOpPackageName(), - mContext.getFeatureId(), contactNumbers, internalCallback); + mContext.getAttributionTag(), contactNumbers, internalCallback); } catch (RemoteException e) { Log.e(TAG, "Error calling IImsRcsController#requestCapabilities", e); throw new ImsException("Remote IMS Service is not available", @@ -352,7 +352,7 @@ public class RcsUceAdapter { try { // Telephony.SimInfo#IMS_RCS_UCE_ENABLED can also be used to listen to changes to this. return imsRcsController.isUceSettingEnabled(mSubId, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException e) { Log.e(TAG, "Error calling IImsRcsController#isUceSettingEnabled", e); throw new ImsException("Remote IMS Service is not available", diff --git a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java index 59049160e885..c7e5a5ea3311 100644 --- a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java +++ b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java @@ -322,7 +322,7 @@ public class MemoryUsageTest extends InstrumentationTestCase { mAtm.startActivityAndWait(null, getInstrumentation().getContext().getBasePackageName(), - getInstrumentation().getContext().getFeatureId(), mLaunchIntent, + getInstrumentation().getContext().getAttributionTag(), mLaunchIntent, mimeType, null, null, 0, mLaunchIntent.getFlags(), null, null, UserHandle.USER_CURRENT_OR_SELF); } catch (RemoteException e) { diff --git a/tools/aapt2/link/ManifestFixer.cpp b/tools/aapt2/link/ManifestFixer.cpp index 5aa32f868104..bcfce663db00 100644 --- a/tools/aapt2/link/ManifestFixer.cpp +++ b/tools/aapt2/link/ManifestFixer.cpp @@ -366,8 +366,12 @@ bool ManifestFixer::BuildRules(xml::XmlActionExecutor* executor, }); manifest_action["instrumentation"]["meta-data"] = meta_data_action; + // TODO moltmann: Remove manifest_action["feature"]; manifest_action["feature"]["inherit-from"]; + + manifest_action["attribution"]; + manifest_action["attribution"]["inherit-from"]; manifest_action["original-package"]; manifest_action["overlay"]; manifest_action["protected-broadcast"]; diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 96beacd0a236..e1f16a733f68 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -1352,7 +1352,7 @@ public class WifiManager { try { ParceledListSlice<WifiConfiguration> parceledList = mService.getConfiguredNetworks(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); if (parceledList == null) { return Collections.emptyList(); } @@ -1369,7 +1369,7 @@ public class WifiManager { try { ParceledListSlice<WifiConfiguration> parceledList = mService.getPrivilegedConfiguredNetworks(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); if (parceledList == null) { return Collections.emptyList(); } @@ -1898,7 +1898,7 @@ public class WifiManager { @NonNull List<WifiNetworkSuggestion> networkSuggestions) { try { return mService.addNetworkSuggestions( - networkSuggestions, mContext.getOpPackageName(), mContext.getFeatureId()); + networkSuggestions, mContext.getOpPackageName(), mContext.getAttributionTag()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -2680,8 +2680,8 @@ public class WifiManager { public boolean startScan(WorkSource workSource) { try { String packageName = mContext.getOpPackageName(); - String featureId = mContext.getFeatureId(); - return mService.startScan(packageName, featureId); + String attributionTag = mContext.getAttributionTag(); + return mService.startScan(packageName, attributionTag); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -2713,7 +2713,7 @@ public class WifiManager { public WifiInfo getConnectionInfo() { try { return mService.getConnectionInfo(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -2728,7 +2728,7 @@ public class WifiManager { public List<ScanResult> getScanResults() { try { return mService.getScanResults(mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -2759,7 +2759,7 @@ public class WifiManager { try { return mService.getMatchingScanResults( networkSuggestionsToMatch, scanResults, - mContext.getOpPackageName(), mContext.getFeatureId()); + mContext.getOpPackageName(), mContext.getAttributionTag()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -3198,7 +3198,7 @@ public class WifiManager { new LocalOnlyHotspotCallbackProxy(this, executor, callback); try { String packageName = mContext.getOpPackageName(); - String featureId = mContext.getFeatureId(); + String featureId = mContext.getAttributionTag(); int returnCode = mService.startLocalOnlyHotspot(proxy, packageName, featureId, config); if (returnCode != LocalOnlyHotspotCallback.REQUEST_REGISTERED) { @@ -5889,7 +5889,7 @@ public class WifiManager { try { mService.registerSuggestionConnectionStatusListener(new Binder(), new SuggestionConnectionStatusListenerProxy(executor, listener), - listener.hashCode(), mContext.getOpPackageName(), mContext.getFeatureId()); + listener.hashCode(), mContext.getOpPackageName(), mContext.getAttributionTag()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/wifi/java/android/net/wifi/WifiScanner.java b/wifi/java/android/net/wifi/WifiScanner.java index 5e4891950466..d299cdc6cad8 100644 --- a/wifi/java/android/net/wifi/WifiScanner.java +++ b/wifi/java/android/net/wifi/WifiScanner.java @@ -182,7 +182,7 @@ public class WifiScanner { public List<Integer> getAvailableChannels(int band) { try { Bundle bundle = mService.getAvailableChannels(band, mContext.getOpPackageName(), - mContext.getFeatureId()); + mContext.getAttributionTag()); List<Integer> channels = bundle.getIntegerArrayList(GET_AVAILABLE_CHANNELS_EXTRA); return channels == null ? new ArrayList<>() : channels; } catch (RemoteException e) { @@ -963,7 +963,7 @@ public class WifiScanner { scanParams.putParcelable(SCAN_PARAMS_SCAN_SETTINGS_KEY, settings); scanParams.putParcelable(SCAN_PARAMS_WORK_SOURCE_KEY, workSource); scanParams.putString(REQUEST_PACKAGE_NAME_KEY, mContext.getOpPackageName()); - scanParams.putString(REQUEST_FEATURE_ID_KEY, mContext.getFeatureId()); + scanParams.putString(REQUEST_FEATURE_ID_KEY, mContext.getAttributionTag()); mAsyncChannel.sendMessage(CMD_START_BACKGROUND_SCAN, 0, key, scanParams); } @@ -984,7 +984,7 @@ public class WifiScanner { validateChannel(); Bundle scanParams = new Bundle(); scanParams.putString(REQUEST_PACKAGE_NAME_KEY, mContext.getOpPackageName()); - scanParams.putString(REQUEST_FEATURE_ID_KEY, mContext.getFeatureId()); + scanParams.putString(REQUEST_FEATURE_ID_KEY, mContext.getAttributionTag()); mAsyncChannel.sendMessage(CMD_STOP_BACKGROUND_SCAN, 0, key, scanParams); } @@ -1001,7 +1001,7 @@ public class WifiScanner { validateChannel(); Bundle scanParams = new Bundle(); scanParams.putString(REQUEST_PACKAGE_NAME_KEY, mContext.getOpPackageName()); - scanParams.putString(REQUEST_FEATURE_ID_KEY, mContext.getFeatureId()); + scanParams.putString(REQUEST_FEATURE_ID_KEY, mContext.getAttributionTag()); Message reply = mAsyncChannel.sendMessageSynchronously(CMD_GET_SCAN_RESULTS, 0, 0, scanParams); return reply.what == CMD_OP_SUCCEEDED; @@ -1056,7 +1056,7 @@ public class WifiScanner { scanParams.putParcelable(SCAN_PARAMS_SCAN_SETTINGS_KEY, settings); scanParams.putParcelable(SCAN_PARAMS_WORK_SOURCE_KEY, workSource); scanParams.putString(REQUEST_PACKAGE_NAME_KEY, mContext.getOpPackageName()); - scanParams.putString(REQUEST_FEATURE_ID_KEY, mContext.getFeatureId()); + scanParams.putString(REQUEST_FEATURE_ID_KEY, mContext.getAttributionTag()); mAsyncChannel.sendMessage(CMD_START_SINGLE_SCAN, 0, key, scanParams); } @@ -1073,7 +1073,7 @@ public class WifiScanner { validateChannel(); Bundle scanParams = new Bundle(); scanParams.putString(REQUEST_PACKAGE_NAME_KEY, mContext.getOpPackageName()); - scanParams.putString(REQUEST_FEATURE_ID_KEY, mContext.getFeatureId()); + scanParams.putString(REQUEST_FEATURE_ID_KEY, mContext.getAttributionTag()); mAsyncChannel.sendMessage(CMD_STOP_SINGLE_SCAN, 0, key, scanParams); } @@ -1086,7 +1086,7 @@ public class WifiScanner { validateChannel(); Bundle scanParams = new Bundle(); scanParams.putString(REQUEST_PACKAGE_NAME_KEY, mContext.getOpPackageName()); - scanParams.putString(REQUEST_FEATURE_ID_KEY, mContext.getFeatureId()); + scanParams.putString(REQUEST_FEATURE_ID_KEY, mContext.getAttributionTag()); Message reply = mAsyncChannel.sendMessageSynchronously(CMD_GET_SINGLE_SCAN_RESULTS, 0, 0, scanParams); if (reply.what == WifiScanner.CMD_OP_SUCCEEDED) { diff --git a/wifi/java/android/net/wifi/aware/WifiAwareManager.java b/wifi/java/android/net/wifi/aware/WifiAwareManager.java index 2ebaa1805b2b..c2ae17c4bdeb 100644 --- a/wifi/java/android/net/wifi/aware/WifiAwareManager.java +++ b/wifi/java/android/net/wifi/aware/WifiAwareManager.java @@ -267,7 +267,7 @@ public class WifiAwareManager { try { Binder binder = new Binder(); - mService.connect(binder, mContext.getOpPackageName(), mContext.getFeatureId(), + mService.connect(binder, mContext.getOpPackageName(), mContext.getAttributionTag(), new WifiAwareEventCallbackProxy(this, looper, binder, attachCallback, identityChangedListener), configRequest, identityChangedListener != null); @@ -298,7 +298,7 @@ public class WifiAwareManager { } try { - mService.publish(mContext.getOpPackageName(), mContext.getFeatureId(), clientId, + mService.publish(mContext.getOpPackageName(), mContext.getAttributionTag(), clientId, publishConfig, new WifiAwareDiscoverySessionCallbackProxy(this, looper, true, callback, clientId)); @@ -336,7 +336,7 @@ public class WifiAwareManager { } try { - mService.subscribe(mContext.getOpPackageName(), mContext.getFeatureId(), clientId, + mService.subscribe(mContext.getOpPackageName(), mContext.getAttributionTag(), clientId, subscribeConfig, new WifiAwareDiscoverySessionCallbackProxy(this, looper, false, callback, clientId)); diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java index a310ff6404e7..724ccf0d7c45 100644 --- a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java +++ b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java @@ -1180,7 +1180,7 @@ public class WifiP2pManager { == AsyncChannel.STATUS_SUCCESSFUL) { Bundle bundle = new Bundle(); bundle.putString(CALLING_PACKAGE, c.mContext.getOpPackageName()); - bundle.putString(CALLING_FEATURE_ID, c.mContext.getFeatureId()); + bundle.putString(CALLING_FEATURE_ID, c.mContext.getAttributionTag()); bundle.putBinder(CALLING_BINDER, binder); c.mAsyncChannel.sendMessage(UPDATE_CHANNEL_INFO, 0, c.putListener(null), bundle); diff --git a/wifi/java/android/net/wifi/rtt/WifiRttManager.java b/wifi/java/android/net/wifi/rtt/WifiRttManager.java index cb0c5d41df90..865702af695c 100644 --- a/wifi/java/android/net/wifi/rtt/WifiRttManager.java +++ b/wifi/java/android/net/wifi/rtt/WifiRttManager.java @@ -146,8 +146,8 @@ public class WifiRttManager { Binder binder = new Binder(); try { - mService.startRanging(binder, mContext.getOpPackageName(), mContext.getFeatureId(), - workSource, request, new IRttCallback.Stub() { + mService.startRanging(binder, mContext.getOpPackageName(), + mContext.getAttributionTag(), workSource, request, new IRttCallback.Stub() { @Override public void onRangingFailure(int status) throws RemoteException { clearCallingIdentity(); diff --git a/wifi/tests/src/android/net/wifi/WifiScannerTest.java b/wifi/tests/src/android/net/wifi/WifiScannerTest.java index 0cc76b68a15e..4881200aa2b7 100644 --- a/wifi/tests/src/android/net/wifi/WifiScannerTest.java +++ b/wifi/tests/src/android/net/wifi/WifiScannerTest.java @@ -267,7 +267,7 @@ public class WifiScannerTest { assertNull(messageBundle.getParcelable(WifiScanner.SCAN_PARAMS_WORK_SOURCE_KEY)); assertEquals(mContext.getOpPackageName(), messageBundle.getParcelable(WifiScanner.REQUEST_PACKAGE_NAME_KEY)); - assertEquals(mContext.getFeatureId(), + assertEquals(mContext.getAttributionTag(), messageBundle.getParcelable(WifiScanner.REQUEST_FEATURE_ID_KEY)); } @@ -297,7 +297,7 @@ public class WifiScannerTest { Bundle messageBundle = (Bundle) message.obj; assertEquals(mContext.getOpPackageName(), messageBundle.getParcelable(WifiScanner.REQUEST_PACKAGE_NAME_KEY)); - assertEquals(mContext.getFeatureId(), + assertEquals(mContext.getAttributionTag(), messageBundle.getParcelable(WifiScanner.REQUEST_FEATURE_ID_KEY)); } diff --git a/wifi/tests/src/android/net/wifi/rtt/WifiRttManagerTest.java b/wifi/tests/src/android/net/wifi/rtt/WifiRttManagerTest.java index a9dcde07fd72..e6eae416ba78 100644 --- a/wifi/tests/src/android/net/wifi/rtt/WifiRttManagerTest.java +++ b/wifi/tests/src/android/net/wifi/rtt/WifiRttManagerTest.java @@ -71,7 +71,7 @@ public class WifiRttManagerTest { mMockLooperExecutor = mMockLooper.getNewExecutor(); when(mockContext.getOpPackageName()).thenReturn(packageName); - when(mockContext.getFeatureId()).thenReturn(featureId); + when(mockContext.getAttributionTag()).thenReturn(featureId); } /** |