Fixes execServer with target API 28
authorMatthew Netsch <quic_mnetsch@quicinc.com>
Thu, 11 Jun 2020 22:34:39 +0000 (18:34 -0400)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Wed, 17 Jun 2020 09:02:21 +0000 (05:02 -0400)
Components: Framework
VK-GL-CTS Issue: 2419

Affects:
com.drawelements.deqp.execserver

Change-Id: I37aa175e4c782c1213b65be58a32c4c41aabe4b9

android/package/AndroidManifest.xml
android/package/src/com/drawelements/deqp/execserver/ExecService.java

index 360b21a..53b1108 100644 (file)
@@ -39,6 +39,7 @@
        <uses-permission android:name="android.permission.GET_TASKS" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.RUN_INSTRUMENTATION" />
+       <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
 
        <instrumentation android:label="dEQP-Instrumentation"
                                         android:name="com.drawelements.deqp.testercore.DeqpInstrumentation"
index f8d040d..4f5af18 100644 (file)
@@ -26,9 +26,13 @@ package com.drawelements.deqp.execserver;
 import android.app.Service;
 import android.app.Notification;
 import android.app.Notification.Builder;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
 import android.app.PendingIntent;
+import android.content.Context;
 import android.content.Intent;
 import android.os.Binder;
+import android.os.Build;
 import android.os.IBinder;
 
 import com.drawelements.deqp.execserver.ExecServerActivity;
@@ -83,7 +87,18 @@ public class ExecService extends Service {
                PendingIntent pm = PendingIntent.getActivity(this, 0, launchIntent, 0);
 
                // Start as foreground service.
-               Notification.Builder builder = new Notification.Builder(this);
+               String channel = "";
+
+               if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
+               {
+                       channel = "com.drawelements.deqp.execserver";
+
+                       NotificationChannel noteChan = new NotificationChannel(channel, "dEQP ExecServer", NotificationManager.IMPORTANCE_LOW);
+                       NotificationManager manager  = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+                       manager.createNotificationChannel(noteChan);
+               }
+
+               Notification.Builder builder = new Notification.Builder(this, channel);
                Notification notification = builder.setContentIntent(pm)
                        .setSmallIcon(R.drawable.deqp_app_small).setTicker("ExecServer is running in the background.")
                        .setWhen(System.currentTimeMillis()).setAutoCancel(true).setContentTitle("dEQP ExecServer")