OSDN Git Service

Resolve car dock home activities properly.
authorJohn Spurlock <jspurlock@google.com>
Tue, 9 Jul 2013 13:51:46 +0000 (09:51 -0400)
committerJohn Spurlock <jspurlock@google.com>
Thu, 11 Jul 2013 15:00:26 +0000 (11:00 -0400)
Look up the actual user id (package manager does not understand
UserHandle.USER_CURRENT) and return metadata during resolution
for subsequent checking.

Bug: 9738229
Change-Id: Ib060bacc84473b27a1fb2e717651dc84f018d6f9

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

index 0b8b028..262b7ee 100644 (file)
@@ -33,6 +33,7 @@ import android.content.ServiceConnection;
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+import android.content.pm.UserInfo;
 import android.content.res.CompatibilityInfo;
 import android.content.res.Configuration;
 import android.content.res.Resources;
@@ -4789,8 +4790,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
         ActivityInfo ai = null;
         ResolveInfo info = mContext.getPackageManager().resolveActivityAsUser(
                 intent,
-                PackageManager.MATCH_DEFAULT_ONLY,
-                UserHandle.USER_CURRENT);
+                PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA,
+                getCurrentUserId());
         if (info != null) {
             ai = info.activityInfo;
         }
@@ -4805,6 +4806,16 @@ public class PhoneWindowManager implements WindowManagerPolicy {
         return null;
     }
 
+    private int getCurrentUserId() {
+        try {
+            UserInfo user = ActivityManagerNative.getDefault().getCurrentUser();
+            return user != null ? user.id : UserHandle.USER_NULL;
+        } catch (RemoteException e) {
+            // noop
+        }
+        return UserHandle.USER_NULL;
+    }
+
     void startDockOrHome() {
         awakenDreams();