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

Commit 035f82b3 authored by Jim Miller's avatar Jim Miller Committed by Android Git Automerger
Browse files

am 952b3102: Merge "Fix bug where owner info wasn\'t being updated properly." into jb-mr2-dev

* commit '952b3102':
  Fix bug where owner info wasn't being updated properly.
parents fc8bd4d3 952b3102
Loading
Loading
Loading
Loading
+24 −16
Original line number Original line Diff line number Diff line
@@ -108,24 +108,31 @@ public class LockSettingsService extends ILockSettings.Stub {
                final ContentResolver cr = mContext.getContentResolver();
                final ContentResolver cr = mContext.getContentResolver();
                List<UserInfo> users = um.getUsers();
                List<UserInfo> users = um.getUsers();
                for (int user = 0; user < users.size(); user++) {
                for (int user = 0; user < users.size(); user++) {
                    int userId = users.get(user).getUserHandle().getIdentifier();
                    // Migrate owner info
                    for (String perUserSetting : MIGRATE_SETTINGS_PER_USER) {
                    final int userId = users.get(user).id;
                        // Handle Strings
                    final String OWNER_INFO = Secure.LOCK_SCREEN_OWNER_INFO;
                        String value = Settings.Secure.getStringForUser(cr, perUserSetting, userId);
                    String ownerInfo = Settings.Secure.getStringForUser(cr, OWNER_INFO, userId);
                        if (value != null) {
                    if (ownerInfo != null) {
                            setString(perUserSetting, value, userId);
                        setString(OWNER_INFO, ownerInfo, userId);
                            Settings.Secure.putStringForUser(cr, perUserSetting, "", userId);
                        Settings.Secure.putStringForUser(cr, ownerInfo, "", userId);
                            continue;
                    }
                        }


                    // Migrate owner info enabled.  Note there was a bug where older platforms only
                        // Handle integers
                    // stored this value if the checkbox was toggled at least once. The code detects
                    // this case by handling the exception.
                    final String OWNER_INFO_ENABLED = Secure.LOCK_SCREEN_OWNER_INFO_ENABLED;
                    boolean enabled;
                    try {
                    try {
                            int ivalue = Settings.Secure.getIntForUser(cr, perUserSetting, userId);
                        int ivalue = Settings.Secure.getIntForUser(cr, OWNER_INFO_ENABLED, userId);
                            setLong(perUserSetting, ivalue, userId);
                        enabled = ivalue != 0;
                            Settings.Secure.putIntForUser(cr, perUserSetting, 0, userId);
                        setLong(OWNER_INFO_ENABLED, enabled ? 1 : 0, userId);
                    } catch (SettingNotFoundException e) {
                    } catch (SettingNotFoundException e) {
                        // Setting was never stored. Store it if the string is not empty.
                        if (!TextUtils.isEmpty(ownerInfo)) {
                            setLong(OWNER_INFO_ENABLED, 1, userId);
                        }
                        }
                    }
                    }
                    Settings.Secure.putIntForUser(cr, OWNER_INFO_ENABLED, 0, userId);
                }
                }
                // No need to move the password / pattern files. They're already in the right place.
                // No need to move the password / pattern files. They're already in the right place.
                setString("migrated_user_specific", "true", 0);
                setString("migrated_user_specific", "true", 0);
@@ -447,7 +454,8 @@ public class LockSettingsService extends ILockSettings.Stub {
        Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED
        Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED
    };
    };


    private static final String[] MIGRATE_SETTINGS_PER_USER = new String[] {
    // These are protected with a read permission
    private static final String[] READ_PROFILE_PROTECTED_SETTINGS = new String[] {
        Secure.LOCK_SCREEN_OWNER_INFO_ENABLED,
        Secure.LOCK_SCREEN_OWNER_INFO_ENABLED,
        Secure.LOCK_SCREEN_OWNER_INFO
        Secure.LOCK_SCREEN_OWNER_INFO
    };
    };