Merge "Add more consistent null checks" into main
This commit is contained in:
commit
2a3d34413c
3 changed files with 9 additions and 6 deletions
|
|
@ -1379,6 +1379,9 @@ public class TetheringManager {
|
|||
@RequiresPermission(Manifest.permission.ACCESS_NETWORK_STATE)
|
||||
public void registerTetheringEventCallback(@NonNull Executor executor,
|
||||
@NonNull TetheringEventCallback callback) {
|
||||
Objects.requireNonNull(executor);
|
||||
Objects.requireNonNull(callback);
|
||||
|
||||
final String callerPkg = mContext.getOpPackageName();
|
||||
Log.i(TAG, "registerTetheringEventCallback caller:" + callerPkg);
|
||||
|
||||
|
|
@ -1533,6 +1536,8 @@ public class TetheringManager {
|
|||
Manifest.permission.ACCESS_NETWORK_STATE
|
||||
})
|
||||
public void unregisterTetheringEventCallback(@NonNull final TetheringEventCallback callback) {
|
||||
Objects.requireNonNull(callback);
|
||||
|
||||
final String callerPkg = mContext.getOpPackageName();
|
||||
Log.i(TAG, "unregisterTetheringEventCallback caller:" + callerPkg);
|
||||
|
||||
|
|
|
|||
|
|
@ -2397,9 +2397,6 @@ public class Tethering {
|
|||
hasCallingPermission(NETWORK_SETTINGS)
|
||||
|| hasCallingPermission(PERMISSION_MAINLINE_NETWORK_STACK)
|
||||
|| hasCallingPermission(NETWORK_STACK);
|
||||
if (callback == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
mHandler.post(() -> {
|
||||
mTetheringEventCallbacks.register(callback, new CallbackCookie(hasListPermission));
|
||||
final TetheringCallbackStartedParcel parcel = new TetheringCallbackStartedParcel();
|
||||
|
|
@ -2437,9 +2434,6 @@ public class Tethering {
|
|||
|
||||
/** Unregister tethering event callback */
|
||||
void unregisterTetheringEventCallback(ITetheringEventCallback callback) {
|
||||
if (callback == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
mHandler.post(() -> {
|
||||
mTetheringEventCallbacks.unregister(callback);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -164,6 +164,8 @@ public class TetheringService extends Service {
|
|||
@Override
|
||||
public void registerTetheringEventCallback(ITetheringEventCallback callback,
|
||||
String callerPkg) {
|
||||
// Silently ignore call if the callback is null. This can only happen via reflection.
|
||||
if (callback == null) return;
|
||||
try {
|
||||
if (!hasTetherAccessPermission()) {
|
||||
callback.onCallbackStopped(TETHER_ERROR_NO_ACCESS_TETHERING_PERMISSION);
|
||||
|
|
@ -176,6 +178,8 @@ public class TetheringService extends Service {
|
|||
@Override
|
||||
public void unregisterTetheringEventCallback(ITetheringEventCallback callback,
|
||||
String callerPkg) {
|
||||
// Silently ignore call if the callback is null. This can only happen via reflection.
|
||||
if (callback == null) return;
|
||||
try {
|
||||
if (!hasTetherAccessPermission()) {
|
||||
callback.onCallbackStopped(TETHER_ERROR_NO_ACCESS_TETHERING_PERMISSION);
|
||||
|
|
|
|||
Loading…
Reference in a new issue