Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to grant access to USB port through AndroidManifest #84

Open
bastienBCN31 opened this issue Nov 22, 2019 · 3 comments
Open

Comments

@bastienBCN31
Copy link

The execution of arduino-Firmata samples, slightly modifies to adapt to android-serial lib constraints (use of Serial.list(this) instead of Arduino.list()), leads to a crash and the closure of the activity if an Arduino with standardfirmata is connected to the USB

if nothing is connected you get a warning asking to check

  • if something is plugged
  • if a use-feature tag pointing at USB.HOST was inserted in the android manifest

This seems to be possible to correct through the insertion, in the Manifest, of the "use-feature" tag mentioned above and pointing at USB.HOST port. Unfortunately, this is not possible with APDE since the manifest is re-generated from the sketch properties at build time
Tested (KO) on

  • Android 5.1 /APDE 0.51
  • Android 6/APDE 0.51
    Is there a known workaround?
@uheinema
Copy link

Maybe..but not for the feeble minded.

@Calsign:
Is there an official/better way?
Kept me from testing 5.2 up to now.

I wanted/needed to activate largeHeap, and ended up hacking APDE using

  • APK Editor
  • APK Extractor
    to modify /assets/templates/AppManifest.xml.tmpl
    ... seemed to work.
    Forgot the details, and hacked around a bit,
    see below.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package=""
          android:versionCode="1"
          android:versionName="1.0">              
    <uses-sdk android:minSdkVersion="@@min_sdk@@" android:targetSdkVersion="@@target_sdk@@" />
    <application android:label=""
             android:largeHeap="true"
                 android:icon="@drawable/icon">
        <activity android:name=".MainActivity"
                  android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity> 
    </application>
</manifest>

My sketch.properties for this app, is below btw...but that may be relicts from unsuccessful attempts.

#Sat May 23 00:01:04 GMT+02:00 2020
android.largeHeap="true"
manifest.orientation=portrait
manifest.permissions=android.permission.INTERNET,android.permission.READ_EXTERNAL_STORAGE,android.permission.WRITE_EXTERNAL_STORAGE,
manifest.android=largeHeap

@Calsign
Copy link
Owner

Calsign commented May 24, 2020

So APDE used to allow you to customize the manifest directly. I changed that behavior in v0.4.0 (the introduction of multiple build targets) because each target requires a different manifest and it was unclear how to support manifest customizations. Instead the manifest is re-generated from the sketch.properties file on every build, and only a small subset of possible customizations are supported (android.largeHeap is not one of them). It seems that that change was a mistake.

@uheinema Yes technically you can achieve what you want by modifying the manifest template, but this isn't really a solution for most users because it means that every sketch built with the modified version of APDE will have the uses-feature tag.

I've thought a bit about this and I am planning to implement the following solution:

  • By default the manifest is re-generated on every build, as it is now
  • There is a "custom manifest" toggle option for each sketch, saved in sketch.properties
  • When "custom manifest" is selected, a new manifest is not generated on each build. Instead, APDE looks for a manifest in the sketch folder based on the build target
  • AndroidManifest.app.xml for app, AndroidManifest.wallpaper.xml, etc.
  • There is an option to generate these four manifest files based on the current sketch properties configuration
  • So the workflow for customizing the manifest will look like enabling "custom manifest", generating the manifest files, and then editing the custom manifest(s) in an external editor

Any suggestions or improvements to this plan are welcome, otherwise I will probably make it happen in the next week or so and try to include in the the v0.5.2 release.

@uheinema
Copy link

Grrr. the BackButtan ate my text...

So short:

Brilliant.

But isn't this a lot of work on your side for relatively little effect?

How about (optionaly, see 'Build on internal/external') putting the templates (all! And why not the whole assets folder...makes 'Reimport Android.jar' etc. superflous, and would allow access to the whole android XMLism, MainActivity, etc....I hate the stuff, but it is needed sometimes) on external storage?

Templates could then be searched (in order of precedence)

  • in the sketch folder
  • on external storage
  • internaly

And I think they could/should remain templates.

Keep it up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants