am b1e5137a: Merge "Move owner info from Settings.Secure to LockSettings" into jb-mr2-dev

* commit 'b1e5137a807d19a9cbc241c0ba84c3c49b32fceb':
  Move owner info from Settings.Secure to LockSettings
This commit is contained in:
Jim Miller
2013-04-17 13:44:23 -07:00
committed by Android Git Automerger
4 changed files with 95 additions and 23 deletions

View File

@@ -3260,6 +3260,7 @@ public final class Settings {
/**
* This preference contains the string that shows for owner info on LockScreen.
* @hide
* @deprecated
*/
public static final String LOCK_SCREEN_OWNER_INFO = "lock_screen_owner_info";
@@ -3287,6 +3288,7 @@ public final class Settings {
/**
* This preference enables showing the owner info on LockScreen.
* @hide
* @deprecated
*/
public static final String LOCK_SCREEN_OWNER_INFO_ENABLED =
"lock_screen_owner_info_enabled";
@@ -4102,9 +4104,7 @@ public final class Settings {
MOUNT_UMS_AUTOSTART,
MOUNT_UMS_PROMPT,
MOUNT_UMS_NOTIFY_ENABLED,
UI_NIGHT_MODE,
LOCK_SCREEN_OWNER_INFO,
LOCK_SCREEN_OWNER_INFO_ENABLED
UI_NIGHT_MODE
};
/**

View File

@@ -140,6 +140,10 @@ public class LockPatternUtils {
public final static String PASSWORD_HISTORY_KEY = "lockscreen.passwordhistory";
private static final String LOCK_SCREEN_OWNER_INFO = Settings.Secure.LOCK_SCREEN_OWNER_INFO;
private static final String LOCK_SCREEN_OWNER_INFO_ENABLED =
Settings.Secure.LOCK_SCREEN_OWNER_INFO_ENABLED;
private final Context mContext;
private final ContentResolver mContentResolver;
private DevicePolicyManager mDevicePolicyManager;
@@ -526,6 +530,22 @@ public class LockPatternUtils {
}
}
public void setOwnerInfo(String info, int userId) {
setString(LOCK_SCREEN_OWNER_INFO, info, userId);
}
public void setOwnerInfoEnabled(boolean enabled) {
setBoolean(LOCK_SCREEN_OWNER_INFO_ENABLED, enabled);
}
public String getOwnerInfo(int userId) {
return getString(LOCK_SCREEN_OWNER_INFO);
}
public boolean isOwnerInfoEnabled() {
return getBoolean(LOCK_SCREEN_OWNER_INFO_ENABLED, false);
}
/**
* Compute the password quality from the given password string.
*/

View File

@@ -23,12 +23,16 @@ import android.content.ContentResolver;
import android.content.Context;
import android.os.BatteryManager;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Slog;
import android.view.View;
import android.widget.TextView;
@@ -37,6 +41,8 @@ import libcore.util.MutableInt;
import java.lang.ref.WeakReference;
import com.android.internal.R;
import com.android.internal.widget.ILockSettings;
import com.android.internal.widget.LockPatternUtils;
/***
* Manages a number of views inside of the given layout. See below for a list of widgets.
@@ -57,6 +63,8 @@ class KeyguardMessageArea extends TextView {
static final int SECURITY_MESSAGE_DURATION = 5000;
protected static final int FADE_DURATION = 750;
private static final String TAG = "KeyguardMessageArea";
// are we showing battery information?
boolean mShowingBatteryInfo = false;
@@ -82,6 +90,9 @@ class KeyguardMessageArea extends TextView {
CharSequence mMessage;
boolean mShowingMessage;
private CharSequence mSeparator;
private LockPatternUtils mLockPatternUtils;
Runnable mClearMessageRunnable = new Runnable() {
@Override
public void run() {
@@ -156,8 +167,6 @@ class KeyguardMessageArea extends TextView {
}
};
private CharSequence mSeparator;
public KeyguardMessageArea(Context context) {
this(context, null);
}
@@ -165,6 +174,8 @@ class KeyguardMessageArea extends TextView {
public KeyguardMessageArea(Context context, AttributeSet attrs) {
super(context, attrs);
mLockPatternUtils = new LockPatternUtils(context);
// This is required to ensure marquee works
setSelected(true);
@@ -228,11 +239,12 @@ class KeyguardMessageArea extends TextView {
String getOwnerInfo() {
ContentResolver res = getContext().getContentResolver();
final boolean ownerInfoEnabled = Settings.Secure.getIntForUser(res,
Settings.Secure.LOCK_SCREEN_OWNER_INFO_ENABLED, 1, UserHandle.USER_CURRENT) != 0;
return ownerInfoEnabled && !mShowingMessage ?
Settings.Secure.getStringForUser(res, Settings.Secure.LOCK_SCREEN_OWNER_INFO,
UserHandle.USER_CURRENT) : null;
String info = null;
final boolean ownerInfoEnabled = mLockPatternUtils.isOwnerInfoEnabled();
if (ownerInfoEnabled && !mShowingMessage) {
info = mLockPatternUtils.getOwnerInfo(mLockPatternUtils.getCurrentUser());
}
return info;
}
private CharSequence getChargeInfo(MutableInt icon) {

View File

@@ -19,6 +19,9 @@ package com.android.server;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.pm.UserInfo;
import static android.content.Context.USER_SERVICE;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
@@ -27,8 +30,10 @@ import android.os.Environment;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.provider.Settings.Secure;
import android.provider.Settings.SettingNotFoundException;
import android.text.TextUtils;
import android.util.Slog;
@@ -40,6 +45,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Arrays;
import java.util.List;
/**
* Keeps the lock pattern/password data and related settings for each user.
@@ -79,23 +85,52 @@ public class LockSettingsService extends ILockSettings.Stub {
private void migrateOldData() {
try {
if (getString("migrated", null, 0) != null) {
// Already migrated
return;
// These Settings moved before multi-user was enabled, so we only have to do it for the
// root user.
if (getString("migrated", null, 0) == null) {
final ContentResolver cr = mContext.getContentResolver();
for (String validSetting : VALID_SETTINGS) {
String value = Settings.Secure.getString(cr, validSetting);
if (value != null) {
setString(validSetting, value, 0);
}
}
// No need to move the password / pattern files. They're already in the right place.
setString("migrated", "true", 0);
Slog.i(TAG, "Migrated lock settings to new location");
}
final ContentResolver cr = mContext.getContentResolver();
for (String validSetting : VALID_SETTINGS) {
String value = Settings.Secure.getString(cr, validSetting);
if (value != null) {
setString(validSetting, value, 0);
// These Settings changed after multi-user was enabled, hence need to be moved per user.
if (getString("migrated_user_specific", null, 0) == null) {
final UserManager um = (UserManager) mContext.getSystemService(USER_SERVICE);
final ContentResolver cr = mContext.getContentResolver();
List<UserInfo> users = um.getUsers();
for (int user = 0; user < users.size(); user++) {
int userId = users.get(user).getUserHandle().getIdentifier();
for (String perUserSetting : MIGRATE_SETTINGS_PER_USER) {
// Handle Strings
String value = Settings.Secure.getStringForUser(cr, perUserSetting, userId);
if (value != null) {
setString(perUserSetting, value, userId);
Settings.Secure.putStringForUser(cr, perUserSetting, "", userId);
continue;
}
// Handle integers
try {
int ivalue = Settings.Secure.getIntForUser(cr, perUserSetting, userId);
setLong(perUserSetting, ivalue, userId);
Settings.Secure.putIntForUser(cr, perUserSetting, 0, userId);
} catch (SettingNotFoundException e) {
}
}
}
// No need to move the password / pattern files. They're already in the right place.
setString("migrated_user_specific", "true", 0);
Slog.i(TAG, "Migrated per-user lock settings to new location");
}
// No need to move the password / pattern files. They're already in the right place.
setString("migrated", "true", 0);
Slog.i(TAG, "Migrated lock settings to new location");
} catch (RemoteException re) {
Slog.e(TAG, "Unable to migrate old data");
Slog.e(TAG, "Unable to migrate old data", re);
}
}
@@ -404,5 +439,10 @@ public class LockSettingsService extends ILockSettings.Stub {
Secure.LOCK_BIOMETRIC_WEAK_FLAGS,
Secure.LOCK_PATTERN_VISIBLE,
Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED
};
};
private static final String[] MIGRATE_SETTINGS_PER_USER = new String[] {
Secure.LOCK_SCREEN_OWNER_INFO_ENABLED,
Secure.LOCK_SCREEN_OWNER_INFO
};
}