From 604b025815add3666fa0a70b2114b7341cb3df3c Mon Sep 17 00:00:00 2001 From: Daniel Silhavy Date: Thu, 11 Jan 2024 14:12:54 +0100 Subject: [PATCH] Set the right content-type header for consumption reports and add handling for the different response codes of the AF --- .../MediaSessionHandlerMessengerService.kt | 8 +++++++- .../network/ConsumptionReportingApi.kt | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/fivegmag/a5gmsmediasessionhandler/MediaSessionHandlerMessengerService.kt b/app/src/main/java/com/fivegmag/a5gmsmediasessionhandler/MediaSessionHandlerMessengerService.kt index 7550696..b6905c8 100644 --- a/app/src/main/java/com/fivegmag/a5gmsmediasessionhandler/MediaSessionHandlerMessengerService.kt +++ b/app/src/main/java/com/fivegmag/a5gmsmediasessionhandler/MediaSessionHandlerMessengerService.kt @@ -570,7 +570,13 @@ class MediaSessionHandlerMessengerService() : Service() { call?.enqueue(object : retrofit2.Callback { override fun onResponse(call: Call, response: Response) { - Log.d(TAG, "Successfully send consumption report") + when(val responseCode = response.code()) { + 204 -> Log.d(TAG, "Consumption Report: Accepted") + 400 -> Log.d(TAG, "Consumption Report: Bad Request") + 415 -> Log.d(TAG, "Consumption Report: Unsupported Media Type") + else -> Log.d(TAG, "Consumption Report: Return code $responseCode") + } + } override fun onFailure(call: Call, t: Throwable) { diff --git a/app/src/main/java/com/fivegmag/a5gmsmediasessionhandler/network/ConsumptionReportingApi.kt b/app/src/main/java/com/fivegmag/a5gmsmediasessionhandler/network/ConsumptionReportingApi.kt index a0194dd..4cd6c20 100644 --- a/app/src/main/java/com/fivegmag/a5gmsmediasessionhandler/network/ConsumptionReportingApi.kt +++ b/app/src/main/java/com/fivegmag/a5gmsmediasessionhandler/network/ConsumptionReportingApi.kt @@ -12,10 +12,12 @@ package com.fivegmag.a5gmsmediasessionhandler.network import okhttp3.RequestBody import retrofit2.Call import retrofit2.http.Body +import retrofit2.http.Headers import retrofit2.http.Path import retrofit2.http.POST interface ConsumptionReportingApi { + @Headers("Content-Type: application/json") @POST("consumption-reporting/{provisioningSessionId}") fun sendConsumptionReport( @Path("provisioningSessionId") provisioningSessionId: String?,