Loading Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -587,6 +587,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ android.hardware.thermal-V1.0-java-constants \ android.hardware.tv.input-V1.0-java-constants \ android.hardware.usb-V1.0-java-constants \ android.hardware.usb-V1.1-java-constants \ android.hardware.vibrator-V1.0-java-constants \ # Loaded with System.loadLibrary by android.view.textclassifier Loading core/java/android/hardware/usb/UsbPort.java +58 −26 Original line number Diff line number Diff line Loading @@ -64,6 +64,18 @@ public final class UsbPort implements Parcelable { */ public static final int MODE_DUAL = Constants.PortMode.DRP; /** * Mode bit: This USB port can support USB Type-C Audio accessory. */ public static final int MODE_AUDIO_ACCESSORY = android.hardware.usb.V1_1.Constants.PortMode_1_1.AUDIO_ACCESSORY; /** * Mode bit: This USB port can support USB Type-C debug accessory. */ public static final int MODE_DEBUG_ACCESSORY = android.hardware.usb.V1_1.Constants.PortMode_1_1.DEBUG_ACCESSORY; /** * Power role: This USB port does not have a power role. */ Loading Loading @@ -148,18 +160,31 @@ public final class UsbPort implements Parcelable { /** @hide */ public static String modeToString(int mode) { switch (mode) { case MODE_NONE: StringBuilder modeString = new StringBuilder(); if (mode == MODE_NONE) { return "none"; case MODE_DFP: return "dfp"; case MODE_UFP: return "ufp"; case MODE_DUAL: return "dual"; default: } if ((mode & MODE_DUAL) == MODE_DUAL) { modeString.append("dual, "); } else { if ((mode & MODE_DFP) == MODE_DFP) { modeString.append("dfp, "); } else if ((mode & MODE_UFP) == MODE_UFP) { modeString.append("ufp, "); } } if ((mode & MODE_AUDIO_ACCESSORY) == MODE_AUDIO_ACCESSORY) { modeString.append("audio_acc, "); } if ((mode & MODE_DEBUG_ACCESSORY) == MODE_DEBUG_ACCESSORY) { modeString.append("debug_acc, "); } if (modeString.length() == 0) { return Integer.toString(mode); } return modeString.substring(0, modeString.length() - 2); } /** @hide */ Loading Loading @@ -240,6 +265,13 @@ public final class UsbPort implements Parcelable { Preconditions.checkArgumentInRange(dataRole, DATA_ROLE_NONE, DATA_ROLE_DEVICE, "dataRole"); } /** @hide */ public boolean isModeSupported(int mode) { if ((mSupportedModes & mode) == mode) return true; return false; } @Override public String toString() { return "UsbPort{id=" + mId + ", supportedModes=" + modeToString(mSupportedModes) + "}"; Loading services/usb/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ LOCAL_SRC_FILES += \ LOCAL_JAVA_LIBRARIES := services.core LOCAL_STATIC_JAVA_LIBRARIES := android.hardware.usb-V1.0-java-static \ android.hardware.usb-V1.1-java-static \ android.hidl.manager-V1.0-java-static include $(BUILD_STATIC_JAVA_LIBRARY) services/usb/java/com/android/server/usb/UsbPortManager.java +36 −2 Original line number Diff line number Diff line Loading @@ -22,11 +22,12 @@ import android.hardware.usb.UsbManager; import android.hardware.usb.UsbPort; import android.hardware.usb.UsbPortStatus; import android.hardware.usb.V1_0.IUsb; import android.hardware.usb.V1_0.IUsbCallback; import android.hardware.usb.V1_0.PortRole; import android.hardware.usb.V1_0.PortRoleType; import android.hardware.usb.V1_0.PortStatus; import android.hardware.usb.V1_0.Status; import android.hardware.usb.V1_1.IUsbCallback; import android.hardware.usb.V1_1.PortStatus_1_1; import android.hidl.manager.V1_0.IServiceManager; import android.hidl.manager.V1_0.IServiceNotification; import android.os.Bundle; Loading Loading @@ -454,6 +455,39 @@ public class UsbPortManager { return; } public void notifyPortStatusChange_1_1(ArrayList<PortStatus_1_1> currentPortStatus, int retval) { if (!portManager.mSystemReady) { return; } if (retval != Status.SUCCESS) { logAndPrint(Log.ERROR, pw, "port status enquiry failed"); return; } ArrayList<RawPortInfo> newPortInfo = new ArrayList<RawPortInfo>(); for (PortStatus_1_1 current : currentPortStatus) { RawPortInfo temp = new RawPortInfo(current.status.portName, current.supportedModes, current.currentMode, current.status.canChangeMode, current.status.currentPowerRole, current.status.canChangePowerRole, current.status.currentDataRole, current.status.canChangeDataRole); newPortInfo.add(temp); logAndPrint(Log.INFO, pw, "ClientCallback: " + current.status.portName); } Message message = portManager.mHandler.obtainMessage(); Bundle bundle = new Bundle(); bundle.putParcelableArrayList(PORT_INFO, newPortInfo); message.what = MSG_UPDATE_PORTS; message.setData(bundle); portManager.mHandler.sendMessage(message); return; } public void notifyRoleSwitchStatus(String portName, PortRole role, int retval) { if (retval == Status.SUCCESS) { logAndPrint(Log.INFO, pw, portName + " role switch successful"); Loading Loading @@ -568,7 +602,7 @@ public class UsbPortManager { IndentingPrintWriter pw) { // Only allow mode switch capability for dual role ports. // Validate that the current mode matches the supported modes we expect. if (supportedModes != UsbPort.MODE_DUAL) { if ((supportedModes & UsbPort.MODE_DUAL) != UsbPort.MODE_DUAL) { canChangeMode = false; if (currentMode != 0 && currentMode != supportedModes) { logAndPrint(Log.WARN, pw, "Ignoring inconsistent current mode from USB " Loading Loading
Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -587,6 +587,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ android.hardware.thermal-V1.0-java-constants \ android.hardware.tv.input-V1.0-java-constants \ android.hardware.usb-V1.0-java-constants \ android.hardware.usb-V1.1-java-constants \ android.hardware.vibrator-V1.0-java-constants \ # Loaded with System.loadLibrary by android.view.textclassifier Loading
core/java/android/hardware/usb/UsbPort.java +58 −26 Original line number Diff line number Diff line Loading @@ -64,6 +64,18 @@ public final class UsbPort implements Parcelable { */ public static final int MODE_DUAL = Constants.PortMode.DRP; /** * Mode bit: This USB port can support USB Type-C Audio accessory. */ public static final int MODE_AUDIO_ACCESSORY = android.hardware.usb.V1_1.Constants.PortMode_1_1.AUDIO_ACCESSORY; /** * Mode bit: This USB port can support USB Type-C debug accessory. */ public static final int MODE_DEBUG_ACCESSORY = android.hardware.usb.V1_1.Constants.PortMode_1_1.DEBUG_ACCESSORY; /** * Power role: This USB port does not have a power role. */ Loading Loading @@ -148,18 +160,31 @@ public final class UsbPort implements Parcelable { /** @hide */ public static String modeToString(int mode) { switch (mode) { case MODE_NONE: StringBuilder modeString = new StringBuilder(); if (mode == MODE_NONE) { return "none"; case MODE_DFP: return "dfp"; case MODE_UFP: return "ufp"; case MODE_DUAL: return "dual"; default: } if ((mode & MODE_DUAL) == MODE_DUAL) { modeString.append("dual, "); } else { if ((mode & MODE_DFP) == MODE_DFP) { modeString.append("dfp, "); } else if ((mode & MODE_UFP) == MODE_UFP) { modeString.append("ufp, "); } } if ((mode & MODE_AUDIO_ACCESSORY) == MODE_AUDIO_ACCESSORY) { modeString.append("audio_acc, "); } if ((mode & MODE_DEBUG_ACCESSORY) == MODE_DEBUG_ACCESSORY) { modeString.append("debug_acc, "); } if (modeString.length() == 0) { return Integer.toString(mode); } return modeString.substring(0, modeString.length() - 2); } /** @hide */ Loading Loading @@ -240,6 +265,13 @@ public final class UsbPort implements Parcelable { Preconditions.checkArgumentInRange(dataRole, DATA_ROLE_NONE, DATA_ROLE_DEVICE, "dataRole"); } /** @hide */ public boolean isModeSupported(int mode) { if ((mSupportedModes & mode) == mode) return true; return false; } @Override public String toString() { return "UsbPort{id=" + mId + ", supportedModes=" + modeToString(mSupportedModes) + "}"; Loading
services/usb/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ LOCAL_SRC_FILES += \ LOCAL_JAVA_LIBRARIES := services.core LOCAL_STATIC_JAVA_LIBRARIES := android.hardware.usb-V1.0-java-static \ android.hardware.usb-V1.1-java-static \ android.hidl.manager-V1.0-java-static include $(BUILD_STATIC_JAVA_LIBRARY)
services/usb/java/com/android/server/usb/UsbPortManager.java +36 −2 Original line number Diff line number Diff line Loading @@ -22,11 +22,12 @@ import android.hardware.usb.UsbManager; import android.hardware.usb.UsbPort; import android.hardware.usb.UsbPortStatus; import android.hardware.usb.V1_0.IUsb; import android.hardware.usb.V1_0.IUsbCallback; import android.hardware.usb.V1_0.PortRole; import android.hardware.usb.V1_0.PortRoleType; import android.hardware.usb.V1_0.PortStatus; import android.hardware.usb.V1_0.Status; import android.hardware.usb.V1_1.IUsbCallback; import android.hardware.usb.V1_1.PortStatus_1_1; import android.hidl.manager.V1_0.IServiceManager; import android.hidl.manager.V1_0.IServiceNotification; import android.os.Bundle; Loading Loading @@ -454,6 +455,39 @@ public class UsbPortManager { return; } public void notifyPortStatusChange_1_1(ArrayList<PortStatus_1_1> currentPortStatus, int retval) { if (!portManager.mSystemReady) { return; } if (retval != Status.SUCCESS) { logAndPrint(Log.ERROR, pw, "port status enquiry failed"); return; } ArrayList<RawPortInfo> newPortInfo = new ArrayList<RawPortInfo>(); for (PortStatus_1_1 current : currentPortStatus) { RawPortInfo temp = new RawPortInfo(current.status.portName, current.supportedModes, current.currentMode, current.status.canChangeMode, current.status.currentPowerRole, current.status.canChangePowerRole, current.status.currentDataRole, current.status.canChangeDataRole); newPortInfo.add(temp); logAndPrint(Log.INFO, pw, "ClientCallback: " + current.status.portName); } Message message = portManager.mHandler.obtainMessage(); Bundle bundle = new Bundle(); bundle.putParcelableArrayList(PORT_INFO, newPortInfo); message.what = MSG_UPDATE_PORTS; message.setData(bundle); portManager.mHandler.sendMessage(message); return; } public void notifyRoleSwitchStatus(String portName, PortRole role, int retval) { if (retval == Status.SUCCESS) { logAndPrint(Log.INFO, pw, portName + " role switch successful"); Loading Loading @@ -568,7 +602,7 @@ public class UsbPortManager { IndentingPrintWriter pw) { // Only allow mode switch capability for dual role ports. // Validate that the current mode matches the supported modes we expect. if (supportedModes != UsbPort.MODE_DUAL) { if ((supportedModes & UsbPort.MODE_DUAL) != UsbPort.MODE_DUAL) { canChangeMode = false; if (currentMode != 0 && currentMode != supportedModes) { logAndPrint(Log.WARN, pw, "Ignoring inconsistent current mode from USB " Loading