Loading app/src/main/AndroidManifest.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -46,6 +46,7 @@ <activity <activity android:name="net.sourceforge.opencamera.MainActivity" android:name="net.sourceforge.opencamera.MainActivity" android:configChanges="orientation|screenSize|keyboardHidden" android:configChanges="orientation|screenSize|keyboardHidden" android:launchMode="singleInstance" android:clearTaskOnLaunch="true" android:clearTaskOnLaunch="true" android:exported="true" android:exported="true" > > Loading app/src/main/java/net/sourceforge/opencamera/DeviceSettings.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -38,4 +38,8 @@ public class DeviceSettings { final boolean isOne = Build.DEVICE.equals("one") || Build.DEVICE.equals("X2"); final boolean isOne = Build.DEVICE.equals("one") || Build.DEVICE.equals("X2"); return isMurena && isOne; return isMurena && isOne; } } public static boolean isMurenaTwo() { return Build.DEVICE.toLowerCase(Locale.US).contains("two"); } } } app/src/main/java/net/sourceforge/opencamera/MainActivity.java +28 −0 Original line number Original line Diff line number Diff line Loading @@ -30,6 +30,7 @@ import java.util.Locale; import java.util.Map; import java.util.Map; import java.util.Objects; import java.util.Objects; import java.util.Set; import java.util.Set; import java.util.Objects; import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.Future; Loading Loading @@ -196,6 +197,11 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen public static volatile Insets test_insets; // test insets for WindowInsets.Type.navigationBars() | WindowInsets.Type.displayCutout() public static volatile Insets test_insets; // test insets for WindowInsets.Type.navigationBars() | WindowInsets.Type.displayCutout() public static volatile Insets test_cutout_insets; // test insets for WindowInsets.Type.displayCutout() public static volatile Insets test_cutout_insets; // test insets for WindowInsets.Type.displayCutout() private boolean murenaTwoHwKill = false; private Handler handler; private Runnable retryRunnable = null; // whether this is a multi-camera device (note, this isn't simply having more than 1 camera, but also having more than one with the same facing) // whether this is a multi-camera device (note, this isn't simply having more than 1 camera, but also having more than one with the same facing) // note that in most cases, code should check the MultiCamButtonPreferenceKey preference as well as the is_multi_cam flag, // note that in most cases, code should check the MultiCamButtonPreferenceKey preference as well as the is_multi_cam flag, // this can be done via isMultiCamEnabled(). // this can be done via isMultiCamEnabled(). Loading Loading @@ -368,6 +374,8 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen magneticSensor = new MagneticSensor(this); magneticSensor = new MagneticSensor(this); //speechControl = new SpeechControl(this); //speechControl = new SpeechControl(this); handler = new Handler(); // determine whether we support Camera2 API // determine whether we support Camera2 API // must be done before setDeviceDefaults() // must be done before setDeviceDefaults() initCamera2Support(); initCamera2Support(); Loading Loading @@ -1539,6 +1547,26 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen else { else { mainUI.onKeyUp(keyCode, event); mainUI.onKeyUp(keyCode, event); } } if (!camera_in_background && keyCode == 131 && DeviceSettings.isMurenaTwo()) { String cameraState = Utils.getProperty("persist.sys.hwswitch.state", null); if (cameraState == null) return super.onKeyUp(keyCode, event); if (retryRunnable != null) { handler.removeCallbacks(retryRunnable); } murenaTwoHwKill = Objects.equals(cameraState, "1"); retryRunnable = () -> { if (!murenaTwoHwKill) { preview.retryOpenCamera(); } else { restartOpenCamera(); } }; handler.postDelayed(retryRunnable, murenaTwoHwKill ? 200 : 5000); } return super.onKeyUp(keyCode, event); return super.onKeyUp(keyCode, event); } } Loading app/src/main/java/net/sourceforge/opencamera/MyApplicationInterface.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -2724,6 +2724,7 @@ public class MyApplicationInterface extends BasicApplicationInterface { @Override @Override public void onCameraError() { public void onCameraError() { if (DeviceSettings.isMurenaTwo()) return; main_activity.getPreview().showToast(null, R.string.camera_error); main_activity.getPreview().showToast(null, R.string.camera_error); } } Loading app/src/main/java/net/sourceforge/opencamera/Utils.java 0 → 100644 +19 −0 Original line number Original line Diff line number Diff line package net.sourceforge.opencamera; import android.os.Build; import java.lang.reflect.Method; import java.util.Locale; public class Utils { public static String getProperty(String key, String defaultValue) { try { Class<?> systemProperties = Class.forName("android.os.SystemProperties"); Method get = systemProperties.getMethod("get", String.class, String.class); return (String) get.invoke(null, key, defaultValue); } catch (Exception e) { e.printStackTrace(); return defaultValue; } } } Loading
app/src/main/AndroidManifest.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -46,6 +46,7 @@ <activity <activity android:name="net.sourceforge.opencamera.MainActivity" android:name="net.sourceforge.opencamera.MainActivity" android:configChanges="orientation|screenSize|keyboardHidden" android:configChanges="orientation|screenSize|keyboardHidden" android:launchMode="singleInstance" android:clearTaskOnLaunch="true" android:clearTaskOnLaunch="true" android:exported="true" android:exported="true" > > Loading
app/src/main/java/net/sourceforge/opencamera/DeviceSettings.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -38,4 +38,8 @@ public class DeviceSettings { final boolean isOne = Build.DEVICE.equals("one") || Build.DEVICE.equals("X2"); final boolean isOne = Build.DEVICE.equals("one") || Build.DEVICE.equals("X2"); return isMurena && isOne; return isMurena && isOne; } } public static boolean isMurenaTwo() { return Build.DEVICE.toLowerCase(Locale.US).contains("two"); } } }
app/src/main/java/net/sourceforge/opencamera/MainActivity.java +28 −0 Original line number Original line Diff line number Diff line Loading @@ -30,6 +30,7 @@ import java.util.Locale; import java.util.Map; import java.util.Map; import java.util.Objects; import java.util.Objects; import java.util.Set; import java.util.Set; import java.util.Objects; import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.Future; Loading Loading @@ -196,6 +197,11 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen public static volatile Insets test_insets; // test insets for WindowInsets.Type.navigationBars() | WindowInsets.Type.displayCutout() public static volatile Insets test_insets; // test insets for WindowInsets.Type.navigationBars() | WindowInsets.Type.displayCutout() public static volatile Insets test_cutout_insets; // test insets for WindowInsets.Type.displayCutout() public static volatile Insets test_cutout_insets; // test insets for WindowInsets.Type.displayCutout() private boolean murenaTwoHwKill = false; private Handler handler; private Runnable retryRunnable = null; // whether this is a multi-camera device (note, this isn't simply having more than 1 camera, but also having more than one with the same facing) // whether this is a multi-camera device (note, this isn't simply having more than 1 camera, but also having more than one with the same facing) // note that in most cases, code should check the MultiCamButtonPreferenceKey preference as well as the is_multi_cam flag, // note that in most cases, code should check the MultiCamButtonPreferenceKey preference as well as the is_multi_cam flag, // this can be done via isMultiCamEnabled(). // this can be done via isMultiCamEnabled(). Loading Loading @@ -368,6 +374,8 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen magneticSensor = new MagneticSensor(this); magneticSensor = new MagneticSensor(this); //speechControl = new SpeechControl(this); //speechControl = new SpeechControl(this); handler = new Handler(); // determine whether we support Camera2 API // determine whether we support Camera2 API // must be done before setDeviceDefaults() // must be done before setDeviceDefaults() initCamera2Support(); initCamera2Support(); Loading Loading @@ -1539,6 +1547,26 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen else { else { mainUI.onKeyUp(keyCode, event); mainUI.onKeyUp(keyCode, event); } } if (!camera_in_background && keyCode == 131 && DeviceSettings.isMurenaTwo()) { String cameraState = Utils.getProperty("persist.sys.hwswitch.state", null); if (cameraState == null) return super.onKeyUp(keyCode, event); if (retryRunnable != null) { handler.removeCallbacks(retryRunnable); } murenaTwoHwKill = Objects.equals(cameraState, "1"); retryRunnable = () -> { if (!murenaTwoHwKill) { preview.retryOpenCamera(); } else { restartOpenCamera(); } }; handler.postDelayed(retryRunnable, murenaTwoHwKill ? 200 : 5000); } return super.onKeyUp(keyCode, event); return super.onKeyUp(keyCode, event); } } Loading
app/src/main/java/net/sourceforge/opencamera/MyApplicationInterface.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -2724,6 +2724,7 @@ public class MyApplicationInterface extends BasicApplicationInterface { @Override @Override public void onCameraError() { public void onCameraError() { if (DeviceSettings.isMurenaTwo()) return; main_activity.getPreview().showToast(null, R.string.camera_error); main_activity.getPreview().showToast(null, R.string.camera_error); } } Loading
app/src/main/java/net/sourceforge/opencamera/Utils.java 0 → 100644 +19 −0 Original line number Original line Diff line number Diff line package net.sourceforge.opencamera; import android.os.Build; import java.lang.reflect.Method; import java.util.Locale; public class Utils { public static String getProperty(String key, String defaultValue) { try { Class<?> systemProperties = Class.forName("android.os.SystemProperties"); Method get = systemProperties.getMethod("get", String.class, String.class); return (String) get.invoke(null, key, defaultValue); } catch (Exception e) { e.printStackTrace(); return defaultValue; } } }