CTSVerifier: Add foreground camera attribute to ITS
Foreground services that target the current Android API
need to start with 'FOREGROUND_SERVICE_TYPE_CAMERA'
and include the foreground camera type in their
respective manifest.
Bug: 155617444
Test: python tests/scene0/test_metadata.py camera=0
with screen turned off.
Change-Id: I1adb0e64579ca812cbd6ebf38d01a0e17aa40c85
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 36e7e99..ed1c4de 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -1982,7 +1982,8 @@
<meta-data android:name="android.nfc.cardemulation.host_nfcf_service" android:resource="@xml/felicaservice"/>
</service>
<!-- Service used for Camera ITS tests -->
- <service android:name=".camera.its.ItsService" >
+ <service android:name=".camera.its.ItsService"
+ android:foregroundServiceType="camera">
<intent-filter>
<action android:name="com.android.cts.verifier.camera.its.START"/>
<category android:name="android.intent.category.DEFAULT" />
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java
index e843ce7..83a6724 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java
@@ -22,6 +22,7 @@
import android.app.Service;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ServiceInfo;
import android.graphics.ImageFormat;
import android.graphics.Rect;
import android.hardware.camera2.CameraCaptureSession;
@@ -332,7 +333,8 @@
.setContentText("CameraITS Service is running")
.setSmallIcon(R.drawable.icon)
.setOngoing(true).build();
- startForeground(SERVICE_NOTIFICATION_ID, notification);
+ startForeground(SERVICE_NOTIFICATION_ID, notification,
+ ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA);
} catch (java.lang.InterruptedException e) {
Logt.e(TAG, "Error starting ItsService (interrupted)", e);
}