Loading core/java/android/os/DropBoxManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -375,7 +375,8 @@ public class DropBoxManager { @RequiresPermission(allOf = { READ_LOGS, PACKAGE_USAGE_STATS }) public @Nullable Entry getNextEntry(String tag, long msec) { try { return mService.getNextEntry(tag, msec, mContext.getOpPackageName()); return mService.getNextEntryWithAttribution(tag, msec, mContext.getOpPackageName(), mContext.getAttributionTag()); } catch (SecurityException e) { if (mContext.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.P) { throw e; Loading core/java/com/android/internal/os/IDropBoxManagerService.aidl +5 −1 Original line number Diff line number Diff line Loading @@ -37,6 +37,10 @@ interface IDropBoxManagerService { boolean isTagEnabled(String tag); /** @see DropBoxManager#getNextEntry */ @UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk=30, publicAlternatives="Use {@link android.os.DropBoxManager#getNextEntry} instead") DropBoxManager.Entry getNextEntry(String tag, long millis, String packageName); DropBoxManager.Entry getNextEntryWithAttribution(String tag, long millis, String packageName, String attributionTag); } services/core/java/com/android/server/DropBoxManagerService.java +16 −6 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.AppOpsManager; import android.content.BroadcastReceiver; Loading Loading @@ -159,7 +160,14 @@ public final class DropBoxManagerService extends SystemService { @Override public DropBoxManager.Entry getNextEntry(String tag, long millis, String callingPackage) { return DropBoxManagerService.this.getNextEntry(tag, millis, callingPackage); return getNextEntryWithAttribution(tag, millis, callingPackage, null); } @Override public DropBoxManager.Entry getNextEntryWithAttribution(String tag, long millis, String callingPackage, String callingAttributionTag) { return DropBoxManagerService.this.getNextEntry(tag, millis, callingPackage, callingAttributionTag); } @Override Loading Loading @@ -470,7 +478,8 @@ public final class DropBoxManagerService extends SystemService { } } private boolean checkPermission(int callingUid, String callingPackage) { private boolean checkPermission(int callingUid, String callingPackage, @Nullable String callingAttributionTag) { // If callers have this permission, then we don't need to check // USAGE_STATS, because they are part of the system and have agreed to // check USAGE_STATS before passing the data along. Loading @@ -484,8 +493,9 @@ public final class DropBoxManagerService extends SystemService { android.Manifest.permission.READ_LOGS, TAG); // Callers also need the ability to read usage statistics switch (getContext().getSystemService(AppOpsManager.class) .noteOp(AppOpsManager.OP_GET_USAGE_STATS, callingUid, callingPackage)) { switch (getContext().getSystemService(AppOpsManager.class).noteOp( AppOpsManager.OP_GET_USAGE_STATS, callingUid, callingPackage, callingAttributionTag, null)) { case AppOpsManager.MODE_ALLOWED: return true; case AppOpsManager.MODE_DEFAULT: Loading @@ -498,8 +508,8 @@ public final class DropBoxManagerService extends SystemService { } public synchronized DropBoxManager.Entry getNextEntry(String tag, long millis, String callingPackage) { if (!checkPermission(Binder.getCallingUid(), callingPackage)) { String callingPackage, @Nullable String callingAttributionTag) { if (!checkPermission(Binder.getCallingUid(), callingPackage, callingAttributionTag)) { return null; } Loading Loading
core/java/android/os/DropBoxManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -375,7 +375,8 @@ public class DropBoxManager { @RequiresPermission(allOf = { READ_LOGS, PACKAGE_USAGE_STATS }) public @Nullable Entry getNextEntry(String tag, long msec) { try { return mService.getNextEntry(tag, msec, mContext.getOpPackageName()); return mService.getNextEntryWithAttribution(tag, msec, mContext.getOpPackageName(), mContext.getAttributionTag()); } catch (SecurityException e) { if (mContext.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.P) { throw e; Loading
core/java/com/android/internal/os/IDropBoxManagerService.aidl +5 −1 Original line number Diff line number Diff line Loading @@ -37,6 +37,10 @@ interface IDropBoxManagerService { boolean isTagEnabled(String tag); /** @see DropBoxManager#getNextEntry */ @UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk=30, publicAlternatives="Use {@link android.os.DropBoxManager#getNextEntry} instead") DropBoxManager.Entry getNextEntry(String tag, long millis, String packageName); DropBoxManager.Entry getNextEntryWithAttribution(String tag, long millis, String packageName, String attributionTag); }
services/core/java/com/android/server/DropBoxManagerService.java +16 −6 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.AppOpsManager; import android.content.BroadcastReceiver; Loading Loading @@ -159,7 +160,14 @@ public final class DropBoxManagerService extends SystemService { @Override public DropBoxManager.Entry getNextEntry(String tag, long millis, String callingPackage) { return DropBoxManagerService.this.getNextEntry(tag, millis, callingPackage); return getNextEntryWithAttribution(tag, millis, callingPackage, null); } @Override public DropBoxManager.Entry getNextEntryWithAttribution(String tag, long millis, String callingPackage, String callingAttributionTag) { return DropBoxManagerService.this.getNextEntry(tag, millis, callingPackage, callingAttributionTag); } @Override Loading Loading @@ -470,7 +478,8 @@ public final class DropBoxManagerService extends SystemService { } } private boolean checkPermission(int callingUid, String callingPackage) { private boolean checkPermission(int callingUid, String callingPackage, @Nullable String callingAttributionTag) { // If callers have this permission, then we don't need to check // USAGE_STATS, because they are part of the system and have agreed to // check USAGE_STATS before passing the data along. Loading @@ -484,8 +493,9 @@ public final class DropBoxManagerService extends SystemService { android.Manifest.permission.READ_LOGS, TAG); // Callers also need the ability to read usage statistics switch (getContext().getSystemService(AppOpsManager.class) .noteOp(AppOpsManager.OP_GET_USAGE_STATS, callingUid, callingPackage)) { switch (getContext().getSystemService(AppOpsManager.class).noteOp( AppOpsManager.OP_GET_USAGE_STATS, callingUid, callingPackage, callingAttributionTag, null)) { case AppOpsManager.MODE_ALLOWED: return true; case AppOpsManager.MODE_DEFAULT: Loading @@ -498,8 +508,8 @@ public final class DropBoxManagerService extends SystemService { } public synchronized DropBoxManager.Entry getNextEntry(String tag, long millis, String callingPackage) { if (!checkPermission(Binder.getCallingUid(), callingPackage)) { String callingPackage, @Nullable String callingAttributionTag) { if (!checkPermission(Binder.getCallingUid(), callingPackage, callingAttributionTag)) { return null; } Loading