aidl: usb: Support enableUsbData()

Change-Id: I369731be320b708e63c92bae08f563607d6a8512
tirimbino
Tim Zimmermann 2 years ago committed by zlewchan
parent 8ce96a3566
commit 729c211a95
  1. 9
      aidl/usb/Usb.cpp
  2. 2
      aidl/usb/Usb.h
  3. 11
      aidl/usb/android.hardware.usb-service.samsung.rc

@ -1,5 +1,6 @@
/*
* Copyright (C) 2021 The Android Open Source Project
* Copyright (C) 2022 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -58,11 +59,17 @@ void queryVersionHelper(android::hardware::usb::Usb *usb,
ScopedAStatus Usb::enableUsbData(const string& in_portName, bool in_enable, int64_t in_transactionId) {
std::vector<PortStatus> currentPortStatus;
bool result = true;
pthread_mutex_lock(&mLock);
if (!WriteStringToFile(in_enable ? "1" : "0", USB_DATA_PATH)) {
ALOGE("Not able to turn %s usb connection notification", in_enable ? "on" : "off");
result = false;
}
if (mCallback != NULL) {
ScopedAStatus ret = mCallback->notifyEnableUsbDataStatus(
in_portName, true, in_enable ? Status::SUCCESS : Status::ERROR, in_transactionId);
in_portName, true, result ? Status::SUCCESS : Status::ERROR, in_transactionId);
if (!ret.isOk())
ALOGE("notifyEnableUsbDataStatus error %s", ret.getDescription().c_str());
} else {

@ -1,5 +1,6 @@
/*
* Copyright (C) 2021 The Android Open Source Project
* Copyright (C) 2022 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,6 +29,7 @@
// Having a margin of ~3 secs for the directory and other related bookeeping
// structures created and uvent fired.
#define PORT_TYPE_TIMEOUT 8
#define USB_DATA_PATH "/sys/devices/virtual/usb_notify/usb_control/usb_data_enabled"
namespace aidl {
namespace android {

@ -2,3 +2,14 @@ service vendor.usb_default /vendor/bin/hw/android.hardware.usb-service.samsung
class hal
user system
group system
on post-fs
chown root system /sys/class/typec/port0/power_role
chown root system /sys/class/typec/port0/data_role
chown root system /sys/class/typec/port0/port_type
chown root system /sys/devices/virtual/sec/ccic/water
chown root system /sys/devices/virtual/usb_notify/usb_control/usb_data_enabled
chmod 664 /sys/class/typec/port0/power_role
chmod 664 /sys/class/typec/port0/data_role
chmod 664 /sys/class/typec/port0/port_type
chmod 664 /sys/devices/virtual/usb_notify/usb_control/usb_data_enabled

Loading…
Cancel
Save