work around root issue

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/89/head
androidacy-user 2 years ago
parent 4e0a6204ad
commit 1484195854

@ -14,7 +14,7 @@
# Uncomment this to preserve the line number information for # Uncomment this to preserve the line number information for
# debugging stack traces. # debugging stack traces.
# -keepattributes SourceFile,LineNumberTable,Signature -keepattributes SourceFile,LineNumberTable,Signature
-printmapping mapping.txt -printmapping mapping.txt
# Optimisations # Optimisations
@ -194,9 +194,7 @@
} }
-keepclassmembers class org.apache.commons.compress.archivers.zip.* { *; } -keepclassmembers class org.apache.commons.compress.archivers.zip.* { *; }
#-keep class com.fox2code.mmm.installer.InstallerInitializer { *; }
-keep,includedescriptorclasses class net.sqlcipher.** { *; }
-keep,includedescriptorclasses interface net.sqlcipher.** { *; }
# dontwarn # dontwarn
-dontwarn android.os.SystemProperties -dontwarn android.os.SystemProperties

@ -192,7 +192,7 @@
android:value="false" /> android:value="false" />
<meta-data <meta-data
android:name="io.sentry.dsn" android:name="io.sentry.dsn"
android:value="https://e199c2a54a1f49b1b5beb3244f2c2358@sentry.androidacy.com/77" /> <!-- enable view hierarchy for crashes --> android:value="https://e199c2a54a1f49b1b5beb3244f2c2358@sentry.androidacy.com/7" /> <!-- enable view hierarchy for crashes -->
<meta-data <meta-data
android:name="io.sentry.attach-view-hierarchy" android:name="io.sentry.attach-view-hierarchy"
android:value="true" /> <!-- Sane value, but feel free to lower it --> android:value="true" /> <!-- Sane value, but feel free to lower it -->

@ -130,12 +130,20 @@ class AndroidacyRepoData(cacheRoot: File?, testMode: Boolean) : RepoData(
fun requestNewToken(): String { fun requestNewToken(): String {
val deviceId = generateDeviceId() val deviceId = generateDeviceId()
val resp = doHttpGet( 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 false
) )
// response is JSON var token: String
val jsonObject = JSONObject(String(resp)) try {
val token = jsonObject.getString("token") 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 // Save the token to the shared preferences
val editor = getSharedPreferences("androidacy")!!.edit() val editor = getSharedPreferences("androidacy")!!.edit()
editor.putString("pref_androidacy_api_token", token) 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...") Timber.i("Token is null, requesting new one...")
try { try {
Timber.i("Requesting new token...") Timber.i("Requesting new token...")
// POST json request to https://production-api.androidacy.com/auth/register
token = requestNewToken() token = requestNewToken()
// Parse token // 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 // Ensure token is valid
if (!isValidToken(token)) { if (!isValidToken(token)) {
Timber.e("Failed to validate token") Timber.e("Failed to validate token")

@ -38,8 +38,8 @@ class InstallerInitializer : Shell.Initializer() {
const val ERROR_NO_PATH = 1 const val ERROR_NO_PATH = 1
const val ERROR_NO_SU = 2 const val ERROR_NO_SU = 2
const val ERROR_OTHER = 3 const val ERROR_OTHER = 3
private var tries = 0
@JvmStatic
val errorNotification: NotificationType? val errorNotification: NotificationType?
get() { get() {
val hasRoot = Shell.isAppGrantedRoot() val hasRoot = Shell.isAppGrantedRoot()
@ -56,7 +56,6 @@ class InstallerInitializer : Shell.Initializer() {
return NotificationType.NO_ROOT return NotificationType.NO_ROOT
} }
@JvmStatic
fun peekMagiskPath(): String? { fun peekMagiskPath(): String? {
return mgskPth return mgskPth
} }
@ -74,23 +73,18 @@ class InstallerInitializer : Shell.Initializer() {
* *
* For read/write only "/data/adb/modules" should be used * For read/write only "/data/adb/modules" should be used
*/ */
@JvmStatic
fun peekModulesPath(): String? { fun peekModulesPath(): String? {
return if (mgskPth == null) null else "$mgskPth/.magisk/modules" return if (mgskPth == null) null else "$mgskPth/.magisk/modules"
} }
@JvmStatic
fun peekMagiskVersion(): Int { fun peekMagiskVersion(): Int {
return mgskVerCode return mgskVerCode
} }
@JvmStatic
fun peekHasRamdisk(): Boolean { fun peekHasRamdisk(): Boolean {
return hsRmdsk return hsRmdsk
} }
@JvmStatic
@JvmOverloads
fun tryGetMagiskPathAsync(callback: Callback, forceCheck: Boolean = false) { fun tryGetMagiskPathAsync(callback: Callback, forceCheck: Boolean = false) {
val mgskPth = mgskPth val mgskPth = mgskPth
val thread: Thread = object : Thread("Magisk GetPath Thread") { val thread: Thread = object : Thread("Magisk GetPath Thread") {
@ -135,6 +129,7 @@ class InstallerInitializer : Shell.Initializer() {
var hsRmdsk = hsRmdsk var hsRmdsk = hsRmdsk
if (mgskPth != null && !forceCheck) return mgskPth if (mgskPth != null && !forceCheck) return mgskPth
val output = ArrayList<String>() val output = ArrayList<String>()
try {
if (!Shell.cmd( if (!Shell.cmd(
"if grep ' / ' /proc/mounts | grep -q '/dev/root' &> /dev/null; " + "if grep ' / ' /proc/mounts | grep -q '/dev/root' &> /dev/null; " +
"then echo true; else echo false; fi", "magisk -V", "magisk --path" "then echo true; else echo false; fi", "magisk -V", "magisk --path"
@ -168,6 +163,14 @@ class InstallerInitializer : Shell.Initializer() {
} }
Companion.mgskVerCode = mgskVerCode Companion.mgskVerCode = mgskVerCode
return mgskPth return mgskPth
} catch (ignored: Exception) {
if (tries < 5) {
tries++
return tryGetMagiskPath(true)
} else {
return null
}
}
} }
} }
} }

@ -24,7 +24,7 @@ buildscript {
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // 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") classpath("org.gradle.android.cache-fix:org.gradle.android.cache-fix.gradle.plugin:2.7.1")
} }
} }

Loading…
Cancel
Save