App USB permission

Hello! I use a DAB receiver with an app on Rpi. After each restart of the system Android asks me for permission to access the USB stick. If I have agreed, then it will not ask, until the restart of Android. The checkbox „as default“ shows no effect. The app rights are enabled in the settings. This Problem is also with other devices. Iam not an Android expert, but is there any solution for it? Thank you very much :)

Tagged:

Comments

  • At first, thank you very much for your answer! I will keep trying to get it. Emteria is a very cool system for a car PC and it will be very good if this works.☺️
  • Hi! This instruction https://stackoverflow.com/questions/13726583/bypass-android-usb-host-permission-confirmation-dialog/30563253#30563253 tells to disassemble the classes.dex file from SystemUI.apk, but Emteria's SystemUI.apk don't have classes.dex inside... Where UsbPermissionActivity can be, other than in SystemUI.apk? I took SystemUI.apk from Emteria's /system/priv-app/SystemUI/SystemUI.apk

  • Could someone please describe the full process we can use to reproduce this issue in our lab?

  • edited March 2019

    Here how I done it in Cyanogenmod 13:

    1. Connect to adb:

    $ adb connect 192.168.1.6:5555

    1. Get SystemUI.apk:

    $ adb pull /system/priv-app/SystemUI/SystemUI.apk /home/user/Desktop/test/

    1. Unzip classes.dex from SystemUI.apk:

    $ unzip /home/user/Desktop/test/SystemUI.apk classes.dex -d /home/user/Desktop/test/

    1. Download smali and backsmali: https://bitbucket.org/JesusFreke/smali/downloads/

    2. Disassemble classes.dex to smali:

    $ java -jar /home/user/Desktop/test/baksmali-2.2.6.jar disassemble /home/user/Desktop/test/classes.dex -o /home/user/Desktop/test2

    1. Edit file

    /home/user/Desktop/test2/com/android/systemui/usb/UsbPermissionActivity.smali

    with text editor and find the line that says:

    invoke-virtual {p0}, Lcom/android/systemui/usb/UsbPermissionActivity;->setupAlert()V

    change this by commenting it out and adding two new lines:

    #invoke-virtual {p0}, Lcom/android/systemui/usb/UsbPermissionActivity;->setupAlert()V

    const/4 v0, 0x1
    iput-boolean v0, p0, Lcom/android/systemui/usb/UsbPermissionActivity;->mPermissionGranted:Z
    invoke-virtual {p0}, Lcom/android/systemui/usb/UsbPermissionActivity;->finish()V

    1. Assemble everything back to classes.dex

    $ java -jar /home/user/Desktop/test/smali-2.2.6.jar assemble /home/user/Desktop/test2 -o /home/user/Desktop/classes.dex

    1. Get classes.dex back to SystemUI.apk:

    $ zip -ru /home/user/Desktop/test/SystemUI.apk /home/user/Desktop/classes.dex

    1. Send SystemUI.apk back to Android:

    $ adb push /home/user/Desktop/test/SystemUI.apk /system/priv-app/SystemUI/

    And Android permission to access the USB stick are granted forever.

    Now for doing that on Emteria:

    1. Connect to adb:

    $ adb connect 192.168.1.6:5555

    1. Get SystemUI.apk:

    $ adb pull /system/priv-app/SystemUI/SystemUI.apk /home/user/Desktop/test/

    1. Unzip classes.dex from SystemUI.apk:

    $ unzip /home/user/Desktop/test/SystemUI.apk classes.dex -d /home/user/Desktop/test/

    Archive: /home/user/Desktop/test/SystemUI.apk
    caution: filename not matched: classes.dex

    There is no classes.dex in SystemUI.apk

    If I try to disassemble whole SystemUI.apk:

    java -jar /home/user/Desktop/test/baksmali-2.2.6.jar disassemble /home/user/Desktop/test/SystemUI.apk -o /home/user/Desktop/test/

    backsmali gives me error:

    Exception in thread "main" org.jf.dexlib2.DexFileFactory$DexFileNotFoundException: Could not find entry classes.dex in /home/user/Desktop/test/SystemUI.apk.
    at org.jf.dexlib2.DexFileFactory$DexEntryFinder.findEntry(DexFileFactory.java:384)
    at org.jf.dexlib2.DexFileFactory.loadDexFile(DexFileFactory.java:89)
    at org.jf.baksmali.DexInputCommand.loadDexFile(DexInputCommand.java:149)
    at org.jf.baksmali.DisassembleCommand.run(DisassembleCommand.java:162)
    at org.jf.baksmali.Main.main(Main.java:102)

    Telling me that classes.dex is needed to disassemble SystemUI.apk and I need classes.dex to find UsbPermissionActivity.smali inside.

    Where can I find UsbPermissionActivity other than in SystemUI.apk?

  • System apps are shipped preoptimized in ODEX format in /system/priv-app/SystemUI/oat/arm/SystemUI.odex.

    We can disable this permission window globally, but first I'd need an application and an USB device to test it here.

  • I'll try to deodex SystemUI.odex. Maybe it is possible to add a new option in Emteria to a select disable/enable USB permissions globally?

  • @mr666acdc, yes maybe this would work. I'll check it.

  • I gave up deodexing and I set up app called "Automate" to automatically click "OK" button after reboot and every time SystemUI permission window appear. If someone need example I can post instruction.

  • We performed several tests and there seem to be two different solutions:

    1) We modify the OS to disable the permission dialog completely. This may introduce an important security issue, since all apps will be able to access all USB devices.

    2) The used application is made direct boot aware. This seems to be the correct approach. With this flag, our test application was saved by default and Android never asked for the permission again (after reboot or not).

Sign In or Register to comment.