cdmf-agent-android
cdmf-agent-android copied to clipboard
Agent crashes when in COSU mode and when system service is used
Here is the crash:
08-02 14:59:49.928 26936-26936/org.wso2.iot.agent E/AgentApplication: UncaughtExceptionHandler got an exception
java.lang.RuntimeException: Unable to start receiver org.wso2.iot.agent.events.listeners.KioskAppInstallationListener: java.lang.SecurityException: No active admin ComponentInfo{org.wso2.iot.agent/org.wso2.iot.agent.services.AgentDeviceAdminReceiver}
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2616)
at android.app.ActivityThread.access$1700(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5258)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.SecurityException: No active admin ComponentInfo{org.wso2.iot.agent/org.wso2.iot.agent.services.AgentDeviceAdminReceiver}
at android.os.Parcel.readException(Parcel.java:1546)
at android.os.Parcel.readException(Parcel.java:1499)
at android.app.admin.IDevicePolicyManager$Stub$Proxy.setLockTaskPackages(IDevicePolicyManager.java:4212)
at android.app.admin.DevicePolicyManager.setLockTaskPackages(DevicePolicyManager.java:3304)
at org.wso2.iot.agent.events.listeners.KioskAppInstallationListener.onReceive(KioskAppInstallationListener.java:102)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2609)
at android.app.ActivityThread.access$1700(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5258)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
I've noticed that there were no prompts to active device administration for the agent. The system service has been installed as a system application (/system/priv-app). Hope this helps.
I'm testing this on Android 5.1.
There is another crash:
08-02 17:15:27.757 21699-21699/org.wso2.iot.agent E/AgentApplication: UncaughtExceptionHandler got an exception
java.lang.RuntimeException: Unable to start receiver org.wso2.iot.agent.events.listeners.KioskAppInstallationListener: java.lang.SecurityException: Admin ComponentInfo{org.wso2.iot.agent/org.wso2.iot.agent.services.AgentDeviceAdminReceiver} does not own the device
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2616)
at android.app.ActivityThread.access$1700(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5258)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.SecurityException: Admin ComponentInfo{org.wso2.iot.agent/org.wso2.iot.agent.services.AgentDeviceAdminReceiver} does not own the device
at android.os.Parcel.readException(Parcel.java:1546)
at android.os.Parcel.readException(Parcel.java:1499)
at android.app.admin.IDevicePolicyManager$Stub$Proxy.setLockTaskPackages(IDevicePolicyManager.java:4212)
at android.app.admin.DevicePolicyManager.setLockTaskPackages(DevicePolicyManager.java:3304)
at org.wso2.iot.agent.events.listeners.KioskAppInstallationListener.onReceive(KioskAppInstallationListener.java:102)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2609)
at android.app.ActivityThread.access$1700(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5258)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
This time agent is set to be device adminstrator. However, it is not set to be device owner as the system service is set to be device owner. There cannot be two device owners.
There is another crash:
08-02 18:41:09.770 16815-16815/org.wso2.iot.agent E/AgentApplication: UncaughtExceptionHandler got an exception
java.lang.RuntimeException: Unable to start receiver org.wso2.iot.agent.events.listeners.KioskAppInstallationListener: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toString()' on a null object reference
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2616)
at android.app.ActivityThread.access$1700(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5258)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toString()' on a null object reference
at org.wso2.iot.agent.events.listeners.KioskAppInstallationListener.addIfPermissionEnforcementExist(KioskAppInstallationListener.java:118)
at org.wso2.iot.agent.events.listeners.KioskAppInstallationListener.onReceive(KioskAppInstallationListener.java:104)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2609)
at android.app.ActivityThread.access$1700(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5258)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
This time, agent is set to be the device owner.
Hi nemanjanedic,
You do not want to use system service with the agent in the COSU mode. Once you build the agent with COSU mode there is no need of a system app. Agent acts as the device owner in COSU mode.
Thanks for the clarifications. For some things like silent app install and update system service is still needed for Android versions before 6. Is this correct?
Hi nemanjanedic, Yes. For the earlier Android versions where the Device-owner concept doesn't supports, you have to go with 'generic agent' plug 'system-app' collaboration to fulfill COPE level features like silent app installation.