From f29c38b7c59861aefcfef163854c37ac91a41a4e Mon Sep 17 00:00:00 2001 From: Jacky Wang Date: Thu, 23 Jan 2025 10:53:11 +0800 Subject: [PATCH] Fix potential NPE in DevelopmentSettingsDashboardFragment Fix: 364044354 Flag: EXEMPT bugfix Test: N/A Change-Id: If4809b44873c620c615696d697a9f2349dbe7890 --- .../development/DevelopmentSettingsDashboardFragment.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java index e663e2594b2..70a905909e9 100644 --- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java +++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java @@ -198,8 +198,12 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra @Override public void onChange(boolean selfChange, Uri uri) { super.onChange(selfChange, uri); + Activity activity = getActivity(); + if (activity == null) { + return; + } final boolean developmentEnabledState = - DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(getContext()); + DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(activity); final boolean switchState = mSwitchBar.isChecked(); // when developer options is enabled, but it is disabled by other privilege apps like: @@ -209,7 +213,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra return; } disableDeveloperOptions(); - getActivity().runOnUiThread(() -> finishFragment()); + activity.runOnUiThread(() -> finishFragment()); } } };