Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuickBlox CallService Compatibility Issue on Android 14 #821

Open
AshwiniPore opened this issue Feb 8, 2024 · 4 comments
Open

QuickBlox CallService Compatibility Issue on Android 14 #821

AshwiniPore opened this issue Feb 8, 2024 · 4 comments

Comments

@AshwiniPore
Copy link

AshwiniPore commented Feb 8, 2024

We have implemented the quickblox.service.CallService in our Android application, and it works seamlessly on versions below 14. However, upon upgrading to Android 14, we encountered functionality disruptions. To address this, we made the following changes in our code and manifest:

In the manifest file:

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
    
<service
    android:name=".quickblox.service.CallService"
    android:exported="false"
    android:foregroundServiceType="mediaPlayback" />

In the service class:

public static void start(Context context) {
    Intent intent = new Intent(context, CallService.class);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        Log.d(TAG, "startForegroundService()");
        context.startForegroundService(intent);
    } else {
        Log.d(TAG, "startService()");
        context.startService(intent);
    }
}

public int onStartCommand(Intent intent, int flags, int startId) {
    if (QBChatService.getInstance().isLoggedIn()) {
        Notification notification = initNotification();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            startForeground(SERVICE_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
        } else {
            startForeground(SERVICE_ID, notification);
        }

        return super.onStartCommand(intent, flags, startId);
    }
}

Despite these changes resolving the functionality issues, our app submission to the Google Play Store was rejected with the following reason:

Issue found: Service interruption or deferment of functionality does not have material user impact.

Details: Your app is using foreground service to Media Playback - Other when it is not required to do so.

We understand that the declared use case(s) may be interrupted or deferred by the system without creating a negative user experience. We seek guidance on how to rectify this issue while ensuring compliance with Google Play Store policies.

Your prompt assistance in resolving this matter is highly appreciated, as it is currently preventing the publication of our app on the Google Play Store.

@kirillTolmachev
Copy link
Member

kirillTolmachev commented Feb 8, 2024

Hello @AshwiniPore
I don't have exact advice but I guess the problem could be in not enough value for foregroundServiceType parameter.
In a foreground service, we keep a connection with a server and interact with SDK. I mean we are using the microphone and camera as well.
Please try to change the parameters for foregroundServiceType and startForegroundService to support also camera and microphone as well.
An example of possibly using you can see in a code snippet below:
AndroidManifest file:

    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
    <uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" />

    <application>
        <service
            android:name=".quickblox.service.CallService"
            android:exported="false"
            android:foregroundServiceType="mediaPlayback|camera|microphone" />

service class:

 @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
       //some code for build notification

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            startForeground(SERVICE_ID, notification, getServiceType());
        } else {
            startForeground(SERVICE_ID, notification);
        }

        return super.onStartCommand(intent, flags, startId);
    }

    @RequiresApi(api = Build.VERSION_CODES.Q)
    private int getServiceType() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
            return ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK | ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA | ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE;
        } else {
            return ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK;
        }
    }

Hope it will help you.

@mihAdsc
Copy link

mihAdsc commented Apr 16, 2024

Hello!
We are having the same issue after migrating to android sdk 34.
Still trying to figure @kirillTolmachev's solution, for some reason the calls are not working anymore on our side (the firebase secret keys json is successfully added and sometimes a call is getting through).
More specifically, I have two test devices, Device1 - Android 13, Device 2 - Android 14. I can call from android 13 to 14 without any issues but I cannot receive a background call, through push notifications, from Android 14 to Android 13.
I'm just wondering, @AshwiniPore did you manage to find a solution for this case?
Thanks!

@QB-maksym-pidhorbunskyi

Hello @mihAdsc
Please try to follow the instructions below:

To solve this problem, remove the "mediaPlayback" type of the foreground service. Only types for the camera and microphone should remain android:foregroundServiceType="camera|microphone".
More information about foreground service types can be read in the official documentation Foreground service types are required | Android Developers .
To do this, you need to make changes in several files:

AndroidManifest.xml

    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

    <service
        android:name=".quickblox.service.CallService"
        android:exported="false"
        android:foregroundServiceType="camera|microphone" />

CallService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    //some code for build notification

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
        startForeground(SERVICE_ID, notification,  ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA | ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE);
     } else {
        startForeground(SERVICE_ID, notification);
    }

    return super.onStartCommand(intent, flags, startId);
}

In addition, should obtain runtime-permissions Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO before starting the CallService Request runtime permissions | Android Developers

Let us know if the instructions provided helped you resolve your issue.

@mihAdsc
Copy link

mihAdsc commented Apr 17, 2024

@QB-maksym-pidhorbunskyi it worked just fine! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants