summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SystemUI/src')
-rw-r--r--packages/SystemUI/src/com/android/systemui/SearchPanelView.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardTouchDelegate.java94
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java11
3 files changed, 73 insertions, 39 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/SearchPanelView.java b/packages/SystemUI/src/com/android/systemui/SearchPanelView.java
index c32f741..c7f0e17 100644
--- a/packages/SystemUI/src/com/android/systemui/SearchPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/SearchPanelView.java
@@ -46,6 +46,7 @@ import com.android.internal.widget.multiwaveview.GlowPadView.OnTriggerListener;
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.StatusBarPanel;
+import com.android.systemui.statusbar.phone.KeyguardTouchDelegate;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
public class SearchPanelView extends FrameLayout implements
@@ -88,11 +89,7 @@ public class SearchPanelView extends FrameLayout implements
if (isKeyguardShowing) {
// Have keyguard show the bouncer and launch the activity if the user succeeds.
- try {
- mWm.showAssistant();
- } catch (RemoteException e) {
- // too bad, so sad...
- }
+ KeyguardTouchDelegate.getInstance(getContext()).showAssistant();
onAnimationStarted();
} else {
// Otherwise, keyguard isn't showing so launch it from here.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardTouchDelegate.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardTouchDelegate.java
index 1221a55..5c55f0d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardTouchDelegate.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardTouchDelegate.java
@@ -23,7 +23,7 @@ import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.UserHandle;
-import android.util.Log;
+import android.util.Slog;
import android.view.MotionEvent;
import com.android.internal.policy.IKeyguardExitCallback;
@@ -41,7 +41,9 @@ public class KeyguardTouchDelegate {
static final String KEYGUARD_PACKAGE = "com.android.keyguard";
static final String KEYGUARD_CLASS = "com.android.keyguard.KeyguardService";
- IKeyguardService mService;
+ private static KeyguardTouchDelegate sInstance;
+
+ private volatile IKeyguardService mService;
protected static final boolean DEBUG = false;
protected static final String TAG = "KeyguardTouchDelegate";
@@ -49,83 +51,121 @@ public class KeyguardTouchDelegate {
private final ServiceConnection mKeyguardConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
- Log.v(TAG, "Connected to keyguard");
+ Slog.v(TAG, "Connected to keyguard");
mService = IKeyguardService.Stub.asInterface(service);
}
@Override
public void onServiceDisconnected(ComponentName name) {
- Log.v(TAG, "Disconnected from keyguard");
+ Slog.v(TAG, "Disconnected from keyguard");
mService = null;
+ sInstance = null; // force reconnection if this goes away
}
};
- public KeyguardTouchDelegate(Context context) {
+ private KeyguardTouchDelegate(Context context) {
Intent intent = new Intent();
intent.setClassName(KEYGUARD_PACKAGE, KEYGUARD_CLASS);
if (!context.bindServiceAsUser(intent, mKeyguardConnection,
Context.BIND_AUTO_CREATE, UserHandle.OWNER)) {
- if (DEBUG) Log.v(TAG, "*** Keyguard: can't bind to " + KEYGUARD_CLASS);
+ if (DEBUG) Slog.v(TAG, "*** Keyguard: can't bind to " + KEYGUARD_CLASS);
} else {
- if (DEBUG) Log.v(TAG, "*** Keyguard started");
+ if (DEBUG) Slog.v(TAG, "*** Keyguard started");
+ }
+ }
+
+ public static KeyguardTouchDelegate getInstance(Context context) {
+ if (sInstance == null) {
+ sInstance = new KeyguardTouchDelegate(context);
}
+ return sInstance;
}
public boolean isSecure() {
- boolean secure = false;
- if (mService != null) {
+ final IKeyguardService service = mService;
+ if (service != null) {
try {
- secure = mService.isSecure();
+ return service.isSecure();
} catch (RemoteException e) {
- Log.e(TAG, "RemoteException calling keyguard.isSecure()!", e);
+ Slog.e(TAG, "RemoteException calling keyguard.isSecure()!", e);
}
} else {
- Log.w(TAG, "isSecure(): NO SERVICE!");
+ Slog.w(TAG, "isSecure(): NO SERVICE!");
}
- return secure;
+ return false;
}
public boolean dispatch(MotionEvent event) {
- if (mService != null) {
+ final IKeyguardService service = mService;
+ if (service != null) {
try {
- mService.dispatch(event);
+ service.dispatch(event);
+ return true;
} catch (RemoteException e) {
// What to do?
- Log.e(TAG, "RemoteException sending event to keyguard!", e);
- return false;
+ Slog.e(TAG, "RemoteException sending event to keyguard!", e);
+ }
+ } else {
+ Slog.w(TAG, "dispatch(event): NO SERVICE!");
+ }
+ return false;
+ }
+
+ public boolean isInputRestricted() {
+ final IKeyguardService service = mService;
+ if (service != null) {
+ try {
+ return service.isInputRestricted();
+ } catch (RemoteException e) {
+ Slog.w(TAG , "Remote Exception", e);
+ }
+ } else {
+ Slog.w(TAG, "isInputRestricted(): NO SERVICE!");
+ }
+ return false;
+ }
+
+ public boolean isShowingAndNotHidden() {
+ final IKeyguardService service = mService;
+ if (service != null) {
+ try {
+ return service.isShowingAndNotHidden();
+ } catch (RemoteException e) {
+ Slog.w(TAG , "Remote Exception", e);
}
- return true;
} else {
- Log.w(TAG, "dispatch(event): NO SERVICE!");
+ Slog.w(TAG, "isShowingAndNotHidden(): NO SERVICE!");
}
return false;
}
public void showAssistant() {
- if (mService != null) {
+ final IKeyguardService service = mService;
+ if (service != null) {
try {
- mService.showAssistant();
+ service.showAssistant();
} catch (RemoteException e) {
// What to do?
- Log.e(TAG, "RemoteException launching assistant!", e);
+ Slog.e(TAG, "RemoteException launching assistant!", e);
}
} else {
- Log.w(TAG, "dispatch(event): NO SERVICE!");
+ Slog.w(TAG, "showAssistant(event): NO SERVICE!");
}
}
public void launchCamera() {
- if (mService != null) {
+ final IKeyguardService service = mService;
+ if (service != null) {
try {
- mService.launchCamera();
+ service.launchCamera();
} catch (RemoteException e) {
// What to do?
- Log.e(TAG, "RemoteException launching camera!", e);
+ Slog.e(TAG, "RemoteException launching camera!", e);
}
} else {
- Log.w(TAG, "dispatch(event): NO SERVICE!");
+ Slog.w(TAG, "dispatch(event): NO SERVICE!");
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 596fac6..04885f0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -88,7 +88,6 @@ public class NavigationBarView extends LinearLayout {
// used to disable the camera icon in navbar when disabled by DPM
private boolean mCameraDisabledByDpm;
- KeyguardTouchDelegate mKeyguardTouchDelegate;
private final OnTouchListener mCameraTouchListener = new OnTouchListener() {
@Override
@@ -112,7 +111,7 @@ public class NavigationBarView extends LinearLayout {
}
break;
}
- return mKeyguardTouchDelegate.dispatch(event);
+ return KeyguardTouchDelegate.getInstance(getContext()).dispatch(event);
}
};
@@ -155,8 +154,6 @@ public class NavigationBarView extends LinearLayout {
mBarTransitions = new NavigationBarTransitions(this);
- mKeyguardTouchDelegate = new KeyguardTouchDelegate(mContext);
-
mCameraDisabledByDpm = isCameraDisabledByDpm();
watchForDevicePolicyChanges();
}
@@ -341,7 +338,7 @@ public class NavigationBarView extends LinearLayout {
final int disabledFlags = dpm.getKeyguardDisabledFeatures(null, userId);
final boolean disabledBecauseKeyguardSecure =
(disabledFlags & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) != 0
- && mKeyguardTouchDelegate.isSecure();
+ && KeyguardTouchDelegate.getInstance(getContext()).isSecure();
return dpm.getCameraDisabled(null) || disabledBecauseKeyguardSecure;
} catch (RemoteException e) {
Log.e(TAG, "Can't get userId", e);
@@ -426,9 +423,9 @@ public class NavigationBarView extends LinearLayout {
protected void launchForAccessibilityClick(View v) {
if (v == getCameraButton()) {
- mKeyguardTouchDelegate.launchCamera();
+ KeyguardTouchDelegate.getInstance(getContext()).launchCamera();
} else if (v == getSearchLight()) {
- mKeyguardTouchDelegate.showAssistant();
+ KeyguardTouchDelegate.getInstance(getContext()).showAssistant();
}
}