mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 16:07:39 +00:00
Cleanup stuffs
This commit is contained in:
parent
581419b6a3
commit
c6b3f06b95
@ -32,7 +32,7 @@ android {
|
|||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
shrinkResources true
|
shrinkResources true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
|
||||||
'proguard-rules.pro', 'proguard-kotlin.pro'
|
'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
## So every class is case insensitive to avoid some bizare problems
|
|
||||||
-dontusemixedcaseclassnames
|
|
||||||
|
|
||||||
## If reflection issues come up uncomment this, that should temporarily fix it
|
|
||||||
#-keep class kotlin.** { *; }
|
|
||||||
#-keep class kotlin.Metadata { *; }
|
|
||||||
#-keepclassmembers class kotlin.Metadata {
|
|
||||||
# public <methods>;
|
|
||||||
#}
|
|
||||||
|
|
||||||
## Never warn about Kotlin, it should work as-is
|
|
||||||
-dontwarn kotlin.**
|
|
||||||
|
|
||||||
## Removes runtime null checks - doesn't really matter if it crashes on kotlin or java NPE
|
|
||||||
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
|
|
||||||
static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
|
|
||||||
}
|
|
||||||
|
|
||||||
## Useless option for dex
|
|
||||||
-dontpreverify
|
|
9
app/proguard-rules.pro
vendored
9
app/proguard-rules.pro
vendored
@ -16,6 +16,15 @@
|
|||||||
# public *;
|
# public *;
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
# Kotlin
|
||||||
|
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
|
||||||
|
public static void checkExpressionValueIsNotNull(...);
|
||||||
|
public static void checkNotNullExpressionValue(...);
|
||||||
|
public static void checkReturnedValueIsNotNull(...);
|
||||||
|
public static void checkFieldIsNotNull(...);
|
||||||
|
public static void checkParameterIsNotNull(...);
|
||||||
|
}
|
||||||
|
|
||||||
# Stubs
|
# Stubs
|
||||||
-keep class a.* { *; }
|
-keep class a.* { *; }
|
||||||
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
package a;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.work.WorkerParameters;
|
|
||||||
|
|
||||||
import com.topjohnwu.magisk.core.UpdateCheckService;
|
|
||||||
|
|
||||||
public class g extends w<UpdateCheckService> {
|
|
||||||
/* Stub */
|
|
||||||
public g(@NonNull Context context, @NonNull WorkerParameters workerParams) {
|
|
||||||
super(context, workerParams);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +1,12 @@
|
|||||||
package a
|
package a
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import androidx.work.Worker
|
|
||||||
import androidx.work.WorkerParameters
|
|
||||||
import com.topjohnwu.magisk.core.App
|
import com.topjohnwu.magisk.core.App
|
||||||
import com.topjohnwu.magisk.core.GeneralReceiver
|
import com.topjohnwu.magisk.core.GeneralReceiver
|
||||||
import com.topjohnwu.magisk.core.SplashActivity
|
import com.topjohnwu.magisk.core.SplashActivity
|
||||||
import com.topjohnwu.magisk.core.base.BaseWorkerWrapper
|
|
||||||
import com.topjohnwu.magisk.core.download.DownloadService
|
import com.topjohnwu.magisk.core.download.DownloadService
|
||||||
import com.topjohnwu.magisk.legacy.flash.FlashActivity
|
import com.topjohnwu.magisk.legacy.flash.FlashActivity
|
||||||
import com.topjohnwu.magisk.legacy.surequest.SuRequestActivity
|
import com.topjohnwu.magisk.legacy.surequest.SuRequestActivity
|
||||||
import com.topjohnwu.magisk.ui.MainActivity
|
import com.topjohnwu.magisk.ui.MainActivity
|
||||||
import java.lang.reflect.ParameterizedType
|
|
||||||
|
|
||||||
class b : MainActivity()
|
class b : MainActivity()
|
||||||
|
|
||||||
@ -29,27 +24,3 @@ class h : GeneralReceiver()
|
|||||||
class j : DownloadService()
|
class j : DownloadService()
|
||||||
|
|
||||||
class m : SuRequestActivity()
|
class m : SuRequestActivity()
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper class to workaround Proguard rule :
|
|
||||||
* -keep class * extends Worker
|
|
||||||
* */
|
|
||||||
abstract class w<T : BaseWorkerWrapper>(
|
|
||||||
context: Context,
|
|
||||||
workerParams: WorkerParameters
|
|
||||||
) : Worker(context, workerParams) {
|
|
||||||
|
|
||||||
private var base: T? = null
|
|
||||||
|
|
||||||
override fun doWork() = base?.doWork() ?: Result.failure()
|
|
||||||
|
|
||||||
override fun onStopped() = base?.onStopped() ?: Unit
|
|
||||||
|
|
||||||
init {
|
|
||||||
try {
|
|
||||||
base = ((javaClass.genericSuperclass as ParameterizedType)
|
|
||||||
.actualTypeArguments[0] as Class<T>).newInstance()
|
|
||||||
base?.attachWorker(this)
|
|
||||||
} catch (e : java.lang.Exception) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -147,7 +147,6 @@ object ClassMap {
|
|||||||
MainActivity::class.java to a.b::class.java,
|
MainActivity::class.java to a.b::class.java,
|
||||||
SplashActivity::class.java to a.c::class.java,
|
SplashActivity::class.java to a.c::class.java,
|
||||||
FlashActivity::class.java to a.f::class.java,
|
FlashActivity::class.java to a.f::class.java,
|
||||||
UpdateCheckService::class.java to a.g::class.java,
|
|
||||||
GeneralReceiver::class.java to a.h::class.java,
|
GeneralReceiver::class.java to a.h::class.java,
|
||||||
DownloadService::class.java to a.j::class.java,
|
DownloadService::class.java to a.j::class.java,
|
||||||
SuRequestActivity::class.java to a.m::class.java,
|
SuRequestActivity::class.java to a.m::class.java,
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
package com.topjohnwu.magisk.core
|
package com.topjohnwu.magisk.core
|
||||||
|
|
||||||
import androidx.work.ListenableWorker
|
import android.content.Context
|
||||||
|
import androidx.work.Worker
|
||||||
|
import androidx.work.WorkerParameters
|
||||||
import com.topjohnwu.magisk.BuildConfig
|
import com.topjohnwu.magisk.BuildConfig
|
||||||
import com.topjohnwu.magisk.core.base.BaseWorkerWrapper
|
|
||||||
import com.topjohnwu.magisk.core.view.Notifications
|
import com.topjohnwu.magisk.core.view.Notifications
|
||||||
import com.topjohnwu.magisk.data.repository.MagiskRepository
|
import com.topjohnwu.magisk.data.repository.MagiskRepository
|
||||||
import com.topjohnwu.magisk.extensions.inject
|
import com.topjohnwu.magisk.extensions.inject
|
||||||
import com.topjohnwu.superuser.Shell
|
import com.topjohnwu.superuser.Shell
|
||||||
|
|
||||||
class UpdateCheckService : BaseWorkerWrapper() {
|
class UpdateCheckService(context: Context, workerParams: WorkerParameters)
|
||||||
|
: Worker(context, workerParams) {
|
||||||
|
|
||||||
private val magiskRepo: MagiskRepository by inject()
|
private val magiskRepo: MagiskRepository by inject()
|
||||||
|
|
||||||
override fun doWork(): ListenableWorker.Result {
|
override fun doWork(): Result {
|
||||||
// Make sure shell initializer was ran
|
// Make sure shell initializer was ran
|
||||||
Shell.getShell()
|
Shell.getShell()
|
||||||
return runCatching {
|
return runCatching {
|
||||||
@ -21,9 +23,9 @@ class UpdateCheckService : BaseWorkerWrapper() {
|
|||||||
Notifications.managerUpdate(applicationContext)
|
Notifications.managerUpdate(applicationContext)
|
||||||
else if (Info.env.magiskVersionCode < Info.remote.magisk.versionCode)
|
else if (Info.env.magiskVersionCode < Info.remote.magisk.versionCode)
|
||||||
Notifications.magiskUpdate(applicationContext)
|
Notifications.magiskUpdate(applicationContext)
|
||||||
ListenableWorker.Result.success()
|
Result.success()
|
||||||
}.getOrElse {
|
}.getOrElse {
|
||||||
ListenableWorker.Result.failure()
|
Result.failure()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,11 @@ import android.net.Uri
|
|||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.work.*
|
import androidx.work.*
|
||||||
import com.topjohnwu.magisk.BuildConfig
|
|
||||||
import com.topjohnwu.magisk.R
|
import com.topjohnwu.magisk.R
|
||||||
import com.topjohnwu.magisk.core.*
|
import com.topjohnwu.magisk.core.Config
|
||||||
|
import com.topjohnwu.magisk.core.Const
|
||||||
|
import com.topjohnwu.magisk.core.Info
|
||||||
|
import com.topjohnwu.magisk.core.UpdateCheckService
|
||||||
import com.topjohnwu.magisk.extensions.get
|
import com.topjohnwu.magisk.extensions.get
|
||||||
import com.topjohnwu.superuser.internal.UiThreadHandler
|
import com.topjohnwu.superuser.internal.UiThreadHandler
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@ -42,12 +44,13 @@ object Utils {
|
|||||||
.setRequiresDeviceIdle(true)
|
.setRequiresDeviceIdle(true)
|
||||||
.build()
|
.build()
|
||||||
val request = PeriodicWorkRequest
|
val request = PeriodicWorkRequest
|
||||||
.Builder(ClassMap[UpdateCheckService::class.java] as Class<Worker>, 12, TimeUnit.HOURS)
|
.Builder(UpdateCheckService::class.java, 12, TimeUnit.HOURS)
|
||||||
.setConstraints(constraints)
|
.setConstraints(constraints)
|
||||||
.build()
|
.build()
|
||||||
WorkManager.getInstance(context).enqueueUniquePeriodicWork(
|
WorkManager.getInstance(context).enqueueUniquePeriodicWork(
|
||||||
Const.ID.CHECK_MAGISK_UPDATE_WORKER_ID,
|
Const.ID.CHECK_MAGISK_UPDATE_WORKER_ID,
|
||||||
ExistingPeriodicWorkPolicy.REPLACE, request)
|
ExistingPeriodicWorkPolicy.REPLACE, request
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
WorkManager.getInstance(context)
|
WorkManager.getInstance(context)
|
||||||
.cancelUniqueWork(Const.ID.CHECK_MAGISK_UPDATE_WORKER_ID)
|
.cancelUniqueWork(Const.ID.CHECK_MAGISK_UPDATE_WORKER_ID)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user