From 21b2af68e526496a6ccd1697162ffdab87581c96 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 30 Aug 2023 02:21:06 +0530 Subject: [PATCH 1/5] Context.getAuthDataDump extension function --- .../foundation/e/apps/utils/Extensions.kt | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/src/main/java/foundation/e/apps/utils/Extensions.kt b/app/src/main/java/foundation/e/apps/utils/Extensions.kt index aa763f6a8..d9bba25b0 100644 --- a/app/src/main/java/foundation/e/apps/utils/Extensions.kt +++ b/app/src/main/java/foundation/e/apps/utils/Extensions.kt @@ -4,10 +4,14 @@ import android.content.Context import android.net.ConnectivityManager import android.net.NetworkCapabilities import androidx.appcompat.app.AlertDialog +import com.aurora.gplayapi.data.models.AuthData +import com.google.gson.Gson import foundation.e.apps.R +import foundation.e.apps.data.preference.DataStoreModule import java.text.SimpleDateFormat import java.util.Date import java.util.Locale +import org.json.JSONObject fun Date.getFormattedString(format: String, locale: Locale = Locale.getDefault()): String { val dateFormat = SimpleDateFormat(format, locale) @@ -42,3 +46,24 @@ fun Context.isNetworkAvailable(): Boolean { return false } + +fun Context.getAuthDataDump(): String { + val gson = Gson() + // TODO: replace with context.configuration + val authData = DataStoreModule(this, gson).getAuthDataSync().let { + gson.fromJson(it, AuthData::class.java) + } + val filteredData = JSONObject().apply { + put("email", authData.email) + put("authToken", authData.authToken) + put("gsfId", authData.gsfId) + put("locale", authData.locale) + put("tokenDispenserUrl", authData.tokenDispenserUrl) + put("deviceCheckInConsistencyToken", authData.deviceCheckInConsistencyToken) + put("deviceConfigToken", authData.deviceConfigToken) + put("dfeCookie", authData.dfeCookie) + put("isAnonymous", authData.isAnonymous) + put("deviceInfoProvider", authData.deviceInfoProvider) + } + return filteredData.toString(4) +} \ No newline at end of file -- GitLab From 558b1221b5efd9f42155be1bbc6cb0bcafded2de Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Wed, 30 Aug 2023 02:26:42 +0530 Subject: [PATCH 2/5] define receiver --- app/src/main/AndroidManifest.xml | 9 +++++++++ .../java/foundation/e/apps/data/Constants.kt | 3 +++ .../e/apps/receivers/DumpAuthData.kt | 20 +++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 app/src/main/java/foundation/e/apps/receivers/DumpAuthData.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 45284720d..8cb81d31b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -73,6 +73,15 @@ + + + + + + Date: Wed, 30 Aug 2023 02:47:50 +0530 Subject: [PATCH 3/5] add license --- .../foundation/e/apps/receivers/DumpAuthData.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/java/foundation/e/apps/receivers/DumpAuthData.kt b/app/src/main/java/foundation/e/apps/receivers/DumpAuthData.kt index 81181453c..4341f402c 100644 --- a/app/src/main/java/foundation/e/apps/receivers/DumpAuthData.kt +++ b/app/src/main/java/foundation/e/apps/receivers/DumpAuthData.kt @@ -1,3 +1,19 @@ +/* + * Copyright MURENA SAS 2023 + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package foundation.e.apps.receivers import android.content.BroadcastReceiver -- GitLab From 914fb2ca91b5e036e853b8f5244fa78b08d0dd24 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Thu, 31 Aug 2023 02:16:33 +0530 Subject: [PATCH 4/5] add the adb commands in a comment --- .../main/java/foundation/e/apps/receivers/DumpAuthData.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/foundation/e/apps/receivers/DumpAuthData.kt b/app/src/main/java/foundation/e/apps/receivers/DumpAuthData.kt index 4341f402c..601cc0cf4 100644 --- a/app/src/main/java/foundation/e/apps/receivers/DumpAuthData.kt +++ b/app/src/main/java/foundation/e/apps/receivers/DumpAuthData.kt @@ -24,6 +24,13 @@ import foundation.e.apps.data.Constants.TAG_AUTHDATA_DUMP import foundation.e.apps.utils.getAuthDataDump import timber.log.Timber +/** + * ADB commands: + * + * adb logcat -c + * adb logcat -s "AUTHDATA_DUMP" & + * adb shell am broadcast -a foundation.e.apps.action.DUMP_GACCOUNT_INFO --receiver-include-background + */ class DumpAuthData: BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent?) { if (intent?.action != ACTION_AUTHDATA_DUMP) { -- GitLab From f609eb7211c0ead53f214d1f61c12f6d99e3e301 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Thu, 31 Aug 2023 02:18:48 +0530 Subject: [PATCH 5/5] move dump method --- .../e/apps/receivers/DumpAuthData.kt | 30 +++++++++++++++++-- .../foundation/e/apps/utils/Extensions.kt | 25 ---------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/receivers/DumpAuthData.kt b/app/src/main/java/foundation/e/apps/receivers/DumpAuthData.kt index 601cc0cf4..b6c4573d1 100644 --- a/app/src/main/java/foundation/e/apps/receivers/DumpAuthData.kt +++ b/app/src/main/java/foundation/e/apps/receivers/DumpAuthData.kt @@ -19,9 +19,12 @@ package foundation.e.apps.receivers import android.content.BroadcastReceiver import android.content.Context import android.content.Intent +import com.aurora.gplayapi.data.models.AuthData +import com.google.gson.Gson import foundation.e.apps.data.Constants.ACTION_AUTHDATA_DUMP import foundation.e.apps.data.Constants.TAG_AUTHDATA_DUMP -import foundation.e.apps.utils.getAuthDataDump +import foundation.e.apps.data.preference.DataStoreModule +import org.json.JSONObject import timber.log.Timber /** @@ -33,11 +36,32 @@ import timber.log.Timber */ class DumpAuthData: BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent?) { - if (intent?.action != ACTION_AUTHDATA_DUMP) { + if (intent?.action != ACTION_AUTHDATA_DUMP || context == null) { return } - context?.getAuthDataDump().let { + getAuthDataDump(context).let { Timber.tag(TAG_AUTHDATA_DUMP).i(it) } } + + private fun getAuthDataDump(context: Context): String { + val gson = Gson() + // TODO: replace with context.configuration + val authData = DataStoreModule(context, gson).getAuthDataSync().let { + gson.fromJson(it, AuthData::class.java) + } + val filteredData = JSONObject().apply { + put("email", authData.email) + put("authToken", authData.authToken) + put("gsfId", authData.gsfId) + put("locale", authData.locale) + put("tokenDispenserUrl", authData.tokenDispenserUrl) + put("deviceCheckInConsistencyToken", authData.deviceCheckInConsistencyToken) + put("deviceConfigToken", authData.deviceConfigToken) + put("dfeCookie", authData.dfeCookie) + put("isAnonymous", authData.isAnonymous) + put("deviceInfoProvider", authData.deviceInfoProvider) + } + return filteredData.toString(4) + } } \ No newline at end of file diff --git a/app/src/main/java/foundation/e/apps/utils/Extensions.kt b/app/src/main/java/foundation/e/apps/utils/Extensions.kt index d9bba25b0..6550e88fd 100644 --- a/app/src/main/java/foundation/e/apps/utils/Extensions.kt +++ b/app/src/main/java/foundation/e/apps/utils/Extensions.kt @@ -4,14 +4,10 @@ import android.content.Context import android.net.ConnectivityManager import android.net.NetworkCapabilities import androidx.appcompat.app.AlertDialog -import com.aurora.gplayapi.data.models.AuthData -import com.google.gson.Gson import foundation.e.apps.R -import foundation.e.apps.data.preference.DataStoreModule import java.text.SimpleDateFormat import java.util.Date import java.util.Locale -import org.json.JSONObject fun Date.getFormattedString(format: String, locale: Locale = Locale.getDefault()): String { val dateFormat = SimpleDateFormat(format, locale) @@ -45,25 +41,4 @@ fun Context.isNetworkAvailable(): Boolean { } return false -} - -fun Context.getAuthDataDump(): String { - val gson = Gson() - // TODO: replace with context.configuration - val authData = DataStoreModule(this, gson).getAuthDataSync().let { - gson.fromJson(it, AuthData::class.java) - } - val filteredData = JSONObject().apply { - put("email", authData.email) - put("authToken", authData.authToken) - put("gsfId", authData.gsfId) - put("locale", authData.locale) - put("tokenDispenserUrl", authData.tokenDispenserUrl) - put("deviceCheckInConsistencyToken", authData.deviceCheckInConsistencyToken) - put("deviceConfigToken", authData.deviceConfigToken) - put("dfeCookie", authData.dfeCookie) - put("isAnonymous", authData.isAnonymous) - put("deviceInfoProvider", authData.deviceInfoProvider) - } - return filteredData.toString(4) } \ No newline at end of file -- GitLab