Fixed AutofillPreferenceCategory so it's UI is properly refreshed.
Test: manual verification Test: runtest --path packages/apps/Settings/tests/unit/src/com/android/settings/core/PreferenceControllerContractTest.java Bug: 65700540 Bug: 111838239 Change-Id: If4e80a47d65aea34b94271e43ac38612373f4fa2
This commit is contained in:
@@ -19,6 +19,7 @@ import android.content.Context;
|
|||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@@ -30,22 +31,23 @@ import androidx.preference.PreferenceCategory;
|
|||||||
public final class AutofillPreferenceCategory extends PreferenceCategory {
|
public final class AutofillPreferenceCategory extends PreferenceCategory {
|
||||||
|
|
||||||
private static final String TAG = "AutofillPreferenceCategory";
|
private static final String TAG = "AutofillPreferenceCategory";
|
||||||
|
private static final long DELAYED_MESSAGE_TIME_MS = 2000;
|
||||||
|
|
||||||
private final ContentResolver mContentResolver;
|
private final ContentResolver mContentResolver;
|
||||||
private final ContentObserver mSettingsObserver;
|
private final ContentObserver mSettingsObserver;
|
||||||
|
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
public AutofillPreferenceCategory(Context context, AttributeSet attrs) {
|
public AutofillPreferenceCategory(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
|
||||||
mSettingsObserver = new ContentObserver(new Handler()) {
|
mSettingsObserver = new ContentObserver(mHandler) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(boolean selfChange, Uri uri, int userId) {
|
public void onChange(boolean selfChange, Uri uri, int userId) {
|
||||||
Log.w(TAG, "Autofill Service changed, but UI cannot be refreshed");
|
// We cannot apply the change yet because AutofillManager.isEnabled() state is
|
||||||
// TODO(b/111838239): we cannot update the UI because AFM.isEnabled() will return
|
// updated by a ContentObserver as well and there's no guarantee of which observer
|
||||||
// the previous value. Once that's fixed, we'll need to call one of the 2 callbacks
|
// is called first - hence, it's possible that the state didn't change here yet.
|
||||||
// below:
|
mHandler.postDelayed(() -> notifyDependencyChange(shouldDisableDependents()),
|
||||||
// notifyChanged();
|
DELAYED_MESSAGE_TIME_MS);
|
||||||
// notifyDependencyChange(shouldDisableDependents());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mContentResolver = context.getContentResolver();
|
mContentResolver = context.getContentResolver();
|
||||||
|
Reference in New Issue
Block a user