|
22 | 22 | import java.util.concurrent.atomic.AtomicBoolean; |
23 | 23 | import java.util.concurrent.atomic.AtomicInteger; |
24 | 24 |
|
| 25 | +import android.app.ActivityManager; |
25 | 26 | import android.app.ActivityManagerNative; |
26 | 27 | import android.app.backup.BackupManager; |
27 | 28 | import android.content.BroadcastReceiver; |
|
60 | 61 |
|
61 | 62 | public class SettingsProvider extends ContentProvider { |
62 | 63 | private static final String TAG = "SettingsProvider"; |
63 | | - private static final boolean LOCAL_LOGV = false; |
| 64 | + private static final boolean LOCAL_LOGV = true; |
64 | 65 |
|
65 | 66 | private static final String TABLE_SYSTEM = "system"; |
66 | 67 | private static final String TABLE_SECURE = "secure"; |
@@ -621,24 +622,10 @@ public Bundle call(String method, String request, Bundle args) { |
621 | 622 | if (args != null) { |
622 | 623 | int reqUser = args.getInt(Settings.CALL_METHOD_USER_KEY, callingUser); |
623 | 624 | 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); |
642 | 629 | } |
643 | 630 | } |
644 | 631 |
|
@@ -678,9 +665,6 @@ public Bundle call(String method, String request, Bundle args) { |
678 | 665 | // the Settings.NameValueTable.VALUE static. |
679 | 666 | final String newValue = (args == null) |
680 | 667 | ? null : args.getString(Settings.NameValueTable.VALUE); |
681 | | - if (newValue == null) { |
682 | | - throw new IllegalArgumentException("Bad value for " + method); |
683 | | - } |
684 | 668 |
|
685 | 669 | final ContentValues values = new ContentValues(); |
686 | 670 | values.put(Settings.NameValueTable.NAME, request); |
|
0 commit comments