am 9ceafdb7: am 47ffc605: Merge "Show message when intent is forwarded across profiles." into lmp-mr1-dev
* commit '9ceafdb79473e28173e523bda8b1bc7982907726': Show message when intent is forwarded across profiles.
This commit is contained in:
@@ -100,6 +100,7 @@ public class ResolverActivity extends Activity implements AdapterView.OnItemClic
|
|||||||
private int mMaxColumns;
|
private int mMaxColumns;
|
||||||
private int mLastSelected = ListView.INVALID_POSITION;
|
private int mLastSelected = ListView.INVALID_POSITION;
|
||||||
private boolean mResolvingHome = false;
|
private boolean mResolvingHome = false;
|
||||||
|
private int mProfileSwitchMessageId = -1;
|
||||||
|
|
||||||
private UsageStatsManager mUsm;
|
private UsageStatsManager mUsm;
|
||||||
private Map<String, UsageStats> mStats;
|
private Map<String, UsageStats> mStats;
|
||||||
@@ -200,6 +201,11 @@ public class ResolverActivity extends Activity implements AdapterView.OnItemClic
|
|||||||
List<ResolveInfo> rList, boolean alwaysUseOption) {
|
List<ResolveInfo> rList, boolean alwaysUseOption) {
|
||||||
setTheme(R.style.Theme_DeviceDefault_Resolver);
|
setTheme(R.style.Theme_DeviceDefault_Resolver);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// Determine whether we should show that intent is forwarded
|
||||||
|
// from managed profile to owner or other way around.
|
||||||
|
setProfileSwitchMessageId(intent.getContentUserHint());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mLaunchedFromUid = ActivityManagerNative.getDefault().getLaunchedFromUid(
|
mLaunchedFromUid = ActivityManagerNative.getDefault().getLaunchedFromUid(
|
||||||
getActivityToken());
|
getActivityToken());
|
||||||
@@ -320,6 +326,22 @@ public class ResolverActivity extends Activity implements AdapterView.OnItemClic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setProfileSwitchMessageId(int contentUserHint) {
|
||||||
|
if (contentUserHint != UserHandle.USER_CURRENT &&
|
||||||
|
contentUserHint != UserHandle.myUserId()) {
|
||||||
|
UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
|
||||||
|
UserInfo originUserInfo = userManager.getUserInfo(contentUserHint);
|
||||||
|
boolean originIsManaged = originUserInfo != null ? originUserInfo.isManagedProfile()
|
||||||
|
: false;
|
||||||
|
boolean targetIsManaged = userManager.isManagedProfile();
|
||||||
|
if (originIsManaged && !targetIsManaged) {
|
||||||
|
mProfileSwitchMessageId = com.android.internal.R.string.forward_intent_to_owner;
|
||||||
|
} else if (!originIsManaged && targetIsManaged) {
|
||||||
|
mProfileSwitchMessageId = com.android.internal.R.string.forward_intent_to_work;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn on launch mode that is safe to use when forwarding intents received from
|
* Turn on launch mode that is safe to use when forwarding intents received from
|
||||||
* applications and running in system processes. This mode uses Activity.startActivityAsCaller
|
* applications and running in system processes. This mode uses Activity.startActivityAsCaller
|
||||||
@@ -642,6 +664,11 @@ public class ResolverActivity extends Activity implements AdapterView.OnItemClic
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void safelyStartActivity(Intent intent) {
|
public void safelyStartActivity(Intent intent) {
|
||||||
|
// If needed, show that intent is forwarded
|
||||||
|
// from managed profile to owner or other way around.
|
||||||
|
if (mProfileSwitchMessageId != -1) {
|
||||||
|
Toast.makeText(this, getString(mProfileSwitchMessageId), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
if (!mSafeForwardingMode) {
|
if (!mSafeForwardingMode) {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
onActivityStarted(intent);
|
onActivityStarted(intent);
|
||||||
|
|||||||
Reference in New Issue
Block a user