Switch to listening for USER_INITIALIZE broadcast in the Settings app.

The PRE_BOOT_COMPLETED broadcast is no longer sent when creating a new
profile.
Also, we no longer listen to BOOT_COMPLETED as that adds too much overload.

Bug: 17102460
Change-Id: I05eb56c7a05748e8a91b9717966c20ac586d90ef
This commit is contained in:
Alexandra Gherghina
2014-08-18 13:16:17 +01:00
parent f14fa7ed4e
commit f2e39f2ee4
2 changed files with 5 additions and 3 deletions

View File

@@ -97,8 +97,7 @@
<receiver android:name="ManagedProfileSetup"> <receiver android:name="ManagedProfileSetup">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/> <action android:name="android.intent.action.USER_INITIALIZE"/>
<action android:name="android.intent.action.PRE_BOOT_COMPLETED"/>
</intent-filter> </intent-filter>
</receiver> </receiver>

View File

@@ -22,6 +22,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.util.Log;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
@@ -37,6 +38,7 @@ import static android.content.pm.PackageManager.GET_RESOLVED_FILTER;
* adds cross-profile intent filters for the appropriate Settings activities). * adds cross-profile intent filters for the appropriate Settings activities).
*/ */
public class ManagedProfileSetup extends BroadcastReceiver { public class ManagedProfileSetup extends BroadcastReceiver {
private static final String TAG = "Settings";
private static final String PRIMARY_PROFILE_SETTING = private static final String PRIMARY_PROFILE_SETTING =
"com.android.settings.PRIMARY_PROFILE_CONTROLLED"; "com.android.settings.PRIMARY_PROFILE_CONTROLLED";
@@ -46,7 +48,8 @@ public class ManagedProfileSetup extends BroadcastReceiver {
if (!Utils.isManagedProfile(um)) { if (!Utils.isManagedProfile(um)) {
return; return;
} }
Log.i(TAG, "Received broadcast: " + broadcast.getAction()
+ ". Setting up intent forwarding for managed profile.");
final PackageManager pm = context.getPackageManager(); final PackageManager pm = context.getPackageManager();
// Clear any previous intent forwarding we set up // Clear any previous intent forwarding we set up
pm.clearCrossProfileIntentFilters(UserHandle.myUserId()); pm.clearCrossProfileIntentFilters(UserHandle.myUserId());