mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-24 23:19:31 -05:00
Add a patch for tri-state torch on clark
This commit is contained in:
parent
dce1e38193
commit
f835a6e5f1
@ -0,0 +1,83 @@
|
||||
From 1802dfd756eb6d68560c8e2d4659c690e3110e04 Mon Sep 17 00:00:00 2001
|
||||
From: Tad <tad@spotco.us>
|
||||
Date: Wed, 4 Oct 2017 20:31:17 -0400
|
||||
Subject: [PATCH] Tri-state torch
|
||||
|
||||
Change-Id: Ica35b7e9132de188694cd0f2d22e7bc62aa0415b
|
||||
---
|
||||
.../cyanogenmod/settings/device/TorchAction.java | 33 ++++++++++++++--------
|
||||
1 file changed, 22 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/cmactions/src/com/cyanogenmod/settings/device/TorchAction.java b/cmactions/src/com/cyanogenmod/settings/device/TorchAction.java
|
||||
index a3bcdce..7a2e107 100755
|
||||
--- a/cmactions/src/com/cyanogenmod/settings/device/TorchAction.java
|
||||
+++ b/cmactions/src/com/cyanogenmod/settings/device/TorchAction.java
|
||||
@@ -32,7 +32,8 @@ public class TorchAction implements SensorAction {
|
||||
private final int mVibratorPeriod;
|
||||
private final Vibrator mVibrator;
|
||||
private String mRearCameraId;
|
||||
- private static boolean mTorchEnabled;;
|
||||
+ private String mFrontCameraId;
|
||||
+ private static int mTorchState = 0;
|
||||
|
||||
public TorchAction(Context mContext, int vibratorPeriod) {
|
||||
mCameraManager = (CameraManager) mContext.getSystemService(Context.CAMERA_SERVICE);
|
||||
@@ -45,7 +46,8 @@ public class TorchAction implements SensorAction {
|
||||
int cOrientation = characteristics.get(CameraCharacteristics.LENS_FACING);
|
||||
if (cOrientation == CameraCharacteristics.LENS_FACING_BACK) {
|
||||
mRearCameraId = cameraId;
|
||||
- break;
|
||||
+ } else if (cOrientation == CameraCharacteristics.LENS_FACING_FRONT){
|
||||
+ mFrontCameraId = cameraId;
|
||||
}
|
||||
}
|
||||
} catch (CameraAccessException e) {
|
||||
@@ -55,10 +57,23 @@ public class TorchAction implements SensorAction {
|
||||
@Override
|
||||
public void action() {
|
||||
mVibrator.vibrate(mVibratorPeriod);
|
||||
- if (mRearCameraId != null) {
|
||||
+ if (mRearCameraId != null && mFrontCameraId != null) {
|
||||
try {
|
||||
- mCameraManager.setTorchMode(mRearCameraId, !mTorchEnabled);
|
||||
- mTorchEnabled = !mTorchEnabled;
|
||||
+ switch(mTorchState) {
|
||||
+ case 0:
|
||||
+ mCameraManager.setTorchMode(mRearCameraId, true);
|
||||
+ mTorchState = 1;
|
||||
+ break;
|
||||
+ case 1:
|
||||
+ mCameraManager.setTorchMode(mRearCameraId, false);
|
||||
+ mCameraManager.setTorchMode(mFrontCameraId, true);
|
||||
+ mTorchState = 2;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ mCameraManager.setTorchMode(mFrontCameraId, false);
|
||||
+ mTorchState = 0;
|
||||
+ break;
|
||||
+ }
|
||||
} catch (CameraAccessException e) {
|
||||
}
|
||||
}
|
||||
@@ -67,16 +82,12 @@ public class TorchAction implements SensorAction {
|
||||
private class MyTorchCallback extends CameraManager.TorchCallback {
|
||||
@Override
|
||||
public void onTorchModeChanged(String cameraId, boolean enabled) {
|
||||
- if (!cameraId.equals(mRearCameraId))
|
||||
- return;
|
||||
- mTorchEnabled = enabled;
|
||||
+
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTorchModeUnavailable(String cameraId) {
|
||||
- if (!cameraId.equals(mRearCameraId))
|
||||
- return;
|
||||
- mTorchEnabled = false;
|
||||
+ mTorchState = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
--
|
||||
2.14.2
|
||||
|
@ -93,6 +93,7 @@ patch -p1 < $patches"android_external_sqlite/0001-Secure_Delete.patch" #Enable s
|
||||
enter "frameworks/base"
|
||||
git revert 0326bb5e41219cf502727c3aa44ebf2daa19a5b3 #re-enable doze on devices without gms
|
||||
git fetch https://review.lineageos.org/LineageOS/android_frameworks_base refs/changes/75/151975/37 && git cherry-pick FETCH_HEAD #network traffic
|
||||
git fetch https://review.lineageos.org/LineageOS/android_frameworks_base refs/changes/28/191728/1 && git cherry-pick FETCH_HEAD #revert protected apps nonsense
|
||||
sed -i 's/DEFAULT_MAX_FILES = 1000;/DEFAULT_MAX_FILES = 0;/' services/core/java/com/android/server/DropBoxManagerService.java; #Disable DropBox
|
||||
sed -i '0,/wifi,cell,battery/s/wifi,cell,battery,dnd,flashlight,rotation,bt,airplane/wifi,cell,bt,dnd,flashlight,rotation,battery,profiles,location,airplane,saver,hotspot,nfc/' packages/SystemUI/res/values/config.xml;
|
||||
sed -i 's/ScaleSetting = 1.0f;/ScaleSetting = 0.5f;/' services/core/java/com/android/server/wm/WindowManagerService.java; #Speedup animation scale
|
||||
@ -201,6 +202,7 @@ sed -i 's/shouldUseOptimizations(weight)/true/' cm/lib/main/java/org/cyanogenmod
|
||||
#
|
||||
enter "device/motorola/clark"
|
||||
enableDexPreOpt
|
||||
patch -p1 < $patches"android_device_motorola_Clark/0001-Tri_State_Torch.patch" #Tri-state torch
|
||||
|
||||
enter "device/oneplus/bacon"
|
||||
enableDexPreOpt
|
||||
|
Loading…
Reference in New Issue
Block a user