diff --git a/Android.bp b/Android.bp index ba6e690619da9..b715b7336d239 100644 --- a/Android.bp +++ b/Android.bp @@ -151,6 +151,7 @@ java_defaults { "core/java/android/content/pm/permission/IRuntimePermissionPresenter.aidl", "core/java/android/database/IContentObserver.aidl", "core/java/android/debug/IAdbManager.aidl", + "core/java/android/debug/IAdbTransport.aidl", ":libcamera_client_aidl", ":libcamera_client_framework_aidl", "core/java/android/hardware/IConsumerIrService.aidl", diff --git a/core/java/android/debug/AdbManagerInternal.java b/core/java/android/debug/AdbManagerInternal.java index 916609db2a0ee..071202f84d9e3 100644 --- a/core/java/android/debug/AdbManagerInternal.java +++ b/core/java/android/debug/AdbManagerInternal.java @@ -23,4 +23,17 @@ package android.debug; * @hide Only should be called from the system server. */ public abstract class AdbManagerInternal { + /** + * Registers a ADB transport mechanism. + * + * @param transport ADB transport interface to register + */ + public abstract void registerTransport(IAdbTransport transport); + + /** + * Unregisters a previously registered ADB transport mechanism. + * + * @param transport previously-added ADB transport interface to be removed + */ + public abstract void unregisterTransport(IAdbTransport transport); } diff --git a/core/java/android/debug/IAdbTransport.aidl b/core/java/android/debug/IAdbTransport.aidl new file mode 100644 index 0000000000000..6579deb6a6cdf --- /dev/null +++ b/core/java/android/debug/IAdbTransport.aidl @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2018 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; + +/** @hide */ +interface IAdbTransport { +} diff --git a/services/core/java/com/android/server/adb/AdbService.java b/services/core/java/com/android/server/adb/AdbService.java index 558d7ccda4d1c..a079a0f5757a9 100644 --- a/services/core/java/com/android/server/adb/AdbService.java +++ b/services/core/java/com/android/server/adb/AdbService.java @@ -18,7 +18,10 @@ package com.android.server.adb; import android.content.Context; import android.debug.AdbManagerInternal; import android.debug.IAdbManager; +import android.debug.IAdbTransport; import android.os.Binder; +import android.os.IBinder; +import android.util.ArrayMap; import com.android.internal.util.DumpUtils; import com.android.internal.util.IndentingPrintWriter; @@ -51,11 +54,21 @@ public class AdbService extends IAdbManager.Stub { } private class AdbManagerInternalImpl extends AdbManagerInternal { + @Override + public void registerTransport(IAdbTransport transport) { + mTransports.put(transport.asBinder(), transport); + } + + @Override + public void unregisterTransport(IAdbTransport transport) { + mTransports.remove(transport.asBinder()); + } } private static final String TAG = "AdbService"; private final Context mContext; + private final ArrayMap mTransports = new ArrayMap<>(); private AdbService(Context context) { mContext = context; @@ -73,8 +86,8 @@ public class AdbService extends IAdbManager.Stub { if (args == null || args.length == 0 || "-a".equals(args[0])) { pw.println("ADB Manager State:"); pw.increaseIndent(); - pw.println("None"); - // TODO: flesh out with status. + pw.print("Number of registered transports: "); + pw.println(mTransports.size()); } else { pw.println("Dump current ADB state"); pw.println(" No commands available");