设备重新启动或USB弹射后,每次绕过或防止USB读取许可

发布于 2025-02-08 14:44:14 字数 2452 浏览 1 评论 0原文

我正在为Android TV制作GPS跟踪器,并使用U-Box 7 GPS接收器从串行端口读取GPS数据。设备设置为关闭时间表时间,每个重新启动后,我的应用程序在连接时要求GPS接收器读取USB读取许可。 有什么办法绕过它,

我正在使用flutter和usb_serial包,因为

我的清单看起来像:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.geolocator">
    <uses-feature android:name="android.hardware.usb.host" />
    <uses-permission android:name="android.permission.INTERNET" />
   

   <application
        android:label="geolocator"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize"
            android:directBootAware="true">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
             
              android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
            android:resource="@xml/device_filter"
              />
            <intent-filter>
                <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"/>
                <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
                <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

I am making a GPS tracker for android tv and I am reading gps data from a serial port using U-box 7 GPS receiver. the device is set to turn off on the schedule time and after each restart, my app asks for USB read permission of GPS receiver when connected.
is there any way to bypass it

I am using flutter and usb_serial package for it

My manifest looks like :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.geolocator">
    <uses-feature android:name="android.hardware.usb.host" />
    <uses-permission android:name="android.permission.INTERNET" />
   

   <application
        android:label="geolocator"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize"
            android:directBootAware="true">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
             
              android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
            android:resource="@xml/device_filter"
              />
            <intent-filter>
                <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"/>
                <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
                <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟凡古楼 2025-02-15 14:44:14

首先,您需要查找设备的Vender_ID和product_id,然后在device.xml中指定它,并在清单中提及

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- 0x0403 / 0x6001: FTDI FT232R UART -->
    <usb-device vendor-id="1027" product-id="24577" />

    <usb-device vendor-id="5446" product-id="423" />
    <usb-device vendor-id="3690" product-id="290" />
    
    <!-- 0x0403 / 0x6015: FTDI FT231X -->
  
</resources>

First you need to find vender_id and product_id of device and specify it in device.xml and mention in manifest

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- 0x0403 / 0x6001: FTDI FT232R UART -->
    <usb-device vendor-id="1027" product-id="24577" />

    <usb-device vendor-id="5446" product-id="423" />
    <usb-device vendor-id="3690" product-id="290" />
    
    <!-- 0x0403 / 0x6015: FTDI FT231X -->
  
</resources>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文