Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support android 12 cookies #18

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add https support for android 12
  • Loading branch information
Rasoul Miri committed Jun 9, 2023
commit d114e68fce446fd18c5484ab93610bb6a7fcab84
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ internal object CookieHandler {
this.path = path
this.domain = domain
this.maxAge = CookieHandler.getMaxAge()
this.secure = true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,17 @@ object SifoCookieManager {
}
val cookies = cookieManager.cookieStore.cookies
for (cookie in cookies) {
val cookieString = cookie.name + "=" + cookie.value + "; Domain=" + cookie.domain
Log.e("cookieString",cookieString)
android.webkit.CookieManager.getInstance().setCookie(cookie.domain, cookieString)
val cookieString =
cookie.name + "=" + cookie.value + "; Domain=" + cookie.domain + "; SameSite=None; path=/; secure; HttpOnly"
Log.e("cookieString", cookieString)

var newDomain = cookie.domain.trim()
if (newDomain.startsWith(".")) {
newDomain = newDomain.replaceFirst(".", "")
}
newDomain = "https://$newDomain"
android.webkit.CookieManager.getInstance()
.setCookie(newDomain, cookieString)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal class TSMobileAnalyticsBackend : TSMobileAnalytics {
}
val sdkVersion = BuildConfig.VERSION_NAME
val appVersion = activity.getApplicationVersion()
val cookieValue = "trackPanelistOnly=$onlyPanelist&isWebViewBased=$isWebBased&sdkVersion=$sdkVersion&appVersion=$appVersion; Samesite=None; secure; Httponly"
val cookieValue = "trackPanelistOnly=$onlyPanelist&isWebViewBased=$isWebBased&sdkVersion=$sdkVersion&appVersion=$appVersion; SameSite=None; secure; Httponly"
val metaCookie = CookieHandler.createHttpCookie(TagStringsAndValues.SIFO_META_COOKIE_NAME, cookieValue)
CookieHandler.setupPanelistCookies(listOf(metaCookie))
if (paramsAreValid(cpID, applicationName)) {
Expand Down