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

Commit 937dfdf2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents de7135fb eb2695c2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -93,7 +93,8 @@ public class AppActionButtonPreferenceController extends BasePreferenceControlle

    @Override
    public int getAvailabilityStatus() {
        return AVAILABLE;
        return AppUtils.isInstant(mParent.getPackageInfo().applicationInfo)
            ? DISABLED_FOR_USER : AVAILABLE;
    }

    @Override
+21 −0
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ public class AppActionButtonPreferenceControllerTest {
    private DevicePolicyManagerWrapper mDevicePolicyManager;
    @Mock
    private AppInfoDashboardFragment mFragment;
    @Mock
    private ApplicationInfo mAppInfo;

    private Context mContext;
    private AppActionButtonPreferenceController mController;
@@ -96,6 +98,25 @@ public class AppActionButtonPreferenceControllerTest {
        ReflectionHelpers.setField(mController, "mApplicationFeatureProvider",
                mFeatureFactory.applicationFeatureProvider);
        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