DO NOT MERGE Set ANR_SHOW_BACKGROUND for system user

Because the Android framework reads this value as the system user, it
needs to be set for the system user for the option to work properly on
Automotive.

Bug: 163571398
Test: manual (verified set properly via adb shell, verified behavior via
OEM provided test apk)

Change-Id: I5994c02b62425352ddd49bd273b9e7b301159fd3
diff --git a/tests/CarDeveloperOptions/src/com/android/car/developeroptions/development/AppsNotRespondingPreferenceController.java b/tests/CarDeveloperOptions/src/com/android/car/developeroptions/development/AppsNotRespondingPreferenceController.java
index f504d1b..86d89f4 100644
--- a/tests/CarDeveloperOptions/src/com/android/car/developeroptions/development/AppsNotRespondingPreferenceController.java
+++ b/tests/CarDeveloperOptions/src/com/android/car/developeroptions/development/AppsNotRespondingPreferenceController.java
@@ -16,6 +16,7 @@
 package com.android.car.developeroptions.development;
 
 import android.content.Context;
+import android.os.UserHandle;
 import android.provider.Settings;
 
 import androidx.annotation.VisibleForTesting;
@@ -47,24 +48,31 @@
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
         final boolean isEnabled = (Boolean) newValue;
-        Settings.Secure.putInt(mContext.getContentResolver(),
+        // Set for system user since Android framework will read it as that user.
+        // Note that this will enable/disable this option for all users.
+        Settings.Secure.putIntForUser(mContext.getContentResolver(),
                 Settings.Secure.ANR_SHOW_BACKGROUND,
-                isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
+                isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF,
+                UserHandle.SYSTEM.getIdentifier());
         return true;
     }
 
     @Override
     public void updateState(Preference preference) {
-        final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
-                Settings.Secure.ANR_SHOW_BACKGROUND, SETTING_VALUE_OFF);
+        final int mode = Settings.Secure.getIntForUser(mContext.getContentResolver(),
+                Settings.Secure.ANR_SHOW_BACKGROUND,
+                SETTING_VALUE_OFF, UserHandle.SYSTEM.getIdentifier());
         ((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
     }
 
     @Override
     protected void onDeveloperOptionsSwitchDisabled() {
         super.onDeveloperOptionsSwitchDisabled();
-        Settings.Secure.putInt(mContext.getContentResolver(),
-                Settings.Secure.ANR_SHOW_BACKGROUND, SETTING_VALUE_OFF);
+        // Set for system user since Android framework will read it as that user.
+        // Note that this will enable/disable this option for all users.
+        Settings.Secure.putIntForUser(mContext.getContentResolver(),
+                Settings.Secure.ANR_SHOW_BACKGROUND,
+                SETTING_VALUE_OFF, UserHandle.SYSTEM.getIdentifier());
         ((SwitchPreference) mPreference).setChecked(false);
     }
 }