OSDN Git Service

DO NOT MERGE: Add a null check for the OnStartTetheringCallback.
authorJeremy Klein <jlklein@google.com>
Sun, 13 Mar 2016 00:29:54 +0000 (16:29 -0800)
committerLorenzo Colitti <lorenzo@google.com>
Fri, 9 Dec 2016 04:42:02 +0000 (13:42 +0900)
This avoids a NullPointerException when trying to call the callback
and gives a more readable error message.

(cherry picked from commit 5f277e1667b49976a77c9fa79b9a04d775f3b49e)

Change-Id: Ia419ff68ef10f308f9e44be47420e27099ee6070

core/java/android/net/ConnectivityManager.java

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