Loading src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java +3 −4 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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: Loading tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java +4 −7 Original line number Diff line number Diff line Loading @@ -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), Loading Loading @@ -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); Loading @@ -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 Loading Loading
src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java +3 −4 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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: Loading
tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java +4 −7 Original line number Diff line number Diff line Loading @@ -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), Loading Loading @@ -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); Loading @@ -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 Loading