From cf731bc480e2e11474b5d820b7d7a04bd0eff176 Mon Sep 17 00:00:00 2001 From: Ningyuan Wang Date: Mon, 16 May 2016 13:54:01 -0700 Subject: Fix null intent handling This also fixes the potential crash when handling intent with null action string. BUG=28689719 TEST=compile TEST=runtest frameworks-wifi Change-Id: I6ef3e07e38f33d8c5040dd358f161224095189d6 --- service/java/com/android/server/wifi/WifiTrafficPoller.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/service/java/com/android/server/wifi/WifiTrafficPoller.java b/service/java/com/android/server/wifi/WifiTrafficPoller.java index 38ec1a5b6..336e0d786 100644 --- a/service/java/com/android/server/wifi/WifiTrafficPoller.java +++ b/service/java/com/android/server/wifi/WifiTrafficPoller.java @@ -84,13 +84,16 @@ final class WifiTrafficPoller { new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - if (intent.getAction().equals( - WifiManager.NETWORK_STATE_CHANGED_ACTION)) { + if (intent == null) { + return; + } + if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals( + intent.getAction())) { mNetworkInfo = (NetworkInfo) intent.getParcelableExtra( WifiManager.EXTRA_NETWORK_INFO); - } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { + } else if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) { mScreenOn.set(false); - } else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { + } else if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) { mScreenOn.set(true); } evaluateTrafficStatsPolling(); -- cgit v1.2.3