OSDN Git Service

Use the permission for hotword recognition
authorSandeep Siddhartha <sansid@google.com>
Fri, 6 Sep 2013 19:32:52 +0000 (12:32 -0700)
committerSandeep Siddhartha <sansid@google.com>
Fri, 6 Sep 2013 19:48:51 +0000 (12:48 -0700)
- Also fixes an issue with PendingIntents being launched from the
  lockscreen taking a lot of time

Change-Id: I91b44328ba68b225454322b90a5b19a0d4c9a772

packages/Keyguard/AndroidManifest.xml
packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java

index 7d77c48..d2c82c8 100644 (file)
@@ -37,6 +37,8 @@
     <uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW" />
     <uses-permission android:name="android.permission.BIND_DEVICE_ADMIN" />
     <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" />
+    <!-- Permission to perform hotword recognition -->
+    <uses-permission android:name="android.permission.HOTWORD_RECOGNITION" />
 
     <application android:label="@string/app_name"
         android:process="com.android.systemui"
index 00124b0..78b842c 100644 (file)
@@ -1784,30 +1784,23 @@ public class KeyguardHostView extends KeyguardViewBase {
             }
         }
 
-        public void onHotwordRecognized(final PendingIntent intent) {
+        public void onHotwordRecognized(final Intent intent) {
             if (DEBUG) Log.d(TAG, "onHotwordRecognized");
             maybeStopHotwordDetector();
+            // See if an activity can handle this intent.
+            if (getContext().getPackageManager().resolveActivity(intent, 0) == null)
+                return;
             if (SecurityMode.None == mCurrentSecuritySelection) {
                 if (intent != null) {
-                    try {
-                        intent.send();
-                    } catch (PendingIntent.CanceledException e) {
-                        Log.w(TAG, "Failed to launch PendingIntent. Encountered CanceledException");
-                    }
+                    mActivityLauncher.launchActivity(intent, true, true, null, null);
                 }
                 mCallback.userActivity(0);
-                mCallback.dismiss(false);
             } else if (ENABLE_HOTWORD_SECURE && mLockPatternUtils.isSecure()) {
                 setOnDismissAction(new OnDismissAction() {
                     @Override
                     public boolean onDismiss() {
                         if (intent != null) {
-                            try {
-                                intent.send();
-                            } catch (PendingIntent.CanceledException e) {
-                                Log.w(TAG, "Failed to launch PendingIntent."
-                                        + "Encountered CanceledException");
-                            }
+                            mActivityLauncher.launchActivity(intent, true, true, null, null);
                         }
                         return false;
                     }