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

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

Merge "Add ability to show/hide default_home preference."

parents ed383193 b60d2cbb
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -54,4 +54,7 @@

    <!-- Whether wallpaper attribution should be shown or not. -->
    <bool name="config_show_wallpaper_attribution">true</bool>

    <!-- Whether default_home should be shown or not. -->
    <bool name="config_show_default_home">true</bool>
</resources>
+2 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;

import com.android.settings.R;
import com.android.settingslib.wrapper.PackageManagerWrapper;

import java.util.ArrayList;
@@ -53,7 +54,7 @@ public class DefaultHomePreferenceController extends DefaultAppPreferenceControl

    @Override
    public boolean isAvailable() {
        return true;
        return mContext.getResources().getBoolean(R.bool.config_show_default_home);
    }

    @Override
+1 −0
Original line number Diff line number Diff line
@@ -22,4 +22,5 @@
    <bool name="config_display_recent_apps">false</bool>
    <bool name="config_location_mode_available">false</bool>
    <bool name="config_show_wallpaper_attribution">false</bool>
    <bool name="config_show_default_home">false</bool>
</resources>
+5 −6
Original line number Diff line number Diff line
@@ -147,20 +147,19 @@ public class DefaultAppSettingsTest {
    @Test
    public void testNonIndexableKeys_existInXmlLayout() {
        final Context context = spy(RuntimeEnvironment.application);
        final Context mockContext = mock(Context.class);
        when(mockContext.getApplicationContext()).thenReturn(mockContext);
        when(context.getApplicationContext()).thenReturn(context);
        final UserManager userManager = mock(UserManager.class, RETURNS_DEEP_STUBS);

        when(mockContext.getSystemService(Context.USER_SERVICE))
        when(context.getSystemService(Context.USER_SERVICE))
                .thenReturn(userManager);
        when(userManager.getUserInfo(anyInt()).isRestricted()).thenReturn(true);

        when(mockContext.getSystemService(Context.TELEPHONY_SERVICE))
        when(context.getSystemService(Context.TELEPHONY_SERVICE))
                .thenReturn(mock(TelephonyManager.class));
        when(mockContext.getPackageManager())
        when(context.getPackageManager())
                .thenReturn(mock(PackageManager.class));
        final List<String> niks = DefaultAppSettings.SEARCH_INDEX_DATA_PROVIDER
                .getNonIndexableKeys(mockContext);
                .getNonIndexableKeys(context);

        final int xmlId = (new DefaultAppSettings()).getPreferenceScreenResId();

+10 −3
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.util.ReflectionHelpers;

import java.util.Arrays;
@@ -54,18 +55,18 @@ import java.util.Arrays;
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class DefaultHomePreferenceControllerTest {

    @Mock
    private Context mContext;
    @Mock
    private UserManager mUserManager;
    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
    private PackageManagerWrapper mPackageManager;

    private Context mContext;
    private DefaultHomePreferenceController mController;

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        mContext = spy(RuntimeEnvironment.application);
        when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);

        mController = spy(new DefaultHomePreferenceController(mContext));
@@ -73,10 +74,16 @@ public class DefaultHomePreferenceControllerTest {
    }

    @Test
    public void isAlwaysAvailable() {
    public void testDefaultHome_byDefault_shouldBeShown() {
        assertThat(mController.isAvailable()).isTrue();
    }

    @Test
    @Config(qualifiers = "mcc999")
    public void testDefaultHome_ifDisabled_shouldNotBeShown() {
        assertThat(mController.isAvailable()).isFalse();
    }

    @Test
    public void getDefaultApp_shouldGetDefaultBrowserPackage() {
        assertThat(mController.getDefaultAppInfo()).isNotNull();