Merge "Cleanup USER_OWNER in Settings"
This commit is contained in:
@@ -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.content.pm.UserInfo;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
@@ -45,14 +46,15 @@ public class ManagedProfileSetup extends BroadcastReceiver {
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent broadcast) {
|
public void onReceive(Context context, Intent broadcast) {
|
||||||
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||||
if (!Utils.isManagedProfile(um)) {
|
UserInfo userInfo = um.getUserInfo(UserHandle.myUserId());
|
||||||
|
if (userInfo == null || !userInfo.isManagedProfile()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.i(TAG, "Received broadcast: " + broadcast.getAction()
|
Log.i(TAG, "Received broadcast: " + broadcast.getAction()
|
||||||
+ ". Setting up intent forwarding for managed profile.");
|
+ ". 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(userInfo.id);
|
||||||
|
|
||||||
// Set up intent forwarding for implicit intents
|
// Set up intent forwarding for implicit intents
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
@@ -70,8 +72,8 @@ public class ManagedProfileSetup extends BroadcastReceiver {
|
|||||||
boolean shouldForward = info.activityInfo.metaData.getBoolean(
|
boolean shouldForward = info.activityInfo.metaData.getBoolean(
|
||||||
PRIMARY_PROFILE_SETTING);
|
PRIMARY_PROFILE_SETTING);
|
||||||
if (shouldForward) {
|
if (shouldForward) {
|
||||||
pm.addCrossProfileIntentFilter(info.filter, UserHandle.myUserId(),
|
pm.addCrossProfileIntentFilter(info.filter, userInfo.id,
|
||||||
UserHandle.USER_OWNER, PackageManager.SKIP_CURRENT_PROFILE);
|
userInfo.profileGroupId, PackageManager.SKIP_CURRENT_PROFILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -781,7 +781,8 @@ public class RunningState {
|
|||||||
mPm = mApplicationContext.getPackageManager();
|
mPm = mApplicationContext.getPackageManager();
|
||||||
mUm = (UserManager)mApplicationContext.getSystemService(Context.USER_SERVICE);
|
mUm = (UserManager)mApplicationContext.getSystemService(Context.USER_SERVICE);
|
||||||
mMyUserId = UserHandle.myUserId();
|
mMyUserId = UserHandle.myUserId();
|
||||||
mHideManagedProfiles = mMyUserId != UserHandle.USER_OWNER;
|
UserInfo userInfo = mUm.getUserInfo(mMyUserId);
|
||||||
|
mHideManagedProfiles = userInfo == null || !userInfo.canHaveProfile();
|
||||||
mResumed = false;
|
mResumed = false;
|
||||||
mBackgroundThread = new HandlerThread("RunningState:Background");
|
mBackgroundThread = new HandlerThread("RunningState:Background");
|
||||||
mBackgroundThread.start();
|
mBackgroundThread.start();
|
||||||
|
Reference in New Issue
Block a user