Merge "Added attribution tag to note listener" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7aa01124c4
@@ -6553,14 +6553,15 @@ public class AppOpsManager {
|
||||
public interface OnOpNotedListener {
|
||||
/**
|
||||
* Called when an op was noted.
|
||||
*
|
||||
* @param code The op code.
|
||||
* @param uid The UID performing the operation.
|
||||
* @param packageName The package performing the operation.
|
||||
* @param attributionTag The attribution tag performing the operation.
|
||||
* @param flags The flags of this op
|
||||
* @param result The result of the note.
|
||||
*/
|
||||
void onOpNoted(int code, int uid, String packageName, @OpFlags int flags, @Mode int result);
|
||||
void onOpNoted(int code, int uid, String packageName, String attributionTag,
|
||||
@OpFlags int flags, @Mode int result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6593,14 +6594,15 @@ public class AppOpsManager {
|
||||
* Called when an op was started.
|
||||
*
|
||||
* Note: This is only for op starts. It is not called when an op is noted or stopped.
|
||||
*
|
||||
* @param op The op code.
|
||||
* @param uid The UID performing the operation.
|
||||
* @param packageName The package performing the operation.
|
||||
* @param attributionTag The attribution tag performing the operation.
|
||||
* @param flags The flags of this op
|
||||
* @param result The result of the start.
|
||||
*/
|
||||
void onOpStarted(int op, int uid, String packageName, @OpFlags int flags, @Mode int result);
|
||||
void onOpStarted(int op, int uid, String packageName, String attributionTag,
|
||||
@OpFlags int flags, @Mode int result);
|
||||
}
|
||||
|
||||
AppOpsManager(Context context, IAppOpsService service) {
|
||||
@@ -7183,8 +7185,9 @@ public class AppOpsManager {
|
||||
}
|
||||
cb = new IAppOpsStartedCallback.Stub() {
|
||||
@Override
|
||||
public void opStarted(int op, int uid, String packageName, int flags, int mode) {
|
||||
callback.onOpStarted(op, uid, packageName, flags, mode);
|
||||
public void opStarted(int op, int uid, String packageName, String attributionTag,
|
||||
int flags, int mode) {
|
||||
callback.onOpStarted(op, uid, packageName, attributionTag, flags, mode);
|
||||
}
|
||||
};
|
||||
mStartedWatchers.put(callback, cb);
|
||||
@@ -7250,8 +7253,9 @@ public class AppOpsManager {
|
||||
}
|
||||
cb = new IAppOpsNotedCallback.Stub() {
|
||||
@Override
|
||||
public void opNoted(int op, int uid, String packageName, int flags, int mode) {
|
||||
callback.onOpNoted(op, uid, packageName, flags, mode);
|
||||
public void opNoted(int op, int uid, String packageName, String attributionTag,
|
||||
int flags, int mode) {
|
||||
callback.onOpNoted(op, uid, packageName, attributionTag, flags, mode);
|
||||
}
|
||||
};
|
||||
mNotedWatchers.put(callback, cb);
|
||||
|
||||
@@ -18,5 +18,5 @@ package com.android.internal.app;
|
||||
|
||||
// Iterface to observe op note/checks of ops
|
||||
oneway interface IAppOpsNotedCallback {
|
||||
void opNoted(int op, int uid, String packageName, int flags, int mode);
|
||||
void opNoted(int op, int uid, String packageName, String attributionTag, int flags, int mode);
|
||||
}
|
||||
|
||||
@@ -18,5 +18,5 @@ package com.android.internal.app;
|
||||
|
||||
// Iterface to observe op starts
|
||||
oneway interface IAppOpsStartedCallback {
|
||||
void opStarted(int op, int uid, String packageName, int flags, int mode);
|
||||
void opStarted(int op, int uid, String packageName, String attributionTag, int flags, int mode);
|
||||
}
|
||||
|
||||
@@ -473,7 +473,8 @@ public class AppOpsControllerImpl extends BroadcastReceiver implements AppOpsCon
|
||||
|
||||
@Override
|
||||
public void onOpNoted(int code, int uid, String packageName,
|
||||
@AppOpsManager.OpFlags int flags, @AppOpsManager.Mode int result) {
|
||||
String attributionTag, @AppOpsManager.OpFlags int flags,
|
||||
@AppOpsManager.Mode int result) {
|
||||
if (DEBUG) {
|
||||
Log.w(TAG, "Noted op: " + code + " with result "
|
||||
+ AppOpsManager.MODE_NAMES[result] + " for package " + packageName);
|
||||
|
||||
@@ -69,6 +69,7 @@ import java.util.List;
|
||||
@TestableLooper.RunWithLooper
|
||||
public class AppOpsControllerTest extends SysuiTestCase {
|
||||
private static final String TEST_PACKAGE_NAME = "test";
|
||||
private static final String TEST_ATTRIBUTION_NAME = "attribution";
|
||||
private static final int TEST_UID = UserHandle.getUid(0, 0);
|
||||
private static final int TEST_UID_OTHER = UserHandle.getUid(1, 0);
|
||||
private static final int TEST_UID_NON_USER_SENSITIVE = UserHandle.getUid(2, 0);
|
||||
@@ -164,7 +165,7 @@ public class AppOpsControllerTest extends SysuiTestCase {
|
||||
mController.onOpActiveChanged(
|
||||
AppOpsManager.OP_RECORD_AUDIO, TEST_UID, TEST_PACKAGE_NAME, true);
|
||||
mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME,
|
||||
AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
TEST_ATTRIBUTION_NAME, AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCallback).onActiveStateChanged(AppOpsManager.OP_RECORD_AUDIO,
|
||||
TEST_UID, TEST_PACKAGE_NAME, true);
|
||||
@@ -218,8 +219,8 @@ public class AppOpsControllerTest extends SysuiTestCase {
|
||||
mController.onOpActiveChanged(AppOpsManager.OP_CAMERA,
|
||||
TEST_UID, TEST_PACKAGE_NAME, true);
|
||||
mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION,
|
||||
TEST_UID, TEST_PACKAGE_NAME, AppOpsManager.OP_FLAG_SELF,
|
||||
AppOpsManager.MODE_ALLOWED);
|
||||
TEST_UID, TEST_PACKAGE_NAME, TEST_ATTRIBUTION_NAME,
|
||||
AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
assertEquals(3, mController.getActiveAppOps().size());
|
||||
}
|
||||
|
||||
@@ -230,8 +231,8 @@ public class AppOpsControllerTest extends SysuiTestCase {
|
||||
mController.onOpActiveChanged(AppOpsManager.OP_CAMERA,
|
||||
TEST_UID_OTHER, TEST_PACKAGE_NAME, true);
|
||||
mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION,
|
||||
TEST_UID, TEST_PACKAGE_NAME, AppOpsManager.OP_FLAG_SELF,
|
||||
AppOpsManager.MODE_ALLOWED);
|
||||
TEST_UID, TEST_PACKAGE_NAME, TEST_ATTRIBUTION_NAME,
|
||||
AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
assertEquals(2,
|
||||
mController.getActiveAppOpsForUser(UserHandle.getUserId(TEST_UID)).size());
|
||||
assertEquals(1,
|
||||
@@ -262,7 +263,7 @@ public class AppOpsControllerTest extends SysuiTestCase {
|
||||
public void opNotedScheduledForRemoval() {
|
||||
mController.setBGHandler(mMockHandler);
|
||||
mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME,
|
||||
AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
TEST_ATTRIBUTION_NAME, AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
verify(mMockHandler).scheduleRemoval(any(AppOpItem.class), anyLong());
|
||||
}
|
||||
|
||||
@@ -274,7 +275,7 @@ public class AppOpsControllerTest extends SysuiTestCase {
|
||||
mController.onOpActiveChanged(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME,
|
||||
true);
|
||||
mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME,
|
||||
AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
TEST_ATTRIBUTION_NAME, AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
assertFalse(mController.getActiveAppOps().isEmpty());
|
||||
|
||||
mController.setListening(false);
|
||||
@@ -288,9 +289,9 @@ public class AppOpsControllerTest extends SysuiTestCase {
|
||||
mController.setBGHandler(mMockHandler);
|
||||
|
||||
mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME,
|
||||
AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
TEST_ATTRIBUTION_NAME, AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME,
|
||||
AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
TEST_ATTRIBUTION_NAME, AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
|
||||
// Only one post to notify subscribers
|
||||
verify(mMockHandler, times(1)).post(any());
|
||||
@@ -304,9 +305,9 @@ public class AppOpsControllerTest extends SysuiTestCase {
|
||||
mController.setBGHandler(mMockHandler);
|
||||
|
||||
mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME,
|
||||
AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
TEST_ATTRIBUTION_NAME, AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME,
|
||||
AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
TEST_ATTRIBUTION_NAME, AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
|
||||
// Only one post to notify subscribers
|
||||
verify(mMockHandler, times(2)).scheduleRemoval(any(), anyLong());
|
||||
@@ -324,7 +325,7 @@ public class AppOpsControllerTest extends SysuiTestCase {
|
||||
AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME, true);
|
||||
|
||||
mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME,
|
||||
AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
TEST_ATTRIBUTION_NAME, AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
|
||||
// Check that we "scheduled" the removal. Don't actually schedule until we are ready to
|
||||
// process messages at a later time.
|
||||
@@ -353,7 +354,7 @@ public class AppOpsControllerTest extends SysuiTestCase {
|
||||
mController.addCallback(new int[]{AppOpsManager.OP_FINE_LOCATION}, mCallback);
|
||||
|
||||
mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME,
|
||||
AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
TEST_ATTRIBUTION_NAME, AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
|
||||
mController.onOpActiveChanged(
|
||||
AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME, true);
|
||||
@@ -382,7 +383,7 @@ public class AppOpsControllerTest extends SysuiTestCase {
|
||||
mController.addCallback(new int[]{AppOpsManager.OP_FINE_LOCATION}, mCallback);
|
||||
|
||||
mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME,
|
||||
AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
TEST_ATTRIBUTION_NAME, AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
|
||||
mController.onOpActiveChanged(
|
||||
AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME, true);
|
||||
@@ -400,7 +401,7 @@ public class AppOpsControllerTest extends SysuiTestCase {
|
||||
AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME, true);
|
||||
|
||||
mController.onOpNoted(AppOpsManager.OP_FINE_LOCATION, TEST_UID, TEST_PACKAGE_NAME,
|
||||
AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
TEST_ATTRIBUTION_NAME, AppOpsManager.OP_FLAG_SELF, AppOpsManager.MODE_ALLOWED);
|
||||
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mCallback).onActiveStateChanged(
|
||||
|
||||
@@ -201,14 +201,15 @@ public final class SensorPrivacyService extends SystemService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpStarted(int code, int uid, String packageName,
|
||||
public void onOpStarted(int code, int uid, String packageName, String attributionTag,
|
||||
@AppOpsManager.OpFlags int flags, @AppOpsManager.Mode int result) {
|
||||
onOpNoted(code, uid, packageName, flags, result);
|
||||
onOpNoted(code, uid, packageName, attributionTag, flags, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpNoted(int code, int uid, String packageName,
|
||||
@AppOpsManager.OpFlags int flags, @AppOpsManager.Mode int result) {
|
||||
String attributionTag, @AppOpsManager.OpFlags int flags,
|
||||
@AppOpsManager.Mode int result) {
|
||||
if (result != MODE_ALLOWED || (flags & AppOpsManager.OP_FLAGS_ALL_TRUSTED) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2111,7 +2111,8 @@ public final class ActiveServices {
|
||||
private final AppOpsManager.OnOpNotedListener mOpNotedCallback =
|
||||
new AppOpsManager.OnOpNotedListener() {
|
||||
@Override
|
||||
public void onOpNoted(int op, int uid, String pkgName, int flags, int result) {
|
||||
public void onOpNoted(int op, int uid, String pkgName,
|
||||
String attributionTag, int flags, int result) {
|
||||
incrementOpCountIfNeeded(op, uid, result);
|
||||
}
|
||||
};
|
||||
@@ -2119,7 +2120,8 @@ public final class ActiveServices {
|
||||
private final AppOpsManager.OnOpStartedListener mOpStartedCallback =
|
||||
new AppOpsManager.OnOpStartedListener() {
|
||||
@Override
|
||||
public void onOpStarted(int op, int uid, String pkgName, int flags,
|
||||
public void onOpStarted(int op, int uid, String pkgName,
|
||||
String attributionTag, int flags,
|
||||
int result) {
|
||||
incrementOpCountIfNeeded(op, uid, result);
|
||||
}
|
||||
|
||||
@@ -3124,7 +3124,7 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
final Ops ops = getOpsLocked(uid, packageName, attributionTag, bypass,
|
||||
true /* edit */);
|
||||
if (ops == null) {
|
||||
scheduleOpNotedIfNeededLocked(code, uid, packageName, flags,
|
||||
scheduleOpNotedIfNeededLocked(code, uid, packageName, attributionTag, flags,
|
||||
AppOpsManager.MODE_IGNORED);
|
||||
if (DEBUG) Slog.d(TAG, "noteOperation: no op for code " + code + " uid " + uid
|
||||
+ " package " + packageName);
|
||||
@@ -3142,7 +3142,7 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
final UidState uidState = ops.uidState;
|
||||
if (isOpRestrictedLocked(uid, code, packageName, bypass)) {
|
||||
attributedOp.rejected(uidState.state, flags);
|
||||
scheduleOpNotedIfNeededLocked(code, uid, packageName, flags,
|
||||
scheduleOpNotedIfNeededLocked(code, uid, packageName, attributionTag, flags,
|
||||
AppOpsManager.MODE_IGNORED);
|
||||
return AppOpsManager.MODE_IGNORED;
|
||||
}
|
||||
@@ -3155,7 +3155,8 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
+ switchCode + " (" + code + ") uid " + uid + " package "
|
||||
+ packageName);
|
||||
attributedOp.rejected(uidState.state, flags);
|
||||
scheduleOpNotedIfNeededLocked(code, uid, packageName, flags, uidMode);
|
||||
scheduleOpNotedIfNeededLocked(code, uid, packageName, attributionTag, flags,
|
||||
uidMode);
|
||||
return uidMode;
|
||||
}
|
||||
} else {
|
||||
@@ -3167,7 +3168,8 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
+ switchCode + " (" + code + ") uid " + uid + " package "
|
||||
+ packageName);
|
||||
attributedOp.rejected(uidState.state, flags);
|
||||
scheduleOpNotedIfNeededLocked(code, uid, packageName, flags, mode);
|
||||
scheduleOpNotedIfNeededLocked(code, uid, packageName, attributionTag, flags,
|
||||
mode);
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
@@ -3177,7 +3179,7 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
+ packageName + (attributionTag == null ? ""
|
||||
: "." + attributionTag));
|
||||
}
|
||||
scheduleOpNotedIfNeededLocked(code, uid, packageName, flags,
|
||||
scheduleOpNotedIfNeededLocked(code, uid, packageName, attributionTag, flags,
|
||||
AppOpsManager.MODE_ALLOWED);
|
||||
attributedOp.accessed(proxyUid, proxyPackageName, proxyAttributionTag, uidState.state,
|
||||
flags);
|
||||
@@ -3580,7 +3582,7 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
final Ops ops = getOpsLocked(uid, packageName, attributionTag, bypass, true /* edit */);
|
||||
if (ops == null) {
|
||||
if (!dryRun) {
|
||||
scheduleOpStartedIfNeededLocked(code, uid, packageName,
|
||||
scheduleOpStartedIfNeededLocked(code, uid, packageName, attributionTag,
|
||||
flags, AppOpsManager.MODE_IGNORED);
|
||||
}
|
||||
if (DEBUG) Slog.d(TAG, "startOperation: no op for code " + code + " uid " + uid
|
||||
@@ -3590,7 +3592,7 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
final Op op = getOpLocked(ops, code, uid, true);
|
||||
if (isOpRestrictedLocked(uid, code, packageName, bypass)) {
|
||||
if (!dryRun) {
|
||||
scheduleOpStartedIfNeededLocked(code, uid, packageName,
|
||||
scheduleOpStartedIfNeededLocked(code, uid, packageName, attributionTag,
|
||||
flags, AppOpsManager.MODE_IGNORED);
|
||||
}
|
||||
return AppOpsManager.MODE_IGNORED;
|
||||
@@ -3611,7 +3613,8 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
}
|
||||
if (!dryRun) {
|
||||
attributedOp.rejected(uidState.state, flags);
|
||||
scheduleOpStartedIfNeededLocked(code, uid, packageName, flags, uidMode);
|
||||
scheduleOpStartedIfNeededLocked(code, uid, packageName, attributionTag,
|
||||
flags, uidMode);
|
||||
}
|
||||
return uidMode;
|
||||
}
|
||||
@@ -3626,7 +3629,8 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
+ packageName);
|
||||
if (!dryRun) {
|
||||
attributedOp.rejected(uidState.state, flags);
|
||||
scheduleOpStartedIfNeededLocked(code, uid, packageName, flags, mode);
|
||||
scheduleOpStartedIfNeededLocked(code, uid, packageName, attributionTag,
|
||||
flags, mode);
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
@@ -3634,7 +3638,7 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
if (DEBUG) Slog.d(TAG, "startOperation: allowing code " + code + " uid " + uid
|
||||
+ " package " + packageName);
|
||||
if (!dryRun) {
|
||||
scheduleOpStartedIfNeededLocked(code, uid, packageName, flags,
|
||||
scheduleOpStartedIfNeededLocked(code, uid, packageName, attributionTag, flags,
|
||||
AppOpsManager.MODE_ALLOWED);
|
||||
try {
|
||||
attributedOp.started(clientId, proxyUid, proxyPackageName, proxyAttributionTag,
|
||||
@@ -3774,7 +3778,7 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
}
|
||||
|
||||
private void scheduleOpStartedIfNeededLocked(int code, int uid, String pkgName,
|
||||
@OpFlags int flags, @Mode int result) {
|
||||
String attributionTag, @OpFlags int flags, @Mode int result) {
|
||||
ArraySet<StartedCallback> dispatchedCallbacks = null;
|
||||
final int callbackListCount = mStartedWatchers.size();
|
||||
for (int i = 0; i < callbackListCount; i++) {
|
||||
@@ -3799,18 +3803,21 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
|
||||
mHandler.sendMessage(PooledLambda.obtainMessage(
|
||||
AppOpsService::notifyOpStarted,
|
||||
this, dispatchedCallbacks, code, uid, pkgName, flags, result));
|
||||
this, dispatchedCallbacks, code, uid, pkgName, attributionTag, flags,
|
||||
result));
|
||||
}
|
||||
|
||||
private void notifyOpStarted(ArraySet<StartedCallback> callbacks,
|
||||
int code, int uid, String packageName, @OpFlags int flags, @Mode int result) {
|
||||
int code, int uid, String packageName, String attributionTag, @OpFlags int flags,
|
||||
@Mode int result) {
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
final int callbackCount = callbacks.size();
|
||||
for (int i = 0; i < callbackCount; i++) {
|
||||
final StartedCallback callback = callbacks.valueAt(i);
|
||||
try {
|
||||
callback.mCallback.opStarted(code, uid, packageName, flags, result);
|
||||
callback.mCallback.opStarted(code, uid, packageName, attributionTag, flags,
|
||||
result);
|
||||
} catch (RemoteException e) {
|
||||
/* do nothing */
|
||||
}
|
||||
@@ -3821,7 +3828,7 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
}
|
||||
|
||||
private void scheduleOpNotedIfNeededLocked(int code, int uid, String packageName,
|
||||
@OpFlags int flags, @Mode int result) {
|
||||
String attributionTag, @OpFlags int flags, @Mode int result) {
|
||||
ArraySet<NotedCallback> dispatchedCallbacks = null;
|
||||
final int callbackListCount = mNotedWatchers.size();
|
||||
for (int i = 0; i < callbackListCount; i++) {
|
||||
@@ -3842,11 +3849,13 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
}
|
||||
mHandler.sendMessage(PooledLambda.obtainMessage(
|
||||
AppOpsService::notifyOpChecked,
|
||||
this, dispatchedCallbacks, code, uid, packageName, flags, result));
|
||||
this, dispatchedCallbacks, code, uid, packageName, attributionTag, flags,
|
||||
result));
|
||||
}
|
||||
|
||||
private void notifyOpChecked(ArraySet<NotedCallback> callbacks,
|
||||
int code, int uid, String packageName, @OpFlags int flags, @Mode int result) {
|
||||
int code, int uid, String packageName, String attributionTag, @OpFlags int flags,
|
||||
@Mode int result) {
|
||||
// There are features watching for checks in our process. The callbacks in
|
||||
// these features may require permissions our remote caller does not have.
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
@@ -3855,7 +3864,8 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
for (int i = 0; i < callbackCount; i++) {
|
||||
final NotedCallback callback = callbacks.valueAt(i);
|
||||
try {
|
||||
callback.mCallback.opNoted(code, uid, packageName, flags, result);
|
||||
callback.mCallback.opNoted(code, uid, packageName, attributionTag, flags,
|
||||
result);
|
||||
} catch (RemoteException e) {
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
@@ -66,11 +66,13 @@ public class AppOpsNotedWatcherTest {
|
||||
inOrder.verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
|
||||
.times(1)).onOpNoted(eq(AppOpsManager.OP_FINE_LOCATION),
|
||||
eq(Process.myUid()), eq(getContext().getPackageName()),
|
||||
eq(AppOpsManager.OP_FLAG_SELF), eq(AppOpsManager.MODE_ALLOWED));
|
||||
eq(getContext().getAttributionTag()), eq(AppOpsManager.OP_FLAG_SELF),
|
||||
eq(AppOpsManager.MODE_ALLOWED));
|
||||
inOrder.verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
|
||||
.times(1)).onOpNoted(eq(AppOpsManager.OP_CAMERA),
|
||||
eq(Process.myUid()), eq(getContext().getPackageName()),
|
||||
eq(AppOpsManager.OP_FLAG_SELF), eq(AppOpsManager.MODE_ALLOWED));
|
||||
eq(getContext().getAttributionTag()), eq(AppOpsManager.OP_FLAG_SELF),
|
||||
eq(AppOpsManager.MODE_ALLOWED));
|
||||
|
||||
// Stop watching
|
||||
appOpsManager.stopWatchingNoted(listener);
|
||||
@@ -94,7 +96,8 @@ public class AppOpsNotedWatcherTest {
|
||||
verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
|
||||
.times(2)).onOpNoted(eq(AppOpsManager.OP_FINE_LOCATION),
|
||||
eq(Process.myUid()), eq(getContext().getPackageName()),
|
||||
eq(AppOpsManager.OP_FLAG_SELF), eq(AppOpsManager.MODE_ALLOWED));
|
||||
eq(getContext().getAttributionTag()), eq(AppOpsManager.OP_FLAG_SELF),
|
||||
eq(AppOpsManager.MODE_ALLOWED));
|
||||
|
||||
// Finish up
|
||||
appOpsManager.stopWatchingNoted(listener);
|
||||
|
||||
@@ -63,11 +63,13 @@ public class AppOpsStartedWatcherTest {
|
||||
inOrder.verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
|
||||
.times(1)).onOpStarted(eq(AppOpsManager.OP_FINE_LOCATION),
|
||||
eq(Process.myUid()), eq(getContext().getPackageName()),
|
||||
eq(AppOpsManager.OP_FLAG_SELF), eq(AppOpsManager.MODE_ALLOWED));
|
||||
eq(getContext().getAttributionTag()), eq(AppOpsManager.OP_FLAG_SELF),
|
||||
eq(AppOpsManager.MODE_ALLOWED));
|
||||
inOrder.verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
|
||||
.times(1)).onOpStarted(eq(AppOpsManager.OP_CAMERA),
|
||||
eq(Process.myUid()), eq(getContext().getPackageName()),
|
||||
eq(AppOpsManager.OP_FLAG_SELF), eq(AppOpsManager.MODE_ALLOWED));
|
||||
eq(getContext().getAttributionTag()), eq(AppOpsManager.OP_FLAG_SELF),
|
||||
eq(AppOpsManager.MODE_ALLOWED));
|
||||
|
||||
// Stop watching
|
||||
appOpsManager.stopWatchingStarted(listener);
|
||||
@@ -91,7 +93,8 @@ public class AppOpsStartedWatcherTest {
|
||||
verify(listener, timeout(NOTIFICATION_TIMEOUT_MILLIS)
|
||||
.times(2)).onOpStarted(eq(AppOpsManager.OP_CAMERA),
|
||||
eq(Process.myUid()), eq(getContext().getPackageName()),
|
||||
eq(AppOpsManager.OP_FLAG_SELF), eq(AppOpsManager.MODE_ALLOWED));
|
||||
eq(getContext().getAttributionTag()), eq(AppOpsManager.OP_FLAG_SELF),
|
||||
eq(AppOpsManager.MODE_ALLOWED));
|
||||
verifyNoMoreInteractions(listener);
|
||||
|
||||
// Finish up
|
||||
|
||||
Reference in New Issue
Block a user