ToniKorin / cordova-plugin-autostart

This Cordova plugin will start automatically your app after the every boot or the auto-update of your application. You can enable or disable the autostart function in your app.
https://github.com/ToniKorin/cordova-plugin-autostart
Apache License 2.0
107 stars 77 forks source link

autostart not working on android 10 os #41

Open ShehanS opened 4 years ago

ShehanS commented 4 years ago

I tried to develop auto start app and it's working on android 7 well but android 10 it's not working.

ShehanS commented 4 years ago

2020-09-27 11:27:39.437 509-2022/system_process I/PackageDexOptimizer: Running dexopt (dexoptNeeded=1) on: /data/app/4u0wt5jDduYhqZRoBO3LSQ==/io.ionic.starter-trvTOysC86JM1N6blaqkPA==/base.apk pkg=io.ionic.starter isa=x86_64 dexoptFlags=boot_complete,debuggable,public,enable_hidden_api_checks targetFilter=verify oatDir=/data/app/4u0wt5jDduYhqZRoBO3LSQ==/io.ionic.starter-trvTOysC86JM1N6blaqkPA==/oat classLoaderContext=PCL[]{PCL[/system/framework/android.test.base.jar]} 2020-09-27 11:27:39.501 412-573/? V/installd: DexInv: --- BEGIN '/data/app/~~4u0wt5jDduYhqZRoBO3LSQ==/io.ionic.starter-trvTOysC86JM1N6blaqkPA==/base.apk' --- 2020-09-27 11:27:42.298 2239-2239/? I/dex2oat32: /apex/com.android.art/bin/dex2oat32 --input-vdex-fd=-1 --output-vdex-fd=9 --updatable-bcp-packages-file=/system/etc/updatable-bcp-packages.txt --resolve-startup-const-strings=true --max-image-block-size=524288 --compiler-filter=verify --debuggable --classpath-dir=/data/app/~~4u0wt5jDduYhqZRoBO3LSQ==/io.ionic.starter-trvTOysC86JM1N6blaqkPA== --class-loader-context=PCL[]{PCL[/system/framework/android.test.base.jar]} --generate-mini-debug-info --compact-dex-level=none --compilation-reason=boot 2020-09-27 11:27:52.607 412-573/? V/installd: DexInv: --- END '/data/app/~~4u0wt5jDduYhqZRoBO3LSQ==/io.ionic.starter-trvTOysC86JM1N6blaqkPA==/base.apk' (success) --- 2020-09-27 11:27:57.737 509-2022/system_process I/BackgroundDexOptService: Pinning optimized code {io.ionic.starter} 2020-09-27 11:27:57.738 509-2022/system_process D/IorapForwardingService: onPackagesUpdated: io.ionic.starter 2020-09-27 11:28:24.349 509-536/system_process I/ActivityManager: Start proc 3627:io.ionic.starter/u0a152 for broadcast {io.ionic.starter/com.tonikorin.cordova.plugin.autostart.BootCompletedReceiver} 2020-09-27 11:28:24.532 3627-3627/io.ionic.starter D/ApplicationLoaders: Returning zygote-cached class loader: /system/framework/android.test.base.jar 2020-09-27 11:28:24.592 3627-3627/io.ionic.starter D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true 2020-09-27 11:28:24.607 3627-3627/io.ionic.starter D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true 2020-09-27 11:28:24.680 509-1863/system_process I/ActivityTaskManager: START u0 {flg=0x14000000 cmp=io.ionic.starter/.MainActivity (has extras)} from uid 10152 2020-09-27 11:28:24.681 509-1863/system_process W/ActivityTaskManager: Background activity start [callingPackage: io.ionic.starter; callingUid: 10152; isCallingUidForeground: false; callingUidHasAnyVisibleWindow: false; callingUidProcState: RECEIVER; isCallingUidPersistentSystemProcess: false; realCallingUid: 10152; isRealCallingUidForeground: false; realCallingUidHasAnyVisibleWindow: false; realCallingUidProcState: RECEIVER; isRealCallingUidPersistentSystemProcess: false; originatingPendingIntent: null; isBgStartWhitelisted: false; intent: Intent { flg=0x14000000 cmp=io.ionic.starter/.MainActivity (has extras) }; callerApp: ProcessRecord{1e21a9b 3627:io.ionic.starter/u0a152}] 2020-09-27 11:28:24.798 509-535/system_process W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.USER_PRESENT flg=0x24200010 } to io.ionic.starter/com.tonikorin.cordova.plugin.autostart.UserPresentReceiver 2020-09-27 11:29:15.204 509-3455/system_process I/ActivityManager: Killing 3627:io.ionic.starter/u0a152 (adj 985): empty #17

ghost commented 3 years ago

I have the same problem. Autostrart works with android versions < 10 only

ShehanS commented 3 years ago

It's solved for me after below changes `

        <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
        <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
        <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
    </config-file>`

image

Maxime145 commented 3 years ago

Not working for me.

I am using the "cordova-plugin-autostart" plugin and the "@ ionic-native / autostart" package.

When I check the permissions it returns "true", so it can be assumed that the plugin is supposed to work.

But on android (10 and 11) nothing happens at startup or restart.

peitschie commented 2 years ago

For me, only these two permissions are necessary (Android 10 + 11)

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

Relevant notes from Android documentation:

As @ShehanS noted, the user needs to manually enable "Allow display over other apps" in the app permissions to allow this plugin to work as designed.

jmarshall-com commented 2 years ago

Thanks @ShehanS and @peitschie for their detailed answers here; they solved my problem.

I've found that the SYSTEM_ALERT_WINDOW permission is not needed-- I only needed to add RECEIVE_BOOT_COMPLETED into config.xml . This is for Android 11.

Note that the app might only auto-start a minute or more after the boot looks completed and after you unlock the screen.

tushe commented 1 year ago

UP...

coderbuzz commented 1 year ago

Already fixed in this PR but not merged yet @ToniKorin

tushe commented 1 year ago

Thanks!

coderbuzz commented 1 year ago

Merged