1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.shade; 18 19 import com.android.systemui.camera.CameraGestureHelper; 20 import com.android.systemui.dagger.SysUISingleton; 21 import com.android.systemui.statusbar.phone.KeyguardBypassController; 22 23 import javax.inject.Inject; 24 25 /** Handles launching camera from Shade. */ 26 @SysUISingleton 27 public class CameraLauncher { 28 private final CameraGestureHelper mCameraGestureHelper; 29 private final KeyguardBypassController mKeyguardBypassController; 30 31 private boolean mLaunchingAffordance; 32 33 @Inject CameraLauncher( CameraGestureHelper cameraGestureHelper, KeyguardBypassController keyguardBypassController )34 public CameraLauncher( 35 CameraGestureHelper cameraGestureHelper, 36 KeyguardBypassController keyguardBypassController 37 ) { 38 mCameraGestureHelper = cameraGestureHelper; 39 mKeyguardBypassController = keyguardBypassController; 40 } 41 42 /** Launches the camera. */ launchCamera(int source, boolean isShadeFullyCollapsed)43 public void launchCamera(int source, boolean isShadeFullyCollapsed) { 44 if (!isShadeFullyCollapsed) { 45 setLaunchingAffordance(true); 46 } 47 48 mCameraGestureHelper.launchCamera(source); 49 } 50 51 /** 52 * Set whether we are currently launching an affordance. This is currently only set when 53 * launched via a camera gesture. 54 */ setLaunchingAffordance(boolean launchingAffordance)55 public void setLaunchingAffordance(boolean launchingAffordance) { 56 mLaunchingAffordance = launchingAffordance; 57 mKeyguardBypassController.setLaunchingAffordance(launchingAffordance); 58 } 59 60 /** 61 * Return true when a bottom affordance is launching an occluded activity with a splash screen. 62 */ isLaunchingAffordance()63 public boolean isLaunchingAffordance() { 64 return mLaunchingAffordance; 65 } 66 67 /** 68 * Whether the camera application can be launched for the camera launch gesture. 69 */ canCameraGestureBeLaunched(int barState)70 public boolean canCameraGestureBeLaunched(int barState) { 71 return mCameraGestureHelper.canCameraGestureBeLaunched(barState); 72 } 73 } 74