Merge "Launch new Home app when selecting Home app in Settings"
diff --git a/src/com/android/settings/applications/defaultapps/DefaultHomePicker.java b/src/com/android/settings/applications/defaultapps/DefaultHomePicker.java
index dca7ad1..aebe343 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultHomePicker.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultHomePicker.java
@@ -18,6 +18,7 @@
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 @@
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;
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePickerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePickerTest.java
index b500637..4724620 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePickerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultHomePickerTest.java
@@ -73,6 +73,7 @@
@Mock
private PackageManager mPackageManager;
+ private Context mContext;
private DefaultHomePicker mPicker;
@Before
@@ -85,7 +86,8 @@
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 @@
verify(mPackageManagerWrapper).replacePreferredActivity(any(IntentFilter.class),
anyInt(), any(ComponentName[].class), any(ComponentName.class));
+ verify(mContext).startActivity(any());
}
@Test