fix(magnification): make always on toggle unavailable when capabilities is window only
As b/328787031, we make the MagnificationAlwaysOnPreferenceController observe the magnification capabilities then update the preference enabled state. Therefore, when changing the capabilities to window mode only, the preference will become unavailable. We use the bug-fix flag to verify the fix with rollout process. Bug: 328787031 Flag: ACONFIG com.android.settings.accessibility.hide_magnification_always_on_toggle_when_window_mode_only DEVELOPMENT Test: manually flip the flag atest MagnificationCapabilitiesTest atest ToggleScreenMagnificationPreferenceFragmentTest atest MagnificationAlwaysOnPreferenceControllerTest Change-Id: I1a25f80131d84ecdd927030e40a18ebb32b7862f
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.settings.accessibility;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.ContentObserver;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
@@ -101,5 +102,28 @@ public final class MagnificationCapabilities {
|
||||
MagnificationMode.FULLSCREEN, contentResolver.getUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an observer class that gets callbacks when magnification capabilities changes.
|
||||
*
|
||||
* @param context A {@link Context}.
|
||||
* @param contentObserver The object that receives callbacks when changes occur.
|
||||
*/
|
||||
public static void registerObserver(Context context, ContentObserver contentObserver) {
|
||||
context.getContentResolver().registerContentObserver(
|
||||
Settings.Secure.getUriFor(KEY_CAPABILITY),
|
||||
/* notifyForDescendants= */ false,
|
||||
contentObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a magnification capabilities change observer.
|
||||
*
|
||||
* @param context A {@link Context}.
|
||||
* @param contentObserver The previously registered observer that is no longer needed.
|
||||
*/
|
||||
public static void unregisterObserver(Context context, ContentObserver contentObserver) {
|
||||
context.getContentResolver().unregisterContentObserver(contentObserver);
|
||||
}
|
||||
|
||||
private MagnificationCapabilities() {}
|
||||
}
|
||||
|
Reference in New Issue
Block a user