OSDN Git Service

Hide camera icon in navbar when disabled by DPM.
authorAdrian Roos <roosa@google.com>
Fri, 10 Jan 2014 20:58:22 +0000 (12:58 -0800)
committerAdrian Roos <roosa@google.com>
Sat, 11 Jan 2014 02:19:49 +0000 (18:19 -0800)
Hides the camera icon in the keyguard more reliably if the device policy disables it.

Bug: 11655611
Change-Id: Ic66f41b6703bf2028edc269cf10f9c167a22081d

packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardTouchDelegate.java
packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java

index 2a43cf6..0be66f8 100644 (file)
@@ -16,6 +16,8 @@
 
 package com.android.systemui.statusbar.phone;
 
+import com.google.android.collect.Lists;
+
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
@@ -28,6 +30,8 @@ import android.view.MotionEvent;
 
 import com.android.internal.policy.IKeyguardService;
 
+import java.util.List;
+
 
 /**
  * Facilitates event communication between navigation bar and keyguard.  Currently used to
@@ -40,6 +44,8 @@ public class KeyguardTouchDelegate {
     static final String KEYGUARD_CLASS = "com.android.keyguard.KeyguardService";
 
     private static KeyguardTouchDelegate sInstance;
+    private static final List<OnKeyguardConnectionListener> sConnectionListeners =
+            Lists.newArrayList();
 
     private volatile IKeyguardService mService;
 
@@ -52,6 +58,10 @@ public class KeyguardTouchDelegate {
             Slog.v(TAG, "Connected to keyguard");
             mService = IKeyguardService.Stub.asInterface(service);
 
+            for (int i = 0; i < sConnectionListeners.size(); i++) {
+                OnKeyguardConnectionListener listener = sConnectionListeners.get(i);
+                listener.onKeyguardServiceConnected(KeyguardTouchDelegate.this);
+            }
         }
 
         @Override
@@ -59,6 +69,11 @@ public class KeyguardTouchDelegate {
             Slog.v(TAG, "Disconnected from keyguard");
             mService = null;
             sInstance = null; // force reconnection if this goes away
+
+            for (int i = 0; i < sConnectionListeners.size(); i++) {
+                OnKeyguardConnectionListener listener = sConnectionListeners.get(i);
+                listener.onKeyguardServiceDisconnected(KeyguardTouchDelegate.this);
+            }
         }
 
     };
@@ -182,4 +197,13 @@ public class KeyguardTouchDelegate {
         }
     }
 
+    public static void addListener(OnKeyguardConnectionListener listener) {
+        sConnectionListeners.add(listener);
+    }
+
+    public interface OnKeyguardConnectionListener {
+
+        void onKeyguardServiceConnected(KeyguardTouchDelegate keyguardTouchDelegate);
+        void onKeyguardServiceDisconnected(KeyguardTouchDelegate keyguardTouchDelegate);
+    }
 }
index 839016d..35d5a69 100644 (file)
@@ -57,6 +57,8 @@ import com.android.systemui.statusbar.policy.KeyButtonView;
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
 
+import static com.android.systemui.statusbar.phone.KeyguardTouchDelegate.OnKeyguardConnectionListener;
+
 public class NavigationBarView extends LinearLayout {
     final static boolean DEBUG = false;
     final static String TAG = "PhoneStatusBar/NavigationBarView";
@@ -172,6 +174,25 @@ public class NavigationBarView extends LinearLayout {
         }
     };
 
+    private final OnKeyguardConnectionListener mKeyguardConnectionListener =
+            new OnKeyguardConnectionListener() {
+                @Override
+                public void onKeyguardServiceConnected(
+                        KeyguardTouchDelegate keyguardTouchDelegate) {
+                    post(new Runnable() {
+                        @Override
+                        public void run() {
+                            mCameraDisabledByDpm = isCameraDisabledByDpm();
+                        }
+                    });
+                }
+
+                @Override
+                public void onKeyguardServiceDisconnected(
+                        KeyguardTouchDelegate keyguardTouchDelegate) {
+                }
+            };
+
     private class H extends Handler {
         public void handleMessage(Message m) {
             switch (m.what) {
@@ -211,6 +232,7 @@ public class NavigationBarView extends LinearLayout {
 
         mBarTransitions = new NavigationBarTransitions(this);
 
+        KeyguardTouchDelegate.addListener(mKeyguardConnectionListener);
         mCameraDisabledByDpm = isCameraDisabledByDpm();
         watchForDevicePolicyChanges();
     }