Scrolling search results and autorotate cause crash
Activity.getCurrentFocus() can return null,
let's avoid a crash.
Bug: 111865137
Test: manual - Search in settings, scroll, rotate and scroll again.
Change-Id: I3d1437ee8dacc4dbd51f0b58df8a855b713668f0
diff --git a/src/com/android/settings/intelligence/search/SearchFragment.java b/src/com/android/settings/intelligence/search/SearchFragment.java
index 4642b16..c76eda3 100644
--- a/src/com/android/settings/intelligence/search/SearchFragment.java
+++ b/src/com/android/settings/intelligence/search/SearchFragment.java
@@ -344,9 +344,11 @@
final Activity activity = getActivity();
if (activity != null) {
View view = activity.getCurrentFocus();
- InputMethodManager imm = (InputMethodManager)
- activity.getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
+ if (view != null) {
+ InputMethodManager imm = (InputMethodManager)
+ activity.getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
+ }
}
if (mResultsRecyclerView != null) {