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

Unverified Commit b43bd4e3 authored by Roman Birg's avatar Roman Birg Committed by Michael Bestas
Browse files

SystemUI: handle camera launch gesture from keyhandler



Co-authored-by: default avatarMichael Bestas <mikeioannina@cyanogenmod.org>
Change-Id: Iba9211b7d342f618c4082c34d11663d89861607a
parent 91aa5cbd
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -272,6 +272,8 @@ public class StatusBarManager {
    public static final int CAMERA_LAUNCH_SOURCE_LIFT_TRIGGER = 2;
    /** @hide */
    public static final int CAMERA_LAUNCH_SOURCE_QUICK_AFFORDANCE = 3;
    /** @hide */
    public static final int CAMERA_LAUNCH_SOURCE_SCREEN_GESTURE = 4;

    /**
     * Broadcast action: sent to apps that hold the status bar permission when
+1 −0
Original line number Diff line number Diff line
@@ -460,6 +460,7 @@ constructor(
            StatusBarManager.CAMERA_LAUNCH_SOURCE_LIFT_TRIGGER -> CameraLaunchType.LIFT_TRIGGER
            StatusBarManager.CAMERA_LAUNCH_SOURCE_QUICK_AFFORDANCE ->
                CameraLaunchType.QUICK_AFFORDANCE
            StatusBarManager.CAMERA_LAUNCH_SOURCE_SCREEN_GESTURE -> CameraLaunchType.SCREEN_GESTURE
            else -> throw IllegalArgumentException("Invalid CameraLaunchType value: $value")
        }
    }
+2 −0
Original line number Diff line number Diff line
@@ -27,4 +27,6 @@ enum class CameraLaunchType {
    LIFT_TRIGGER,
    /** Quick affordance button has been pressed */
    QUICK_AFFORDANCE,
    /** Screen gesture has been triggered */
    SCREEN_GESTURE,
}
+4 −1
Original line number Diff line number Diff line
@@ -384,7 +384,10 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba
            mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_CAMERA_LAUNCH,
                    "com.android.systemui:CAMERA_GESTURE");
        }

        if (source != StatusBarManager.CAMERA_LAUNCH_SOURCE_SCREEN_GESTURE) {
            vibrateForCameraGesture();
        }

        if (source == StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) {
            Log.v(CentralSurfaces.TAG, "Camera launch");
+16 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
import android.provider.Settings;
import android.service.dreams.IDreamManager;
import android.service.notification.StatusBarNotification;
import android.util.ArraySet;
@@ -1468,6 +1469,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        filter.addAction(lineageos.content.Intent.ACTION_SCREEN_CAMERA_GESTURE);
        mBroadcastDispatcher.registerReceiver(mBroadcastReceiver, filter, null, UserHandle.ALL);
    }

@@ -1962,6 +1964,20 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
                }
                finishBarAnimations();
                mNotificationsController.resetUserExpandedStates();
            } else if (lineageos.content.Intent.ACTION_SCREEN_CAMERA_GESTURE.equals(action)) {
                boolean userSetupComplete = Settings.Secure.getInt(mContext.getContentResolver(),
                        Settings.Secure.USER_SETUP_COMPLETE, 0) != 0;
                if (!userSetupComplete) {
                    if (DEBUG) Log.d(TAG, String.format(
                            "userSetupComplete = %s, ignoring camera launch gesture.",
                            userSetupComplete));
                    return;
                }

                // This gets executed before we will show Keyguard, so post it in order that the
                // state is correct.
                mMainExecutor.execute(() -> mCommandQueueCallbacks.onCameraLaunchGestureDetected(
                        StatusBarManager.CAMERA_LAUNCH_SOURCE_SCREEN_GESTURE));
            }
            Trace.endSection();
        }