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

Commit b0ab6da4 authored by rongrong.x.gao's avatar rongrong.x.gao Committed by android-build-merger
Browse files

Merge "Launch new Home app when selecting Home app in Settings"

am: f05fc290

Change-Id: I5b9e419fb420351dba76c5dfe1f238f5e4a7e562
parents 57b90397 f05fc290
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.settings.applications.defaultapps;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
@@ -104,6 +105,14 @@ public class DefaultHomePicker extends DefaultAppPickerFragment {
                    IntentFilter.MATCH_CATEGORY_EMPTY,
                    allComponents.toArray(new ComponentName[0]),
                    component);

            // Launch the new Home app so the change is immediately visible even if
            // the Home button is not pressed.
            final Context context = getContext();
            Intent i = new Intent(Intent.ACTION_MAIN);
            i.addCategory(Intent.CATEGORY_HOME);
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(i);
            return true;
        }
        return false;
+4 −1
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ public class DefaultHomePickerTest {
    @Mock
    private PackageManager mPackageManager;

    private Context mContext;
    private DefaultHomePicker mPicker;

    @Before
@@ -85,7 +86,8 @@ public class DefaultHomePickerTest {
        mPicker.onAttach((Context) mActivity);

        ReflectionHelpers.setField(mPicker, "mPm", mPackageManagerWrapper);
        doReturn(RuntimeEnvironment.application).when(mPicker).getContext();
        mContext = spy(RuntimeEnvironment.application);
        doReturn(mContext).when(mPicker).getContext();
    }

    @Test
@@ -94,6 +96,7 @@ public class DefaultHomePickerTest {

        verify(mPackageManagerWrapper).replacePreferredActivity(any(IntentFilter.class),
                anyInt(), any(ComponentName[].class), any(ComponentName.class));
        verify(mContext).startActivity(any());
    }

    @Test