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

Commit 31a7beb2 authored by Thiébaud Weksteen's avatar Thiébaud Weksteen Committed by Sam Dubey
Browse files

Migrate to get{Int,String}ForUser

Reported by the lint CallingSettingsNonUserGetterMethodsDetector.
It is recommended to use the *ForUser variant of these functions to
avoid passing the incorrect user id.

Test: m
Bug: 228774926
Fix: 237603566
Change-Id: I2543be4737a30222284ee75c709419da0d409667
Merged-In: I2543be4737a30222284ee75c709419da0d409667
(cherry picked from commit 5731002f)
parent 55836582
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -8183,8 +8183,8 @@ public class ActivityManagerService extends IActivityManager.Stub
            // do this when the system user is not setup since the setup wizard should be the one
            // to handle home activity in this case.
            if (UserManager.isSplitSystemUser() &&
                    Settings.Secure.getInt(mContext.getContentResolver(),
                         Settings.Secure.USER_SETUP_COMPLETE, 0) != 0
                    Settings.Secure.getIntForUser(mContext.getContentResolver(),
                         Settings.Secure.USER_SETUP_COMPLETE, 0, currentUserId) != 0
                    || SystemProperties.getBoolean(SYSTEM_USER_HOME_NEEDED, false)) {
                t.traceBegin("enableHomeActivity");
                ComponentName cName = new ComponentName(mContext, SystemUserHomeActivity.class);
+7 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.server.am;

import android.app.ActivityThread;
import android.content.ContentResolver;
import android.provider.Settings;
import android.util.ArrayMap;

@@ -53,9 +54,12 @@ public class ActivityManagerUtils {
    static int getAndroidIdHash() {
        // No synchronization is required. Double-initialization is fine here.
        if (sAndroidIdHash == null) {
            final String androidId = Settings.Secure.getString(
                    ActivityThread.currentApplication().getContentResolver(),
                    Settings.Secure.ANDROID_ID);
            final ContentResolver resolver = ActivityThread.currentApplication()
                                             .getContentResolver();
            final String androidId = Settings.Secure.getStringForUser(
                    resolver,
                    Settings.Secure.ANDROID_ID,
                    resolver.getUserId());
            sAndroidIdHash = getUnsignedHashUnCached(
                    sInjectedAndroidId != null ? sInjectedAndroidId : androidId);
        }
+6 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.app.AnrController;
import android.app.ApplicationErrorReport;
import android.app.ApplicationExitInfo;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.IncrementalStatesInfo;
@@ -626,8 +627,11 @@ class ProcessErrorStateRecord {
    }

    private boolean getShowBackground() {
        return Settings.Secure.getInt(mService.mContext.getContentResolver(),
                Settings.Secure.ANR_SHOW_BACKGROUND, 0) != 0;
        final ContentResolver resolver = mService.mContext.getContentResolver();
        return Settings.Secure.getIntForUser(resolver,
            Settings.Secure.ANR_SHOW_BACKGROUND,
            0,
            resolver.getUserId()) != 0;
    }

    /**
+2 −2
Original line number Diff line number Diff line
@@ -218,8 +218,8 @@ public class ActivityStartController {
                    vers = ri.activityInfo.applicationInfo.metaData.getString(
                            Intent.METADATA_SETUP_VERSION);
                }
                String lastVers = Settings.Secure.getString(
                        resolver, Settings.Secure.LAST_SETUP_SHOWN);
                String lastVers = Settings.Secure.getStringForUser(
                        resolver, Settings.Secure.LAST_SETUP_SHOWN, resolver.getUserId());
                if (vers != null && !vers.equals(lastVers)) {
                    intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
                    intent.setComponent(new ComponentName(