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

Commit eb2695c2 authored by Doris Ling's avatar Doris Ling
Browse files

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
parent b0e89cd1
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -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
+21 −0
Original line number Original line Diff line number Diff line
@@ -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