-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide X-Device-Id in headers; fix update controller
- Loading branch information
Showing
6 changed files
with
66 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/tomclaw/appsend/core/DeviceIdInterceptor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.tomclaw.appsend.core | ||
|
||
import okhttp3.Interceptor | ||
import okhttp3.Response | ||
import java.io.IOException | ||
|
||
class DeviceIdInterceptor(private val deviceId: String) : Interceptor { | ||
|
||
@Throws(IOException::class) | ||
override fun intercept(chain: Interceptor.Chain): Response { | ||
return chain.proceed( | ||
chain.request().newBuilder() | ||
.header("X-Device-ID", deviceId) | ||
.build() | ||
) | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/tomclaw/appsend/core/DeviceIdProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.tomclaw.appsend.core | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Context | ||
import android.provider.Settings | ||
import android.provider.Settings.Secure.ANDROID_ID | ||
|
||
interface DeviceIdProvider { | ||
|
||
fun getDeviceId(): String | ||
|
||
} | ||
|
||
class DeviceIdProviderImpl( | ||
private val context: Context | ||
) : DeviceIdProvider { | ||
|
||
@SuppressLint("HardwareIds") | ||
override fun getDeviceId(): String { | ||
return Settings.Secure.getString(context.contentResolver, ANDROID_ID) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters