h-mdm / hmdm-android

Mobile Device Management (MDM) System for Android (mobile agent - launcher). Used for silent app installation and sending the info to the server. See more info on the website!
https://h-mdm.com
Apache License 2.0
183 stars 89 forks source link

Silent App Install not working properly, only installing one app then stops. #8

Open sandles opened 2 years ago

sandles commented 2 years ago

The problem seems to be related to not being able to receive the app installed succesfully Intent, caused by Error BroadcastReceiver components are not allowed to register to receive intents. This is on an Android 11 AOSP device.

2022-08-25 15:52:18.531 2093-2093/com.hmdm.launcher W/System.err: android.content.ReceiverCallNotAllowedException: BroadcastReceiver components are not allowed to register to receive intents 2022-08-25 15:52:18.531 2093-2093/com.hmdm.launcher W/System.err: at android.app.ReceiverRestrictedContext.registerReceiver(ContextImpl.java:132) 2022-08-25 15:52:18.531 2093-2093/com.hmdm.launcher W/System.err: at android.app.ReceiverRestrictedContext.registerReceiver(ContextImpl.java:121) 2022-08-25 15:52:18.531 2093-2093/com.hmdm.launcher W/System.err: at com.hmdm.launcher.helper.ConfigUpdater.registerAppInstallReceiver(ConfigUpdater.java:921) 2022-08-25 15:52:18.531 2093-2093/com.hmdm.launcher W/System.err: at com.hmdm.launcher.helper.ConfigUpdater.checkAndUpdateApplications(ConfigUpdater.java:596) 2022-08-25 15:52:18.531 2093-2093/com.hmdm.launcher W/System.err: at com.hmdm.launcher.helper.ConfigUpdater.loadAndInstallFiles(ConfigUpdater.java:575) 2022-08-25 15:52:18.532 2093-2093/com.hmdm.launcher W/System.err: at com.hmdm.launcher.helper.ConfigUpdater.access$1500(ConfigUpdater.java:55) 2022-08-25 15:52:18.532 2093-2093/com.hmdm.launcher W/System.err: at com.hmdm.launcher.helper.ConfigUpdater$8.onPostExecute(ConfigUpdater.java:442) 2022-08-25 15:52:18.532 2093-2093/com.hmdm.launcher W/System.err: at com.hmdm.launcher.helper.ConfigUpdater$8.onPostExecute(ConfigUpdater.java:431) 2022-08-25 15:52:18.532 2093-2093/com.hmdm.launcher W/System.err: at android.os.AsyncTask.finish(AsyncTask.java:771) 2022-08-25 15:52:18.532 2093-2093/com.hmdm.launcher W/System.err: at android.os.AsyncTask.access$900(AsyncTask.java:199) 2022-08-25 15:52:18.532 2093-2093/com.hmdm.launcher W/System.err: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788) 2022-08-25 15:52:18.532 2093-2093/com.hmdm.launcher W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106) 2022-08-25 15:52:18.533 2093-2093/com.hmdm.launcher W/System.err: at android.os.Looper.loop(Looper.java:223) 2022-08-25 15:52:18.533 2093-2093/com.hmdm.launcher W/System.err: at android.app.ActivityThread.main(ActivityThread.java:7656) 2022-08-25 15:52:18.533 2093-2093/com.hmdm.launcher W/System.err: at java.lang.reflect.Method.invoke(Native Method) 2022-08-25 15:52:18.534 2093-2093/com.hmdm.launcher W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 2022-08-25 15:52:18.534 2093-2093/com.hmdm.launcher W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

h-mdm commented 2 years ago

I wonder why this issue is raised on an Android 11. This issue could happen on earlier Android OS builds (up to 5) but it has been fixed in later Android versions.

Anyway, I think nothing could be done with this as this seems to be the Android OS bug. At least, Android documentation doesn't mention this restriction, and the last mention of this issue on stackoverflow is dated by 2013.

The exception is caught in the Headwind MDM code and just logged.

sandles commented 2 years ago

Okay, I am not totally sure that error is the cause of the issue. Maybe it is just logged.

I am also seeing this Exception, does this look like an issue?

2022-08-26 16:38:59.849 2158-2469/com.hmdm.launcher I/HeadwindMDM: RemoteLogWorker scheduled 2022-08-26 16:38:59.919 2158-2208/com.hmdm.launcher E/WM-WorkerWrapper: Work [ id=04b0113c-3bb8-4eef-88ce-bb3efe8a2092, tags={ com.hmdm.launcher.worker.PushNotificationWorker, com.hmdm.launcher } ] failed because it threw an exception/error java.util.concurrent.ExecutionException: java.lang.RuntimeException: Can't create handler inside thread Thread[pool-2-thread-1,5,main] that has not called Looper.prepare() at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:516) at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:475) at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:300) at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:923) Caused by: java.lang.RuntimeException: Can't create handler inside thread Thread[pool-2-thread-1,5,main] that has not called Looper.prepare() at android.os.Handler.(Handler.java:227) at android.os.Handler.(Handler.java:129) at com.hmdm.launcher.helper.ConfigUpdater.(ConfigUpdater.java:81) at com.hmdm.launcher.helper.ConfigUpdater.forceConfigUpdate(ConfigUpdater.java:107) at com.hmdm.launcher.worker.PushNotificationWorker.doMqttWork(PushNotificationWorker.java:159) at com.hmdm.launcher.worker.PushNotificationWorker.doWork(PushNotificationWorker.java:93) at androidx.work.Worker$1.run(Worker.java:85) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)  at java.lang.Thread.run(Thread.java:923) 

h-mdm commented 2 years ago

You are right, this one is something more serious. This issue will be diagnosed and fixed in further versions of Headwind MDM agent.