Move trust usb setting to global, and drop keyguard from name

* We're expanding this to allow disabling usb devices always.

Change-Id: Ibdea983160ae88c3eb696540631facefc288b859
This commit is contained in:
Chirayu Desai
2021-12-30 16:56:55 +05:30
committed by Michael Bestas
parent 61767fe1e3
commit a97180fa58
2 changed files with 28 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
/**
* Copyright (C) 2015-2016 The CyanogenMod Project
* 2017-2021 The LineageOS Project
* 2017-2022 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,7 +60,7 @@ public class LineageDatabaseHelper extends SQLiteOpenHelper{
private static final boolean LOCAL_LOGV = false;
private static final String DATABASE_NAME = "lineagesettings.db";
private static final int DATABASE_VERSION = 15;
private static final int DATABASE_VERSION = 16;
private static final String DATABASE_NAME_OLD = "cmsettings.db";
@@ -408,6 +408,17 @@ public class LineageDatabaseHelper extends SQLiteOpenHelper{
}
upgradeVersion = 15;
}
if (upgradeVersion < 16) {
// Move trust_restrict_usb to global
if (mUserHandle == UserHandle.USER_OWNER) {
moveSettingsToNewTable(db, LineageTableNames.TABLE_SECURE,
LineageTableNames.TABLE_GLOBAL, new String[] {
LineageSettings.Global.TRUST_RESTRICT_USB
}, true);
}
upgradeVersion = 16;
}
// *** Remember to update DATABASE_VERSION above!
if (upgradeVersion != newVersion) {
Log.wtf(TAG, "warning: upgrading settings database to version "

View File

@@ -2943,18 +2943,6 @@ public final class LineageSettings {
/** @hide */
public static final Validator NETWORK_TRAFFIC_SHOW_UNITS_VALIDATOR = sBooleanValidator;
/**
* Restrict USB when the screen is locked
* 0 = Off, 1 = On
*
* @hide
*/
public static final String TRUST_RESTRICT_USB_KEYGUARD = "trust_restrict_usb";
/** @hide */
public static final Validator TRUST_RESTRICT_USB_KEYGUARD_VALIDATOR =
sBooleanValidator;
/**
* Trust warnings status
*
@@ -3044,7 +3032,6 @@ public final class LineageSettings {
VALIDATORS.put(NETWORK_TRAFFIC_UNITS, NETWORK_TRAFFIC_UNITS_VALIDATOR);
VALIDATORS.put(NETWORK_TRAFFIC_SHOW_UNITS, NETWORK_TRAFFIC_SHOW_UNITS_VALIDATOR);
VALIDATORS.put(TETHERING_ALLOW_VPN_UPSTREAMS, TETHERING_ALLOW_VPN_UPSTREAMS_VALIDATOR);
VALIDATORS.put(TRUST_RESTRICT_USB_KEYGUARD, TRUST_RESTRICT_USB_KEYGUARD_VALIDATOR);
VALIDATORS.put(TRUST_WARNINGS, TRUST_WARNINGS_VALIDATOR);
VALIDATORS.put(VOLUME_PANEL_ON_LEFT, VOLUME_PANEL_ON_LEFT_VALIDATOR);
}
@@ -3451,6 +3438,20 @@ public final class LineageSettings {
* @hide
*/
public static final String WIFI_AUTO_PRIORITIES_CONFIGURATION = "wifi_auto_priority";
/**
* Restrict USB
* 0 = Off, never
* 1 = Only when the screen is locked
* 2 = On, always
*
* @hide
*/
public static final String TRUST_RESTRICT_USB = "trust_restrict_usb";
/** @hide */
public static final Validator TRUST_RESTRICT_USB_VALIDATOR =
new InclusiveIntegerRangeValidator(0, 2);
// endregion
/**
@@ -3496,6 +3497,7 @@ public final class LineageSettings {
public static final Map<String, Validator> VALIDATORS =
new ArrayMap<String, Validator>();
static {
VALIDATORS.put(TRUST_RESTRICT_USB, TRUST_RESTRICT_USB_VALIDATOR);
VALIDATORS.put(__MAGICAL_TEST_PASSING_ENABLER,
__MAGICAL_TEST_PASSING_ENABLER_VALIDATOR);
};