Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f47d883e authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Forward attributionTag to appopsManager

Bug: 136595429
Test: TH
Change-Id: I38595352ba116d71fc64114f92c7948bff8dce39
parent 65ebb4f6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -113,8 +113,8 @@ public class SmsPermissions {
    public boolean checkCallingCanSendSms(String callingPackage, String callingAttributionTag,
            String message) {
        mContext.enforceCallingPermission(Manifest.permission.SEND_SMS, message);
        return mAppOps.noteOp(AppOpsManager.OPSTR_SEND_SMS, Binder.getCallingUid(), callingPackage)
                == AppOpsManager.MODE_ALLOWED;
        return mAppOps.noteOp(AppOpsManager.OPSTR_SEND_SMS, Binder.getCallingUid(), callingPackage,
                callingAttributionTag, null) == AppOpsManager.MODE_ALLOWED;
    }

    /**
+9 −6
Original line number Diff line number Diff line
@@ -124,8 +124,9 @@ public class SmsPermissionsTest extends TelephonyTest {

    @Test
    public void testCheckCallingSendTextPermissions_persist_noAppOps() {
        Mockito.when(mMockAppOps.noteOp(
                AppOpsManager.OPSTR_SEND_SMS, Binder.getCallingUid(), PACKAGE))
        Mockito.when(
                mMockAppOps.noteOp(AppOpsManager.OPSTR_SEND_SMS, Binder.getCallingUid(), PACKAGE,
                        ATTRIBUTION_TAG, null))
                .thenReturn(AppOpsManager.MODE_ERRORED);
        assertFalse(mSmsPermissionsTest.checkCallingCanSendText(
                true /* persistMessageForNonDefaultSmsApp */, PACKAGE, ATTRIBUTION_TAG, MESSAGE));
@@ -139,8 +140,9 @@ public class SmsPermissionsTest extends TelephonyTest {
                .enforceCallingPermission(Manifest.permission.MODIFY_PHONE_STATE, MESSAGE);
        Mockito.doThrow(new SecurityException(MESSAGE)).when(mMockContext)
                .enforceCallingPermission(Manifest.permission.SEND_SMS, MESSAGE);
        Mockito.when(mMockAppOps.noteOp(
                AppOpsManager.OPSTR_SEND_SMS, Binder.getCallingUid(), PACKAGE))
        Mockito.when(
                mMockAppOps.noteOp(AppOpsManager.OPSTR_SEND_SMS, Binder.getCallingUid(), PACKAGE,
                        ATTRIBUTION_TAG, null))
                .thenReturn(AppOpsManager.MODE_ERRORED);

        assertTrue(mSmsPermissionsTest.checkCallingCanSendText(
@@ -183,8 +185,9 @@ public class SmsPermissionsTest extends TelephonyTest {

    @Test
    public void testCheckCallingSendTextPermissions_noPersist_noAppOps() {
        Mockito.when(mMockAppOps.noteOp(
                AppOpsManager.OPSTR_SEND_SMS, Binder.getCallingUid(), PACKAGE))
        Mockito.when(
                mMockAppOps.noteOp(AppOpsManager.OPSTR_SEND_SMS, Binder.getCallingUid(), PACKAGE,
                        ATTRIBUTION_TAG, null))
                .thenReturn(AppOpsManager.MODE_ERRORED);
        assertFalse(mSmsPermissionsTest.checkCallingCanSendText(
                false /* persistMessageForNonDefaultSmsApp */, PACKAGE, ATTRIBUTION_TAG, MESSAGE));