Merge "AdbService sends callback on adb debugging enabled / disabled."
This commit is contained in:
@@ -285,6 +285,23 @@ aidl_interface {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aidl_interface {
|
||||||
|
name: "android.debug_aidl",
|
||||||
|
unstable: true,
|
||||||
|
srcs: [
|
||||||
|
"android/debug/AdbTransportType.aidl",
|
||||||
|
"android/debug/FingerprintAndPairDevice.aidl",
|
||||||
|
"android/debug/IAdbCallback.aidl",
|
||||||
|
"android/debug/IAdbManager.aidl",
|
||||||
|
"android/debug/PairDevice.aidl",
|
||||||
|
],
|
||||||
|
backend: {
|
||||||
|
cpp: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// Avoid including Parcelable classes as we don't want to have two copies of
|
// Avoid including Parcelable classes as we don't want to have two copies of
|
||||||
// Parcelable cross the libraries. This is used by telephony-common (frameworks/opt/telephony)
|
// Parcelable cross the libraries. This is used by telephony-common (frameworks/opt/telephony)
|
||||||
// and TeleService app (packages/services/Telephony).
|
// and TeleService app (packages/services/Telephony).
|
||||||
|
|||||||
31
core/java/android/debug/IAdbCallback.aidl
Normal file
31
core/java/android/debug/IAdbCallback.aidl
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.debug;
|
||||||
|
|
||||||
|
import android.debug.AdbTransportType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback interface of {@link android.debug.IAdbCallbackManager}.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
oneway interface IAdbCallback {
|
||||||
|
/**
|
||||||
|
* On debugging enabled, service providing IAdbManager calls this function.
|
||||||
|
*/
|
||||||
|
void onDebuggingChanged(boolean enabled, AdbTransportType type);
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
package android.debug;
|
package android.debug;
|
||||||
|
|
||||||
import android.debug.FingerprintAndPairDevice;
|
import android.debug.FingerprintAndPairDevice;
|
||||||
|
import android.debug.IAdbCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface to communicate remotely with the {@code AdbService} in the system server.
|
* Interface to communicate remotely with the {@code AdbService} in the system server.
|
||||||
@@ -111,4 +112,14 @@ interface IAdbManager {
|
|||||||
* QR code.
|
* QR code.
|
||||||
*/
|
*/
|
||||||
boolean isAdbWifiQrSupported();
|
boolean isAdbWifiQrSupported();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register callback for ADB debugging changed notification.
|
||||||
|
*/
|
||||||
|
void registerCallback(IAdbCallback callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregister callback for ADB debugging changed notification.
|
||||||
|
*/
|
||||||
|
void unregisterCallback(IAdbCallback callback);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import android.debug.AdbManager;
|
|||||||
import android.debug.AdbManagerInternal;
|
import android.debug.AdbManagerInternal;
|
||||||
import android.debug.AdbTransportType;
|
import android.debug.AdbTransportType;
|
||||||
import android.debug.FingerprintAndPairDevice;
|
import android.debug.FingerprintAndPairDevice;
|
||||||
|
import android.debug.IAdbCallback;
|
||||||
import android.debug.IAdbManager;
|
import android.debug.IAdbManager;
|
||||||
import android.debug.IAdbTransport;
|
import android.debug.IAdbTransport;
|
||||||
import android.debug.PairDevice;
|
import android.debug.PairDevice;
|
||||||
@@ -36,6 +37,7 @@ import android.net.Uri;
|
|||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
|
import android.os.RemoteCallbackList;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
@@ -88,6 +90,7 @@ public class AdbService extends IAdbManager.Stub {
|
|||||||
private final AdbConnectionPortListener mPortListener = new AdbConnectionPortListener();
|
private final AdbConnectionPortListener mPortListener = new AdbConnectionPortListener();
|
||||||
private AdbDebuggingManager.AdbConnectionPortPoller mConnectionPortPoller;
|
private AdbDebuggingManager.AdbConnectionPortPoller mConnectionPortPoller;
|
||||||
|
|
||||||
|
private final RemoteCallbackList<IAdbCallback> mCallbacks = new RemoteCallbackList<>();
|
||||||
/**
|
/**
|
||||||
* Manages the service lifecycle for {@code AdbService} in {@code SystemServer}.
|
* Manages the service lifecycle for {@code AdbService} in {@code SystemServer}.
|
||||||
*/
|
*/
|
||||||
@@ -411,6 +414,21 @@ public class AdbService extends IAdbManager.Stub {
|
|||||||
return mConnectionPort.get();
|
return mConnectionPort.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerCallback(IAdbCallback callback) throws RemoteException {
|
||||||
|
if (DEBUG) {
|
||||||
|
Slog.d(TAG, "Registering callback " + callback);
|
||||||
|
}
|
||||||
|
mCallbacks.register(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregisterCallback(IAdbCallback callback) throws RemoteException {
|
||||||
|
if (DEBUG) {
|
||||||
|
Slog.d(TAG, "Unregistering callback " + callback);
|
||||||
|
}
|
||||||
|
mCallbacks.unregister(callback);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* This listener is only used when ro.adb.secure=0. Otherwise, AdbDebuggingManager will
|
* This listener is only used when ro.adb.secure=0. Otherwise, AdbDebuggingManager will
|
||||||
* do this.
|
* do this.
|
||||||
@@ -517,6 +535,23 @@ public class AdbService extends IAdbManager.Stub {
|
|||||||
if (mDebuggingManager != null) {
|
if (mDebuggingManager != null) {
|
||||||
mDebuggingManager.setAdbEnabled(enable, transportType);
|
mDebuggingManager.setAdbEnabled(enable, transportType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
Slog.d(TAG, "Broadcasting enable = " + enable + ", type = " + transportType);
|
||||||
|
}
|
||||||
|
mCallbacks.broadcast((callback) -> {
|
||||||
|
if (DEBUG) {
|
||||||
|
Slog.d(TAG, "Sending enable = " + enable + ", type = " + transportType
|
||||||
|
+ " to " + callback);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
callback.onDebuggingChanged(enable, transportType);
|
||||||
|
} catch (RemoteException ex) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Slog.d(TAG, "Unable to send onDebuggingChanged:", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user