Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development'
Browse files Browse the repository at this point in the history
  • Loading branch information
dsilhavy committed Aug 2, 2023
2 parents 8bcc50d + a4399c3 commit f2367f0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
minSdk 29
targetSdk 33
versionCode 1
versionName "1.0.0"
versionName "1.0.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -43,7 +43,7 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

// 5GMAG
implementation 'com.fivegmag:a5gmscommonlibrary:1.0.0'
implementation 'com.fivegmag:a5gmscommonlibrary:1.0.1'

// Retrofit
def retrofit_version = "2.9.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import com.fivegmag.a5gmscommonlibrary.helpers.SessionHandlerMessageTypes
import com.fivegmag.a5gmscommonlibrary.models.EntryPoint
import com.fivegmag.a5gmscommonlibrary.models.ServiceAccessInformation
import com.fivegmag.a5gmscommonlibrary.models.ServiceListEntry
import com.fivegmag.a5gmsmediasessionhandler.network.HeaderInterceptor
import com.fivegmag.a5gmsmediasessionhandler.network.ServiceAccessInformationApi
import okhttp3.OkHttpClient
import retrofit2.Call
import retrofit2.Response
import retrofit2.Retrofit
Expand Down Expand Up @@ -60,6 +62,7 @@ class MediaSessionHandlerMessengerService() : Service() {
SessionHandlerMessageTypes.START_PLAYBACK_BY_SERVICE_LIST_ENTRY_MESSAGE -> handleStartPlaybackByServiceListEntryMessage(
msg
)

SessionHandlerMessageTypes.SET_M5_ENDPOINT -> setM5Endpoint(msg)
else -> super.handleMessage(msg)
}
Expand Down Expand Up @@ -108,7 +111,7 @@ class MediaSessionHandlerMessengerService() : Service() {
null,
SessionHandlerMessageTypes.SESSION_HANDLER_TRIGGERS_PLAYBACK
)
var finalEntryPoints : ArrayList<EntryPoint>? = serviceListEntry.entryPoints
var finalEntryPoints: ArrayList<EntryPoint>? = serviceListEntry.entryPoints
if (finalEntryPoints == null || finalEntryPoints.size == 0) {
finalEntryPoints =
currentServiceAccessInformation.streamingAccess.entryPoints
Expand Down Expand Up @@ -149,7 +152,14 @@ class MediaSessionHandlerMessengerService() : Service() {
}

private fun initializeRetrofitForServiceAccessInformation(url: String) {
val headerInterceptor = HeaderInterceptor()
val okHttpClient = OkHttpClient()
.newBuilder()
.addInterceptor(headerInterceptor)
.build()

val retrofitServiceAccessInformation: Retrofit = Retrofit.Builder()
.client(okHttpClient)
.baseUrl(url)
.addConverterFactory(GsonConverterFactory.create())
.build()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.fivegmag.a5gmsmediasessionhandler.network

import com.fivegmag.a5gmscommonlibrary.helpers.UserAgentTokens
import okhttp3.Interceptor
import okhttp3.Response

class HeaderInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response = chain.run {
proceed(
request()
.newBuilder()
.removeHeader("User-Agent")
.addHeader("User-Agent", "${UserAgentTokens.FIVE_G_MS_REL_17_MEDIA_SESSION_HANDLER} ${okhttp3.internal.Version.userAgent()}")
.build()
)
}
}

0 comments on commit f2367f0

Please sign in to comment.