usb: convert gadget to apex
This commit is contained in:
@@ -261,7 +261,7 @@ PRODUCT_COPY_FILES += \
|
||||
# USB
|
||||
PRODUCT_PACKAGES += \
|
||||
com.android.hardware.usb \
|
||||
android.hardware.usb.gadget-service.rpi
|
||||
com.android.hardware.usb.gadget.rpi5
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
frameworks/native/data/etc/android.hardware.usb.accessory.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.accessory.xml \
|
||||
|
@@ -40,6 +40,3 @@
|
||||
|
||||
# Suspend
|
||||
/vendor/bin/suspend_blocker_rpi u:object_r:suspend_blocker_exec:s0
|
||||
|
||||
# USB
|
||||
/vendor/bin/hw/android\.hardware\.usb\.gadget-service\.rpi u:object_r:hal_usb_gadget_default_exec:s0
|
||||
|
@@ -5,24 +5,49 @@
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.usb.gadget-service.rpi",
|
||||
defaults: ["hidl_defaults"],
|
||||
relative_install_path: "hw",
|
||||
init_rc: ["android.hardware.usb.gadget-service.rpi.rc"],
|
||||
vintf_fragments: ["android.hardware.usb.gadget-service.rpi.xml"],
|
||||
vendor: true,
|
||||
srcs: [
|
||||
"service.cpp",
|
||||
"MonitorFfs.cpp",
|
||||
"UsbGadget.cpp",
|
||||
"UsbGadgetUtils.cpp",
|
||||
"main.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"android.hardware.usb.gadget-V1-ndk",
|
||||
"libbinder_ndk",
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libhardware",
|
||||
"libhidlbase",
|
||||
"libbinder_ndk",
|
||||
"liblog",
|
||||
"libutils",
|
||||
],
|
||||
static_libs: ["libusbconfigfs-rpi"],
|
||||
installable: false,
|
||||
}
|
||||
|
||||
prebuilt_etc {
|
||||
name: "android.hardware.usb.gadget-service.rpi.rc",
|
||||
src: "android.hardware.usb.gadget-service.rpi.rc",
|
||||
installable: false,
|
||||
}
|
||||
|
||||
prebuilt_etc {
|
||||
name: "android.hardware.usb.gadget-service.rpi.xml",
|
||||
src: "android.hardware.usb.gadget-service.rpi.xml",
|
||||
sub_dir: "vintf",
|
||||
installable: false,
|
||||
}
|
||||
|
||||
apex {
|
||||
name: "com.android.hardware.usb.gadget.rpi5",
|
||||
manifest: "apex_manifest.json",
|
||||
file_contexts: "apex_file_contexts",
|
||||
key: "com.android.hardware.key",
|
||||
certificate: ":com.android.hardware.certificate",
|
||||
updatable: false,
|
||||
vendor: true,
|
||||
|
||||
binaries: ["android.hardware.usb.gadget-service.rpi"],
|
||||
prebuilts: [
|
||||
"android.hardware.usb.gadget-service.rpi.rc",
|
||||
"android.hardware.usb.gadget-service.rpi.xml",
|
||||
],
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
#define LOG_TAG "libusbconfigfs"
|
||||
|
||||
#include "include/UsbGadgetCommon.h"
|
||||
#include "UsbGadgetCommon.h"
|
||||
|
||||
namespace aidl {
|
||||
namespace android {
|
@@ -17,7 +17,7 @@
|
||||
|
||||
#define LOG_TAG "libusbconfigfs"
|
||||
|
||||
#include "include/UsbGadgetCommon.h"
|
||||
#include "UsbGadgetCommon.h"
|
||||
|
||||
namespace aidl {
|
||||
namespace android {
|
@@ -1,4 +1,4 @@
|
||||
service vendor.usb_gadget-default /vendor/bin/hw/android.hardware.usb.gadget-service.rpi
|
||||
service vendor.usb_gadget-rpi /apex/com.android.hardware.usb.gadget.rpi5/bin/hw/android.hardware.usb.gadget-service.rpi
|
||||
class hal
|
||||
user system
|
||||
group system shell mtp
|
||||
|
3
usb/apex_file_contexts
Normal file
3
usb/apex_file_contexts
Normal file
@@ -0,0 +1,3 @@
|
||||
(/.*)? u:object_r:vendor_file:s0
|
||||
/etc(/.*)? u:object_r:vendor_configs_file:s0
|
||||
/bin/hw/android\.hardware\.usb\.gadget-service\.rpi u:object_r:hal_usb_gadget_default_exec:s0
|
4
usb/apex_manifest.json
Normal file
4
usb/apex_manifest.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "com.android.hardware.usb.gadget.rpi5",
|
||||
"version": 1
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
// Copyright (C) 2020 The Android Open Source Project
|
||||
// Copyright (C) 2024 KonstaKANG
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cc_library_static {
|
||||
name: "libusbconfigfs-rpi",
|
||||
vendor_available: true,
|
||||
export_include_dirs: ["include"],
|
||||
|
||||
srcs: [
|
||||
"UsbGadgetUtils.cpp",
|
||||
"MonitorFfs.cpp",
|
||||
],
|
||||
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
],
|
||||
|
||||
shared_libs: [
|
||||
"android.hardware.usb.gadget-V1-ndk",
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libhidlbase",
|
||||
"libutils",
|
||||
],
|
||||
}
|
@@ -15,19 +15,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "UsbGadget.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include "UsbGadget.h"
|
||||
|
||||
using ::aidl::android::hardware::usb::gadget::UsbGadget;
|
||||
|
||||
int main() {
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
||||
std::shared_ptr<UsbGadget> usbgadget = ndk::SharedRefBase::make<UsbGadget>();
|
||||
|
||||
const std::string instance = std::string() + UsbGadget::descriptor + "/default";
|
||||
binder_status_t status = AServiceManager_addService(usbgadget->asBinder().get(), instance.c_str());
|
||||
CHECK(status == STATUS_OK);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return -1;
|
||||
return EXIT_FAILURE; // should not reach
|
||||
}
|
Reference in New Issue
Block a user