package com.android.internal.app;
+import static android.content.pm.PackageManager.MATCH_DEFAULT_ONLY;
+
import android.app.Activity;
+import android.app.ActivityManagerNative;
import android.app.AppGlobals;
import android.os.Bundle;
import android.content.Context;
import android.content.Intent;
import android.content.pm.IPackageManager;
import android.content.pm.UserInfo;
+import android.os.Process;
+import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
-import android.app.ActivityManagerNative;
-import android.os.RemoteException;
import android.util.Slog;
+import android.widget.Toast;
import java.util.List;
import java.util.Set;
-
-
-
/*
* This is used in conjunction with the {@link setCrossProfileIntentFilter} method of
* {@link DevicePolicyManager} to enable intents to be passed in and out of a managed profile.
String className = intentReceived.getComponent().getClassName();
final UserHandle userDest;
+ final int userMessageId;
if (className.equals(FORWARD_INTENT_TO_USER_OWNER)) {
+ userMessageId = com.android.internal.R.string.forward_intent_to_owner;
userDest = UserHandle.OWNER;
} else if (className.equals(FORWARD_INTENT_TO_MANAGED_PROFILE)) {
+ userMessageId = com.android.internal.R.string.forward_intent_to_work;
userDest = getManagedProfile();
} else {
Slog.wtf(TAG, IntentForwarderActivity.class.getName() + " cannot be called directly");
+ userMessageId = -1;
userDest = null;
}
if (userDest == null) { // This covers the case where there is no managed profile.
}
if (canForward) {
newIntent.prepareToLeaveUser(callingUserId);
+
+ final android.content.pm.ResolveInfo ri = getPackageManager().resolveActivityAsUser(
+ newIntent, MATCH_DEFAULT_ONLY, userDest.getIdentifier());
+
+ // Only show a disclosure if this is a normal (non-OS) app
+ final boolean shouldShowDisclosure =
+ !UserHandle.isSameApp(ri.activityInfo.applicationInfo.uid, Process.SYSTEM_UID);
+
startActivityAsUser(newIntent, userDest);
+
+ if (shouldShowDisclosure) {
+ Toast.makeText(this, getString(userMessageId), Toast.LENGTH_LONG).show();
+ }
} else {
Slog.wtf(TAG, "the intent: " + newIntent + "cannot be forwarded from user "
+ callingUserId + " to user " + userDest.getIdentifier());
<string name="permission_request_notification_title">Permission requested</string>
<string name="permission_request_notification_with_subtitle">Permission requested\nfor account <xliff:g id="account" example="foo@gmail.com">%s</xliff:g>.</string>
+ <!-- Message to show when an intent automatically switches users into the personal profile. -->
+ <string name="forward_intent_to_owner">You\'re using this app in your personal space</string>
+ <!-- Message to show when an intent automatically switches users into a work profile. -->
+ <string name="forward_intent_to_work">You\'re using this app in your work space</string>
+
<!-- Label to show for a service that is running because it is an input method. -->
<string name="input_method_binding_label">Input method</string>
<!-- Label to show for a service that is running because it is a sync adapter. -->
*/
-->
<resources>
-
<!-- We don't want to publish private symbols in android.R as part of the
SDK. Instead, put them here. -->
<private-symbols package="com.android.internal" />
<java-symbol type="style" name="Animation.LockScreen" />
<java-symbol type="style" name="Theme.Dialog.RecentApplications" />
<java-symbol type="style" name="Theme.ExpandedMenu" />
+ <java-symbol type="string" name="forward_intent_to_owner" />
+ <java-symbol type="string" name="forward_intent_to_work" />
<!-- From services -->
<java-symbol type="anim" name="screen_rotate_0_enter" />