fixed NPE while initializing controllers by commenting out the failure

one for temporal fix

Added @Nullable in parameters of buildPreferenceControllers() to prevent using nullable parameter to functions requires non-nullable.

Bug: 315330037
Test: see developer options preferences show/hide based on the
controllers isAvailable()

Change-Id: If42faea900a2220d9b1f5e38e1befbd5a555e78a
This commit is contained in:
David Liu
2023-12-11 20:58:31 +00:00
parent f04ee0dfab
commit 13c63260a3
3 changed files with 11 additions and 8 deletions

View File

@@ -727,10 +727,11 @@
android:title="@string/enable_non_resizable_multi_window" android:title="@string/enable_non_resizable_multi_window"
android:summary="@string/enable_non_resizable_multi_window_summary" /> android:summary="@string/enable_non_resizable_multi_window_summary" />
<SwitchPreferenceCompat // TODO(b/315859328): Temporally removed since causing search indexing failure.
android:key="back_navigation_animation" <!-- <SwitchPreferenceCompat-->
android:title="@string/back_navigation_animation" <!-- android:key="back_navigation_animation"-->
android:summary="@string/back_navigation_animation_summary" /> <!-- android:title="@string/back_navigation_animation"-->
<!-- android:summary="@string/back_navigation_animation_summary" />-->
<Preference <Preference
android:key="reset_shortcut_manager_throttling" android:key="reset_shortcut_manager_throttling"

View File

@@ -49,6 +49,7 @@ import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
@@ -606,8 +607,9 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
} }
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context, private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
Activity activity, Lifecycle lifecycle, DevelopmentSettingsDashboardFragment fragment, @Nullable Activity activity, @Nullable Lifecycle lifecycle,
BluetoothA2dpConfigStore bluetoothA2dpConfigStore) { @Nullable DevelopmentSettingsDashboardFragment fragment,
@Nullable BluetoothA2dpConfigStore bluetoothA2dpConfigStore) {
final List<AbstractPreferenceController> controllers = new ArrayList<>(); final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new MemoryUsagePreferenceController(context)); controllers.add(new MemoryUsagePreferenceController(context));
controllers.add(new BugReportPreferenceController(context)); controllers.add(new BugReportPreferenceController(context));
@@ -735,7 +737,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
controllers.add(new OverlaySettingsPreferenceController(context)); controllers.add(new OverlaySettingsPreferenceController(context));
controllers.add(new StylusHandwritingPreferenceController(context)); controllers.add(new StylusHandwritingPreferenceController(context));
controllers.add(new IngressRateLimitPreferenceController((context))); controllers.add(new IngressRateLimitPreferenceController((context)));
controllers.add(new BackAnimationPreferenceController(context, fragment)); // controllers.add(new BackAnimationPreferenceController(context, fragment));
controllers.add(new PhantomProcessPreferenceController(context)); controllers.add(new PhantomProcessPreferenceController(context));
controllers.add(new ContrastPreferenceController( controllers.add(new ContrastPreferenceController(
context, context.getSystemService(UiModeManager.class))); context, context.getSystemService(UiModeManager.class)));

View File

@@ -136,7 +136,7 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider {
try { try {
controllersFromCode = createPreferenceControllers(context); controllersFromCode = createPreferenceControllers(context);
} catch (Exception e) { } catch (Exception e) {
Log.w(TAG, "Error initial controller"); Log.w(TAG, "Error initializing controller in fragment: " + this + ", e: " + e);
} }
final List<SearchIndexableResource> res = getXmlResourcesToIndex(context, true); final List<SearchIndexableResource> res = getXmlResourcesToIndex(context, true);