Add a null check for the OnStartTetheringCallback.

This avoids a NullPointerException when trying to call the callback
and gives a more readable error message.

(cherry picked from commit 35e99ea8ef)

Change-Id: Ia419ff68ef10f308f9e44be47420e27099ee6070
This commit is contained in:
Jeremy Klein
2016-03-12 16:29:54 -08:00
committed by Lorenzo Colitti
parent ce2cfa545d
commit d6114b0eda

View File

@@ -2079,6 +2079,8 @@ public class ConnectivityManager {
@SystemApi @SystemApi
public void startTethering(int type, boolean showProvisioningUi, public void startTethering(int type, boolean showProvisioningUi,
final OnStartTetheringCallback callback, Handler handler) { final OnStartTetheringCallback callback, Handler handler) {
checkNotNull(callback, "OnStartTetheringCallback cannot be null.");
ResultReceiver wrappedCallback = new ResultReceiver(handler) { ResultReceiver wrappedCallback = new ResultReceiver(handler) {
@Override @Override
protected void onReceiveResult(int resultCode, Bundle resultData) { protected void onReceiveResult(int resultCode, Bundle resultData) {
@@ -2089,6 +2091,7 @@ public class ConnectivityManager {
} }
} }
}; };
try { try {
mService.startTethering(type, wrappedCallback, showProvisioningUi); mService.startTethering(type, wrappedCallback, showProvisioningUi);
} catch (RemoteException e) { } catch (RemoteException e) {