Skip to content

Commit e1f02ef

Browse files
Christopher TateAndroid (Google) Code Review
authored andcommitted
Merge "Miscellaneous fixes for Settings" into jb-mr1-dev
2 parents ce3ef0a + d5fe147 commit e1f02ef

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

core/java/android/provider/Settings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ public boolean putStringForUser(ContentResolver cr, String name, String value,
739739
try {
740740
Bundle arg = new Bundle();
741741
arg.putString(Settings.NameValueTable.VALUE, value);
742+
arg.putInt(CALL_METHOD_USER_KEY, userHandle);
742743
IContentProvider cp = lazyGetProvider(cr);
743744
cp.call(mCallSetCommand, name, arg);
744745
} catch (RemoteException e) {

packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.concurrent.atomic.AtomicBoolean;
2323
import java.util.concurrent.atomic.AtomicInteger;
2424

25+
import android.app.ActivityManager;
2526
import android.app.ActivityManagerNative;
2627
import android.app.backup.BackupManager;
2728
import android.content.BroadcastReceiver;
@@ -60,7 +61,7 @@
6061

6162
public class SettingsProvider extends ContentProvider {
6263
private static final String TAG = "SettingsProvider";
63-
private static final boolean LOCAL_LOGV = false;
64+
private static final boolean LOCAL_LOGV = true;
6465

6566
private static final String TABLE_SYSTEM = "system";
6667
private static final String TABLE_SECURE = "secure";
@@ -621,24 +622,10 @@ public Bundle call(String method, String request, Bundle args) {
621622
if (args != null) {
622623
int reqUser = args.getInt(Settings.CALL_METHOD_USER_KEY, callingUser);
623624
if (reqUser != callingUser) {
624-
getContext().enforceCallingPermission(
625-
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
626-
"Not permitted to access settings for other users");
627-
if (reqUser == UserHandle.USER_CURRENT) {
628-
try {
629-
reqUser = ActivityManagerNative.getDefault().getCurrentUser().id;
630-
} catch (RemoteException e) {
631-
// can't happen
632-
}
633-
if (LOCAL_LOGV) {
634-
Slog.v(TAG, " USER_CURRENT resolved to " + reqUser);
635-
}
636-
}
637-
if (reqUser < 0) {
638-
throw new IllegalArgumentException("Bad user handle " + reqUser);
639-
}
640-
callingUser = reqUser;
641-
if (LOCAL_LOGV) Slog.v(TAG, " fetching setting for user " + callingUser);
625+
callingUser = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
626+
Binder.getCallingUid(), reqUser, false, true,
627+
"get/set setting for user", null);
628+
if (LOCAL_LOGV) Slog.v(TAG, " access setting for user " + callingUser);
642629
}
643630
}
644631

@@ -678,9 +665,6 @@ public Bundle call(String method, String request, Bundle args) {
678665
// the Settings.NameValueTable.VALUE static.
679666
final String newValue = (args == null)
680667
? null : args.getString(Settings.NameValueTable.VALUE);
681-
if (newValue == null) {
682-
throw new IllegalArgumentException("Bad value for " + method);
683-
}
684668

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

0 commit comments

Comments
 (0)