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

Commit c3f6c0d5 authored by Vania Januar's avatar Vania Januar Committed by Android (Google) Code Review
Browse files

Merge "Replace placeholder ROLE_ASSISTANT with ROLE_NOTES."

parents c0e31b3b e5651cd8
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -91,8 +91,7 @@ public class StylusDevicesController extends AbstractPreferenceController implem
            return null;
        }

        // TODO(b/254834764): replace with notes role once merged
        List<String> roleHolders = rm.getRoleHoldersAsUser(RoleManager.ROLE_ASSISTANT,
        List<String> roleHolders = rm.getRoleHoldersAsUser(RoleManager.ROLE_NOTES,
                mContext.getUser());
        if (roleHolders.isEmpty()) {
            return null;
@@ -113,6 +112,7 @@ public class StylusDevicesController extends AbstractPreferenceController implem
        pref.setKey(KEY_DEFAULT_NOTES);
        pref.setTitle(mContext.getString(R.string.stylus_default_notes_app));
        pref.setIcon(R.drawable.ic_article);
        pref.setOnPreferenceClickListener(this);
        pref.setEnabled(true);
        pref.setSummary(appName);
        return pref;
@@ -148,9 +148,8 @@ public class StylusDevicesController extends AbstractPreferenceController implem
            case KEY_DEFAULT_NOTES:
                PackageManager pm = mContext.getPackageManager();
                String packageName = pm.getPermissionControllerPackageName();
                // TODO(b/254834764): replace with notes role once merged
                Intent intent = new Intent(Intent.ACTION_MANAGE_DEFAULT_APP).setPackage(
                        packageName).putExtra(Intent.EXTRA_ROLE_NAME, RoleManager.ROLE_ASSISTANT);
                        packageName).putExtra(Intent.EXTRA_ROLE_NAME, RoleManager.ROLE_NOTES);
                mContext.startActivity(intent);
                break;
            case KEY_HANDWRITING:
+4 −7
Original line number Diff line number Diff line
@@ -99,8 +99,7 @@ public class StylusDevicesControllerTest {
        when(mContext.getSystemService(RoleManager.class)).thenReturn(mRm);
        doNothing().when(mContext).startActivity(any());

        // TODO(b/254834764): notes role placeholder
        when(mRm.getRoleHoldersAsUser(eq(RoleManager.ROLE_ASSISTANT), any(UserHandle.class)))
        when(mRm.getRoleHoldersAsUser(eq(RoleManager.ROLE_NOTES), any(UserHandle.class)))
                .thenReturn(Collections.singletonList(NOTES_PACKAGE_NAME));
        when(mContext.getPackageManager()).thenReturn(mPm);
        when(mPm.getApplicationInfo(eq(NOTES_PACKAGE_NAME),
@@ -237,8 +236,7 @@ public class StylusDevicesControllerTest {

    @Test
    public void defaultNotesPreference_noRoleHolder_hidesNotesRoleApp() {
        // TODO(b/254834764): replace with notes role once merged
        when(mRm.getRoleHoldersAsUser(eq(RoleManager.ROLE_ASSISTANT), any(UserHandle.class)))
        when(mRm.getRoleHoldersAsUser(eq(RoleManager.ROLE_NOTES), any(UserHandle.class)))
                .thenReturn(Collections.emptyList());
        showScreen(mController);

@@ -258,14 +256,13 @@ public class StylusDevicesControllerTest {
        showScreen(mController);
        Preference defaultNotesPref = mPreferenceContainer.getPreference(0);
        mController.onPreferenceClick(defaultNotesPref);
        verify(mContext).startActivity(captor.capture());

        verify(mContext).startActivity(captor.capture());
        Intent intent = captor.getValue();
        assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MANAGE_DEFAULT_APP);
        assertThat(intent.getPackage()).isEqualTo(permissionPackageName);
        // TODO(b/254834764): when notes role is merged
        assertThat(intent.getStringExtra(Intent.EXTRA_ROLE_NAME)).isEqualTo(
                RoleManager.ROLE_ASSISTANT);
                RoleManager.ROLE_NOTES);
    }

    @Test