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

added support for include xml elements inside <manifest><application> AndroidManifest.xml #2691

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

dvjdjvu
Copy link

@dvjdjvu dvjdjvu commented Oct 21, 2022

My changes affect builddozer and python-for-kivy.

I added support for add rules for autostart. Now you can use section in buildozer.spec:

android.extra_manifest_application = %(source.dir)s/xml/receivers.xml

1 updated android.extra_manifest_application to android.extra_manifest_application_entry (see below)
2 updated android.extra_manifest_application_entry to android.extra_manifest_application_xml (see below)

for add rules in AndroidManifest.xml for autostart:

<receiver android:name=".MyBroadcastReceiver" android:enabled="true" android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        <action android:name="android.intent.action.QUICKBOOT_POWERON" />
        <action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
    </intent-filter>
</receiver>

This is article doesn't work Starting Kivy App and Service on bootup on Android

Copy link

@lufebe16 lufebe16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks o.k. but ...
There is no appropriate entry in tests/test_build.py. Does it really work?

@lufebe16
Copy link

Went from a deeper test of these changes.

Related changes in buildozer work correctly. But in python-for-android (here) a problem exists with the name of the entry. It was surprising to see, that the new entry was accepted by p4a even before any adaptations have been done.

After application of the proposed changes to p4a nothing changed. The new entry was accepted, but ignored.

The problem seems to be the name. Because its a substring of another option. This might be a bug somwhere in p4a or maybe in the argument parsing library used.

After replaceing 'extra-manifest-application' to 'extra-manifest-application-entry' all over buildozer and p4a the change will work.

@dvjdjvu
Copy link
Author

dvjdjvu commented Dec 14, 2022

The problem seems to be the name. Because its a substring of another option. This might be a bug somwhere in p4a or maybe in the argument parsing library used.

Yes, when I did test project (article, git), I got this problem, but when I do this decide local, everything work.

After replaceing 'extra-manifest-application' to 'extra-manifest-application-entry' all over buildozer and p4a the change will work.

I think this way true. I will change code.

@dvjdjvu
Copy link
Author

dvjdjvu commented Dec 14, 2022

I did it. Updated to "extra-manifest-application-entry".

lufebe16
lufebe16 previously approved these changes Dec 14, 2022
Copy link

@lufebe16 lufebe16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requested changes have been applied. So this will be o.k.

@Duke0425
Copy link

May I ask when these changes will be merged, I also encountered these problems. My project needs to reset the buildozer package every time, which makes it troublesome for me to modify its source code

@dvjdjvu
Copy link
Author

dvjdjvu commented Jan 19, 2023

image
I don't know. Somebody who have accesses must approve merge pull request.

@Duke0425
Copy link

Duke0425 commented Feb 2, 2023

image I don't know. Somebody who have accesses must approve merge pull request.

@tshirtman @matham If the modification is correct, can it be merged into? Please click approve, I am still modifying the library code during development, which makes me a headache

js-teevee
js-teevee previously approved these changes Feb 13, 2023
@js-teevee
Copy link

can we get an update on this please? these changes will allow for starting on boot and restarting when reinstalled etc. the java/android hooks are necessary. this will take kivy/python-for-android to the next level and allow python apps/services to better hook into android.

Copy link
Member

@misl6 misl6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI @dvjdjvu !

I'm sorry for the late reply. I've left some comments.

Feel free to ping me when you're ready for a review.

@@ -851,6 +851,9 @@ def parse_args_and_make_package(args=None):
ap.add_argument('--extra-manifest-xml', default='',
help=('Extra xml to write directly inside the <manifest> element of'
'AndroidManifest.xml'))
ap.add_argument('--extra-manifest-application-entry', default='',
Copy link
Member

@misl6 misl6 Feb 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename --extra-manifest-application-entry to --extra-manifest-application-xml, since it adds some extra XML into <manifest><application>?

Copy link
Author

@dvjdjvu dvjdjvu Feb 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can.

@@ -63,6 +63,9 @@
android:theme="{{args.android_apptheme}}{% if not args.window %}.Fullscreen{% endif %}"
android:hardwareAccelerated="true"
android:extractNativeLibs="true" >

{{ args.extra_manifest_application_entry }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add this snippet to all the supported bootstraps.

Copy link
Author

@dvjdjvu dvjdjvu Feb 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In service_library, service_only and webview not need.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dvjdjvu please do not resolve conversations, unless it's quite clear that are resolved.

Why this is not needed on webview, service_library and service_only ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know what these things were for, now I have studied a little. I think you are right, it should be added.

@dvjdjvu dvjdjvu dismissed stale reviews from js-teevee and lufebe16 via f5f6e7c February 15, 2023 16:54
@dvjdjvu
Copy link
Author

dvjdjvu commented Feb 16, 2023

Hi @misl6. I did the review.

@dvjdjvu
Copy link
Author

dvjdjvu commented Feb 16, 2023

And I added choice type start service START_STICKY, START_NOT_STICKY and START_REDELIVER_INTENT.
Default use now and before START_NOT_STICKY, but when you close app, service close too.

And I used this code for restart service.

PythonService = autoclass('org.kivy.android.PythonService')
PythonService.mService.setAutoRestartService(True)

Now you can use

PythonService.mService.setTypeStartSticky()
PythonService.mService.setTypeStartNotSticky()
PythonService.mService.setTypeStartRedeliverIntent()

With setTypeStartNotSticky, service doesnt close when app swipping or close.

@misl6
Copy link
Member

misl6 commented Feb 16, 2023

@dvjdjvu
Can we keep the additions (START_STICKY/START_NOT_STICKY/START_REDELIVER_INTENT) into a different PR?

Feel free to ping me when you're ready with the review!

@dvjdjvu
Copy link
Author

dvjdjvu commented Feb 17, 2023

Ok @misl6. You can merge this pull request and close it. I won't do anything else here. I removed the changes START_STICKY from here. We need to close this section.

I will open new pull request for START_STICKY/START_NOT_STICKY/START_REDELIVER_INTENT.

Copy link
Member

@misl6 misl6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left a comment requesting more info, as I think this feature should also be added to other bootstraps, and not only sdl2.

Also, please add your feature to the python-for-android documentation: https://github.com/kivy/python-for-android/tree/develop/doc/source

@dvjdjvu
Copy link
Author

dvjdjvu commented Feb 20, 2023

Hi @misl6, I did everythings. I hope.

@dvjdjvu
Copy link
Author

dvjdjvu commented May 11, 2023

Hello @misl6, you did update? Please do it.
(I updated my project, and all edits are gone :(( )

@CristianPi
Copy link

any news? this is blocking

@dvjdjvu
Copy link
Author

dvjdjvu commented Sep 25, 2023

@misl6 @lufebe16 @js-teevee, I updated the PR to the latest versions of the source code.

@kwuite
Copy link

kwuite commented Oct 1, 2023

@dvjdjvu I found your article today while learning Kivy and researching how to build a service that can keep running when the app closes or the phone is restarted. Thanks for the work you put out there!

I was able to build and deploy your code to my docker-android container and pushed my logic to a fork from kivy_service_test. Hopefully this can help people to use your logic untill they merge it.

If you want I can do a PR to your repo. Here is my fork that can help out by installing your python-for-android and buildozer fork via git with poetry:

@colebrooks
Copy link

So is this completely dead? I just ran into the need to register a receiver in the manifest, and manually editing the template doesn't feel like a very robust or portable solution. Given the other facilities in buildozer to mutate the generated manifest, I'm surprised this functionality hasn't been merged yet/wasn't just included from the beginning.

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

Successfully merging this pull request may close these issues.

None yet

8 participants