Added default config to enable adding users from lockscreen

A config value is added for enabling/disabling the ability
to add users while screen is locked. The config value, currently false,
is read and applied to the setting only if the user has not set the
value as true/false explicitly.

Bug-Id: b/24662310
Change-Id: Ie00ab0952c64cbc9805794bc0dde350920750026
This commit is contained in:
Suprabh Shukla
2015-12-02 16:51:16 -08:00
parent 47040d6247
commit 269c11eee1
2 changed files with 23 additions and 3 deletions

View File

@@ -209,4 +209,7 @@
<!-- Default for Settings.Secure.NFC_PAYMENT_COMPONENT -->
<string name="def_nfc_payment_component"></string>
<!-- Default setting for ability to add users from the lock screen -->
<bool name="def_add_users_from_lockscreen">false</bool>
</resources>

View File

@@ -61,6 +61,7 @@ import android.util.SparseArray;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.content.PackageMonitor;
import com.android.internal.os.BackgroundThread;
import com.android.providers.settings.SettingsState.Setting;
import java.io.File;
import java.io.FileDescriptor;
@@ -72,8 +73,6 @@ import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import com.android.providers.settings.SettingsState.Setting;
/**
* <p>
* This class is a content provider that publishes the system settings.
@@ -1891,7 +1890,7 @@ public class SettingsProvider extends ContentProvider {
}
private final class UpgradeController {
private static final int SETTINGS_VERSION = 122;
private static final int SETTINGS_VERSION = 123;
private final int mUserId;
@@ -2043,6 +2042,24 @@ public class SettingsProvider extends ContentProvider {
}
currentVersion = 122;
}
if (currentVersion == 122) {
// Version 123: Adding a default value for the ability to add a user from
// the lock screen.
if (userId == UserHandle.USER_SYSTEM) {
final SettingsState globalSettings = getGlobalSettingsLocked();
Setting currentSetting = globalSettings.getSettingLocked(
Settings.Global.ADD_USERS_WHEN_LOCKED);
if (currentSetting == null) {
globalSettings.insertSettingLocked(
Settings.Global.ADD_USERS_WHEN_LOCKED,
getContext().getResources().getBoolean(
R.bool.def_add_users_from_lockscreen) ? "1" : "0",
SettingsState.SYSTEM_PACKAGE_NAME);
}
}
currentVersion = 123;
}
// vXXX: Add new settings above this point.
// Return the current version.