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

Commit a680beb2 authored by Steven Wu's avatar Steven Wu
Browse files

Store flashlight status and broadcast it needed for flashlight slice.

Test: manual
Bug: 74913192
Change-Id: I54ead1727d08b113dec13e3f7c128895770e68f1
parent a41a7094
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -7519,6 +7519,21 @@ public final class Settings {
         */
        public static final int CAMERA_LIFT_TRIGGER_ENABLED_DEFAULT = 1;
        /**
         * Whether or not the flashlight (camera torch mode) is available required to turn
         * on flashlight.
         *
         * @hide
         */
        public static final String FLASHLIGHT_AVAILABLE = "flashlight_available";
        /**
         * Whether or not flashlight is enabled.
         *
         * @hide
         */
        public static final String FLASHLIGHT_ENABLED = "flashlight_enabled";
        /**
         * Whether the assist gesture should be enabled.
         *
+3 −1
Original line number Diff line number Diff line
@@ -617,7 +617,9 @@ public class SettingsBackupTest {
                 Settings.Secure.LOW_POWER_MANUAL_ACTIVATION_COUNT,
                 Settings.Secure.LOW_POWER_WARNING_ACKNOWLEDGED,
                 Settings.Secure.SUPPRESS_AUTO_BATTERY_SAVER_SUGGESTION,
                 Settings.Secure.PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE);
                 Settings.Secure.PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE,
                 Settings.Secure.FLASHLIGHT_AVAILABLE,
                 Settings.Secure.FLASHLIGHT_ENABLED);

    @Test
    public void systemSettingsBackedUpOrBlacklisted() {
+14 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.policy;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
@@ -24,6 +25,8 @@ import android.hardware.camera2.CameraManager;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Process;
import android.provider.Settings;
import android.provider.Settings.Secure;
import android.text.TextUtils;
import android.util.Log;

@@ -46,6 +49,9 @@ public class FlashlightControllerImpl implements FlashlightController {
    private static final int DISPATCH_CHANGED = 1;
    private static final int DISPATCH_AVAILABILITY_CHANGED = 2;

    private static final String ACTION_FLASHLIGHT_CHANGED =
        "com.android.settings.flashlight.action.FLASHLIGHT_CHANGED";

    private final CameraManager mCameraManager;
    private final Context mContext;
    /** Call {@link #ensureHandler()} before using */
@@ -206,6 +212,9 @@ public class FlashlightControllerImpl implements FlashlightController {
        public void onTorchModeUnavailable(String cameraId) {
            if (TextUtils.equals(cameraId, mCameraId)) {
                setCameraAvailable(false);
                Settings.Secure.putInt(
                    mContext.getContentResolver(), Settings.Secure.FLASHLIGHT_AVAILABLE, 0);

            }
        }

@@ -214,6 +223,11 @@ public class FlashlightControllerImpl implements FlashlightController {
            if (TextUtils.equals(cameraId, mCameraId)) {
                setCameraAvailable(true);
                setTorchMode(enabled);
                Settings.Secure.putInt(
                    mContext.getContentResolver(), Settings.Secure.FLASHLIGHT_AVAILABLE, 1);
                Settings.Secure.putInt(
                    mContext.getContentResolver(), Secure.FLASHLIGHT_ENABLED, enabled ? 1 : 0);
                mContext.sendBroadcast(new Intent(ACTION_FLASHLIGHT_CHANGED));
            }
        }