Fix crash when trying to open app info page
Fixed a crash in App info page that happens when no work profile exists, also fixed some unit tests. Fixes: 152933121 Test: make RunSettingsRoboTests ROBOTEST_FILTER=InteractAcrossProfilesPreferenceControllerTest Test: make RunSettingsRoboTests ROBOTEST_FILTER=InteractAcrossProfilesControllerTest Test: make RunSettingsRoboTests ROBOTEST_FILTER=InteractAcrossProfilesSettingsTest Test: make RunSettingsRoboTests ROBOTEST_FILTER=InteractAcrossProfilesDetailsTest Change-Id: I7a1e5857cb1e10b96b33abd64359ba30459b1b13
This commit is contained in:
committed by
Kholoud Mohamed
parent
0d3732a595
commit
f9a03cd415
@@ -240,6 +240,9 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
|
|||||||
Context context, String packageName) {
|
Context context, String packageName) {
|
||||||
UserManager userManager = context.getSystemService(UserManager.class);
|
UserManager userManager = context.getSystemService(UserManager.class);
|
||||||
UserHandle workProfile = InteractAcrossProfilesSettings.getWorkProfile(userManager);
|
UserHandle workProfile = InteractAcrossProfilesSettings.getWorkProfile(userManager);
|
||||||
|
if (workProfile == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
UserHandle personalProfile = userManager.getProfileParent(workProfile);
|
UserHandle personalProfile = userManager.getProfileParent(workProfile);
|
||||||
return context.getSystemService(
|
return context.getSystemService(
|
||||||
CrossProfileApps.class).canConfigureInteractAcrossProfiles(packageName)
|
CrossProfileApps.class).canConfigureInteractAcrossProfiles(packageName)
|
||||||
|
@@ -75,7 +75,7 @@ public class InteractAcrossProfilesDetailsTest {
|
|||||||
|
|
||||||
assertThat(InteractAcrossProfilesDetails.getPreferenceSummary(
|
assertThat(InteractAcrossProfilesDetails.getPreferenceSummary(
|
||||||
mContext, CROSS_PROFILE_PACKAGE_NAME))
|
mContext, CROSS_PROFILE_PACKAGE_NAME))
|
||||||
.isEqualTo(mContext.getString(R.string.app_permission_summary_allowed));
|
.isEqualTo(mContext.getString(R.string.interact_across_profiles_summary_allowed));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -98,7 +98,21 @@ public class InteractAcrossProfilesDetailsTest {
|
|||||||
|
|
||||||
assertThat(InteractAcrossProfilesDetails.getPreferenceSummary(
|
assertThat(InteractAcrossProfilesDetails.getPreferenceSummary(
|
||||||
mContext, CROSS_PROFILE_PACKAGE_NAME))
|
mContext, CROSS_PROFILE_PACKAGE_NAME))
|
||||||
.isEqualTo(mContext.getString(R.string.app_permission_summary_not_allowed));
|
.isEqualTo(mContext.getString(
|
||||||
|
R.string.interact_across_profiles_summary_not_allowed));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getPreferenceSummary_noWorkProfile_returnsNotAllowed() {
|
||||||
|
shadowOf(mUserManager).addUser(
|
||||||
|
PERSONAL_PROFILE_ID, "personal-profile"/* name */, 0/* flags */);
|
||||||
|
shadowOf(mPackageManager).setInstalledPackagesForUserId(
|
||||||
|
PERSONAL_PROFILE_ID, ImmutableList.of(CROSS_PROFILE_PACKAGE_NAME));
|
||||||
|
|
||||||
|
assertThat(InteractAcrossProfilesDetails.getPreferenceSummary(
|
||||||
|
mContext, CROSS_PROFILE_PACKAGE_NAME))
|
||||||
|
.isEqualTo(mContext.getString(
|
||||||
|
R.string.interact_across_profiles_summary_not_allowed));
|
||||||
}
|
}
|
||||||
|
|
||||||
private PermissionInfo createCrossProfilesPermissionInfo() {
|
private PermissionInfo createCrossProfilesPermissionInfo() {
|
||||||
|
Reference in New Issue
Block a user