Android 12 - PROVISIONING_SUCCESSFUL intent never received - android

We are migrating our Device policy app to Android 12 last API. during our test we notice that the intent PROVISIONING_SUCCESSFUL was never received so the related activity never started , instead of that ACTION_PROFILE_PROVISIONING_COMPLETE is well received in our admin receiver.
The documentation and comment in the aosp source says that :
PROVISIONING_SUCCESSFUL Action is sent to indicate that provisioning of a managed profile or managed device has completed successfully.
It'll be sent at the same time as DeviceAdminReceiver#ACTION_PROFILE_PROVISIONING_COMPLETE broadcast but this will be delivered faster as it's an activity intent.
ProvisioningSuccessActivity entry in manifest :
<activity
android:exported="true"
android:name=".ProvisioningSuccessActivity"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<intent-filter>
<action android:name="android.app.action.PROVISIONING_SUCCESSFUL"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
I'm wondering if someone encountered the same issue ? thanks

I believe Karthi Keyan is right
As is said by a contributor to the google testing app for provisioning, the famous testdpc
They migrated all entry points to provisioning to use intents
android.app.action.GET_PROVISIONING_MODE and android.app.action.ADMIN_POLICY_COMPLIANCE
https://github.com/googlesamples/android-testdpc/issues/133#issuecomment-944367382
I also need to migrate the EMM app to suit Android 12 and I will adopt this approach

From Android 12, you will need to include the new changes to support provisioning as DPC.
https://developer.android.google.cn/work/versions/android-12#deprecations
Follow the steps given here https://developers.google.com/android/work/play/emm-api/prov-devices#set_up_device_owner_mode_google_account.
Answering to the question on the reason for PROVISIONING_SUCCESSFUL never received, it is expected as per the flow. The documentation from Android is not updated to reflect the behaviour.
Please refer to the source code https://cs.android.com/android/platform/superproject/+/android-12.1.0_r8:packages/apps/ManagedProvisioning/src/com/android/managedprovisioning/finalization/ProvisioningIntentProvider.java;l=48
where we can confirm that ComplianceScreen is launched instead of ProvisioningSuccessful Screen if the setup is part of setup wizard.

Related

Cannot publish app targeting to Android 12

Getting an error on uploading an app to the Google Play store
You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter, but without the 'android:exported' property set. This file can't be installed on Android 12 or higher. See: developer.android.com/about/versions/12/behavior-changes-12#exported
All activities, activity alias, services, or broadcast receivers that have intent-filter are marked with android:exported.
The app installs to device and emulator running Android 12 without errors. Also, Android Studio doesn't report any error on merged AndroidManifest file.
Any ideas what could be wrong when there are no errors on the development environment but Google Play store still complains? How this can be resolved?
I think mentioned link in your question answers itself.
In simple words, if your app is responding to system or by other apps and if that is intended then you need set android:exported=true else false. I mean if your app activity gets opened by any other app or your app listens to other apps broadcasts or your app starts any service by other apps then this case is involved.
Doing this will resolve your issue on play store while publishing app. This assessment is done as part of behaviour changes when targeting android 12
https://developer.android.com/about/versions/12/behavior-changes-12#exported
Update : Add below tag in all your activities, services, broadcasts etc.
android:exported="false/true" based on above explanation.
E.g.
<service android:name="com.example.app.backgroundService"
android:exported="false">
<intent-filter>
<action android:name="com.example.app.START_BACKGROUND" />
</intent-filter>
</service>
Dexguard can be the cause of this issue. Add rule -keepresourcexmlattributenames manifest/** to your Dexguard/Proguard file.
The original answer found https://stackoverflow.com/a/70703375/1474153

Voice input for biking app

I am developing an Android Wear biking app. I am trying to enable the "Ok Google, Start cycling" into my app. It works perfectly if I say it to the phone, but not to my Moto360. Also in the Android Wear app, I am unable to choose my app as the default for "Start bike ride" Any suggestions?
This is what I have in my manifest, and it is based off of Google's example.
<intent-filter>
<action android:name="vnd.google.fitness.TRACK" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="vnd.google.fitness.activity/biking"/>
</intent-filter>
I searched other similar questions but didn't find a result.
Thanks for your help
Providing a Wear app is a requirement for being listed in the available apps to register for a system provided voice intent on Android Wear and appear in the Android Wear application for choosing as the default for that voice action. Per the Adding Voice Capabilities training, you attach the appropriate <intent-filter> to an activity in your Wear app. One point of note if you aren't ready to provide a full Wear app is this section of the same page:
When users speak the voice action, your app can filter for the intent that is fired to start an activity. If you want to start a service to do something in the background, show an activity as a visual cue and start the service in the activity. Make sure to call finish() when you want to get rid of the visual cue.
In your case, your activity could just display a visual cue that you are launching something (say using a ConfirmationActivity with an OPEN_ON_PHONE_ANIMATION from the Wearable UI library) and then send a message to your phone app, which would then listen for that message using a WearableListenerService and start the bike ride on the phone, posting your notification.
Note that a full Wear app with more customization is going to be expected as many apps, such as Runtastic on Android Wear add quite a few more abilities that augment the standard experience. While not out yet, an upcoming release of Android Wear will be adding offline (i.e., without a phone) GPS support for Android Wear watches that have GPS ability (currently only the not yet released Sony Smartwatch 3) and of course those abilities will require a full Android Wear experience and cannot rely on a phone app (although details have not yet been released).
You need to add a launcher intent-filter to it; then, saying "OK Google, start [app name]" will start the app. The launcher filter is:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Receive SMS to Android app without opening the app at least once

I am trying to receive SMS from my android app. I have following receiver specified in my manifest.
<receiver android:exported="true" android:name="com.lahiruchandima.myapp.SMSReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
SMSReceiver successfully receives SMS if my app is installed and opened once (app does not need to be running at the moment the SMS is received to the device). But, if i do not open my app at least once after a fresh install, it doesn't receive any SMS.
Does anybody know a way to make it possible to receive SMS without opening the app at least once?
Does anybody know a way to make it possible to receive SMS without opening the app at least once?
It can't be done, on newer Android versions at least. Ever since Android 3.1, apps are installed in a stopped state, and require that the user open it at least once before components like your BroadcastReceiver can function. This is for security reasons, to prevent, or at least hamper, malicious program behavior.

Not allowed to start service Intent without permission - sender does not get permissions

I'm working with Mark Murphy's excellent Commonsware books - but it's a lot to digest. I built the 'FakePlayer' app (pretends to be an mp3 player). It contains a service. As a learning experience I tried to write a trivial app (has only a button) whose click handler does:
Intent i = new Intent();
i.setAction("com.example.cwfakeplayer.MyPlayerService");
Context context = getApplicationContext();
context.startService(i);
It worked fine - the service start ok. I noticed Eclipse complaining about no permission on the service, so I updated the service's manifest by adding 2 lines, android:permissions and android:exported:
<service
android:name="MyPlayerService"
android:permission="com.example.fakeplayer.permission.MY_PLAYER_PERMISSION"
android:exported="true"
<intent-filter>
<action android:name="com.example.fakeplayer.MyPlayerService"></action>
</intent-filter>
</service>
I reloaded the player app onto the device (I'm using a Galaxy S2) using 'debug' under eclipse. It seemed to work; the starter app caused a permission exception, which I expected.
I then added to the starter app's manifest (to give it the permission):
<manifest
...
<uses-sdk ....
....
<uses-permission android:name="com.example.fakeplayer.permission.MY_PLAYER_PERMISSION" />
I reloaded the starter app onto the device (using debug under Eclipse). Still get the permission error in the starter app.
I removed both apps from the device and reinstalled (using debug...), service app first, then starter. Still get perm error.
I am working my way through the 'how to use a remote service' section of Mr. Murphy's Advanced Android book, so I realized this is not the best way perhaps to work across apps.
I did a 'adb shell dumpsys package', located the starter app, and found it had 'permissionsFixed=false' and no 'grantedPermissions' section. I take this to mean the manifest change in the starter app did not manage to get the perm added to the app. But I have no idea why. As a learning experience, it's generated only confusion so far....
Any clues greatly appreciated! Thanks!
I updated the service's manifest by adding 2 lines, android:permissions and android:exported
Technically, android:exported="true" is superfluous, as having the <intent-filter> automatically makes the <service> be exported.
I removed both apps from the device and reinstalled (using debug...), service app first, then starter. Still get perm error.
You do not show where you ever declare the custom permission with the <permission> element. In practice, if you control both apps, put the same <permission> element in both manifests, so the order of installation of your two apps no longer matters.
Try replace this in your manifest
<service android:name="com.example.fakeplayer.MyPlayerService"></service>
instead of
<service
android:name="MyPlayerService"
android:permission="com.example.fakeplayer.permission.MY_PLAYER_PERMISSION"
android:exported="true"
<intent-filter>
<action android:name="com.example.fakeplayer.MyPlayerService"></action>
</intent-filter>
</service>
If this doesn't work, kindly post out your error.

Interact with Android Setup Wizard

I am trying to develop a setup wizard for Android, as I would like to add some functionality to the one existing from Google. Is it possible to somehow interact with the Android wizard? Because when I have searched for information I've seen that not using Google's Wizard might cause some trouble, regarding gmail account activation and so on.
If not, could an activity be called immediately before or after Google's wizard? Would it be enough to just listen to the BOOT_COMPLETED event?
Thank you very much in advance!
I don't know how you will use this unless you are making a rom and can add your app to system but basically you make your setupwizard add-on a Home activity with action MAIN, and categories HOME,DEFAULT. You should also set the priority higher than 1. If any of this is unclear you can look at the Launcher source/manifest that is publicly available.
When your activity is done it should deactivate itself with the PackageManager (setComponentEnabledSetting) and that should be it.
You can add additional activities that start the first time the phone is boot up. You just have to mimic the same behavior as Google's SetupWizardActivity.
Here's the relevant portion in the AndroidManifest.xml for reference:
<activity android:theme="#style/InvisibleNoTitle" android:label="#string/setup_wizard_title" android:name="SetupWizardActivity" android:excludeFromRecents="true" android:launchMode="singleTop" android:immersive="true">
<intent-filter android:priority="5">
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
This will allow you to run your application before/after SetupWizardActivity, depending on your priority. I believe higher numbers for android:prioirity run first, but don't quote me on that.
You can find out the AndroidManifest xml for various Android-related apks using apktool. You can even inspect some of apks you picked up from the Play Store or whatever other sources.

Categories

Resources