Removing unnecessary system RPC for checking flags on every touch event
Change-Id: I8116bef952dbd49d1bad6c8844149538a6d0fa6b
This commit is contained in:
parent
2ca0aa7076
commit
c1edfa7328
|
@ -21,6 +21,9 @@ import static androidx.core.util.Preconditions.checkNotNull;
|
|||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.ContentObserver;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.GuardedBy;
|
||||
|
@ -256,6 +259,16 @@ abstract class BaseFlags {
|
|||
@Override
|
||||
public void initialize(Context context) {
|
||||
contentResolver = context.getContentResolver();
|
||||
contentResolver.registerContentObserver(Settings.Global.getUriFor(getKey()), true,
|
||||
new ContentObserver(new Handler(Looper.getMainLooper())) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
superInitialize(context);
|
||||
}});
|
||||
superInitialize(context);
|
||||
}
|
||||
|
||||
private void superInitialize(Context context) {
|
||||
super.initialize(context);
|
||||
}
|
||||
|
||||
|
@ -274,10 +287,5 @@ abstract class BaseFlags {
|
|||
}
|
||||
return Settings.Global.getInt(contentResolver, getKey(), defaultValue ? 1 : 0) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean get() {
|
||||
return getFromStorage(null, getDefaultValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue