diff options
3 files changed, 29 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index b5f38ae..74bc698 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -38,6 +38,7 @@ import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.systemui.R; +import com.android.systemui.statusbar.policy.FlashlightController; /** * Implementation for the bottom area of the Keyguard, including camera/phone affordance and status @@ -63,6 +64,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL private ActivityStarter mActivityStarter; private UnlockMethodCache mUnlockMethodCache; private LockPatternUtils mLockPatternUtils; + private FlashlightController mFlashlightController; public KeyguardBottomAreaView(Context context) { super(context); @@ -102,6 +104,10 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL mActivityStarter = activityStarter; } + public void setFlashlightController(FlashlightController flashlightController) { + mFlashlightController = flashlightController; + } + private Intent getCameraIntent() { KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext); boolean currentUserHasTrust = updateMonitor.getUserHasTrust( @@ -189,6 +195,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL } public void launchCamera() { + mFlashlightController.killFlashlight(); Intent intent = getCameraIntent(); if (intent == SECURE_CAMERA_INTENT) { mContext.startActivityAsUser(intent, UserHandle.CURRENT); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index a5dee6d..59becd3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -752,6 +752,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } mFlashlightController = new FlashlightController(mContext); + mKeyguardBottomArea.setFlashlightController(mFlashlightController); mUserSwitcherController = new UserSwitcherController(mContext); mKeyguardMonitor = new KeyguardMonitor(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java index 46f8c80..e05e34b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightController.java @@ -94,6 +94,16 @@ public class FlashlightController { } } + public void killFlashlight() { + boolean enabled; + synchronized (this) { + enabled = mFlashlightEnabled; + } + if (enabled) { + mHandler.post(mKillFlashlightRunnable); + } + } + public synchronized boolean isAvailable() { return ENFORCE_AVAILABILITY_LISTENER ? mCameraAvailable : (mCameraId != null); } @@ -320,6 +330,17 @@ public class FlashlightController { } }; + private final Runnable mKillFlashlightRunnable = new Runnable() { + @Override + public void run() { + synchronized (this) { + mFlashlightEnabled = false; + } + updateFlashlight(true /* forceDisable */); + dispatchOff(); + } + }; + private final CameraManager.AvailabilityListener mAvailabilityListener = new CameraManager.AvailabilityListener() { @Override |