Add null check for the taken callback
The requestTetheredInterface() and releaseTetheredInterface() in EthernetManager is annotated as @NonNull. Basically, the taken callback parameter to the service implementation should also be @NonNull. However, it still possible to use native commands to call the method in the aidl. If a null callback is taken, it may cause unexpected results and cause crashes. Add a null check and throw NPE as a warning. Bug: 190058445 Test: adb commands Change-Id: I18fd63aba3f7326597fc3a8c93ba8c9097bf7348
This commit is contained in:
@@ -35,6 +35,7 @@ import com.android.internal.util.IndentingPrintWriter;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
@@ -172,6 +173,7 @@ public class EthernetServiceImpl extends IEthernetManager.Stub {
|
||||
|
||||
@Override
|
||||
public void requestTetheredInterface(ITetheredInterfaceCallback callback) {
|
||||
Objects.requireNonNull(callback, "callback must not be null");
|
||||
NetworkStack.checkNetworkStackPermissionOr(mContext,
|
||||
android.Manifest.permission.NETWORK_SETTINGS);
|
||||
mTracker.requestTetheredInterface(callback);
|
||||
@@ -179,6 +181,7 @@ public class EthernetServiceImpl extends IEthernetManager.Stub {
|
||||
|
||||
@Override
|
||||
public void releaseTetheredInterface(ITetheredInterfaceCallback callback) {
|
||||
Objects.requireNonNull(callback, "callback must not be null");
|
||||
NetworkStack.checkNetworkStackPermissionOr(mContext,
|
||||
android.Manifest.permission.NETWORK_SETTINGS);
|
||||
mTracker.releaseTetheredInterface(callback);
|
||||
|
||||
Reference in New Issue
Block a user