@posx/capacitor-usb-printer 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,6 +9,7 @@ import android.hardware.usb.*;
|
|
|
9
9
|
import android.os.Build;
|
|
10
10
|
import android.util.Log;
|
|
11
11
|
|
|
12
|
+
import android.system.Os;
|
|
12
13
|
import java.io.File;
|
|
13
14
|
import java.util.ArrayList;
|
|
14
15
|
import java.util.Collections;
|
|
@@ -40,14 +41,12 @@ public class UsbPrinter {
|
|
|
40
41
|
try {
|
|
41
42
|
int busNum = Integer.parseInt(parts[parts.length - 2]);
|
|
42
43
|
int devNum = Integer.parseInt(parts[parts.length - 1]);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
} catch (Exception ignored) {}
|
|
44
|
+
// USB char device: major=189, minor=(busNum-1)*128+(devNum-1)
|
|
45
|
+
int minor = (busNum - 1) * 128 + (devNum - 1);
|
|
46
|
+
// Os.readlink() only needs sysfs:lnk_file read (allowed for all domains)
|
|
47
|
+
String target = Os.readlink("/sys/dev/char/189:" + minor);
|
|
48
|
+
return new File(target).getName(); // e.g. "1-1.1" from "../../.../usb1/1-1/1-1.1"
|
|
49
|
+
} catch (Exception e) { Log.w(TAG, "getPortPath failed: " + e.getMessage()); }
|
|
51
50
|
return "";
|
|
52
51
|
}
|
|
53
52
|
|
package/package.json
CHANGED