Only show app action button if it is not instant app.

- for instant app, we are showing another set of buttons, and hence the
regular app action buttons should be not be available.

Change-Id: I53f2a10921451c281166e123671c088ab87b2b0d
Fixes: 71919219
Test: make RunSettingsRoboTests
This commit is contained in:
Doris Ling
2018-01-18 14:16:27 -08:00
parent b0e89cd1c3
commit eb2695c2aa
2 changed files with 23 additions and 1 deletions

View File

@@ -93,7 +93,8 @@ public class AppActionButtonPreferenceController extends BasePreferenceControlle
@Override @Override
public int getAvailabilityStatus() { public int getAvailabilityStatus() {
return AVAILABLE; return AppUtils.isInstant(mParent.getPackageInfo().applicationInfo)
? DISABLED_FOR_USER : AVAILABLE;
} }
@Override @Override

View File

@@ -79,6 +79,8 @@ public class AppActionButtonPreferenceControllerTest {
private DevicePolicyManagerWrapper mDevicePolicyManager; private DevicePolicyManagerWrapper mDevicePolicyManager;
@Mock @Mock
private AppInfoDashboardFragment mFragment; private AppInfoDashboardFragment mFragment;
@Mock
private ApplicationInfo mAppInfo;
private Context mContext; private Context mContext;
private AppActionButtonPreferenceController mController; private AppActionButtonPreferenceController mController;
@@ -96,6 +98,25 @@ public class AppActionButtonPreferenceControllerTest {
ReflectionHelpers.setField(mController, "mApplicationFeatureProvider", ReflectionHelpers.setField(mController, "mApplicationFeatureProvider",
mFeatureFactory.applicationFeatureProvider); mFeatureFactory.applicationFeatureProvider);
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager); when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
final PackageInfo packageInfo = mock(PackageInfo.class);
packageInfo.applicationInfo = mAppInfo;
when(mFragment.getPackageInfo()).thenReturn(packageInfo);
}
@Test
public void getAvailabilityStatus_notInstantApp_shouldReturnAvailable() {
ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
(InstantAppDataProvider) (i -> false));
assertThat(mController.getAvailabilityStatus()).isEqualTo(mController.AVAILABLE);
}
@Test
public void getAvailabilityStatus_isInstantApp_shouldReturnDisabled() {
ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
(InstantAppDataProvider) (i -> true));
assertThat(mController.getAvailabilityStatus()).isEqualTo(mController.DISABLED_FOR_USER);
} }
@Test @Test