From b1acf9ceb6f9b2897d138be335f0fe5a6dc35ef4 Mon Sep 17 00:00:00 2001 From: Fabrice Di Meglio Date: Thu, 26 Jun 2014 15:45:37 -0700 Subject: [PATCH] Fix bug #15914018 Search - "wifi" does not gives any result for WifiSettings - prevent the NPE by checking if the drawable reference is not null Was a regression from c8e2eeeaa1666d37abc16d0505a1ef6e9a5bae91 Change-Id: I467dfd41b76eacd0ad1c67bc138481964b2e5b13 --- .../android/settings/wifi/AccessPoint.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/com/android/settings/wifi/AccessPoint.java b/src/com/android/settings/wifi/AccessPoint.java index cd085654f0e..9db1163301a 100644 --- a/src/com/android/settings/wifi/AccessPoint.java +++ b/src/com/android/settings/wifi/AccessPoint.java @@ -228,28 +228,29 @@ class AccessPoint extends Preference { @Override protected void onBindView(View view) { super.onBindView(view); - updateIcon(getLevel()); + updateIcon(getLevel(), getContext()); notifyChanged(); } - protected void updateIcon(int level) { + protected void updateIcon(int level, Context context) { if (level == -1) { setIcon(null); } else { Drawable drawable = getIcon(); if (drawable == null) { - drawable = getContext().getTheme().obtainStyledAttributes( + drawable = context.getTheme().obtainStyledAttributes( wifi_signal_attributes).getDrawable(0); setIcon(drawable); } - drawable.setLevel(level); - drawable.setState((security != SECURITY_NONE) ? STATE_SECURED : STATE_NONE); + if (drawable != null) { + drawable.setLevel(level); + drawable.setState((security != SECURITY_NONE) ? STATE_SECURED : STATE_NONE); + } } } - @Override public int compareTo(Preference preference) { if (!(preference instanceof AccessPoint)) { @@ -474,12 +475,12 @@ class AccessPoint extends Preference { /** Updates the title and summary; may indirectly call notifyChanged() */ private void refresh() { setTitle(ssid); - updateIcon(getLevel()); + + final Context context = getContext(); + updateIcon(getLevel(), context); StringBuilder summary = new StringBuilder(); - Context context = getContext(); - if (mState != null) { // This is the active connection summary.append(Summary.get(context, mState)); } else if (mConfig != null && ((mConfig.status == WifiConfiguration.Status.DISABLED &&