diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 45284720d41036a242af49af41f0dfd0b9e50157..8cb81d31be6badb30819801e661c9a2a1b372d80 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -73,6 +73,15 @@ + + + + + + . + */ + +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.data.preference.DataStoreModule +import org.json.JSONObject +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 || context == null) { + return + } + 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 aa763f6a816a0d2f6d8d73b135c7e6a1528c247d..6550e88fdb8b523f68db355c404b4e8f18c4b7fc 100644 --- a/app/src/main/java/foundation/e/apps/utils/Extensions.kt +++ b/app/src/main/java/foundation/e/apps/utils/Extensions.kt @@ -41,4 +41,4 @@ fun Context.isNetworkAvailable(): Boolean { } return false -} +} \ No newline at end of file