google cloud messaging - How configure GCM for an Android Device Policy Controller (DPC) -
i want use demo application testdpc released google create work profile own device policy controller added code app in order connect gcm service receive cloud messages start actions on device.
connect gcm used example code tested separately , works, thing added boot listener (receiverstarter) in order activate gcm listener everytime user reboot device.
strange thing when install app on device (samsung note 4 android 5.1.1 api 22) without create managed profile gcm client works properly.
if app installed create work profile , app itslef take control on new profile same code gcm doesn't work anymore. can see (using notifications) in case dpc app can register gcm , fetch gcm id , can read in console listener (mygcmlistenerservice) doesn't receive cloud messages if listener not , running, cannot see errors and/or logs in console.
maybe need more permissions?
here manifest
<?xml version="1.0" encoding="utf-8"?> <uses-permission android:name="android.permission.get_accounts" /> <uses-permission android:name="android.permission.manage_accounts" /> <uses-permission android:name="android.permission.package_usage_stats" /> <uses-permission android:name="android.permission.access_wifi_state" /> <uses-permission android:name="android.permission.change_wifi_state" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.wake_lock" /> <uses-permission android:name="android.permission.receive_boot_completed" /> <uses-permission android:name="com.google.android.c2dm.permission.receive" /> <permission android:name="com.xxx.emmagent.permission.c2d_message" android:protectionlevel="signature" /> <uses-permission android:name="com.xxx.emmagent.permission.c2d_message" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:theme="@style/apptheme" android:label="@string/app_name"> <activity android:name=".launchactivity"> <intent-filter> <action android:name="android.intent.action.main"/> <category android:name="android.intent.category.launcher"/> </intent-filter> </activity> <activity android:name=".gcm.mainactivity" android:label="@string/app_name" android:theme="@style/setuptheme"/> <activity android:name=".policymanagementactivity" android:label="@string/app_name" android:windowsoftinputmode="adjustpan"/> <activity android:name=".addaccountactivity" android:label="@string/app_name" android:theme="@style/setuptheme"/> <activity android:name=".enableprofileactivity" android:label="@string/app_name" android:theme="@style/setuptheme"/> <activity android:name=".enabledeviceowneractivity" android:label="@string/app_name" android:theme="@style/setuptheme"/> <activity android:name=".cosu.enablecosuactivity" android:label="@string/app_name" android:theme="@style/setuptheme"/> <activity android:name=".syncauth.setupsyncauthmanagement" android:label="@string/app_name" android:theme="@style/setuptheme"/> <activity android:name=".syncauth.finishsyncauthdeviceowneractivity" android:label="@string/app_name" android:theme="@style/setuptheme"/> <activity android:name=".syncauth.finishsyncauthprofileowneractivity" android:label="@string/app_name" android:theme="@style/setuptheme"/> <activity android:name=".policy.locktask.kioskmodeactivity" android:label="@string/kiosk_mode" android:launchmode="singleinstance" android:locktaskmode="if_whitelisted" android:enabled="false"> <intent-filter> <action android:name="android.intent.action.main"/> <category android:name="android.intent.category.home"/> <category android:name="android.intent.category.default"/> </intent-filter> </activity> <receiver android:name=".deviceadminreceiver" android:description="@string/app_name" android:label="@string/app_name" android:permission="android.permission.bind_device_admin"> <meta-data android:name="android.app.device_admin" android:resource="@xml/device_admin_receiver"/> <intent-filter> <action android:name="android.app.action.device_admin_enabled"/> <action android:name="android.app.action.profile_provisioning_complete"/> </intent-filter> </receiver> <provider android:authorities="com.xxx.emmagent.fileprovider" android:name="android.support.v4.content.fileprovider" android:granturipermissions="true" android:exported="false"> <meta-data android:name="android.support.file_provider_paths" android:resource="@xml/filepaths" /> </provider> <!-- gcm messagging --> <!-- [start gcm_receiver] --> <receiver android:name="com.google.android.gms.gcm.gcmreceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.send" > <intent-filter> <action android:name="com.google.android.c2dm.intent.receive" /> <category android:name="com.xxx.emmagent" /> </intent-filter> </receiver> <!-- [end gcm_receiver] --> <!-- [start gcm_listener] --> <service android:name=".gcm.mygcmlistenerservice" android:exported="true" > <intent-filter> <action android:name="com.google.android.c2dm.intent.receive" /> </intent-filter> </service> <!-- [end gcm_listener] --> <!-- [start instanceid_listener] --> <service android:name=".gcm.myinstanceidlistenerservice" android:exported="false"> <intent-filter> <action android:name="com.google.android.gms.iid.instanceid"/> </intent-filter> </service> <!-- [end instanceid_listener] --> <service android:name=".gcm.registrationintentservice" android:exported="false"> </service> <receiver android:name=".gcm.receiverstarter" android:enabled="true" android:exported="false"> <intent-filter> <action android:name="android.intent.action.boot_completed"/> </intent-filter> </receiver> </application> i don't think depends code, said same app , same code without work profile works well.
ideas?
in advance
edit: here same problem
according knowledge os avoid triggering managed profile intents personal profile (unless grant privileges). although request reserved device gcm, device unable trigger app's activities when app in managed profile.
what have keep separate unit in personal profile handles receiving gcm operations. can grant privileges intents cross share managed profile. in way can send trigger though intent app in managed profile relevant information operation. let me know if not clear.
please go through this link (ensuring compatibility managed profiles) understand enabling cross profile intents.
Comments
Post a Comment