Loading apex/jobscheduler/service/java/com/android/server/AppStateTrackerImpl.java +2 −5 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import android.app.AppOpsManager; import android.app.AppOpsManager.PackageOps; import android.app.IActivityManager; import android.app.usage.UsageStatsManager; import android.content.AttributionSource; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -747,10 +746,8 @@ public class AppStateTrackerImpl implements AppStateTracker { public void opChanged(int op, int uid, String packageName) throws RemoteException { boolean restricted = false; try { final AttributionSource attributionSource = new AttributionSource.Builder(uid).setPackageName(packageName).build(); restricted = mAppOpsService.checkOperationWithState(TARGET_OP, attributionSource.asState()) != AppOpsManager.MODE_ALLOWED; restricted = mAppOpsService.checkOperation(TARGET_OP, uid, packageName) != AppOpsManager.MODE_ALLOWED; } catch (RemoteException e) { // Shouldn't happen } Loading apex/jobscheduler/service/java/com/android/server/tare/InternalResourceService.java +2 −6 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ import android.app.tare.EconomyManager; import android.app.tare.IEconomyManager; import android.app.usage.UsageEvents; import android.app.usage.UsageStatsManagerInternal; import android.content.AttributionSource; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; Loading Loading @@ -231,11 +230,8 @@ public class InternalResourceService extends SystemService { public void opChanged(int op, int uid, String packageName) { boolean restricted = false; try { final AttributionSource attributionSource = new AttributionSource.Builder(uid) .setPackageName(packageName) .build(); restricted = mAppOpsService.checkOperationWithState( AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, attributionSource.asState()) restricted = mAppOpsService.checkOperation( AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, uid, packageName) != AppOpsManager.MODE_ALLOWED; } catch (RemoteException e) { // Shouldn't happen Loading core/java/android/app/AppOpsManager.java +7 −29 Original line number Diff line number Diff line Loading @@ -8357,9 +8357,7 @@ public class AppOpsManager { */ public int unsafeCheckOpRawNoThrow(int op, int uid, @NonNull String packageName) { try { final AttributionSource attributionSource = new AttributionSource.Builder(uid).setPackageName(packageName).build(); return mService.checkOperationWithStateRaw(op, attributionSource.asState()); return mService.checkOperationRaw(op, uid, packageName, null); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -8522,12 +8520,7 @@ public class AppOpsManager { } } final AttributionSource attributionSource = new AttributionSource.Builder(uid) .setPackageName(packageName) .setAttributionTag(attributionTag) .build(); SyncNotedAppOp syncOp = mService.noteOperationWithState(op, attributionSource.asState(), SyncNotedAppOp syncOp = mService.noteOperation(op, uid, packageName, attributionTag, collectionMode == COLLECT_ASYNC, message, shouldCollectMessage); if (syncOp.getOpMode() == MODE_ALLOWED) { Loading Loading @@ -8767,9 +8760,7 @@ public class AppOpsManager { @UnsupportedAppUsage public int checkOp(int op, int uid, String packageName) { try { final AttributionSource attributionSource = new AttributionSource.Builder(uid).setPackageName(packageName).build(); int mode = mService.checkOperationWithState(op, attributionSource.asState()); int mode = mService.checkOperation(op, uid, packageName); if (mode == MODE_ERRORED) { throw new SecurityException(buildSecurityExceptionMsg(op, uid, packageName)); } Loading @@ -8790,9 +8781,7 @@ public class AppOpsManager { @UnsupportedAppUsage public int checkOpNoThrow(int op, int uid, String packageName) { try { final AttributionSource attributionSource = new AttributionSource.Builder(uid).setPackageName(packageName).build(); int mode = mService.checkOperationWithState(op, attributionSource.asState()); int mode = mService.checkOperation(op, uid, packageName); return mode == AppOpsManager.MODE_FOREGROUND ? AppOpsManager.MODE_ALLOWED : mode; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); Loading Loading @@ -9037,14 +9026,8 @@ public class AppOpsManager { } } final AttributionSource attributionSource = new AttributionSource.Builder(uid) .setPackageName(packageName) .setAttributionTag(attributionTag) .build(); SyncNotedAppOp syncOp = mService.startOperationWithState(token, op, attributionSource.asState(), startIfModeDefault, collectionMode == COLLECT_ASYNC, message, SyncNotedAppOp syncOp = mService.startOperation(token, op, uid, packageName, attributionTag, startIfModeDefault, collectionMode == COLLECT_ASYNC, message, shouldCollectMessage, attributionFlags, attributionChainId); if (syncOp.getOpMode() == MODE_ALLOWED) { Loading Loading @@ -9257,12 +9240,7 @@ public class AppOpsManager { public void finishOp(IBinder token, int op, int uid, @NonNull String packageName, @Nullable String attributionTag) { try { final AttributionSource attributionSource = new AttributionSource.Builder(uid) .setPackageName(packageName) .setAttributionTag(attributionTag) .build(); mService.finishOperationWithState(token, op, attributionSource.asState()); mService.finishOperation(token, op, uid, packageName, attributionTag); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading core/java/android/app/AppOpsManagerInternal.java +29 −22 Original line number Diff line number Diff line Loading @@ -26,12 +26,11 @@ import android.util.SparseArray; import android.util.SparseIntArray; import com.android.internal.app.IAppOpsCallback; import com.android.internal.util.function.HeptFunction; import com.android.internal.util.function.HexFunction; import com.android.internal.util.function.NonaFunction; import com.android.internal.util.function.QuadFunction; import com.android.internal.util.function.QuintConsumer; import com.android.internal.util.function.QuintFunction; import com.android.internal.util.function.TriConsumer; import com.android.internal.util.function.TriFunction; import com.android.internal.util.function.UndecFunction; /** Loading @@ -46,13 +45,15 @@ public abstract class AppOpsManagerInternal { * Allows overriding check operation behavior. * * @param code The op code to check. * @param attributionSource the {@link AttributionSource} responsible for data access * @param uid The UID for which to check. * @param packageName The package for which to check. * @param attributionTag The attribution tag for which to check. * @param raw Whether to check the raw op i.e. not interpret the mode based on UID state. * @param superImpl The super implementation. * @return The app op check result. */ int checkOperation(int code, AttributionSource attributionSource, boolean raw, TriFunction<Integer, AttributionSource, Boolean, Integer> int checkOperation(int code, int uid, String packageName, @Nullable String attributionTag, boolean raw, QuintFunction<Integer, Integer, String, String, Boolean, Integer> superImpl); /** Loading @@ -72,23 +73,25 @@ public abstract class AppOpsManagerInternal { * Allows overriding note operation behavior. * * @param code The op code to note. * @param attributionSource the {@link AttributionSource} responsible for data access * @param uid The UID for which to note. * @param packageName The package for which to note. {@code null} for system package. * @param featureId Id of the feature in the package * @param shouldCollectAsyncNotedOp If an {@link AsyncNotedAppOp} should be collected * @param message The message in the async noted op * @param superImpl The super implementation. * @return The app op note result. */ SyncNotedAppOp noteOperation(int code, AttributionSource attributionSource, boolean shouldCollectAsyncNotedOp, SyncNotedAppOp noteOperation(int code, int uid, @Nullable String packageName, @Nullable String featureId, boolean shouldCollectAsyncNotedOp, @Nullable String message, boolean shouldCollectMessage, @NonNull QuintFunction<Integer, AttributionSource, Boolean, String, Boolean, @NonNull HeptFunction<Integer, Integer, String, String, Boolean, String, Boolean, SyncNotedAppOp> superImpl); /** * Allows overriding note proxy operation behavior. * * @param code The op code to note. * @param attributionSource the {@link AttributionSource} responsible for data access * @param attributionSource The permission identity of the caller. * @param shouldCollectAsyncNotedOp If an {@link AsyncNotedAppOp} should be collected * @param message The message in the async noted op * @param shouldCollectMessage whether to collect messages Loading @@ -107,7 +110,9 @@ public abstract class AppOpsManagerInternal { * * @param token The client state. * @param code The op code to start. * @param attributionSource the {@link AttributionSource} responsible for data access * @param uid The UID for which to note. * @param packageName The package for which to note. {@code null} for system package. * @param attributionTag the attribution tag. * @param startIfModeDefault Whether to start the op of the mode is default. * @param shouldCollectAsyncNotedOp If an {@link AsyncNotedAppOp} should be collected * @param message The message in the async noted op Loading @@ -117,12 +122,12 @@ public abstract class AppOpsManagerInternal { * @param superImpl The super implementation. * @return The app op note result. */ SyncNotedAppOp startOperation(IBinder token, int code, AttributionSource attributionSource, SyncNotedAppOp startOperation(IBinder token, int code, int uid, @Nullable String packageName, @Nullable String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, @Nullable String message, boolean shouldCollectMessage, @AttributionFlags int attributionFlags, int attributionChainId, @NonNull NonaFunction<IBinder, Integer, AttributionSource, Boolean, @NonNull UndecFunction<IBinder, Integer, Integer, String, String, Boolean, Boolean, String, Boolean, Integer, Integer, SyncNotedAppOp> superImpl); /** Loading @@ -130,7 +135,7 @@ public abstract class AppOpsManagerInternal { * * @param clientId The client calling start, represented by an IBinder * @param code The op code to start. * @param attributionSource the {@link AttributionSource} responsible for data access * @param attributionSource The permission identity of the caller. * @param startIfModeDefault Whether to start the op of the mode is default. * @param shouldCollectAsyncNotedOp If an {@link AsyncNotedAppOp} should be collected * @param message The message in the async noted op Loading @@ -156,19 +161,21 @@ public abstract class AppOpsManagerInternal { * * @param clientId The client state. * @param code The op code to finish. * @param attributionSource the {@link AttributionSource} responsible for data access */ default void finishOperation(IBinder clientId, int code, AttributionSource attributionSource, @NonNull TriConsumer<IBinder, Integer, AttributionSource> superImpl) { superImpl.accept(clientId, code, attributionSource); * @param uid The UID for which the op was noted. * @param packageName The package for which it was noted. {@code null} for system package. * @param attributionTag the attribution tag. */ default void finishOperation(IBinder clientId, int code, int uid, String packageName, String attributionTag, @NonNull QuintConsumer<IBinder, Integer, Integer, String, String> superImpl) { superImpl.accept(clientId, code, uid, packageName, attributionTag); } /** * Allows overriding finish proxy op. * * @param code The op code to finish. * @param attributionSource the {@link AttributionSource} responsible for data access * @param attributionSource The permission identity of the caller. * @param skipProxyOperation Whether to skip the proxy in the proxy/proxied operation * @param clientId The client calling finishProxyOperation * @param superImpl The "standard" implementation to potentially call Loading core/java/android/content/AttributionSource.java +0 −6 Original line number Diff line number Diff line Loading @@ -234,12 +234,6 @@ public final class AttributionSource implements Parcelable { return withToken(sDefaultToken); } /** @hide */ public AttributionSource withUid(int uid) { return new AttributionSource(uid, getPid(), getPackageName(), getAttributionTag(), getToken(), mAttributionSourceState.renouncedPermissions, getDeviceId(), getNext()); } /** @hide */ public AttributionSource withPid(int pid) { return new AttributionSource(getUid(), pid, getPackageName(), getAttributionTag(), Loading Loading
apex/jobscheduler/service/java/com/android/server/AppStateTrackerImpl.java +2 −5 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import android.app.AppOpsManager; import android.app.AppOpsManager.PackageOps; import android.app.IActivityManager; import android.app.usage.UsageStatsManager; import android.content.AttributionSource; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -747,10 +746,8 @@ public class AppStateTrackerImpl implements AppStateTracker { public void opChanged(int op, int uid, String packageName) throws RemoteException { boolean restricted = false; try { final AttributionSource attributionSource = new AttributionSource.Builder(uid).setPackageName(packageName).build(); restricted = mAppOpsService.checkOperationWithState(TARGET_OP, attributionSource.asState()) != AppOpsManager.MODE_ALLOWED; restricted = mAppOpsService.checkOperation(TARGET_OP, uid, packageName) != AppOpsManager.MODE_ALLOWED; } catch (RemoteException e) { // Shouldn't happen } Loading
apex/jobscheduler/service/java/com/android/server/tare/InternalResourceService.java +2 −6 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ import android.app.tare.EconomyManager; import android.app.tare.IEconomyManager; import android.app.usage.UsageEvents; import android.app.usage.UsageStatsManagerInternal; import android.content.AttributionSource; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; Loading Loading @@ -231,11 +230,8 @@ public class InternalResourceService extends SystemService { public void opChanged(int op, int uid, String packageName) { boolean restricted = false; try { final AttributionSource attributionSource = new AttributionSource.Builder(uid) .setPackageName(packageName) .build(); restricted = mAppOpsService.checkOperationWithState( AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, attributionSource.asState()) restricted = mAppOpsService.checkOperation( AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, uid, packageName) != AppOpsManager.MODE_ALLOWED; } catch (RemoteException e) { // Shouldn't happen Loading
core/java/android/app/AppOpsManager.java +7 −29 Original line number Diff line number Diff line Loading @@ -8357,9 +8357,7 @@ public class AppOpsManager { */ public int unsafeCheckOpRawNoThrow(int op, int uid, @NonNull String packageName) { try { final AttributionSource attributionSource = new AttributionSource.Builder(uid).setPackageName(packageName).build(); return mService.checkOperationWithStateRaw(op, attributionSource.asState()); return mService.checkOperationRaw(op, uid, packageName, null); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -8522,12 +8520,7 @@ public class AppOpsManager { } } final AttributionSource attributionSource = new AttributionSource.Builder(uid) .setPackageName(packageName) .setAttributionTag(attributionTag) .build(); SyncNotedAppOp syncOp = mService.noteOperationWithState(op, attributionSource.asState(), SyncNotedAppOp syncOp = mService.noteOperation(op, uid, packageName, attributionTag, collectionMode == COLLECT_ASYNC, message, shouldCollectMessage); if (syncOp.getOpMode() == MODE_ALLOWED) { Loading Loading @@ -8767,9 +8760,7 @@ public class AppOpsManager { @UnsupportedAppUsage public int checkOp(int op, int uid, String packageName) { try { final AttributionSource attributionSource = new AttributionSource.Builder(uid).setPackageName(packageName).build(); int mode = mService.checkOperationWithState(op, attributionSource.asState()); int mode = mService.checkOperation(op, uid, packageName); if (mode == MODE_ERRORED) { throw new SecurityException(buildSecurityExceptionMsg(op, uid, packageName)); } Loading @@ -8790,9 +8781,7 @@ public class AppOpsManager { @UnsupportedAppUsage public int checkOpNoThrow(int op, int uid, String packageName) { try { final AttributionSource attributionSource = new AttributionSource.Builder(uid).setPackageName(packageName).build(); int mode = mService.checkOperationWithState(op, attributionSource.asState()); int mode = mService.checkOperation(op, uid, packageName); return mode == AppOpsManager.MODE_FOREGROUND ? AppOpsManager.MODE_ALLOWED : mode; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); Loading Loading @@ -9037,14 +9026,8 @@ public class AppOpsManager { } } final AttributionSource attributionSource = new AttributionSource.Builder(uid) .setPackageName(packageName) .setAttributionTag(attributionTag) .build(); SyncNotedAppOp syncOp = mService.startOperationWithState(token, op, attributionSource.asState(), startIfModeDefault, collectionMode == COLLECT_ASYNC, message, SyncNotedAppOp syncOp = mService.startOperation(token, op, uid, packageName, attributionTag, startIfModeDefault, collectionMode == COLLECT_ASYNC, message, shouldCollectMessage, attributionFlags, attributionChainId); if (syncOp.getOpMode() == MODE_ALLOWED) { Loading Loading @@ -9257,12 +9240,7 @@ public class AppOpsManager { public void finishOp(IBinder token, int op, int uid, @NonNull String packageName, @Nullable String attributionTag) { try { final AttributionSource attributionSource = new AttributionSource.Builder(uid) .setPackageName(packageName) .setAttributionTag(attributionTag) .build(); mService.finishOperationWithState(token, op, attributionSource.asState()); mService.finishOperation(token, op, uid, packageName, attributionTag); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
core/java/android/app/AppOpsManagerInternal.java +29 −22 Original line number Diff line number Diff line Loading @@ -26,12 +26,11 @@ import android.util.SparseArray; import android.util.SparseIntArray; import com.android.internal.app.IAppOpsCallback; import com.android.internal.util.function.HeptFunction; import com.android.internal.util.function.HexFunction; import com.android.internal.util.function.NonaFunction; import com.android.internal.util.function.QuadFunction; import com.android.internal.util.function.QuintConsumer; import com.android.internal.util.function.QuintFunction; import com.android.internal.util.function.TriConsumer; import com.android.internal.util.function.TriFunction; import com.android.internal.util.function.UndecFunction; /** Loading @@ -46,13 +45,15 @@ public abstract class AppOpsManagerInternal { * Allows overriding check operation behavior. * * @param code The op code to check. * @param attributionSource the {@link AttributionSource} responsible for data access * @param uid The UID for which to check. * @param packageName The package for which to check. * @param attributionTag The attribution tag for which to check. * @param raw Whether to check the raw op i.e. not interpret the mode based on UID state. * @param superImpl The super implementation. * @return The app op check result. */ int checkOperation(int code, AttributionSource attributionSource, boolean raw, TriFunction<Integer, AttributionSource, Boolean, Integer> int checkOperation(int code, int uid, String packageName, @Nullable String attributionTag, boolean raw, QuintFunction<Integer, Integer, String, String, Boolean, Integer> superImpl); /** Loading @@ -72,23 +73,25 @@ public abstract class AppOpsManagerInternal { * Allows overriding note operation behavior. * * @param code The op code to note. * @param attributionSource the {@link AttributionSource} responsible for data access * @param uid The UID for which to note. * @param packageName The package for which to note. {@code null} for system package. * @param featureId Id of the feature in the package * @param shouldCollectAsyncNotedOp If an {@link AsyncNotedAppOp} should be collected * @param message The message in the async noted op * @param superImpl The super implementation. * @return The app op note result. */ SyncNotedAppOp noteOperation(int code, AttributionSource attributionSource, boolean shouldCollectAsyncNotedOp, SyncNotedAppOp noteOperation(int code, int uid, @Nullable String packageName, @Nullable String featureId, boolean shouldCollectAsyncNotedOp, @Nullable String message, boolean shouldCollectMessage, @NonNull QuintFunction<Integer, AttributionSource, Boolean, String, Boolean, @NonNull HeptFunction<Integer, Integer, String, String, Boolean, String, Boolean, SyncNotedAppOp> superImpl); /** * Allows overriding note proxy operation behavior. * * @param code The op code to note. * @param attributionSource the {@link AttributionSource} responsible for data access * @param attributionSource The permission identity of the caller. * @param shouldCollectAsyncNotedOp If an {@link AsyncNotedAppOp} should be collected * @param message The message in the async noted op * @param shouldCollectMessage whether to collect messages Loading @@ -107,7 +110,9 @@ public abstract class AppOpsManagerInternal { * * @param token The client state. * @param code The op code to start. * @param attributionSource the {@link AttributionSource} responsible for data access * @param uid The UID for which to note. * @param packageName The package for which to note. {@code null} for system package. * @param attributionTag the attribution tag. * @param startIfModeDefault Whether to start the op of the mode is default. * @param shouldCollectAsyncNotedOp If an {@link AsyncNotedAppOp} should be collected * @param message The message in the async noted op Loading @@ -117,12 +122,12 @@ public abstract class AppOpsManagerInternal { * @param superImpl The super implementation. * @return The app op note result. */ SyncNotedAppOp startOperation(IBinder token, int code, AttributionSource attributionSource, SyncNotedAppOp startOperation(IBinder token, int code, int uid, @Nullable String packageName, @Nullable String attributionTag, boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, @Nullable String message, boolean shouldCollectMessage, @AttributionFlags int attributionFlags, int attributionChainId, @NonNull NonaFunction<IBinder, Integer, AttributionSource, Boolean, @NonNull UndecFunction<IBinder, Integer, Integer, String, String, Boolean, Boolean, String, Boolean, Integer, Integer, SyncNotedAppOp> superImpl); /** Loading @@ -130,7 +135,7 @@ public abstract class AppOpsManagerInternal { * * @param clientId The client calling start, represented by an IBinder * @param code The op code to start. * @param attributionSource the {@link AttributionSource} responsible for data access * @param attributionSource The permission identity of the caller. * @param startIfModeDefault Whether to start the op of the mode is default. * @param shouldCollectAsyncNotedOp If an {@link AsyncNotedAppOp} should be collected * @param message The message in the async noted op Loading @@ -156,19 +161,21 @@ public abstract class AppOpsManagerInternal { * * @param clientId The client state. * @param code The op code to finish. * @param attributionSource the {@link AttributionSource} responsible for data access */ default void finishOperation(IBinder clientId, int code, AttributionSource attributionSource, @NonNull TriConsumer<IBinder, Integer, AttributionSource> superImpl) { superImpl.accept(clientId, code, attributionSource); * @param uid The UID for which the op was noted. * @param packageName The package for which it was noted. {@code null} for system package. * @param attributionTag the attribution tag. */ default void finishOperation(IBinder clientId, int code, int uid, String packageName, String attributionTag, @NonNull QuintConsumer<IBinder, Integer, Integer, String, String> superImpl) { superImpl.accept(clientId, code, uid, packageName, attributionTag); } /** * Allows overriding finish proxy op. * * @param code The op code to finish. * @param attributionSource the {@link AttributionSource} responsible for data access * @param attributionSource The permission identity of the caller. * @param skipProxyOperation Whether to skip the proxy in the proxy/proxied operation * @param clientId The client calling finishProxyOperation * @param superImpl The "standard" implementation to potentially call Loading
core/java/android/content/AttributionSource.java +0 −6 Original line number Diff line number Diff line Loading @@ -234,12 +234,6 @@ public final class AttributionSource implements Parcelable { return withToken(sDefaultToken); } /** @hide */ public AttributionSource withUid(int uid) { return new AttributionSource(uid, getPid(), getPackageName(), getAttributionTag(), getToken(), mAttributionSourceState.renouncedPermissions, getDeviceId(), getNext()); } /** @hide */ public AttributionSource withPid(int pid) { return new AttributionSource(getUid(), pid, getPackageName(), getAttributionTag(), Loading