forked from LeddaZ/frameworks_base
3.0 KiB
3.0 KiB
How double-click power launches the camera
Last update: July 2022
Sequence of events
- PhoneWindowManager.java is responsible for all power button presses (see
interceptPowerKeyDown
) - Even though
PhoneWindowManager
has a lot of logic to detect all manner of power button multi-presses and gestures, it also checks withGestureLauncherService
, which is also offered the chance to intercept the power key GestureLauncherService
is responsible for the camera timeout, and if it detects one, it forwards it to the StatusBarManagerService (which hands it off to SystemUI)- Inside SystemUI,
onCameraLaunchDetected
in CentralSurfacesCommandQueueCallbacks.java looks at the keyguard state and determines- whether the camera is even allowed
- whether the screen is on; if not, we need to delay until that happens
- whether the device is locked (defined as "keyguard is showing").
- If the device is unlocked (no keyguard), the camera is launched immediately
- If the keyguard is up, however, NotificationPanelViewController.launchCamera takes over to handle the "secure camera" (a different intent, usually directing to the same app, but giving that app the cue to not allow access to the photo roll, etc).
- If the intent would have to launch a resolver (because the user has multiple camera apps installed and has not chosen one to always launch for the
SECURE_CAMERA_INTENT
, then - in order to show the resolver, the lockscreen "bouncer" (authentication method) is first presented - Otherwise (just one secure camera), it is launched
Which intent launches the camera app?
CameraGestureHelper encapsulate this logic. Roughly:
- If the keyguard is not showing (device is unlocked)
CameraIntents.getInsecureCameraIntent()
, defined to beMediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA
.
- If the keyguard is showing (device is locked)
- one of
CameraIntents.getInsecureCameraIntent()
orCameraIntents.getSecureCameraIntent()
, which areMediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA
andMediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE
, respectively
- one of
- Note that starting in Android 12, as required by some OEMs, if the special string resource
config_cameraGesturePackage
is nonempty, this will be treated as a package name to be added to the insecure camera intent, constraining the invocation to that single app and typically preventing implicit intent resolution. This package must be on the device or the camera gesture will no longer work properly