Merge "Catch exception when checking WifiDisplay availability"

am: 7a08901d1b

Change-Id: I426208a605e3771238bd91c135e47faf1b559e58
This commit is contained in:
Fan Zhang
2017-11-16 01:33:31 +00:00
committed by android-build-merger
2 changed files with 24 additions and 9 deletions

View File

@@ -36,6 +36,7 @@ import android.net.wifi.p2p.WifiP2pManager.Channel;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.ServiceManager;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.ListPreference;
@@ -212,8 +213,13 @@ public final class WifiDisplaySettings extends SettingsPreferenceFragment {
}
public static boolean isAvailable(Context context) {
return context.getSystemService(Context.DISPLAY_SERVICE) != null
&& context.getSystemService(Context.WIFI_P2P_SERVICE) != null;
try {
return context.getSystemService(Context.DISPLAY_SERVICE) != null
&& context.getSystemService(Context.WIFI_P2P_SERVICE) != null;
} catch (Exception e) {
// Service is not registered, so this is definitely not available.
return false;
}
}
private void scheduleUpdate(int changes) {