Add fields to infer UsbPortStatus and allow enabling usb while docked

Adding two fields to UsbPortStatus to infer the following:
a. usbDataStatus: To infer the current USB data status of the port.
b. powerBrickStatus: To infer whether a power brick is connected
                     to the USB port.

The change also adds a new method, enableUsbDataWhileDocked to
allow enabling Usb port while being docked.

Bug: 211677613
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: I4fb352679a52326bf4b0fc5aa3d218a0f34cecdb
diff --git a/usb/aidl/default/Usb.cpp b/usb/aidl/default/Usb.cpp
index 0624963..92b09a2 100644
--- a/usb/aidl/default/Usb.cpp
+++ b/usb/aidl/default/Usb.cpp
@@ -74,6 +74,22 @@
     return ScopedAStatus::ok();
 }
 
+ScopedAStatus Usb::enableUsbDataWhileDocked(const string& in_portName, int64_t in_transactionId) {
+
+    pthread_mutex_lock(&mLock);
+    if (mCallback != NULL) {
+        ScopedAStatus ret = mCallback->notifyEnableUsbDataWhileDockedStatus(
+            in_portName, Status::NOT_SUPPORTED, in_transactionId);
+        if (!ret.isOk())
+            ALOGE("notifyEnableUsbDataWhileDockedStatus error %s", ret.getDescription().c_str());
+    } else {
+        ALOGE("Not notifying the userspace. Callback is not set");
+    }
+    pthread_mutex_unlock(&mLock);
+
+    return ScopedAStatus::ok();
+}
+
 Status queryMoistureDetectionStatus(std::vector<PortStatus> *currentPortStatus) {
     string enabled, status, path, DetectedPath;
 
@@ -473,7 +489,7 @@
                 port.second ? canSwitchRoleHelper(port.first) : false;
 
             (*currentPortStatus)[i].supportedModes.push_back(PortMode::DRP);
-            (*currentPortStatus)[i].usbDataEnabled = true;
+            (*currentPortStatus)[i].usbDataStatus.push_back(UsbDataStatus::ENABLED);
 
             ALOGI("%d:%s connected:%d canChangeMode:%d canChagedata:%d canChangePower:%d "
                 "usbDataEnabled:%d",