天天看點

rockchip android ----列印機支援(/dev/usb/lp0)

列印機支援 /dev/usb/lp0

        • 核心配置
        • 建立節點
          • Android 7.1
          • Android 9.0

核心配置

CONFIG_USB_PRINTER=y
           

建立節點

更新檔位置

/system/core

Android 7.1
diff --git a/init/devices.cpp b/init/devices.cpp
index ada1e28..22993fa 100644
--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -407,6 +407,13 @@ void DeviceHandler::HandleDeviceEvent(const Uevent& uevent) {
             int device_id = uevent.minor % 128 + 1;
             devpath = StringPrintf("/dev/bus/usb/%03d/%03d", bus_id, device_id);
         }
+    } else if (uevent.subsystem == "usbmisc") {
+        if (!uevent.device_name.empty()) {
+            devpath = "/dev/" + uevent.device_name;
+        } else {
+            // ignore other USB events
+            return;
+        }
     } else if (StartsWith(uevent.subsystem, "usb")) {
         // ignore other USB events
         return;
           
Android 9.0
diff --git a/init/devices.cpp b/init/devices.cpp
index 9ef416b..0128a5d 100644
--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -699,6 +699,14 @@ static void handle_generic_device_event(struct uevent *uevent)
                  make_dir(devpath, 0755);
                  snprintf(devpath, sizeof(devpath), "/dev/bus/usb/%03d/%03d", bus_id, device_id);
              }
+         } else if (!strncmp(uevent->subsystem, "usbmisc", 7)) {
+            if (!strncmp(uevent->device_name, "usb/lp", 6)) {
+                base = "/dev/usb/";
+                make_dir(base, 0755);
+            } else {
+                /* ignore other USB events */
+                return;
+            }
          } else {
              /* ignore other USB events */
              return;
           
rockchip android ----列印機支援(/dev/usb/lp0)