package com.android.systemui.statusbar.phone;
+import com.google.android.collect.Lists;
+
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import com.android.internal.policy.IKeyguardService;
+import java.util.List;
+
/**
* Facilitates event communication between navigation bar and keyguard. Currently used to
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;
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
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);
+ }
}
};
}
}
+ public static void addListener(OnKeyguardConnectionListener listener) {
+ sConnectionListeners.add(listener);
+ }
+
+ public interface OnKeyguardConnectionListener {
+
+ void onKeyguardServiceConnected(KeyguardTouchDelegate keyguardTouchDelegate);
+ void onKeyguardServiceDisconnected(KeyguardTouchDelegate keyguardTouchDelegate);
+ }
}
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";
}
};
+ 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) {
mBarTransitions = new NavigationBarTransitions(this);
+ KeyguardTouchDelegate.addListener(mKeyguardConnectionListener);
mCameraDisabledByDpm = isCameraDisabledByDpm();
watchForDevicePolicyChanges();
}