summaryrefslogtreecommitdiffstats
path: root/services/usb/java/com/android
diff options
context:
space:
mode:
authorXiaohui Chen <xiaohuic@google.com>2015-05-13 13:18:36 -0700
committerXiaohui Chen <xiaohuic@google.com>2015-06-03 09:32:19 -0700
commitffcfe3411ff6ccaa35c2873151e31c879506dadd (patch)
tree1e8df4f4a430aadc6aef8f4059296bf04d27d25b /services/usb/java/com/android
parentbdd500ecd4ceea7d4e4a06ece08c9b9fd5d8aec5 (diff)
downloadframeworks_base-ffcfe3411ff6ccaa35c2873151e31c879506dadd.zip
frameworks_base-ffcfe3411ff6ccaa35c2873151e31c879506dadd.tar.gz
frameworks_base-ffcfe3411ff6ccaa35c2873151e31c879506dadd.tar.bz2
usb debugging: show alert to secondary user
Bug: 12785423 Change-Id: If7f60899cfdaca7bdad560bd59a78f5be74c24be
Diffstat (limited to 'services/usb/java/com/android')
-rw-r--r--services/usb/java/com/android/server/usb/UsbDebuggingManager.java45
1 files changed, 29 insertions, 16 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbDebuggingManager.java b/services/usb/java/com/android/server/usb/UsbDebuggingManager.java
index 8849acd..9a04e8b 100644
--- a/services/usb/java/com/android/server/usb/UsbDebuggingManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDebuggingManager.java
@@ -16,6 +16,7 @@
package com.android.server.usb;
+import android.app.ActivityManager;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
@@ -24,20 +25,21 @@ import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.net.LocalSocket;
import android.net.LocalSocketAddress;
-import android.os.Handler;
import android.os.Environment;
import android.os.FileUtils;
+import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
-import android.util.Slog;
+import android.os.UserManager;
import android.util.Base64;
+import android.util.Slog;
+import com.android.internal.R;
import com.android.server.FgThread;
-import java.lang.Thread;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
@@ -319,28 +321,39 @@ public class UsbDebuggingManager {
}
private void startConfirmation(String key, String fingerprints) {
- String nameString = Resources.getSystem().getString(
- com.android.internal.R.string.config_customAdbPublicKeyConfirmationComponent);
- ComponentName componentName = ComponentName.unflattenFromString(nameString);
- if (startConfirmationActivity(componentName, key, fingerprints)
- || startConfirmationService(componentName, key, fingerprints)) {
+ int currentUserId = ActivityManager.getCurrentUser();
+ UserHandle userHandle =
+ UserManager.get(mContext).getUserInfo(currentUserId).getUserHandle();
+ String componentString;
+ if (currentUserId == UserHandle.USER_OWNER) {
+ componentString = Resources.getSystem().getString(
+ com.android.internal.R.string.config_customAdbPublicKeyConfirmationComponent);
+ } else {
+ // If the current foreground user is not the primary user we send a different
+ // notification specific to secondary users.
+ componentString = Resources.getSystem().getString(
+ R.string.config_customAdbPublicKeyConfirmationSecondaryUserComponent);
+ }
+ ComponentName componentName = ComponentName.unflattenFromString(componentString);
+ if (startConfirmationActivity(componentName, userHandle, key, fingerprints)
+ || startConfirmationService(componentName, userHandle, key, fingerprints)) {
return;
}
- Slog.e(TAG, "unable to start customAdbPublicKeyConfirmationComponent "
- + nameString + " as an Activity or a Service");
+ Slog.e(TAG, "unable to start customAdbPublicKeyConfirmation[SecondaryUser]Component "
+ + componentString + " as an Activity or a Service");
}
/**
* @returns true if the componentName led to an Activity that was started.
*/
- private boolean startConfirmationActivity(ComponentName componentName, String key,
- String fingerprints) {
+ private boolean startConfirmationActivity(ComponentName componentName, UserHandle userHandle,
+ String key, String fingerprints) {
PackageManager packageManager = mContext.getPackageManager();
Intent intent = createConfirmationIntent(componentName, key, fingerprints);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
try {
- mContext.startActivityAsUser(intent, UserHandle.OWNER);
+ mContext.startActivityAsUser(intent, userHandle);
return true;
} catch (ActivityNotFoundException e) {
Slog.e(TAG, "unable to start adb whitelist activity: " + componentName, e);
@@ -352,11 +365,11 @@ public class UsbDebuggingManager {
/**
* @returns true if the componentName led to a Service that was started.
*/
- private boolean startConfirmationService(ComponentName componentName, String key,
- String fingerprints) {
+ private boolean startConfirmationService(ComponentName componentName, UserHandle userHandle,
+ String key, String fingerprints) {
Intent intent = createConfirmationIntent(componentName, key, fingerprints);
try {
- if (mContext.startService(intent) != null) {
+ if (mContext.startServiceAsUser(intent, userHandle) != null) {
return true;
}
} catch (SecurityException e) {