Merge "Check for keyguard occlusion on camera lift" into oc-dr1-dev
am: e07567cc0b
Change-Id: I75f221c9fe2d869e269b2ff375456041c973166b
This commit is contained in:
@@ -228,6 +228,11 @@ public abstract class WindowManagerInternal {
|
||||
/** @return {@code true} if the keyguard is going away. */
|
||||
public abstract boolean isKeyguardGoingAway();
|
||||
|
||||
/**
|
||||
* @return Whether the keyguard is showing and not occluded.
|
||||
*/
|
||||
public abstract boolean isKeyguardShowingAndNotOccluded();
|
||||
|
||||
/**
|
||||
* Gets the frame of a window given its token.
|
||||
*
|
||||
|
||||
@@ -309,6 +309,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
public static final boolean DEBUG_GESTURES = false;
|
||||
public static final boolean DEBUG_MEDIA = false;
|
||||
public static final boolean DEBUG_MEDIA_FAKE_ARTWORK = false;
|
||||
public static final boolean DEBUG_CAMERA_LIFT = true; // false once b/62623620 is fixed
|
||||
|
||||
public static final boolean DEBUG_WINDOW_STATE = false;
|
||||
|
||||
@@ -5163,11 +5164,14 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
public void onCameraLaunchGestureDetected(int source) {
|
||||
mLastCameraLaunchSource = source;
|
||||
if (mStartedGoingToSleep) {
|
||||
if (DEBUG_CAMERA_LIFT) Slog.d(TAG, "Finish going to sleep before launching camera");
|
||||
mLaunchCameraOnFinishedGoingToSleep = true;
|
||||
return;
|
||||
}
|
||||
if (!mNotificationPanel.canCameraGestureBeLaunched(
|
||||
mStatusBarKeyguardViewManager.isShowing() && mExpandedVisible)) {
|
||||
if (DEBUG_CAMERA_LIFT) Slog.d(TAG, "Can't launch camera right now, mExpandedVisible: " +
|
||||
mExpandedVisible);
|
||||
return;
|
||||
}
|
||||
if (!mDeviceInteractive) {
|
||||
@@ -5187,12 +5191,14 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
mGestureWakeLock.acquire(LAUNCH_TRANSITION_TIMEOUT_MS + 1000L);
|
||||
}
|
||||
if (mScreenTurningOn || mStatusBarKeyguardViewManager.isScreenTurnedOn()) {
|
||||
if (DEBUG_CAMERA_LIFT) Slog.d(TAG, "Launching camera");
|
||||
mNotificationPanel.launchCamera(mDeviceInteractive /* animate */, source);
|
||||
} else {
|
||||
// We need to defer the camera launch until the screen comes on, since otherwise
|
||||
// we will dismiss us too early since we are waiting on an activity to be drawn and
|
||||
// incorrectly get notified because of the screen on event (which resumes and pauses
|
||||
// some activities)
|
||||
if (DEBUG_CAMERA_LIFT) Slog.d(TAG, "Deferring until screen turns on");
|
||||
mLaunchCameraOnScreenTurningOn = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.android.server;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.KeyguardManager;
|
||||
import android.app.StatusBarManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@@ -41,10 +40,12 @@ import android.provider.Settings;
|
||||
import android.util.MutableBoolean;
|
||||
import android.util.Slog;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.WindowManagerInternal;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.statusbar.StatusBarManagerInternal;
|
||||
|
||||
/**
|
||||
@@ -56,6 +57,7 @@ import com.android.server.statusbar.StatusBarManagerInternal;
|
||||
*/
|
||||
public class GestureLauncherService extends SystemService {
|
||||
private static final boolean DBG = false;
|
||||
private static final boolean DBG_CAMERA_LIFT = true; // false once b/62623620 is fixed
|
||||
private static final String TAG = "GestureLauncherService";
|
||||
|
||||
/**
|
||||
@@ -82,7 +84,7 @@ public class GestureLauncherService extends SystemService {
|
||||
private Context mContext;
|
||||
private final MetricsLogger mMetricsLogger;
|
||||
private PowerManager mPowerManager;
|
||||
private KeyguardManager mKeyguardManager;
|
||||
private WindowManagerInternal mWindowManagerInternal;
|
||||
|
||||
/** The wake lock held when a gesture is detected. */
|
||||
private WakeLock mWakeLock;
|
||||
@@ -150,8 +152,7 @@ public class GestureLauncherService extends SystemService {
|
||||
return;
|
||||
}
|
||||
|
||||
mKeyguardManager = (KeyguardManager) mContext.getSystemService(
|
||||
Context.KEYGUARD_SERVICE);
|
||||
mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
|
||||
mPowerManager = (PowerManager) mContext.getSystemService(
|
||||
Context.POWER_SERVICE);
|
||||
mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
||||
@@ -517,33 +518,40 @@ public class GestureLauncherService extends SystemService {
|
||||
private final class CameraLiftTriggerEventListener extends TriggerEventListener {
|
||||
@Override
|
||||
public void onTrigger(TriggerEvent event) {
|
||||
if (DBG_CAMERA_LIFT) Slog.d(TAG, String.format("onTrigger event - time: %d, name: %s",
|
||||
event.timestamp, event.sensor.getName()));
|
||||
if (!mCameraLiftRegistered) {
|
||||
if (DBG) Slog.d(TAG, "Ignoring camera lift event because it's unregistered.");
|
||||
if (DBG_CAMERA_LIFT) Slog.d(TAG, "Ignoring camera lift event because it's " +
|
||||
"unregistered.");
|
||||
return;
|
||||
}
|
||||
if (event.sensor == mCameraLiftTriggerSensor) {
|
||||
Resources resources = mContext.getResources();
|
||||
SensorManager sensorManager = (SensorManager) mContext.getSystemService(
|
||||
Context.SENSOR_SERVICE);
|
||||
|
||||
if (DBG) {
|
||||
boolean keyguardShowingAndNotOccluded =
|
||||
mWindowManagerInternal.isKeyguardShowingAndNotOccluded();
|
||||
boolean interactive = mPowerManager.isInteractive();
|
||||
if (DBG_CAMERA_LIFT) {
|
||||
float[] values = event.values;
|
||||
Slog.d(TAG, String.format("Received a camera lift trigger event: " +
|
||||
"values=[%.4f].", values[0]));
|
||||
Slog.d(TAG, String.format("Received a camera lift trigger " +
|
||||
"event: values=[%.4f], keyguard showing: %b, interactive: %b", values[0],
|
||||
keyguardShowingAndNotOccluded, interactive));
|
||||
}
|
||||
if (mKeyguardManager.isKeyguardLocked() || !mPowerManager.isInteractive()) {
|
||||
if (keyguardShowingAndNotOccluded || !interactive) {
|
||||
if (handleCameraGesture(true /* useWakelock */,
|
||||
StatusBarManager.CAMERA_LAUNCH_SOURCE_LIFT_TRIGGER)) {
|
||||
MetricsLogger.action(mContext, MetricsEvent.ACTION_CAMERA_LIFT_TRIGGER);
|
||||
}
|
||||
} else if (DBG) {
|
||||
Slog.d(TAG, "Ignoring lift event because device is awake");
|
||||
} else {
|
||||
if (DBG_CAMERA_LIFT) Slog.d(TAG, "Ignoring lift event");
|
||||
}
|
||||
|
||||
mCameraLiftRegistered = sensorManager.requestTriggerSensor(mCameraLiftTriggerListener,
|
||||
mCameraLiftTriggerSensor);
|
||||
mCameraLiftRegistered = sensorManager.requestTriggerSensor(
|
||||
mCameraLiftTriggerListener, mCameraLiftTriggerSensor);
|
||||
|
||||
if (DBG) Slog.d(TAG, "Camera lift trigger sensor re-registered: " + mCameraLiftRegistered);
|
||||
if (DBG_CAMERA_LIFT) Slog.d(TAG, "Camera lift trigger sensor re-registered: " +
|
||||
mCameraLiftRegistered);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3040,6 +3040,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
return mPolicy.isKeyguardLocked();
|
||||
}
|
||||
|
||||
public boolean isKeyguardShowingAndNotOccluded() {
|
||||
return mPolicy.isKeyguardShowingAndNotOccluded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isKeyguardSecure() {
|
||||
int userId = UserHandle.getCallingUserId();
|
||||
@@ -7290,6 +7294,11 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
return WindowManagerService.this.mKeyguardGoingAway;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isKeyguardShowingAndNotOccluded() {
|
||||
return WindowManagerService.this.isKeyguardShowingAndNotOccluded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showGlobalActions() {
|
||||
WindowManagerService.this.showGlobalActions();
|
||||
|
||||
Reference in New Issue
Block a user