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
# 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
-dontwarn pl.droidsonroids.gif.GifDrawable

@ -192,7 +192,7 @@
android:value="false" />
<meta-data
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
android:name="io.sentry.attach-view-hierarchy"
android:value="true" /> <!-- Sane value, but feel free to lower it -->
@ -213,4 +213,4 @@
android:value="0.2" />
</application>
</manifest>
</manifest>

@ -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(
}
}
}
}
}

@ -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<String>()
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
}
}
}
}
}
}

@ -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")
}
}

Loading…
Cancel
Save