settings: Use Id from ContentResolver

Making this change allows to determine 
automatically the proper user ID depending on the
context used to create the resolver

Change-Id: I08021fa56856ef4792da780bca1c0e77526e72a6
This commit is contained in:
Luca Stefani
2022-01-03 13:15:19 +01:00
parent d389bf1773
commit ebaa32ef9f

View File

@@ -569,7 +569,7 @@ public final class LineageSettings {
* @return the corresponding value, or null if not present
*/
public static String getString(ContentResolver resolver, String name) {
return getStringForUser(resolver, name, UserHandle.myUserId());
return getStringForUser(resolver, name, resolver.getUserId());
}
/**
@@ -580,7 +580,7 @@ public final class LineageSettings {
* @return the corresponding value, or null if not present
*/
public static String getString(ContentResolver resolver, String name, String def) {
String str = getStringForUser(resolver, name, UserHandle.myUserId());
String str = getStringForUser(resolver, name, resolver.getUserId());
return str == null ? def : str;
}
@@ -603,7 +603,7 @@ public final class LineageSettings {
* @return true if the value was set, false on database errors
*/
public static boolean putString(ContentResolver resolver, String name, String value) {
return putStringForUser(resolver, name, value, UserHandle.myUserId());
return putStringForUser(resolver, name, value, resolver.getUserId());
}
/** @hide */
@@ -632,7 +632,7 @@ public final class LineageSettings {
* or not a valid integer.
*/
public static int getInt(ContentResolver cr, String name, int def) {
return getIntForUser(cr, name, def, UserHandle.myUserId());
return getIntForUser(cr, name, def, cr.getUserId());
}
/** @hide */
@@ -665,7 +665,7 @@ public final class LineageSettings {
*/
public static int getInt(ContentResolver cr, String name)
throws LineageSettingNotFoundException {
return getIntForUser(cr, name, UserHandle.myUserId());
return getIntForUser(cr, name, cr.getUserId());
}
/** @hide */
@@ -693,7 +693,7 @@ public final class LineageSettings {
* @return true if the value was set, false on database errors
*/
public static boolean putInt(ContentResolver cr, String name, int value) {
return putIntForUser(cr, name, value, UserHandle.myUserId());
return putIntForUser(cr, name, value, cr.getUserId());
}
/** @hide */
@@ -717,7 +717,7 @@ public final class LineageSettings {
* or not a valid {@code long}.
*/
public static long getLong(ContentResolver cr, String name, long def) {
return getLongForUser(cr, name, def, UserHandle.myUserId());
return getLongForUser(cr, name, def, cr.getUserId());
}
/** @hide */
@@ -752,7 +752,7 @@ public final class LineageSettings {
*/
public static long getLong(ContentResolver cr, String name)
throws LineageSettingNotFoundException {
return getLongForUser(cr, name, UserHandle.myUserId());
return getLongForUser(cr, name, cr.getUserId());
}
/** @hide */
@@ -780,7 +780,7 @@ public final class LineageSettings {
* @return true if the value was set, false on database errors
*/
public static boolean putLong(ContentResolver cr, String name, long value) {
return putLongForUser(cr, name, value, UserHandle.myUserId());
return putLongForUser(cr, name, value, cr.getUserId());
}
/** @hide */
@@ -804,7 +804,7 @@ public final class LineageSettings {
* or not a valid float.
*/
public static float getFloat(ContentResolver cr, String name, float def) {
return getFloatForUser(cr, name, def, UserHandle.myUserId());
return getFloatForUser(cr, name, def, cr.getUserId());
}
/** @hide */
@@ -838,7 +838,7 @@ public final class LineageSettings {
*/
public static float getFloat(ContentResolver cr, String name)
throws LineageSettingNotFoundException {
return getFloatForUser(cr, name, UserHandle.myUserId());
return getFloatForUser(cr, name, cr.getUserId());
}
/** @hide */
@@ -869,7 +869,7 @@ public final class LineageSettings {
* @return true if the value was set, false on database errors
*/
public static boolean putFloat(ContentResolver cr, String name, float value) {
return putFloatForUser(cr, name, value, UserHandle.myUserId());
return putFloatForUser(cr, name, value, cr.getUserId());
}
/** @hide */
@@ -2377,7 +2377,7 @@ public final class LineageSettings {
* @return the corresponding value, or null if not present
*/
public static String getString(ContentResolver resolver, String name) {
return getStringForUser(resolver, name, UserHandle.myUserId());
return getStringForUser(resolver, name, resolver.getUserId());
}
/**
@@ -2388,7 +2388,7 @@ public final class LineageSettings {
* @return the corresponding value, or null if not present
*/
public static String getString(ContentResolver resolver, String name, String def) {
String str = getStringForUser(resolver, name, UserHandle.myUserId());
String str = getStringForUser(resolver, name, resolver.getUserId());
return str == null ? def : str;
}
@@ -2411,7 +2411,7 @@ public final class LineageSettings {
* @return true if the value was set, false on database errors
*/
public static boolean putString(ContentResolver resolver, String name, String value) {
return putStringForUser(resolver, name, value, UserHandle.myUserId());
return putStringForUser(resolver, name, value, resolver.getUserId());
}
/** @hide */
@@ -2440,7 +2440,7 @@ public final class LineageSettings {
* or not a valid integer.
*/
public static int getInt(ContentResolver cr, String name, int def) {
return getIntForUser(cr, name, def, UserHandle.myUserId());
return getIntForUser(cr, name, def, cr.getUserId());
}
/** @hide */
@@ -2473,7 +2473,7 @@ public final class LineageSettings {
*/
public static int getInt(ContentResolver cr, String name)
throws LineageSettingNotFoundException {
return getIntForUser(cr, name, UserHandle.myUserId());
return getIntForUser(cr, name, cr.getUserId());
}
/** @hide */
@@ -2501,7 +2501,7 @@ public final class LineageSettings {
* @return true if the value was set, false on database errors
*/
public static boolean putInt(ContentResolver cr, String name, int value) {
return putIntForUser(cr, name, value, UserHandle.myUserId());
return putIntForUser(cr, name, value, cr.getUserId());
}
/** @hide */
@@ -2525,7 +2525,7 @@ public final class LineageSettings {
* or not a valid {@code long}.
*/
public static long getLong(ContentResolver cr, String name, long def) {
return getLongForUser(cr, name, def, UserHandle.myUserId());
return getLongForUser(cr, name, def, cr.getUserId());
}
/** @hide */
@@ -2560,7 +2560,7 @@ public final class LineageSettings {
*/
public static long getLong(ContentResolver cr, String name)
throws LineageSettingNotFoundException {
return getLongForUser(cr, name, UserHandle.myUserId());
return getLongForUser(cr, name, cr.getUserId());
}
/** @hide */
@@ -2588,7 +2588,7 @@ public final class LineageSettings {
* @return true if the value was set, false on database errors
*/
public static boolean putLong(ContentResolver cr, String name, long value) {
return putLongForUser(cr, name, value, UserHandle.myUserId());
return putLongForUser(cr, name, value, cr.getUserId());
}
/** @hide */
@@ -2612,7 +2612,7 @@ public final class LineageSettings {
* or not a valid float.
*/
public static float getFloat(ContentResolver cr, String name, float def) {
return getFloatForUser(cr, name, def, UserHandle.myUserId());
return getFloatForUser(cr, name, def, cr.getUserId());
}
/** @hide */
@@ -2646,7 +2646,7 @@ public final class LineageSettings {
*/
public static float getFloat(ContentResolver cr, String name)
throws LineageSettingNotFoundException {
return getFloatForUser(cr, name, UserHandle.myUserId());
return getFloatForUser(cr, name, cr.getUserId());
}
/** @hide */
@@ -2677,7 +2677,7 @@ public final class LineageSettings {
* @return true if the value was set, false on database errors
*/
public static boolean putFloat(ContentResolver cr, String name, float value) {
return putFloatForUser(cr, name, value, UserHandle.myUserId());
return putFloatForUser(cr, name, value, cr.getUserId());
}
/** @hide */
@@ -3117,7 +3117,7 @@ public final class LineageSettings {
* @return the corresponding value, or null if not present
*/
public static String getString(ContentResolver resolver, String name) {
return getStringForUser(resolver, name, UserHandle.myUserId());
return getStringForUser(resolver, name, resolver.getUserId());
}
/**
@@ -3128,7 +3128,7 @@ public final class LineageSettings {
* @return the corresponding value, or null if not present
*/
public static String getString(ContentResolver resolver, String name, String def) {
String str = getStringForUser(resolver, name, UserHandle.myUserId());
String str = getStringForUser(resolver, name, resolver.getUserId());
return str == null ? def : str;
}
@@ -3146,7 +3146,7 @@ public final class LineageSettings {
* @return true if the value was set, false on database errors
*/
public static boolean putString(ContentResolver resolver, String name, String value) {
return putStringForUser(resolver, name, value, UserHandle.myUserId());
return putStringForUser(resolver, name, value, resolver.getUserId());
}
/** @hide */
@@ -3170,7 +3170,7 @@ public final class LineageSettings {
* or not a valid integer.
*/
public static int getInt(ContentResolver cr, String name, int def) {
return getIntForUser(cr, name, def, UserHandle.myUserId());
return getIntForUser(cr, name, def, cr.getUserId());
}
/** @hide */
@@ -3203,7 +3203,7 @@ public final class LineageSettings {
*/
public static int getInt(ContentResolver cr, String name)
throws LineageSettingNotFoundException {
return getIntForUser(cr, name, UserHandle.myUserId());
return getIntForUser(cr, name, cr.getUserId());
}
/** @hide */
@@ -3231,7 +3231,7 @@ public final class LineageSettings {
* @return true if the value was set, false on database errors
*/
public static boolean putInt(ContentResolver cr, String name, int value) {
return putIntForUser(cr, name, value, UserHandle.myUserId());
return putIntForUser(cr, name, value, cr.getUserId());
}
/** @hide */
@@ -3255,7 +3255,7 @@ public final class LineageSettings {
* or not a valid {@code long}.
*/
public static long getLong(ContentResolver cr, String name, long def) {
return getLongForUser(cr, name, def, UserHandle.myUserId());
return getLongForUser(cr, name, def, cr.getUserId());
}
/** @hide */
@@ -3290,7 +3290,7 @@ public final class LineageSettings {
*/
public static long getLong(ContentResolver cr, String name)
throws LineageSettingNotFoundException {
return getLongForUser(cr, name, UserHandle.myUserId());
return getLongForUser(cr, name, cr.getUserId());
}
/** @hide */
@@ -3318,7 +3318,7 @@ public final class LineageSettings {
* @return true if the value was set, false on database errors
*/
public static boolean putLong(ContentResolver cr, String name, long value) {
return putLongForUser(cr, name, value, UserHandle.myUserId());
return putLongForUser(cr, name, value, cr.getUserId());
}
/** @hide */
@@ -3342,7 +3342,7 @@ public final class LineageSettings {
* or not a valid float.
*/
public static float getFloat(ContentResolver cr, String name, float def) {
return getFloatForUser(cr, name, def, UserHandle.myUserId());
return getFloatForUser(cr, name, def, cr.getUserId());
}
/** @hide */
@@ -3376,7 +3376,7 @@ public final class LineageSettings {
*/
public static float getFloat(ContentResolver cr, String name)
throws LineageSettingNotFoundException {
return getFloatForUser(cr, name, UserHandle.myUserId());
return getFloatForUser(cr, name, cr.getUserId());
}
/** @hide */
@@ -3407,7 +3407,7 @@ public final class LineageSettings {
* @return true if the value was set, false on database errors
*/
public static boolean putFloat(ContentResolver cr, String name, float value) {
return putFloatForUser(cr, name, value, UserHandle.myUserId());
return putFloatForUser(cr, name, value, cr.getUserId());
}
/** @hide */