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

Commit 9b4b662c authored by Jim Miller's avatar Jim Miller
Browse files

resolved conflicts for merge of 6825c478 to master

Change-Id: Id9657db0b3623c329ae2cff3916c2d0eb4301dd7
parents 68293ecb 6825c478
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -19,9 +19,11 @@ package com.android.server;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;

import static android.content.Context.USER_SERVICE;
import static android.Manifest.permission.READ_PROFILE;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
@@ -143,6 +145,19 @@ public class LockSettingsService extends ILockSettings.Stub {
        mContext.checkCallingOrSelfPermission(PERMISSION);
    }

    private final void checkReadPermission(String requestedKey, int userId) {
        final int callingUid = Binder.getCallingUid();
        for (int i = 0; i < READ_PROFILE_PROTECTED_SETTINGS.length; i++) {
            String key = READ_PROFILE_PROTECTED_SETTINGS[i];
            if (key.equals(requestedKey) && mContext.checkCallingOrSelfPermission(READ_PROFILE)
                    != PackageManager.PERMISSION_GRANTED) {
                throw new SecurityException("uid=" + callingUid
                        + " needs permission " + READ_PROFILE + " to read "
                        + requestedKey + " for user " + userId);
            }
        }
    }

    @Override
    public void setBoolean(String key, boolean value, int userId) throws RemoteException {
        checkWritePermission(userId);
@@ -166,7 +181,7 @@ public class LockSettingsService extends ILockSettings.Stub {

    @Override
    public boolean getBoolean(String key, boolean defaultValue, int userId) throws RemoteException {
        //checkReadPermission(userId);
        checkReadPermission(key, userId);

        String value = readFromDb(key, null, userId);
        return TextUtils.isEmpty(value) ?
@@ -175,7 +190,7 @@ public class LockSettingsService extends ILockSettings.Stub {

    @Override
    public long getLong(String key, long defaultValue, int userId) throws RemoteException {
        //checkReadPermission(userId);
        checkReadPermission(key, userId);

        String value = readFromDb(key, null, userId);
        return TextUtils.isEmpty(value) ? defaultValue : Long.parseLong(value);
@@ -183,7 +198,7 @@ public class LockSettingsService extends ILockSettings.Stub {

    @Override
    public String getString(String key, String defaultValue, int userId) throws RemoteException {
        //checkReadPermission(userId);
        checkReadPermission(key, userId);

        return readFromDb(key, defaultValue, userId);
    }
@@ -429,4 +444,7 @@ public class LockSettingsService extends ILockSettings.Stub {
        Secure.LOCK_SCREEN_OWNER_INFO_ENABLED,
        Secure.LOCK_SCREEN_OWNER_INFO
    };

    // These are protected with a read permission
    private static final String[] READ_PROFILE_PROTECTED_SETTINGS = MIGRATE_SETTINGS_PER_USER;
}