support: Fix multiuser usage
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diff --git a/src/com/bliss/support/preferences/SecureSettingSwitchPreference.java b/src/com/bliss/support/preferences/SecureSettingSwitchPreference.java
index 5349ce4..7504996 100644
--- a/src/com/bliss/support/preferences/SecureSettingSwitchPreference.java
+++ b/src/com/bliss/support/preferences/SecureSettingSwitchPreference.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.provider.Settings;
import androidx.preference.SwitchPreference;
+import android.os.UserHandle;
import android.util.AttributeSet;
public class SecureSettingSwitchPreference extends SwitchPreference {
@@ -41,7 +42,8 @@
// It's already there, so the same as persisting
return true;
}
- Settings.Secure.putInt(getContext().getContentResolver(), getKey(), value ? 1 : 0);
+ Settings.Secure.putIntForUser(getContext().getContentResolver(),
+ getKey(), value ? 1 : 0, UserHandle.USER_CURRENT);
return true;
}
return false;
@@ -52,8 +54,8 @@
if (!shouldPersist()) {
return defaultReturnValue;
}
- return Settings.Secure.getInt(getContext().getContentResolver(),
- getKey(), defaultReturnValue ? 1 : 0) != 0;
+ return Settings.Secure.getIntForUser(getContext().getContentResolver(),
+ getKey(), defaultReturnValue ? 1 : 0, UserHandle.USER_CURRENT) != 0;
}
@Override
diff --git a/src/com/bliss/support/preferences/SystemSettingSwitchPreference.java b/src/com/bliss/support/preferences/SystemSettingSwitchPreference.java
index 51ce015..f83f3db 100644
--- a/src/com/bliss/support/preferences/SystemSettingSwitchPreference.java
+++ b/src/com/bliss/support/preferences/SystemSettingSwitchPreference.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.provider.Settings;
import androidx.preference.SwitchPreference;
+import android.os.UserHandle;
import android.util.AttributeSet;
public class SystemSettingSwitchPreference extends SwitchPreference {
@@ -41,7 +42,8 @@
// It's already there, so the same as persisting
return true;
}
- Settings.System.putInt(getContext().getContentResolver(), getKey(), value ? 1 : 0);
+ Settings.System.putIntForUser(getContext().getContentResolver(),
+ getKey(), value ? 1 : 0, UserHandle.USER_CURRENT);
return true;
}
return false;
@@ -52,8 +54,8 @@
if (!shouldPersist()) {
return defaultReturnValue;
}
- return Settings.System.getInt(getContext().getContentResolver(),
- getKey(), defaultReturnValue ? 1 : 0) != 0;
+ return Settings.System.getIntForUser(getContext().getContentResolver(),
+ getKey(), defaultReturnValue ? 1 : 0, UserHandle.USER_CURRENT) != 0;
}
@Override