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

Commit d5fe1479 authored by Christopher Tate's avatar Christopher Tate
Browse files

Miscellaneous fixes for Settings

(1) It's okay to write literal null as a settings element value
(2) Properly convey the user handle in the put-for-user variant

Bug 7137201
Bug 7139826

Change-Id: I0ed77d65e8377f0e0580a2668f10b7167ad34928
parent 4e2eb658
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -739,6 +739,7 @@ public final class Settings {
            try {
                Bundle arg = new Bundle();
                arg.putString(Settings.NameValueTable.VALUE, value);
                arg.putInt(CALL_METHOD_USER_KEY, userHandle);
                IContentProvider cp = lazyGetProvider(cr);
                cp.call(mCallSetCommand, name, arg);
            } catch (RemoteException e) {
+6 −22
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import java.util.HashSet;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.backup.BackupManager;
import android.content.BroadcastReceiver;
@@ -60,7 +61,7 @@ import android.util.SparseArray;

public class SettingsProvider extends ContentProvider {
    private static final String TAG = "SettingsProvider";
    private static final boolean LOCAL_LOGV = false;
    private static final boolean LOCAL_LOGV = true;

    private static final String TABLE_SYSTEM = "system";
    private static final String TABLE_SECURE = "secure";
@@ -621,24 +622,10 @@ public class SettingsProvider extends ContentProvider {
        if (args != null) {
            int reqUser = args.getInt(Settings.CALL_METHOD_USER_KEY, callingUser);
            if (reqUser != callingUser) {
                getContext().enforceCallingPermission(
                        android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
                        "Not permitted to access settings for other users");
                if (reqUser == UserHandle.USER_CURRENT) {
                    try {
                        reqUser = ActivityManagerNative.getDefault().getCurrentUser().id;
                    } catch (RemoteException e) {
                        // can't happen
                    }
                    if (LOCAL_LOGV) {
                        Slog.v(TAG, "   USER_CURRENT resolved to " + reqUser);
                    }
                }
                if (reqUser < 0) {
                    throw new IllegalArgumentException("Bad user handle " + reqUser);
                }
                callingUser = reqUser;
                if (LOCAL_LOGV) Slog.v(TAG, "   fetching setting for user " + callingUser);
                callingUser = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
                        Binder.getCallingUid(), reqUser, false, true,
                        "get/set setting for user", null);
                if (LOCAL_LOGV) Slog.v(TAG, "   access setting for user " + callingUser);
            }
        }

@@ -678,9 +665,6 @@ public class SettingsProvider extends ContentProvider {
        // the Settings.NameValueTable.VALUE static.
        final String newValue = (args == null)
                ? null : args.getString(Settings.NameValueTable.VALUE);
        if (newValue == null) {
            throw new IllegalArgumentException("Bad value for " + method);
        }

        final ContentValues values = new ContentValues();
        values.put(Settings.NameValueTable.NAME, request);