Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7374fc32 authored by Sahil Sonar's avatar Sahil Sonar 💬
Browse files

wip! camera: Extend hw kill switch extension for hiroh

  - TODO: Change Android to actual device ro.product.device
parent 6368f596
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -40,8 +40,8 @@ public class DeviceSettings {
        return isMurena && isOne;
    }

    public static boolean isMurenaTwo() {
        return Build.DEVICE.toLowerCase(Locale.US).contains("two");
    public static boolean isHwKillSwitch() {
        return Build.DEVICE.toLowerCase(Locale.US).contains("two") || Build.DEVICE.toLowerCase(Locale.US).contains("android");
    }

    public static boolean isTablet(Context context) {
+1 −1
Original line number Diff line number Diff line
@@ -1639,7 +1639,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
            mainUI.onKeyUp(keyCode, event);
        }

        if (!camera_in_background && keyCode == 131 && DeviceSettings.isMurenaTwo()) {
        if (!camera_in_background && (keyCode == 131 || keyCode == 61) && DeviceSettings.isHwKillSwitch()) {
            String cameraState = Utils.getProperty("persist.sys.hwswitch.state", null);
            if (cameraState == null) return super.onKeyUp(keyCode, event);

+1 −1
Original line number Diff line number Diff line
@@ -2639,7 +2639,7 @@ public class MyApplicationInterface extends BasicApplicationInterface {

    @Override
    public void onCameraError() {
        if (DeviceSettings.isMurenaTwo()) return;
        if (DeviceSettings.isHwKillSwitch()) return;
        main_activity.getPreview().showToast(null, R.string.camera_error);
    }

+2 −2
Original line number Diff line number Diff line
@@ -2121,7 +2121,7 @@ public class DrawPreview {
            int pixels_offset = (int) (20 * scale_font + 0.5f); // convert dps to pixels
            if( preview.hasPermissions() ) {
                String cameraState = Utils.getProperty("persist.sys.hwswitch.state", null);
                if (cameraState != null && DeviceSettings.isMurenaTwo() && preview.openCameraFailed()) {
                if (cameraState != null && DeviceSettings.isHwKillSwitch() && preview.openCameraFailed()) {
                    boolean enabled = Objects.equals(cameraState, "1");
                    int text1 = enabled ? R.string.failed_to_open_camera_two_1_disabled : R.string.failed_to_open_camera_two_1_enabled;
                    int text2 = enabled ? R.string.failed_to_open_camera_two_2_disabled : R.string.failed_to_open_camera_two_2_enabled;
@@ -2129,7 +2129,7 @@ public class DrawPreview {
                    canvas.drawText(getContext().getResources().getString(text2), canvas.getWidth() / 2.0f, canvas.getHeight() / 2.0f + pixels_offset, p);
                }

                if ( !DeviceSettings.isMurenaTwo() && preview.openCameraFailed() ) {
                if ( !DeviceSettings.isHwKillSwitch() && preview.openCameraFailed() ) {
                    canvas.drawText(getContext().getResources().getString(R.string.failed_to_open_camera_1), canvas.getWidth() / 2.0f, canvas.getHeight() / 2.0f, p);
                    canvas.drawText(getContext().getResources().getString(R.string.failed_to_open_camera_2), canvas.getWidth() / 2.0f, canvas.getHeight() / 2.0f + pixels_offset, p);
                    canvas.drawText(getContext().getResources().getString(R.string.failed_to_open_camera_3), canvas.getWidth() / 2.0f, canvas.getHeight() / 2.0f + 2 * pixels_offset, p);