android N 串口打不开,请问如何配置

carl.xu 2020-08-11 01:36:29
ailiving@ailiving-desktop:/mnt/data/ailiving/Workfolder/carl/aili/d/d-4/sc60_android7.1.2_ailiving/device$ git diff qcom/common/rootdir/etc/init.qcom.rc
diff --git a/device/qcom/common/rootdir/etc/init.qcom.rc b/device/qcom/common/rootdir/etc/init.qcom.rc
index 8714587ca3..1b04022f0f 100755
--- a/device/qcom/common/rootdir/etc/init.qcom.rc
+++ b/device/qcom/common/rootdir/etc/init.qcom.rc
@@ -83,6 +83,19 @@ on boot
chmod 0777 /dev/ttyHSL2
chmod 0777 /dev/ttyHSL1
chmod 0777 /dev/ttyHSL3

ailiving@ailiving-desktop:/mnt/data/ailiving/Workfolder/carl/aili/d/d-4/sc60_android7.1.2_ailiving/device$ git diff qcom/common/rootdir/etc/ueventd.qcom.rc
diff --git a/device/qcom/common/rootdir/etc/ueventd.qcom.rc b/device/qcom/common/rootdir/etc/ueventd.qcom.rc
index e1a4deaffb..26011316d5 100755
--- a/device/qcom/common/rootdir/etc/ueventd.qcom.rc
+++ b/device/qcom/common/rootdir/etc/ueventd.qcom.rc
@@ -177,6 +177,19 @@
/dev/smd2 0660 bluetooth net_bt_stack
/dev/ttyHSL1 0660 system system
/dev/ttyHS1 0660 system system
+/dev/ttyHSL3 0660 system system

ailiving@ailiving-desktop:/mnt/data/ailiving/Workfolder/carl/aili/d/d-4/sc60_android7.1.2_ailiving/device$ git diff qcom/sepolicy/common/device.te
diff --git a/device/qcom/sepolicy/common/device.te b/device/qcom/sepolicy/common/device.te
index fc358fb7c3..f60d212253 100644
--- a/device/qcom/sepolicy/common/device.te
+++ b/device/qcom/sepolicy/common/device.te
@@ -141,3 +141,4 @@ type at_device, dev_type;

#define Bluetooth device
type bt_device, dev_type;
+type ailving_uart_file, dev_type, file_type, mlstrustedobject;

ailiving@ailiving-desktop:/mnt/data/ailiving/Workfolder/carl/aili/d/d-4/sc60_android7.1.2_ailiving/device$ git diff qcom/sepolicy/msm8953/file_contexts
diff --git a/device/qcom/sepolicy/msm8953/file_contexts b/device/qcom/sepolicy/msm8953/file_contexts
index a0d9171c83..a93a84079b 100644
--- a/device/qcom/sepolicy/msm8953/file_contexts
+++ b/device/qcom/sepolicy/msm8953/file_contexts
@@ -53,3 +53,4 @@
/sys/kernel/dload/emmc_dload u:object_r:sysfs_emmc_dload:s0
/data/ailiving(/.*)? u:object_r:download_data_file:s0
/sys/kernel/ailiving_sata(/.*)? u:object_r:ailiving_power_file:s0
+/dev/ttyHSL3 u:object_r:ailving_uart_file:s0

ailiving@ailiving-desktop:/mnt/data/ailiving/Workfolder/carl/aili/d/d-4/sc60_android7.1.2_ailiving/device$ git diff qcom/sepolicy/msm8953/system_app.te
diff --git a/device/qcom/sepolicy/msm8953/system_app.te b/device/qcom/sepolicy/msm8953/system_app.te
index e9e19b0fd8..9cec234968 100644
--- a/device/qcom/sepolicy/msm8953/system_app.te
+++ b/device/qcom/sepolicy/msm8953/system_app.te
@@ -32,3 +32,8 @@ allow system_app download_data_file:file { create read write open getattr unlink
allow system_app ailiving_power_file:file { create read write open getattr unlink rename };
allow system_app sysfs:file write;
allow system_app persist_file:file { create read write open getattr unlink rename };
+allow system_app ailving_uart_file:dir { write open read ioctl getattr};
+allow system_app ailving_uart_file:chr_file { read write open ioctl };
+allow system_app ailving_uart_file:file { create read write open getattr unlink rename };

我使用的是android N 也就是android 7.1的版本
userdebug下,编译烧录,是没有问题的
问题是:
user版本,编译就提示 android 打不开
01-02 11:36:39.909 3183 3183 E AndroidRuntime: FATAL EXCEPTION: main
01-02 11:36:39.909 3183 3183 E AndroidRuntime: Process: com.ailiving.car.device, PID: 3183
01-02 11:36:39.909 3183 3183 E AndroidRuntime: java.lang.RuntimeException: Unable to create application com.ailiving.car.device.main.MyApplication: java.lang.SecurityException
01-02 11:36:39.909 3183 3183 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5408)
01-02 11:36:39.909 3183 3183 E AndroidRuntime: at android.app.ActivityThread.-wrap2(ActivityThread.java)
01-02 11:36:39.909 3183 3183 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
01-02 11:36:39.909 3183 3183 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
01-02 11:36:39.909 3183 3183 E AndroidRuntime: at android.os.Looper.loop(Looper.java:154)
01-02 11:36:39.909 3183 3183 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6121)
01-02 11:36:39.909 3183 3183 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
01-02 11:36:39.909 3183 3183 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
01-02 11:36:39.909 3183 3183 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
01-02 11:36:39.909 3183 3183 E AndroidRuntime: Caused by: java.lang.SecurityException
01-02 11:36:39.909 3183 3183 E AndroidRuntime: at android_serialport_api.SerialPort.<init>(SerialPort.java:37)
01-02 11:36:39.909 3183 3183 E AndroidRuntime: at com.ailiving.car.device.uart.SerialPortUtils.openSerialPort(SerialPortUtils.java:51)
01-02 11:36:39.909 3183 3183 E AndroidRuntime: at com.ailiving.car.device.main.MyApplication.onCreate(MyApplication.java:275)
01-02 11:36:39.909 3183 3183 E AndroidRuntime: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1025)
01-02 11:36:39.909 3183 3183 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5405)
01-02 11:36:39.909 3183 3183 E AndroidRuntime: ... 8 more
01-02 11:36:39.913 1445 3164 I ActivityManager: Start proc 10168:com.qualcomm.qti.carrierconfigure/1000 for restart com.qualcomm.qti.carrierconfigure
01-02 11:36:39.915 1445 1693 W ActivityManager: Force finishing activity com.ailiving.car.device/.liming.Main2Activity
...全文
3341 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
carl.xu 2020-08-11
  • 打赏
  • 举报
回复
user版本下,试了 setenforce 0 没有权限 Enforcing msm8953_64:/ $ setenforce 0 setenforce: Couldn't set enforcing status to '0': Permission denied 1|msm8953_64:/ $ getenforce Enforcing msm8953_64:/ $ setenforce 0 setenforce: Couldn't set enforcing status to '0': Permission denied 1|msm8953_64:/ $
carl.xu 2020-08-11
  • 打赏
  • 举报
回复
user编译版本,编译后,就提示 open serial 出错,真是奇怪 01-02 13:30:34.181 2726 2726 E AndroidRuntime: Process: com.ailiving.car.device, PID: 2726 01-02 13:30:34.181 2726 2726 E AndroidRuntime: java.lang.RuntimeException: Unable to create application com.ailiving.car.device.main.MyApplication: java.lang.SecurityException 01-02 13:30:34.181 2726 2726 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5408) 01-02 13:30:34.181 2726 2726 E AndroidRuntime: at android.app.ActivityThread.-wrap2(ActivityThread.java) 01-02 13:30:34.181 2726 2726 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546) 01-02 13:30:34.181 2726 2726 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102) 01-02 13:30:34.181 2726 2726 E AndroidRuntime: at android.os.Looper.loop(Looper.java:154) 01-02 13:30:34.181 2726 2726 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6121) 01-02 13:30:34.181 2726 2726 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 01-02 13:30:34.181 2726 2726 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) 01-02 13:30:34.181 2726 2726 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) 01-02 13:30:34.181 2726 2726 E AndroidRuntime: Caused by: java.lang.SecurityException 01-02 13:30:34.181 2726 2726 E AndroidRuntime: at android_serialport_api.SerialPort.<init>(SerialPort.java:37) 01-02 13:30:34.181 2726 2726 E AndroidRuntime: at com.ailiving.car.device.uart.SerialPortUtils.openSerialPort(SerialPortUtils.java:51) 01-02 13:30:34.181 2726 2726 E AndroidRuntime: at com.ailiving.car.device.main.MyApplication.onCreate(MyApplication.java:275) 01-02 13:30:34.181 2726 2726 E AndroidRuntime: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1025) 01-02 13:30:34.181 2726 2726 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5405)
carl.xu 2020-08-11
  • 打赏
  • 举报
回复
userdebug 下搜索到的信息 C:\Users\admin\user_problem>adb shell msm8953_64:/ # ps -Z | grep ailiving u:r:system_app:s0 system 3812 669 2654148 387540 SyS_epoll_ 00f39e2458 S com.ailiving.car.device msm8953_64:/ # cd dev msm8953_64:/dev # ls ttyHSL3 -lZ crwxrwxrwx 1 system system u:object_r:ailving_uart_file:s0 242, 3 1970-01-02 13:27 ttyHSL3
usecf 2020-08-11
  • 打赏
  • 举报
回复
检查下你seliunx的权限是否设置了 adb shell ---> getenforce 看看 如果打开关掉 setenforce 0 再看看你串口节点权限 改成777 试试
carl.xu 2020-08-11
  • 打赏
  • 举报
回复
不知 CSDN 上有这方面研究 的高手不?
carl.xu 2020-08-11
  • 打赏
  • 举报
回复
--------- beginning of main 01-02 11:36:13.466 387 387 W auditd : type=2000 audit(0.0:1): initialized 01-02 11:36:16.579 387 387 I auditd : type=1403 audit(0.0:2): policy loaded auid=4294967295 ses=4294967295 01-02 11:36:16.579 387 387 W auditd : type=1404 audit(0.0:3): enforcing=1 old_enforcing=0 auid=4294967295 ses=4294967295 01-02 11:36:17.964 397 397 I : debuggerd: starting 01-02 11:36:17.988 396 396 I : debuggerd: starting 01-02 11:36:18.000 589 660 D QC-time-services: Daemon:genoff_modem_qmi_service_request: Initiallizing QMI 01-02 11:36:18.000 589 662 D QC-time-services: Daemon: Time-services: All initializations done 01-02 11:36:18.001 589 662 E QC-time-services: Daemon: Time-services: Waiting to acceptconnection 01-02 11:36:18.002 591 591 I ThermalEngine: cpr_band_init: Could not read /sys/module/msm_thermal/cpr_band/curr_cpr_band 01-02 11:36:18.002 591 591 E ThermalEngine: Unable to init battery charging mitigation to 0 01-02 11:36:18.002 591 591 I ThermalEngine: sensors_manager_init: Init 01-02 11:36:18.002 589 660 E QMI_FW : QMUXD: WARNING qmi_qmux_if_pwr_up_init failed! rc=-6 01-02 11:36:18.003 589 660 E QC-time-services: Daemon:genoff_modem_qmi_service_request: qmi_client_get_service_list returned -2num_services 0 01-02 11:36:18.003 591 666 I ThermalEngine: qmi: Instance id 157 for fusion TS --------- beginning of system 01-02 11:36:18.004 398 398 I vold : Vold 3.0 (the awakening) firing up 01-02 11:36:18.005 398 398 V vold : Detected support for: ext4 vfat 01-02 11:36:18.009 638 638 W nqnfcinfo: type=1400 audit(0.0:17): avc: denied { getattr } for path="/vendor" dev="rootfs" ino=12488 scontext=u:r:nqnfcinfo:s0 tcontext=u:object_r:rootfs:s0 tclass=lnk_file permissive=0 01-02 11:36:18.022 398 405 D vold : e4crypt_init_user0 01-02 11:36:18.022 398 405 D vold : e4crypt_prepare_user_storage for volume null, user 0, serial 0, flags 1 01-02 11:36:18.022 398 405 D vold : Preparing: /data/system/users/0 01-02 11:36:18.022 398 405 D vold : Preparing: /data/misc/profiles/cur/0 01-02 11:36:18.023 398 405 D vold : Preparing: /data/misc/profiles/cur/0/foreign-dex 01-02 11:36:18.023 398 405 D vold : Preparing: /data/system_de/0 01-02 11:36:18.023 398 405 D vold : Preparing: /data/misc_de/0 01-02 11:36:18.024 398 405 D vold : Preparing: /data/user_de/0 01-02 11:36:18.024 398 405 D vold : e4crypt_unlock_user_key 0 serial=0 token_present=0 01-02 11:36:18.026 1 1 I vdc : 200 401 Command succeeded 01-02 11:36:18.030 595 595 E adsprpc : vendor/qcom/proprietary/adsprpc/src/adsp_default_listener.c:28:adsp_default_listener_start started 01-02 11:36:18.034 591 591 E ThermalEngine: Unable to open /sys/devices/soc.0/ 01-02 11:36:18.034 591 591 E ThermalEngine: bcl_setup: Unexpected node error 01-02 11:36:18.034 591 591 E ThermalEngine: add_tgt_sensors_set: Error adding bcl 01-02 11:36:18.034 591 591 E ThermalEngine: sensors_init: Error adding BCL TS 01-02 11:36:18.039 407 407 I /system/bin/tzdatacheck: tzdata file /data/misc/zoneinfo/current/tzdata does not exist. No action required. 01-02 11:36:18.046 593 593 D QSEECOMD: : Init dlopen(libdrmtime.so, RTLD_NOW) succeeds 01-02 11:36:18.047 593 593 D QSEECOMD: : Init::Init dlsym(g_FSHandle atime_start) succeeds 01-02 11:36:18.047 593 593 D DrmLibTime: QSEE Time Listener: atime_start 01-02 11:36:18.047 593 593 D QSEECOMAPI: QSEECom_register_listener 11 sb_length = 0x5000 01-02 11:36:18.049 623 623 I keystore: Found keymaster1 module Keymaster QTI HAL, version 100 01-02 11:36:18.049 623 623 I SoftKeymaster: system/keymaster/soft_keymaster_device.cpp, Line 131: Creating device 01-02 11:36:18.049 623 623 D SoftKeymaster: system/keymaster/soft_keymaster_device.cpp, Line 132: Device address: 0x7f9263e000 01-02 11:36:18.051 593 593 D DrmLibTime: registering fs service to QSEECom is done! 01-02 11:36:18.051 593 593 D DrmLibTime: begin to create a thread! 01-02 11:36:18.051 593 593 D DrmLibTime: Creating a pthread in atime_start is done! return 0 01-02 11:36:18.051 593 593 D QSEECOMD: : Init atime_start ret = 0 01-02 11:36:18.051 593 593 D QSEECOMD: : time services: Started (Listener ID = 11) 01-02 11:36:18.051 593 593 E QSEECOMD: : Listener: index = 4, hierarchy = 1 01-02 11:36:18.051 593 593 D QSEECOMD: : Init dlopen(libdrmfs.so, RTLD_NOW) succeeds 01-02 11:36:18.051 593 593 D QSEECOMD: : Init::Init dlsym(g_FSHandle fs_start) succeeds 01-02 11:36:18.051 593 593 D QSEECOMAPI: QSEECom_register_listener 10 sb_length = 0x5000 01-02 11:36:18.052 593 719 D DrmLibTime: QSEE Time Listener: dispatch 01-02 11:36:18.052 593 719 D DrmLibTime: before calling ioctl to read the next time_cmd 01-02 11:36:18.055 592 592 E wcnss_service: wcnss_service: num_modems = 1 01-02 11:36:18.055 592 592 E wcnss_qmi: wcnss_init_qmi: Initialize wcnss QMI Interface 01-02 11:36:18.056 592 592 E QMI_FW : QMUXD: WARNING qmi_qmux_if_pwr_up_init failed! rc=-6 01-02 11:36:18.061 593 593 D QSEECOMD: : Init fs_start ret = 0 01-02 11:36:18.061 593 593 D QSEECOMD: : file system services: Started (Listener ID = 10) 01-02 11:36:18.061 593 593 E QSEECOMD: : Listener: index = 5, hierarchy = 1 01-02 11:36:18.061 593 593 D QSEECOMD: : Init dlopen(libdrmfs.so, RTLD_NOW) succeeds 01-02 11:36:18.061 593 593 D QSEECOMD: : Init::Init dlsym(g_FSHandle gpfs_start) succeeds 01-02 11:36:18.061 593 593 D QSEECOMAPI: QSEECom_register_listener 28672 sb_length = 0x7e000 01-02 11:36:18.063 591 591 I ThermalEngine: Loading config file for virtual sensor 01-02 11:36:18.063 591 591 I ThermalEngine: Loading configuration file /system/etc/thermal-engine.conf 01-02 11:36:18.069 591 591 I ThermalEngine: Parsing section global 01-02 11:36:18.069 591 591 I ThermalEngine: [VIRTUAL-CPUS] 01-02 11:36:18.069 591 591 I ThermalEngine: #algo_type virtual 01-02 11:36:18.069 591 591 I ThermalEngine: trip_sensor tsens_tz_sensor9 01-02 11:36:18.069 591 591 I ThermalEngine: set_point 83000 01-02 11:36:18.069 591 591 I ThermalEngine: set_point_clr 75000 01-02 11:36:18.069 591 591 I ThermalEngine: sensors tsens_tz_sensor9 tsens_tz_sensor10 tsens_tz_sensor11 tsens_tz_sensor12 tsens_tz_sensor13 tsens_tz_sensor4 tsens_tz_sensor5 tsens_tz_sensor6 tsens_tz_sensor7 tsens_tz_sensor8 01-02 11:36:18.069 591 591 I ThermalEngine: weights 01-02 11:36:18.069 591 591 I ThermalEngine: sampling 50 01-02 11:36:18.069 591 591 I ThermalEngine: math 2 01-02 11:36:18.070 408 408 E ANDR-PERF-MPCTL: Checking boot complete 01-02 11:36:18.070 591 591 I ThermalEngine: Loading configuration file /system/etc/thermal-engine.conf 01-02 11:36:18.070 593 593 D QSEECOMD: : Init gpfs_start ret = 0 01-02 11:36:18.070 593 593 D QSEECOMD: : gpfile system services: Started (Listener ID = 28672) 01-02 11:36:18.070 591 591 I ThermalEngine: Parsing section global 01-02 11:36:18.070 593 593 E QSEECOMD: : Listener: index = 6, hierarchy = 1 01-02 11:36:18.070 591 591 I ThermalEngine: [VDD_RSTR_MONITOR-TSENS15] 01-02 11:36:18.070 591 591 I ThermalEngine: #algo_type monitor 01-02 11:36:18.070 591 591 I ThermalEngine: sampling 1000 01-02 11:36:18.070 591 591 I ThermalEngine: sensor tsens_tz_sensor15 01-02 11:36:18.071 591 591 I ThermalEngine: thresholds 110000 01-02 11:36:18.071 591 591 I ThermalEngine: thresholds_clr 105000 01-02 11:36:18.071 591 591 I ThermalEngine: actions vdd_restriction 01-02 11:36:18.071 591 591 I ThermalEngine: action_info 1 01-02 11:36:18.071 591 591 I ThermalEngine: descending 01-02 11:36:18.071 591 591 I ThermalEngine: [VDD_RSTR_MONITOR-TSENS14] 01-02 11:36:18.071 591 591 I ThermalEngine: #algo_type monitor 01-02 11:36:18.071 591 591 I ThermalEngine: sampling 1000 01-02 11:36:18.071 591 591 I ThermalEngine: sensor tsens_tz_sensor14 01-02 11:36:18.071 591 591 I ThermalEngine: thresholds 110000 01-02 11:36:18.071 591 591 I ThermalEngine: thresholds_clr 105000 01-02 11:36:18.071 591 591 I ThermalEngine: actions vdd_restriction 01-02 11:36:18.071 591 591 I ThermalEngine: action_info 1 01-02 11:36:18.071 591 591 I ThermalEngine: descending 01-02 11:36:18.071 591 591 I ThermalEngine: [VDD_RSTR_MONITOR-TSENS13] 01-02 11:36:18.071 591 591 I ThermalEngine: #algo_type monitor 01-02 11:36:18.071 591 591 I ThermalEngine: sampling 1000 01-02 11:36:18.071 591 591 I ThermalEngine: sensor tsens_tz_sensor13 01-02 11:36:18.071 591 591 I ThermalEngine: thresholds 110000 01-02 11:36:18.071 591 591 I ThermalEngine: thresholds_clr 105000 01-02 11:36:18.071 591 591 I ThermalEngine: actions vdd_restriction 01-02 11:36:18.071 591 591 I ThermalEngine: action_info 1 01-02 11:36:18.071 591 591 I ThermalEngine: descending 01-02 11:36:18.071 591 591 I ThermalEngine: [VDD_RSTR_MONITOR-TSENS12] 01-02 11:36:18.071 591 591 I ThermalEngine: #algo_type monitor 01-02 11:36:18.071 591 591 I ThermalEngine: sampling 1000 01-02 11:36:18.071 591 591 I ThermalEngine: sensor tsens_tz_sensor12 01-02 11:36:18.071 591 591 I ThermalEngine: thresholds 110000 01-02 11:36:18.071 591 591 I ThermalEngine: thresholds_clr 105000 01-02 11:36:18.071 591 591 I ThermalEngine: actions vdd_restriction 01-02 11:36:18.071 591 591 I ThermalEngine: action_info 1 01-02 11:36:18.071 591 591 I ThermalEngine: descending 01-02 11:36:18.071 591 591 I ThermalEngine: [VDD_RSTR_MONITOR-TSENS11] 01-02 11:36:18.071 591 591 I ThermalEngine: #algo_type monitor 01-02 11:36:18.071 591 591 I ThermalEngine: sampling 1000 01-02 11:36:18.071 591 591 I ThermalEngine: sensor tsens_tz_sensor11 01-02 11:36:18.071 591 591 I ThermalEngine: thresholds 110000 01-02 11:36:18.071 591 591 I ThermalEngine: thresholds_clr 105000 01-02 11:36:18.0
android 串口驱动源代码 package android.serialport; import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import android.util.Log; public class SerialPort { private static final String TAG = "SerialPort"; /* * Do not remove or rename the field mFd: it is used by native method close(); */ private FileDescriptor mFd; private FileInputStream mFileInputStream; private FileOutputStream mFileOutputStream; public SerialPort(File device, int baudrate) throws SecurityException, IOException { /* Check access permission */ if (!device.canRead() || !device.canWrite()) { try { /* Missing read/write permission, trying to chmod the file */ Process su; su = Runtime.getRuntime().exec("/system/bin/su"); /*String cmd = "chmod 777 " + device.getAbsolutePath() + "\n" + "exit\n";*/ String cmd = "chmod 777 /dev/s3c_serial0" + "\n" + "exit\n"; su.getOutputStream().write(cmd.getBytes()); if ((su.waitFor() != 0) || !device.canRead() || !device.canWrite()) { throw new SecurityException(); } } catch (Exception e) { e.printStackTrace(); throw new SecurityException(); } } mFd = open(device.getAbsolutePath(), baudrate); if (mFd == null) { Log.e(TAG, "native open returns null"); throw new IOException(); } mFileInputStream = new FileInputStream(mFd); mFileOutputStream = new FileOutputStream(mFd); } // Getters and setters public InputStream getInputStream() { return mFileInputStream; } public OutputStream getOutputStream() { return mFileOutputStream; } // JNI private native static FileDescriptor open(String path, int baudrate); public native void close(); static { System.loadLibrary("serial_port"); } }

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧