Fixes execServer with target API 28
Components: Framework
VK-GL-CTS Issue: 2419
Affects:
com.drawelements.deqp.execserver
Change-Id: I37aa175e4c782c1213b65be58a32c4c41aabe4b9
diff --git a/android/package/AndroidManifest.xml b/android/package/AndroidManifest.xml
index 360b21a..53b1108 100644
--- a/android/package/AndroidManifest.xml
+++ b/android/package/AndroidManifest.xml
@@ -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"
diff --git a/android/package/src/com/drawelements/deqp/execserver/ExecService.java b/android/package/src/com/drawelements/deqp/execserver/ExecService.java
index f8d040d..4f5af18 100644
--- a/android/package/src/com/drawelements/deqp/execserver/ExecService.java
+++ b/android/package/src/com/drawelements/deqp/execserver/ExecService.java
@@ -26,9 +26,13 @@
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 @@
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")