Make the default value of flashlight availibility to true.
We read from SettingsProvider to decide whether flashlight slice is available. However, when switching to the second user, FLASHLIGHT_AVAILABLE will be null. The default was 0 which causes the slice returning null, so we have to set it to 1 when there is a physical flash unit to be consistent with system ui. Fixes: 134734608 Test: robotest Change-Id: I981461b1b66e6e273e13a9cbcba96e3ccf0aec68
This commit is contained in:
@@ -39,6 +39,7 @@ import androidx.slice.builders.ListBuilder;
|
||||
import androidx.slice.builders.ListBuilder.RowBuilder;
|
||||
import androidx.slice.builders.SliceAction;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.slices.CustomSliceRegistry;
|
||||
@@ -131,10 +132,19 @@ public class FlashlightSlice implements CustomSliceable {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static boolean isFlashlightAvailable(Context context) {
|
||||
return Settings.Secure.getInt(
|
||||
context.getContentResolver(), Secure.FLASHLIGHT_AVAILABLE, 0) == 1;
|
||||
@VisibleForTesting
|
||||
static boolean isFlashlightAvailable(Context context) {
|
||||
int defaultAvailability = 0;
|
||||
try {
|
||||
// check if there is a flash unit
|
||||
if (getCameraId(context) != null) {
|
||||
defaultAvailability = 1;
|
||||
}
|
||||
} catch (CameraAccessException e) {
|
||||
Log.e(TAG, "Error getting camera id.", e);
|
||||
}
|
||||
return Secure.getInt(context.getContentResolver(),
|
||||
Secure.FLASHLIGHT_AVAILABLE, defaultAvailability) == 1;
|
||||
}
|
||||
|
||||
private static boolean isFlashlightEnabled(Context context) {
|
||||
|
Reference in New Issue
Block a user