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

Commit 0da1357f authored by Christopher Tate's avatar Christopher Tate
Browse files

Log noisily on uid vs user-handle confusion in the settings provider

Make sure that we catch any attempts to pass a uid to the settings
provider's "for this user" code paths.

Bug 11087584
Bug 11208808

Change-Id: I1cc025b2aade9072b4a61b4499d02c82b0085fa2
parent ce6d9066
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.os.Bundle;
import android.os.DropBoxManager;
import android.os.FileObserver;
import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
@@ -62,6 +63,8 @@ public class SettingsProvider extends ContentProvider {
    private static final String TAG = "SettingsProvider";
    private static final boolean LOCAL_LOGV = false;

    private static final boolean USER_CHECK_THROWS = true;

    private static final String TABLE_SYSTEM = "system";
    private static final String TABLE_SECURE = "secure";
    private static final String TABLE_GLOBAL = "global";
@@ -522,6 +525,14 @@ public class SettingsProvider extends ContentProvider {

    // Lazy initialize the database helper and caches for this user, if necessary
    private DatabaseHelper getOrEstablishDatabase(int callingUser) {
        if (callingUser >= Process.SYSTEM_UID) {
            if (USER_CHECK_THROWS) {
                throw new IllegalArgumentException("Uid rather than user handle: " + callingUser);
            } else {
                Slog.wtf(TAG, "establish db for uid rather than user: " + callingUser);
            }
        }

        long oldId = Binder.clearCallingIdentity();
        try {
            DatabaseHelper dbHelper = mOpenHelpers.get(callingUser);