resolved conflicts for 5d0e02b6 to cw-e-dev
Change-Id: Id974d29581304dc644659d1c470b5413d847944b
This commit is contained in:
@@ -5718,6 +5718,15 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public static final String CAMERA_GESTURE_DISABLED = "camera_gesture_disabled";
|
public static final String CAMERA_GESTURE_DISABLED = "camera_gesture_disabled";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the camera launch gesture to double tap the power button when the screen is off
|
||||||
|
* should be disabled.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final String CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED =
|
||||||
|
"camera_double_tap_power_gesture_disabled";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This are the settings to be backed up.
|
* This are the settings to be backed up.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ public class MetricsLogger implements MetricsConstants {
|
|||||||
public static final int ACTION_FINGERPRINT_AUTH = 252;
|
public static final int ACTION_FINGERPRINT_AUTH = 252;
|
||||||
public static final int ACTION_FINGERPRINT_DELETE = 253;
|
public static final int ACTION_FINGERPRINT_DELETE = 253;
|
||||||
public static final int ACTION_FINGERPRINT_RENAME = 254;
|
public static final int ACTION_FINGERPRINT_RENAME = 254;
|
||||||
|
public static final int ACTION_DOUBLE_TAP_POWER_CAMERA_GESTURE = 255;
|
||||||
|
public static final int ACTION_WIGGLE_CAMERA_GESTURE = 256;
|
||||||
|
|
||||||
public static void visible(Context context, int category) throws IllegalArgumentException {
|
public static void visible(Context context, int category) throws IllegalArgumentException {
|
||||||
if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
|
if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
|
||||||
|
|||||||
@@ -2306,6 +2306,10 @@
|
|||||||
must match the value of config_cameraLaunchGestureSensorType in OEM's HAL -->
|
must match the value of config_cameraLaunchGestureSensorType in OEM's HAL -->
|
||||||
<string translatable="false" name="config_cameraLaunchGestureSensorStringType"></string>
|
<string translatable="false" name="config_cameraLaunchGestureSensorStringType"></string>
|
||||||
|
|
||||||
|
<!-- Allow the gesture to double tap the power button twice to start the camera while the device
|
||||||
|
is non-interactive. -->
|
||||||
|
<bool name="config_cameraDoubleTapPowerGestureEnabled">true</bool>
|
||||||
|
|
||||||
<!-- Name of the component to handle network policy notifications. If present,
|
<!-- Name of the component to handle network policy notifications. If present,
|
||||||
disables NetworkPolicyManagerService's presentation of data-usage notifications. -->
|
disables NetworkPolicyManagerService's presentation of data-usage notifications. -->
|
||||||
<string translatable="false" name="config_networkPolicyNotificationComponent"></string>
|
<string translatable="false" name="config_networkPolicyNotificationComponent"></string>
|
||||||
|
|||||||
@@ -2327,6 +2327,7 @@
|
|||||||
<!-- Gesture -->
|
<!-- Gesture -->
|
||||||
<java-symbol type="integer" name="config_cameraLaunchGestureSensorType" />
|
<java-symbol type="integer" name="config_cameraLaunchGestureSensorType" />
|
||||||
<java-symbol type="string" name="config_cameraLaunchGestureSensorStringType" />
|
<java-symbol type="string" name="config_cameraLaunchGestureSensorStringType" />
|
||||||
|
<java-symbol type="bool" name="config_cameraDoubleTapPowerGestureEnabled" />
|
||||||
|
|
||||||
<java-symbol type="string" name="config_networkPolicyNotificationComponent" />
|
<java-symbol type="string" name="config_networkPolicyNotificationComponent" />
|
||||||
<java-symbol type="drawable" name="platlogo_m" />
|
<java-symbol type="drawable" name="platlogo_m" />
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package com.android.server;
|
package com.android.server;
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.KeyguardManager;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -33,10 +32,11 @@ import android.os.PowerManager;
|
|||||||
import android.os.PowerManager.WakeLock;
|
import android.os.PowerManager.WakeLock;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.os.Vibrator;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
|
||||||
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.server.statusbar.StatusBarManagerInternal;
|
import com.android.server.statusbar.StatusBarManagerInternal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,10 +46,16 @@ import com.android.server.statusbar.StatusBarManagerInternal;
|
|||||||
* added.</p>
|
* added.</p>
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
class GestureLauncherService extends SystemService {
|
public class GestureLauncherService extends SystemService {
|
||||||
private static final boolean DBG = false;
|
private static final boolean DBG = false;
|
||||||
private static final String TAG = "GestureLauncherService";
|
private static final String TAG = "GestureLauncherService";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time in milliseconds in which the power button must be pressed twice so it will be considered
|
||||||
|
* as a camera launch.
|
||||||
|
*/
|
||||||
|
private static final long CAMERA_POWER_DOUBLE_TAP_TIME_MS = 300;
|
||||||
|
|
||||||
/** The listener that receives the gesture event. */
|
/** The listener that receives the gesture event. */
|
||||||
private final GestureEventListener mGestureListener = new GestureEventListener();
|
private final GestureEventListener mGestureListener = new GestureEventListener();
|
||||||
|
|
||||||
@@ -91,13 +97,20 @@ class GestureLauncherService extends SystemService {
|
|||||||
*/
|
*/
|
||||||
private int mCameraLaunchLastEventExtra = 0;
|
private int mCameraLaunchLastEventExtra = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether camera double tap power button gesture is currently enabled;
|
||||||
|
*/
|
||||||
|
private boolean mCameraDoubleTapPowerEnabled;
|
||||||
|
private long mLastPowerDownWhileNonInteractive = 0;
|
||||||
|
|
||||||
|
|
||||||
public GestureLauncherService(Context context) {
|
public GestureLauncherService(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
// Nothing to publish.
|
LocalServices.addService(GestureLauncherService.class, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBootPhase(int phase) {
|
public void onBootPhase(int phase) {
|
||||||
@@ -113,17 +126,21 @@ class GestureLauncherService extends SystemService {
|
|||||||
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
||||||
"GestureLauncherService");
|
"GestureLauncherService");
|
||||||
updateCameraRegistered();
|
updateCameraRegistered();
|
||||||
|
updateCameraDoubleTapPowerEnabled();
|
||||||
|
|
||||||
mUserId = ActivityManager.getCurrentUser();
|
mUserId = ActivityManager.getCurrentUser();
|
||||||
mContext.registerReceiver(mUserReceiver, new IntentFilter(Intent.ACTION_USER_SWITCHED));
|
mContext.registerReceiver(mUserReceiver, new IntentFilter(Intent.ACTION_USER_SWITCHED));
|
||||||
registerContentObserver();
|
registerContentObservers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerContentObserver() {
|
private void registerContentObservers() {
|
||||||
mContext.getContentResolver().registerContentObserver(
|
mContext.getContentResolver().registerContentObserver(
|
||||||
Settings.Secure.getUriFor(Settings.Secure.CAMERA_GESTURE_DISABLED),
|
Settings.Secure.getUriFor(Settings.Secure.CAMERA_GESTURE_DISABLED),
|
||||||
false, mSettingObserver, mUserId);
|
false, mSettingObserver, mUserId);
|
||||||
|
mContext.getContentResolver().registerContentObserver(
|
||||||
|
Settings.Secure.getUriFor(Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED),
|
||||||
|
false, mSettingObserver, mUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCameraRegistered() {
|
private void updateCameraRegistered() {
|
||||||
@@ -135,6 +152,13 @@ class GestureLauncherService extends SystemService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateCameraDoubleTapPowerEnabled() {
|
||||||
|
boolean enabled = isCameraDoubleTapPowerSettingEnabled(mContext, mUserId);
|
||||||
|
synchronized (this) {
|
||||||
|
mCameraDoubleTapPowerEnabled = enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void unregisterCameraLaunchGesture() {
|
private void unregisterCameraLaunchGesture() {
|
||||||
if (mRegistered) {
|
if (mRegistered) {
|
||||||
mRegistered = false;
|
mRegistered = false;
|
||||||
@@ -197,6 +221,12 @@ class GestureLauncherService extends SystemService {
|
|||||||
Settings.Secure.CAMERA_GESTURE_DISABLED, 0, userId) == 0);
|
Settings.Secure.CAMERA_GESTURE_DISABLED, 0, userId) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isCameraDoubleTapPowerSettingEnabled(Context context, int userId) {
|
||||||
|
return isCameraDoubleTapPowerEnabled(context.getResources())
|
||||||
|
&& (Settings.Secure.getIntForUser(context.getContentResolver(),
|
||||||
|
Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0, userId) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to enable the camera launch gesture.
|
* Whether to enable the camera launch gesture.
|
||||||
*/
|
*/
|
||||||
@@ -207,13 +237,64 @@ class GestureLauncherService extends SystemService {
|
|||||||
!SystemProperties.getBoolean("gesture.disable_camera_launch", false);
|
!SystemProperties.getBoolean("gesture.disable_camera_launch", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isCameraDoubleTapPowerEnabled(Resources resources) {
|
||||||
|
return resources.getBoolean(
|
||||||
|
com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether GestureLauncherService should be enabled according to system properties.
|
* Whether GestureLauncherService should be enabled according to system properties.
|
||||||
*/
|
*/
|
||||||
public static boolean isGestureLauncherEnabled(Resources resources) {
|
public static boolean isGestureLauncherEnabled(Resources resources) {
|
||||||
// For now, the only supported gesture is camera launch gesture, so whether to enable this
|
return isCameraLaunchEnabled(resources) || isCameraDoubleTapPowerEnabled(resources);
|
||||||
// service equals to isCameraLaunchEnabled();
|
}
|
||||||
return isCameraLaunchEnabled(resources);
|
|
||||||
|
public boolean interceptPowerKeyDown(KeyEvent event, boolean interactive) {
|
||||||
|
boolean launched = false;
|
||||||
|
synchronized (this) {
|
||||||
|
if (!mCameraDoubleTapPowerEnabled) {
|
||||||
|
mLastPowerDownWhileNonInteractive = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (event.getEventTime() - mLastPowerDownWhileNonInteractive
|
||||||
|
< CAMERA_POWER_DOUBLE_TAP_TIME_MS) {
|
||||||
|
launched = true;
|
||||||
|
}
|
||||||
|
mLastPowerDownWhileNonInteractive = interactive ? 0 : event.getEventTime();
|
||||||
|
}
|
||||||
|
if (launched) {
|
||||||
|
Slog.i(TAG, "Power button double tap gesture detected, launching camera.");
|
||||||
|
launched = handleCameraLaunchGesture(false /* useWakelock */,
|
||||||
|
MetricsLogger.ACTION_DOUBLE_TAP_POWER_CAMERA_GESTURE);
|
||||||
|
}
|
||||||
|
return launched;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if camera was launched, false otherwise.
|
||||||
|
*/
|
||||||
|
private boolean handleCameraLaunchGesture(boolean useWakelock, int logCategory) {
|
||||||
|
boolean userSetupComplete = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.USER_SETUP_COMPLETE, 0) != 0;
|
||||||
|
if (!userSetupComplete) {
|
||||||
|
if (DBG) Slog.d(TAG, String.format(
|
||||||
|
"userSetupComplete = %s, ignoring camera launch gesture.",
|
||||||
|
userSetupComplete));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (DBG) Slog.d(TAG, String.format(
|
||||||
|
"userSetupComplete = %s, performing camera launch gesture.",
|
||||||
|
userSetupComplete));
|
||||||
|
|
||||||
|
if (useWakelock) {
|
||||||
|
// Make sure we don't sleep too early
|
||||||
|
mWakeLock.acquire(500L);
|
||||||
|
}
|
||||||
|
StatusBarManagerInternal service = LocalServices.getService(
|
||||||
|
StatusBarManagerInternal.class);
|
||||||
|
service.onCameraLaunchGestureDetected();
|
||||||
|
MetricsLogger.action(mContext, logCategory);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final BroadcastReceiver mUserReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mUserReceiver = new BroadcastReceiver() {
|
||||||
@@ -222,8 +303,9 @@ class GestureLauncherService extends SystemService {
|
|||||||
if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) {
|
if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) {
|
||||||
mUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
|
mUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
|
||||||
mContext.getContentResolver().unregisterContentObserver(mSettingObserver);
|
mContext.getContentResolver().unregisterContentObserver(mSettingObserver);
|
||||||
registerContentObserver();
|
registerContentObservers();
|
||||||
updateCameraRegistered();
|
updateCameraRegistered();
|
||||||
|
updateCameraDoubleTapPowerEnabled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -232,6 +314,7 @@ class GestureLauncherService extends SystemService {
|
|||||||
public void onChange(boolean selfChange, android.net.Uri uri, int userId) {
|
public void onChange(boolean selfChange, android.net.Uri uri, int userId) {
|
||||||
if (userId == mUserId) {
|
if (userId == mUserId) {
|
||||||
updateCameraRegistered();
|
updateCameraRegistered();
|
||||||
|
updateCameraDoubleTapPowerEnabled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -244,36 +327,17 @@ class GestureLauncherService extends SystemService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.sensor == mCameraLaunchSensor) {
|
if (event.sensor == mCameraLaunchSensor) {
|
||||||
handleCameraLaunchGesture(event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleCameraLaunchGesture(SensorEvent event) {
|
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
float[] values = event.values;
|
float[] values = event.values;
|
||||||
Slog.d(TAG, String.format("Received a camera launch event: " +
|
Slog.d(TAG, String.format("Received a camera launch event: " +
|
||||||
"values=[%.4f, %.4f, %.4f].", values[0], values[1], values[2]));
|
"values=[%.4f, %.4f, %.4f].", values[0], values[1], values[2]));
|
||||||
}
|
}
|
||||||
boolean userSetupComplete = Settings.Secure.getInt(mContext.getContentResolver(),
|
if (handleCameraLaunchGesture(true /* useWakelock */,
|
||||||
Settings.Secure.USER_SETUP_COMPLETE, 0) != 0;
|
MetricsLogger.ACTION_WIGGLE_CAMERA_GESTURE)) {
|
||||||
if (!userSetupComplete) {
|
trackCameraLaunchEvent(event);
|
||||||
if (DBG) Slog.d(TAG, String.format(
|
}
|
||||||
"userSetupComplete = %s, ignoring camera launch gesture.",
|
|
||||||
userSetupComplete));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (DBG) Slog.d(TAG, String.format(
|
|
||||||
"userSetupComplete = %s, performing camera launch gesture.",
|
|
||||||
userSetupComplete));
|
|
||||||
|
|
||||||
// Make sure we don't sleep too early
|
|
||||||
mWakeLock.acquire(500L);
|
|
||||||
StatusBarManagerInternal service = LocalServices.getService(
|
|
||||||
StatusBarManagerInternal.class);
|
|
||||||
service.onCameraLaunchGestureDetected();
|
|
||||||
trackCameraLaunchEvent(event);
|
|
||||||
mWakeLock.release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ import com.android.internal.R;
|
|||||||
import com.android.internal.statusbar.IStatusBarService;
|
import com.android.internal.statusbar.IStatusBarService;
|
||||||
import com.android.internal.util.ScreenShapeHelper;
|
import com.android.internal.util.ScreenShapeHelper;
|
||||||
import com.android.internal.widget.PointerLocationView;
|
import com.android.internal.widget.PointerLocationView;
|
||||||
|
import com.android.server.GestureLauncherService;
|
||||||
import com.android.server.LocalServices;
|
import com.android.server.LocalServices;
|
||||||
import com.android.server.policy.keyguard.KeyguardServiceDelegate;
|
import com.android.server.policy.keyguard.KeyguardServiceDelegate;
|
||||||
import com.android.server.policy.keyguard.KeyguardServiceDelegate.DrawnListener;
|
import com.android.server.policy.keyguard.KeyguardServiceDelegate.DrawnListener;
|
||||||
@@ -126,7 +127,6 @@ import java.io.File;
|
|||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -933,10 +933,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GestureLauncherService gestureService = LocalServices.getService(
|
||||||
|
GestureLauncherService.class);
|
||||||
|
boolean gesturedServiceIntercepted = false;
|
||||||
|
if (gestureService != null) {
|
||||||
|
gesturedServiceIntercepted = gestureService.interceptPowerKeyDown(event, interactive);
|
||||||
|
}
|
||||||
|
|
||||||
// If the power key has still not yet been handled, then detect short
|
// If the power key has still not yet been handled, then detect short
|
||||||
// press, long press, or multi press and decide what to do.
|
// press, long press, or multi press and decide what to do.
|
||||||
mPowerKeyHandled = hungUp || mScreenshotChordVolumeDownKeyTriggered
|
mPowerKeyHandled = hungUp || mScreenshotChordVolumeDownKeyTriggered
|
||||||
|| mScreenshotChordVolumeUpKeyTriggered;
|
|| mScreenshotChordVolumeUpKeyTriggered || gesturedServiceIntercepted;
|
||||||
if (!mPowerKeyHandled) {
|
if (!mPowerKeyHandled) {
|
||||||
if (interactive) {
|
if (interactive) {
|
||||||
// When interactive, we're already awake.
|
// When interactive, we're already awake.
|
||||||
|
|||||||
Reference in New Issue
Block a user