Skip to content

Commit

Permalink
prepare work for 2.3.0
Browse files Browse the repository at this point in the history
- initial work on UNTESTED ksu support
- prepare for play release
- don't try to get magisk path if no root
- remove debug logging entirely on release builds
  - if we set an if condition to a constant falsey value, r8 is nice enough to remove it for us
- more that i really don't care to document

Signed-off-by: androidacy-user <[email protected]>
  • Loading branch information
androidacy-user committed Sep 5, 2023
1 parent 33383f2 commit 3f38a8d
Show file tree
Hide file tree
Showing 38 changed files with 382 additions and 278 deletions.
30 changes: 15 additions & 15 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ android {
val timestamp = System.currentTimeMillis()

namespace = "com.fox2code.mmm"
compileSdk = 33
compileSdk = 34
ndkVersion = "25.2.9519653"
signingConfigs {
create("release") {
Expand All @@ -52,9 +52,9 @@ android {
defaultConfig {
applicationId = "com.fox2code.mmm"
minSdk = 24
targetSdk = 33
versionCode = 81
versionName = "2.2.3"
targetSdk = 34
versionCode = 82
versionName = "2.3.0"
vectorDrawables {
useSupportLibrary = true
}
Expand Down Expand Up @@ -460,11 +460,11 @@ dependencies {
// UI
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.activity:activity-ktx:1.7.2")
implementation("androidx.emoji2:emoji2:1.3.0")
implementation("androidx.emoji2:emoji2-views-helper:1.3.0")
implementation("androidx.preference:preference-ktx:1.2.0")
implementation("androidx.emoji2:emoji2:1.4.0")
implementation("androidx.emoji2:emoji2-views-helper:1.4.0")
implementation("androidx.preference:preference-ktx:1.2.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.recyclerview:recyclerview:1.3.0")
implementation("androidx.recyclerview:recyclerview:1.3.1")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("androidx.webkit:webkit:1.7.0")
implementation("com.google.android.material:material:1.9.0")
Expand Down Expand Up @@ -498,12 +498,12 @@ dependencies {
implementation("com.github.Fox2Code:AndroidANSI:1.2.1")

// sentry
implementation("io.sentry:sentry-android:6.25.2")
implementation("io.sentry:sentry-android-timber:6.25.2")
implementation("io.sentry:sentry-android-fragment:6.25.2")
implementation("io.sentry:sentry-android-okhttp:6.25.2")
implementation("io.sentry:sentry-kotlin-extensions:6.25.2")
implementation("io.sentry:sentry-android-ndk:6.25.2")
implementation("io.sentry:sentry-android:6.28.0")
implementation("io.sentry:sentry-android-timber:6.28.0")
implementation("io.sentry:sentry-android-fragment:6.28.0")
implementation("io.sentry:sentry-android-okhttp:6.28.0")
implementation("io.sentry:sentry-kotlin-extensions:6.28.0")
implementation("io.sentry:sentry-android-ndk:6.28.0")

// Markdown
// TODO: switch to an updated implementation
Expand Down Expand Up @@ -543,7 +543,7 @@ dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3")

// yes
implementation("com.github.fingerprintjs:fingerprint-android:2.0.0")
implementation("com.github.fingerprintjs:fingerprint-android:2.0.2")

// room
implementation("androidx.room:room-runtime:2.5.2")
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/kotlin/com/fox2code/mmm/AppUpdateManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AppUpdateManager private constructor() {
lastChecked < System.currentTimeMillis() - 60000L
) return force && peekShouldUpdate()
synchronized(updateLock) {
Timber.d("Checking for app updates")
if (BuildConfig.DEBUG) Timber.d("Checking for app updates")
if (lastChecked != this.lastChecked) return peekShouldUpdate()
// make a request to https://production-api.androidacy.com/amm/updates/check with appVersionCode and token/device_id/client_id
var token = AndroidacyRepoData.token
Expand All @@ -59,7 +59,7 @@ class AppUpdateManager private constructor() {
val response = doHttpGet(url, false)
// convert response to string
val responseString = String(response, Charsets.UTF_8)
Timber.d("Response: $responseString")
if (BuildConfig.DEBUG) Timber.d("Response: $responseString")
// json response has a boolean shouldUpdate and an int latestVersion
JSONObject(responseString).let {
if (it.getBoolean("shouldUpdate")) {
Expand Down Expand Up @@ -105,7 +105,7 @@ class AppUpdateManager private constructor() {
@Throws(IOException::class)
private fun parseCompatibilityFlags(inputStream: InputStream) {
compatDataId.clear()
Timber.d("Not implemented")
if (BuildConfig.DEBUG) Timber.d("Not implemented")
}

fun getCompatibilityFlags(moduleId: String): Int {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/kotlin/com/fox2code/mmm/CrashHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CrashHandler : FoxActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Timber.i("CrashHandler.onCreate(%s)", savedInstanceState)
// log intent with extras
Timber.d("CrashHandler.onCreate: intent=%s", intent)
if (BuildConfig.DEBUG) Timber.d("CrashHandler.onCreate: intent=%s", intent)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_crash_handler)
// set crash_details MaterialTextView to the exception passed in the intent or unknown if null
Expand Down Expand Up @@ -58,7 +58,7 @@ class CrashHandler : FoxActivity() {
if (lastEventId?.matches("^0+$".toRegex()) == true) {
lastEventId = ""
}
Timber.d(
if (BuildConfig.DEBUG) Timber.d(
"CrashHandler.onCreate: lastEventId=%s, crashReportingEnabled=%s",
lastEventId,
crashReportingEnabled
Expand All @@ -71,7 +71,7 @@ class CrashHandler : FoxActivity() {
val submit = findViewById<View>(R.id.feedback_submit)
if (lastEventId.isNullOrEmpty() && crashReportingEnabled) {
// if lastEventId is null, hide the feedback button
Timber.d("CrashHandler.onCreate: lastEventId is null but crash reporting is enabled. This may indicate a bug in the crash reporting system.")
if (BuildConfig.DEBUG) Timber.d("CrashHandler.onCreate: lastEventId is null but crash reporting is enabled. This may indicate a bug in the crash reporting system.")
submit.visibility = View.GONE
findViewById<MaterialTextView>(R.id.feedback_text).setText(R.string.no_sentry_id)
} else {
Expand Down
29 changes: 16 additions & 13 deletions app/src/main/kotlin/com/fox2code/mmm/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
if (ts.time > buildTime.time) {
val pm = packageManager
val intent = Intent(this, ExpiredActivity::class.java)
@Suppress("DEPRECATION") val resolveInfo = pm.queryIntentActivities(intent, 0)
val resolveInfo = pm.queryIntentActivities(intent, 0)
if (resolveInfo.size > 0) {
startActivity(intent)
finish()
Expand Down Expand Up @@ -231,11 +231,8 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
.create()
rebootDialog.show()
}
// get background color and elevation of reboot fab
val searchCard = searchCard!!
// copy reboot fab style to search card
searchCard.elevation = rebootFab.elevation
searchCard.translationY = rebootFab.translationY
searchCard.foreground = rebootFab.foreground
moduleList.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
if (newState != RecyclerView.SCROLL_STATE_IDLE) searchView.clearFocus()
Expand Down Expand Up @@ -307,8 +304,6 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
TrackHelper.track().event("view_list", "settings")
.with(MainApplication.INSTANCE!!.tracker)
startActivity(Intent(this@MainActivity, SettingsActivity::class.java))
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
finish()
}

R.id.online_menu_item -> {
Expand Down Expand Up @@ -388,9 +383,17 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
tryGetMagiskPathAsync(object : InstallerInitializer.Callback {
override fun onPathReceived(path: String?) {
Timber.i("Got magisk path: %s", path)
if (peekMagiskVersion() < Constants.MAGISK_VER_CODE_INSTALL_COMMAND) moduleViewListBuilder.addNotification(
NotificationType.MAGISK_OUTDATED
)
if (peekMagiskVersion() < Constants.MAGISK_VER_CODE_INSTALL_COMMAND) {
if (!InstallerInitializer.isKsu) {
moduleViewListBuilder.addNotification(
NotificationType.MAGISK_OUTDATED
)
} else {
moduleViewListBuilder.addNotification(
NotificationType.KSU_EXPERIMENTAL
)
}
}
if (!MainApplication.isShowcaseMode) moduleViewListBuilder.addNotification(
NotificationType.INSTALL_FROM_STORAGE
)
Expand All @@ -409,7 +412,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis

fun commonNext() {
if (BuildConfig.DEBUG) {
Timber.d("Common next")
if (BuildConfig.DEBUG) Timber.d("Common next")
moduleViewListBuilder.addNotification(NotificationType.DEBUG)
}
NotificationType.NO_INTERNET.autoAdd(moduleViewListBuilderOnline)
Expand All @@ -426,7 +429,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
updateScreenInsets() // Fix an edge case
val context: Context = this@MainActivity
if (runtimeUtils!!.waitInitialSetupFinished(context, this@MainActivity)) {
Timber.d("waiting...")
if (BuildConfig.DEBUG) Timber.d("waiting...")
return
}
swipeRefreshBlocker = System.currentTimeMillis() + 5000L
Expand Down Expand Up @@ -869,7 +872,7 @@ class MainActivity : FoxActivity(), OnRefreshListener, SearchView.OnQueryTextLis
// wait for up to 10 seconds for AndroidacyRepoData to be initialized
var i: Int
if (AndroidacyRepoData.instance.isEnabled && AndroidacyRepoData.instance.memberLevel == null) {
Timber.d("Member level is null, waiting for it to be initialized")
if (BuildConfig.DEBUG) Timber.d("Member level is null, waiting for it to be initialized")
i = 0
while (AndroidacyRepoData.instance.memberLevel == null && i < 20) {
i++
Expand Down
26 changes: 17 additions & 9 deletions app/src/main/kotlin/com/fox2code/mmm/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -264,24 +264,24 @@ class MainApplication : FoxApplication(), Configuration.Provider {
fileUtils.ensureCacheDirs()
fileUtils.ensureURLHandler(this)
}
Timber.d("Initializing AMM")
Timber.d("Started from background: %s", !isInForeground)
Timber.d("AMM is running in debug mode")
if (BuildConfig.DEBUG) Timber.d("Initializing AMM")
if (BuildConfig.DEBUG) Timber.d("Started from background: %s", !isInForeground)
if (BuildConfig.DEBUG) Timber.d("AMM is running in debug mode")
// analytics
Timber.d("Initializing matomo")
if (BuildConfig.DEBUG) Timber.d("Initializing matomo")
getTracker()
if (!isMatomoAllowed()) {
Timber.d("Matomo is not allowed")
if (BuildConfig.DEBUG) Timber.d("Matomo is not allowed")
tracker!!.isOptOut = true
} else {
tracker!!.isOptOut = false
}
if (getSharedPreferences("matomo")!!.getBoolean("install_tracked", false)) {
TrackHelper.track().download().with(INSTANCE!!.getTracker())
Timber.d("Sent install event to matomo")
if (BuildConfig.DEBUG) Timber.d("Sent install event to matomo")
getSharedPreferences("matomo")!!.edit().putBoolean("install_tracked", true).apply()
} else {
Timber.d("Matomo already has install")
if (BuildConfig.DEBUG) Timber.d("Matomo already has install")
}
try {
@Suppress("DEPRECATION") @SuppressLint("PackageManagerGetSignatures") val s =
Expand Down Expand Up @@ -413,12 +413,12 @@ class MainApplication : FoxApplication(), Configuration.Provider {
val activityManager = this.getSystemService(ACTIVITY_SERVICE) as ActivityManager
val appProcesses = activityManager.runningAppProcesses
if (appProcesses == null) {
Timber.d("appProcesses is null")
if (BuildConfig.DEBUG) Timber.d("appProcesses is null")
return false
}
val packageName = this.packageName
for (appProcess in appProcesses) {
Timber.d(
if (BuildConfig.DEBUG) Timber.d(
"Process: %s, Importance: %d", appProcess.processName, appProcess.importance
)
if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND && appProcess.processName == packageName) {
Expand Down Expand Up @@ -503,6 +503,14 @@ class MainApplication : FoxApplication(), Configuration.Provider {
init {
Shell.setDefaultBuilder(Shell.Builder.create()
.setFlags(Shell.FLAG_REDIRECT_STDERR or Shell.FLAG_MOUNT_MASTER).setTimeout(15))
// set verbose logging for debug builds
if (BuildConfig.DEBUG) {
Shell.enableVerboseLogging = true
}
// prewarm shell
Shell.getShell {
// do nothing
}
val random = Random()
do {
secret = random.nextLong()
Expand Down
Loading

0 comments on commit 3f38a8d

Please sign in to comment.