diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 6f1cc41..c4d4149 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -14,7 +14,7 @@ # Uncomment this to preserve the line number information for # debugging stack traces. -# -keepattributes SourceFile,LineNumberTable,Signature +-keepattributes SourceFile,LineNumberTable,Signature -printmapping mapping.txt # Optimisations @@ -194,9 +194,7 @@ } -keepclassmembers class org.apache.commons.compress.archivers.zip.* { *; } - --keep,includedescriptorclasses class net.sqlcipher.** { *; } --keep,includedescriptorclasses interface net.sqlcipher.** { *; } +#-keep class com.fox2code.mmm.installer.InstallerInitializer { *; } # dontwarn -dontwarn android.os.SystemProperties @@ -210,4 +208,4 @@ -dontwarn rikka.core.util.ResourceUtils -dontwarn io.sentry.compose.viewhierarchy.ComposeViewHierarchyExporter -dontwarn org.commonmark.ext.gfm.strikethrough.Strikethrough --dontwarn pl.droidsonroids.gif.GifDrawable \ No newline at end of file +-dontwarn pl.droidsonroids.gif.GifDrawable diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0f7f432..e13d2bd 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -192,7 +192,7 @@ android:value="false" /> + android:value="https://e199c2a54a1f49b1b5beb3244f2c2358@sentry.androidacy.com/7" /> @@ -213,4 +213,4 @@ android:value="0.2" /> - \ No newline at end of file + diff --git a/app/src/main/kotlin/com/fox2code/mmm/androidacy/AndroidacyRepoData.kt b/app/src/main/kotlin/com/fox2code/mmm/androidacy/AndroidacyRepoData.kt index aa3b2bf..8a40624 100644 --- a/app/src/main/kotlin/com/fox2code/mmm/androidacy/AndroidacyRepoData.kt +++ b/app/src/main/kotlin/com/fox2code/mmm/androidacy/AndroidacyRepoData.kt @@ -130,12 +130,20 @@ class AndroidacyRepoData(cacheRoot: File?, testMode: Boolean) : RepoData( fun requestNewToken(): String { val deviceId = generateDeviceId() val resp = doHttpGet( - "https://" + host + "/auth/register?device_id=" + deviceId + "&client_id=" + BuildConfig.ANDROIDACY_CLIENT_ID, + "https://" + host + "/auth/register?fmt=json&device_id=" + deviceId + "&client_id=" + BuildConfig.ANDROIDACY_CLIENT_ID, false ) - // response is JSON - val jsonObject = JSONObject(String(resp)) - val token = jsonObject.getString("token") + var token: String + try { + val jsonObject = JSONObject(String(resp)) + token = jsonObject.getString("token") + } catch (e: JSONException) { + if (String(resp).count() == 64) { + token = String(resp) + } else { + return "" + } + } // Save the token to the shared preferences val editor = getSharedPreferences("androidacy")!!.edit() editor.putString("pref_androidacy_api_token", token) @@ -217,37 +225,8 @@ class AndroidacyRepoData(cacheRoot: File?, testMode: Boolean) : RepoData( Timber.i("Token is null, requesting new one...") try { Timber.i("Requesting new token...") - // POST json request to https://production-api.androidacy.com/auth/register token = requestNewToken() // Parse token - try { - val jsonObject = JSONObject(token!!) - // log last four of token, replacing the rest with asterisks - token = jsonObject.getString("token") - val tempToken = token!! - Timber.d( - "Token: %s", - tempToken.substring(0, tempToken.length - 4) - .replace(".".toRegex(), "*") + tempToken.substring( - tempToken.length - 4 - ) - ) - memberLevel = jsonObject.getString("role") - Timber.d("Member level: %s", memberLevel) - } catch (e: JSONException) { - Timber.e(e, "Failed to parse token: %s", token) - // Show a toast - val mainLooper = Looper.getMainLooper() - val handler = Handler(mainLooper) - handler.post { - Toast.makeText( - INSTANCE, - R.string.androidacy_failed_to_parse_token, - Toast.LENGTH_LONG - ).show() - } - return false - } // Ensure token is valid if (!isValidToken(token)) { Timber.e("Failed to validate token") @@ -541,4 +520,4 @@ class AndroidacyRepoData(cacheRoot: File?, testMode: Boolean) : RepoData( } } } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/com/fox2code/mmm/installer/InstallerInitializer.kt b/app/src/main/kotlin/com/fox2code/mmm/installer/InstallerInitializer.kt index 29b5f15..0a67cef 100644 --- a/app/src/main/kotlin/com/fox2code/mmm/installer/InstallerInitializer.kt +++ b/app/src/main/kotlin/com/fox2code/mmm/installer/InstallerInitializer.kt @@ -38,8 +38,8 @@ class InstallerInitializer : Shell.Initializer() { const val ERROR_NO_PATH = 1 const val ERROR_NO_SU = 2 const val ERROR_OTHER = 3 + private var tries = 0 - @JvmStatic val errorNotification: NotificationType? get() { val hasRoot = Shell.isAppGrantedRoot() @@ -56,7 +56,6 @@ class InstallerInitializer : Shell.Initializer() { return NotificationType.NO_ROOT } - @JvmStatic fun peekMagiskPath(): String? { return mgskPth } @@ -74,23 +73,18 @@ class InstallerInitializer : Shell.Initializer() { * * For read/write only "/data/adb/modules" should be used */ - @JvmStatic fun peekModulesPath(): String? { return if (mgskPth == null) null else "$mgskPth/.magisk/modules" } - @JvmStatic fun peekMagiskVersion(): Int { return mgskVerCode } - @JvmStatic fun peekHasRamdisk(): Boolean { return hsRmdsk } - @JvmStatic - @JvmOverloads fun tryGetMagiskPathAsync(callback: Callback, forceCheck: Boolean = false) { val mgskPth = mgskPth val thread: Thread = object : Thread("Magisk GetPath Thread") { @@ -135,6 +129,7 @@ class InstallerInitializer : Shell.Initializer() { var hsRmdsk = hsRmdsk if (mgskPth != null && !forceCheck) return mgskPth val output = ArrayList() + try { if (!Shell.cmd( "if grep ' / ' /proc/mounts | grep -q '/dev/root' &> /dev/null; " + "then echo true; else echo false; fi", "magisk -V", "magisk --path" @@ -168,6 +163,14 @@ class InstallerInitializer : Shell.Initializer() { } Companion.mgskVerCode = mgskVerCode return mgskPth + } catch (ignored: Exception) { + if (tries < 5) { + tries++ + return tryGetMagiskPath(true) + } else { + return null + } + } } } -} \ No newline at end of file +} diff --git a/build.gradle.kts b/build.gradle.kts index 403bc8f..927fa41 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,7 +24,7 @@ buildscript { // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files - classpath("io.sentry:sentry-android-gradle-plugin:3.7.0") + classpath("io.sentry:sentry-android-gradle-plugin:3.11.0") classpath("org.gradle.android.cache-fix:org.gradle.android.cache-fix.gradle.plugin:2.7.1") } }