Allow UsbDeviceManager to start adbd again.
There's some weird state where if persist.sys.usb.config=none,adb, then
adbd won't get started. Give back adbd start permissions to
UsbDeviceManager to see if that fixes the issue.
Bug: 150130503
Bug: 150116813
Test: adb shell su 0 setprop persist.sys.usb.config none,adb; adb reboot
adb should be online after.
Change-Id: I36c6ef4b20d58570a2d51ed70088ae5c54d6687d
Exempt-From-Owner-Approval: Fix adbd offline failure
(cherry picked from commit 7a3800993d)
This commit is contained in:
committed by
Nikita Ioffe
parent
6f01c62d29
commit
ac29885a0e
@@ -53,4 +53,14 @@ public abstract class AdbManagerInternal {
|
||||
* Returns the file that contains all of the ADB keys and their last used time.
|
||||
*/
|
||||
public abstract File getAdbTempKeysFile();
|
||||
|
||||
/**
|
||||
* Starts adbd for a transport.
|
||||
*/
|
||||
public abstract void startAdbdForTransport(byte transportType);
|
||||
|
||||
/**
|
||||
* Stops adbd for a transport.
|
||||
*/
|
||||
public abstract void stopAdbdForTransport(byte transportType);
|
||||
}
|
||||
|
||||
@@ -144,6 +144,18 @@ public class AdbService extends IAdbManager.Stub {
|
||||
public File getAdbTempKeysFile() {
|
||||
return mDebuggingManager.getAdbTempKeysFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startAdbdForTransport(byte transportType) {
|
||||
FgThread.getHandler().sendMessage(obtainMessage(
|
||||
AdbService::setAdbdEnabledForTransport, AdbService.this, true, transportType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopAdbdForTransport(byte transportType) {
|
||||
FgThread.getHandler().sendMessage(obtainMessage(
|
||||
AdbService::setAdbdEnabledForTransport, AdbService.this, false, transportType));
|
||||
}
|
||||
}
|
||||
|
||||
private void initAdbState() {
|
||||
@@ -437,6 +449,19 @@ public class AdbService extends IAdbManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
private void setAdbdEnabledForTransport(boolean enable, byte transportType) {
|
||||
if (transportType == AdbTransportType.USB) {
|
||||
mIsAdbUsbEnabled = enable;
|
||||
} else if (transportType == AdbTransportType.WIFI) {
|
||||
mIsAdbWifiEnabled = enable;
|
||||
}
|
||||
if (enable) {
|
||||
startAdbd();
|
||||
} else {
|
||||
stopAdbd();
|
||||
}
|
||||
}
|
||||
|
||||
private void setAdbEnabled(boolean enable, byte transportType) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "setAdbEnabled(" + enable + "), mIsAdbUsbEnabled=" + mIsAdbUsbEnabled
|
||||
|
||||
@@ -1917,7 +1917,19 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// Adbd will be started by AdbService once Global.ADB_ENABLED is set.
|
||||
if ((config & UsbManager.FUNCTION_ADB) != 0) {
|
||||
/**
|
||||
* Start adbd if ADB function is included in the configuration.
|
||||
*/
|
||||
LocalServices.getService(AdbManagerInternal.class)
|
||||
.startAdbdForTransport(AdbTransportType.USB);
|
||||
} else {
|
||||
/**
|
||||
* Stop adbd otherwise
|
||||
*/
|
||||
LocalServices.getService(AdbManagerInternal.class)
|
||||
.stopAdbdForTransport(AdbTransportType.USB);
|
||||
}
|
||||
UsbGadgetCallback usbGadgetCallback = new UsbGadgetCallback(mCurrentRequest,
|
||||
config, chargingFunctions);
|
||||
mGadgetProxy.setCurrentUsbFunctions(config, usbGadgetCallback,
|
||||
|
||||
Reference in New Issue
Block a user