am 70917abe: am ff3666ad: Kill flashlight when launching the camera from lockscreen
* commit '70917abeddb096dca993636020c80a1b2085dcc6': Kill flashlight when launching the camera from lockscreen
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user