airsdk / Adobe-Runtime-Support

Report, track and discuss issues in Adobe AIR. Monitored by Adobe - and HARMAN - and maintained by the AIR community.
199 stars 11 forks source link

About FOREGROUND_SERVICE #3273

Open yvant opened 2 months ago

yvant commented 2 months ago

Recent updates within the AIR ecosystem now require that we upgrade the targetSDKVersion to 34. Apparently, it comes with using android.permission.FOREGROUND_SERVICE, which wasn't require before.

With this new requirement, Google Play asks for a video and a description on how the app uses that requirement. Since I didn't know how to answer, I just said that it was a requirement because of the SDK upgrade + added a regular video of my game. The app update was rejected, here's an excerpt of the mail rejection:

Issue found: Play Console declaration and/or app description in Google Play Store does not sufficiently demonstrate the use of permission.
We are unable to approve your app’s use of [FOREGROUND_SERVICE] permission because we found the following information provided to be insufficient in evaluating compliance with [foreground service permission requirements]:
The video link you provided in the Play Console declaration and/or
The app description in the Google Play store.

What can I do to make it pass Google Play review? Is there a way to remove the FOREGROUND_SERVICE permission?

ajwfrost commented 2 months ago

That FOREGROUND_SERVICE permission isn't required (or included) by just the AIR runtimes; but we have come across it when using the Play Asset Delivery functionality. It was required in the manifest file and is probably added for you if using APM. There may be other ANEs that could be using this, so the first step may be to find out where this is coming from..

Re the use from Play Asset Delivery .. I can't actually see the documentation now that specifies that this was required, so let me check with the developer who'd put this together to find out the reason for its inclusion and whether it may be excluded now. But if it is still a requirement, then Google/Android should accept that this is required for using Play Asset Delivery and installing the asset packs etc.

thanks

yvant commented 2 months ago

Thanks for the quick answer. Indeed, I am not sure what requires that. I'll be waiting for your feedback!

marchbold commented 2 months ago

What extensions are you using?

It is required by the android play core lib "to launch foreground extraction service for targetSdkVersion 28+" (ExtractionForegroundService) which is related to the PlayAssetDelivery extension.

We also have a few extensions that use it for other purposes.

yvant commented 2 months ago

I'm using these libraries: ├──com.distriqt.Adverts@15.1.0 ├──com.distriqt.Application@7.1.0 ├──com.distriqt.ApplicationRater@6.4.2 ├──com.distriqt.facebook.Core@17.0.0 ├──com.distriqt.Firebase@9.0.1 ├──com.distriqt.firebase.Crashlytics@9.0.1 ├──com.distriqt.GameServices@8.4.3 ├──com.distriqt.IDFA@5.2.0 ├──com.distriqt.InAppBilling@15.4.0 ├──com.distriqt.Notifications@6.7.0 ├──com.distriqt.PackageManager@3.4.1 ├──com.distriqt.playservices.Licensing@1.0.85 └──com.distriqt.Share@7.6.0

If I have to use it, what kind of message can I send to Google Play? What about the video?

Here's the screenshot they want me to fill. image

yvant commented 2 months ago

Any news on that matter?

marchbold commented 2 months ago

The FOREGROUND_SERVICE/FOREGROUND_SERVICE_DATA_SYNC permissions should fall in the local importing / exporting category I believe for extracting resources.

yvant commented 2 months ago

How can I present that information to Google so they validate the build? As you can see on the screenshot, they need a video and a description to validate the addition of that permission.

ajwfrost commented 2 months ago

FYI we've been looking at the Play Asset Delivery requirements, a lot of that has been updated and their documentation doesn't now talk about that permission.. although, it does still seem that it only works if we do have the ExtractionForegroundService service defined in the manifest. But even with this service, and omitting the FOREGROUND_SERVICE permission, the application does manage to download/extract the asset packs when tested with the Play console 'internal app testing' approach..

So it might be you could omit that permission too? Worth just testing everything carefully (and on different versions of Android -> we're just starting to do this part too) to ensure it doesn't cause problems on particular older or newer devices. Would be nice if the Android documentation was clearer on all this :-(

thanks

yvant commented 2 months ago

What lines should I try to remove from the manifest? I have several lines mentionning "foreground":

1 - <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
2 - <!-- Is required to launch foreground extraction service for targetSdkVersion 34+. -->
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
3 - <service android:name="androidx.work.impl.foreground.SystemForegroundService" android:directBootAware="false" android:enabled="@bool/enable_system_foreground_service_default" android:exported="false"/>
4 - <service android:name="com.google.android.play.core.assetpacks.ExtractionForegroundService" android:enabled="false" android:exported="false" android:foregroundServiceType="dataSync"/>
marchbold commented 2 months ago

I would just try removing the permissions if you don't plan to use the functionality.

yvant commented 2 months ago

Just to be sure I understand well: I should try removing 1 & 2, right? Another question: what ANEs or features use those permissions? I've seen your message regarding local importing / exporting resources but I didn't really understand it.

yvant commented 2 months ago

I'll try to push a new version by removing 1 & 2. 1 - Should I expect some new ANR from these changes? 2 - Would it deactivate some functionalities these are related to? I am still having a hard time trying to figure out what these refer to.

bobaoapae commented 1 month ago

@ajwfrost When using just install-time assets packets you can ommit implementation of play-asset-delivery library on the ANE and also the service permissions. If you plan to use fast-follow | on-demand you will need to request aproval of google using the form submition when targeting android 14+

https://developer.android.com/about/versions/14/changes/fgs-types-required?hl=pt-br

ajwfrost commented 1 month ago

Hi @bobaoapae - thanks for that; the link is about Foreground Services which we'd already reviewed, but we've not actually been able to find the details on what requirements there are with the different play asset delivery types. Do you have any reference for that i.e. something that says you don't need the play asset delivery library or service permissions if just using install-time? And it seems crazy that you would need to request Google's permission just to use their own play asset delivery functionality for fast-follow/on-demand..?!

thanks

bobaoapae commented 1 month ago

Hi @bobaoapae - thanks for that; the link is about Foreground Services which we'd already reviewed, but we've not actually been able to find the details on what requirements there are with the different play asset delivery types. Do you have any reference for that i.e. something that says you don't need the play asset delivery library or service permissions if just using install-time? And it seems crazy that you would need to request Google's permission just to use their own play asset delivery functionality for fast-follow/on-demand..?!

thanks

If you check play asset delivery notification you will see that to use install time assets you just need the plug-in and configure assets folders on grade. And on the next section it's show the need of de library to use on demand and fast follow

Check here: https://developer.android.com/guide/playcore/asset-delivery/integrate-java

Now about the permissions, when you add dependency to the play asset delivery this automatically add the request for permission of foreground service etc, and those permission now on Android 14+ will need the form submission questing approval.

I agree that this is not ideal, and also not very documented. But for use of play asset delivery library each user will need to use the form validation provided by Google.

To Harman the unique alternative it's to just handle that to don't implement the library of using install time assets. Here I'm using my own ane to handle that, I use the assets resource on the application descriptor but I use my own ane to get those files, avoiding for complete the use of the play asset delivery and everything works like a charm without need of the form approval

bobaoapae commented 1 month ago
public static class MyAneExtensionNativeLoaderFunction implements FREFunction {
        @Override
        public FREObject call(FREContext freContext, FREObject[] freObjects) {
            try {
                try (InputStream inputStream = context.getAssetManager().open(freObjects[1].getAsString())) {
                    Log.d(TAG, "loadNative: " + freObjects[1].getAsString() + " " + inputStream.available());
                    FREByteArray freByteArray = FREByteArray.newByteArray(inputStream.available());
                    freByteArray.acquire();
                    ByteBuffer buffer = freByteArray.getBytes();
                    byte[] bufferRead = new byte[1024];
                    int bytesRead;
                    while ((bytesRead = inputStream.read(bufferRead)) != -1) {
                        buffer.put(bufferRead, 0, bytesRead);
                    }
                    freByteArray.release();
                    return freByteArray;
                } catch (FileNotFoundException e) {
                    //if file not found just return null
                    Log.d(TAG, "File not found: ", e);
                    return null;
                }
            } catch (Exception e) {
                Log.e(TAG, "Error: ", e);
            }

            return null;
        }
    }

I use that code on my ANE to open assets packed using install-time, without any dependency

Shaunmax commented 1 month ago

I'll try to push a new version by removing 1 & 2.

@yvant were you able to push a new build ?

believe for extracting resources. @marchbold I am using Zip ane, do they need this permission ?

yvant commented 1 month ago

Yes, I was able to push the new build without said requirements. I can see some new ANR, but nothing critical: globally, my ANRs are a bit lower now.

Shaunmax commented 1 month ago

FOREGROUND_SERVICE_DATA_SYNC

so remove these two lines ?

  <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
yvant commented 1 month ago

This one is not a problem for Google Play and is required for notifications I think. <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>

Just remove the other one.