Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0749499 authored by Vladislav Koldobskiy's avatar Vladislav Koldobskiy Committed by Michael Bestas
Browse files

Camera button support (1/2)

Add new bitmask for Camera button and "hasCamera" boolean.
For those devices that have dedicated Camera key
(like Sony ZL/ZR/Z1/...)
Change-Id: I1a6681664f9f3fd3f30221ba10b082cb5f8cafca

Camera button support: make it actually work
Previous commits were merged so fast that I didn't even
added the code that actually DOES launch the camera.
Let me fix that.
Change-Id: I4fcb3c46e5fd50e273dcf19fd3eb35a3f9d979e0

Camera button support: useful features & bugfixes (1/2)
Screw the remapping, let's make something more useful!
Replaced the code to actually launch Camera app, not just fire the shutter.
I won't remove it: it's cool to have an option to double-click Home for Camera.
Added:
  * Camera wake (with button half-press) and unlock options
  * "Peek": releasing the half-pressed Camera button will
    turn the screen back off
  * Camera playback control

Change-Id: Id49e09e20d81cd80d9800ab8ab0f200d44485a09
parent 0d2b2610
Loading
Loading
Loading
Loading
+95 −70
Original line number Diff line number Diff line
@@ -3035,6 +3035,24 @@ public final class Settings {
         */
        public static final String VOLBTN_MUSIC_CONTROLS = "volbtn_music_controls";

        /**
         * Whether to wake the screen with the camera key half-press.
         * @hide
         */
        public static final String CAMERA_WAKE_SCREEN = "camera_wake_screen";

        /**
         * Whether or not to send device back to sleep if Camera button is released ("Peek")
         * @hide
         */
        public static final String CAMERA_SLEEP_ON_RELEASE = "camera_sleep_on_release";

        /**
         * Whether or not camera button music controls should be enabled to play/pause media tracks
         * @hide
         */
        public static final String CAMERA_MUSIC_CONTROLS = "camera_music_controls";

        /**
         * Whether or not to launch default music player when headset is connected
         * @hide
@@ -3301,6 +3319,7 @@ public final class Settings {
         * 3 - Search
         * 4 - Voice search
         * 5 - In-app search
         * 6 - Launch Camera
         * @hide
         */
        public static final String KEY_HOME_LONG_PRESS_ACTION = "key_home_long_press_action";
@@ -3349,17 +3368,17 @@ public final class Settings {
        public static final String KEY_APP_SWITCH_ACTION = "key_app_switch_action";

        /**
         * Weather to minimize lockscreen challenge on screen turned on
         * Action to perform when the app switch key is long-pressed. (Default is 0)
         * (See KEY_HOME_LONG_PRESS_ACTION for valid values)
         * @hide
         */
        public static final String LOCKSCREEN_MAXIMIZE_WIDGETS = "lockscreen_maximize_widgets";
        public static final String KEY_APP_SWITCH_LONG_PRESS_ACTION = "key_app_switch_long_press_action";

        /**
          * Action to perform when the app switch key is long-pressed. (Default is 0)
          * (See KEY_HOME_LONG_PRESS_ACTION for valid values)
         * Weather to minimize lockscreen challenge on screen turned on
         * @hide
         */
         public static final String KEY_APP_SWITCH_LONG_PRESS_ACTION = "key_app_switch_long_press_action";
        public static final String LOCKSCREEN_MAXIMIZE_WIDGETS = "lockscreen_maximize_widgets";

        /**
         * Performance profile
@@ -3374,6 +3393,12 @@ public final class Settings {
         */
        public static final String HOME_UNLOCK_SCREEN = "home_unlock_screen";

        /**
         * Whether to unlock the screen with the camera key.  The value is boolean (1 or 0).
         * @hide
         */
        public static final String CAMERA_UNLOCK_SCREEN = "camera_unlock_screen";

        /**
         * Whether the lockscreen vibrate should be enabled.
         * @hide
+5 −0
Original line number Diff line number Diff line
@@ -1434,10 +1434,15 @@
             4 - Menu
             8 - Assistant (search)
            16 - App switch
            32 - Camera
         For example, a device with Home, Back and Menu keys would set this
         config to 7. -->
    <integer name="config_deviceHardwareKeys">15</integer>

    <!-- Indicates that the device has Single-stage Camera key
         (without "Focus" state) instead of Dual-stage. -->
    <bool name="config_singleStageCameraKey">false</bool>

    <!-- Defines the system property to set for performance profile xe: sys.cpu.modes. Leave it
         blank if the device do not support performance profiles -->
    <string name="config_perf_profile_prop" translatable="false"></string>
+1 −0
Original line number Diff line number Diff line
@@ -1794,6 +1794,7 @@

  <!-- Hardware Key ReMapping -->
  <java-symbol type="integer" name="config_deviceHardwareKeys" />
  <java-symbol type="bool" name="config_singleStageCameraKey" />

  <!-- Notification and battery light -->
  <java-symbol type="bool" name="config_intrusiveBatteryLed" />
+15 −0
Original line number Diff line number Diff line
@@ -1714,6 +1714,12 @@ public class KeyguardHostView extends KeyguardViewBase {
        return homeOverride;
    }

    private boolean shouldEnableCameraKey() {
        final boolean cameraOverride = Settings.System.getInt(getContext().getContentResolver(),
                Settings.System.CAMERA_UNLOCK_SCREEN, 0) == 1;
        return cameraOverride;
    }

    public void goToWidget(int appWidgetId) {
        mAppWidgetToShow = appWidgetId;
        mSwitchPageRunnable.run();
@@ -1737,6 +1743,15 @@ public class KeyguardHostView extends KeyguardViewBase {
        return false;
    }

    public boolean handleCameraKey() {
        // The following enables the CAMERA key to work for testing automation
        if (shouldEnableCameraKey()) {
            showNextSecurityScreenOrFinish(false);
            return true;
        }
        return false;
    }

    public boolean handleBackKey() {
        if (mCurrentSecuritySelection == SecurityMode.Account) {
            // go back to primary screen and re-disable back
+8 −0
Original line number Diff line number Diff line
@@ -280,6 +280,14 @@ public class KeyguardViewManager {
    public boolean handleKeyDown(int keyCode, KeyEvent event) {
        if (event.getRepeatCount() == 0) {
            mUnlockKeyDown = true;
            // We check for Camera key press in handleKeyDown, because
            // it gives us "instant" unlock, when user depresses
            // the button.
            if (keyCode == KeyEvent.KEYCODE_CAMERA) {
                if (mKeyguardView.handleCameraKey()) {
                    return true;
                }
            }
        }
        if (event.isLongPress()) {
            String action = null;
Loading