diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 76aafb9c..34b687b4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -8,7 +8,9 @@
+
+
@@ -25,7 +27,6 @@
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
- android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ReVancedManager"
android:enableOnBackInvokedCallback="true"
diff --git a/app/src/main/java/app/revanced/manager/patcher/worker/PatcherWorker.kt b/app/src/main/java/app/revanced/manager/patcher/worker/PatcherWorker.kt
index 664b921c..61ca91b2 100644
--- a/app/src/main/java/app/revanced/manager/patcher/worker/PatcherWorker.kt
+++ b/app/src/main/java/app/revanced/manager/patcher/worker/PatcherWorker.kt
@@ -1,9 +1,20 @@
package app.revanced.manager.patcher.worker
+import android.app.Notification
+import android.app.NotificationChannel
+import android.app.NotificationManager
+import android.app.PendingIntent
import android.content.Context
+import android.content.Intent
+import android.graphics.drawable.Icon
+import android.os.PowerManager
import android.util.Log
+import android.view.WindowManager
+import androidx.core.content.ContextCompat
import androidx.work.CoroutineWorker
+import androidx.work.ForegroundInfo
import androidx.work.WorkerParameters
+import app.revanced.manager.R
import app.revanced.manager.domain.repository.SourceRepository
import app.revanced.manager.patcher.Session
import app.revanced.manager.patcher.aapt.Aapt
@@ -18,8 +29,8 @@ import org.koin.core.component.inject
import java.io.File
import java.io.FileNotFoundException
-// TODO: setup wakelock + notification so android doesn't murder us.
-class PatcherWorker(context: Context, parameters: WorkerParameters) : CoroutineWorker(context, parameters),
+class PatcherWorker(context: Context, parameters: WorkerParameters) :
+ CoroutineWorker(context, parameters),
KoinComponent {
private val sourceRepository: SourceRepository by inject()
@@ -38,24 +49,70 @@ class PatcherWorker(context: Context, parameters: WorkerParameters) : CoroutineW
private fun String.logFmt() = "$logPrefix $this"
}
+ override suspend fun getForegroundInfo() = ForegroundInfo(1, createNotification())
+
+ private fun createNotification(): Notification {
+ val notificationIntent = Intent(applicationContext, PatcherWorker::class.java)
+ val pendingIntent: PendingIntent = PendingIntent.getActivity(
+ applicationContext, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE
+ )
+ val channel = NotificationChannel(
+ "revanced-patcher-patching", "Patching", NotificationManager.IMPORTANCE_HIGH
+ )
+ val notificationManager =
+ ContextCompat.getSystemService(applicationContext, NotificationManager::class.java)
+ notificationManager!!.createNotificationChannel(channel)
+ return Notification.Builder(applicationContext, channel.id)
+ .setContentTitle(applicationContext.getText(R.string.app_name))
+ .setContentText(applicationContext.getText(R.string.patcher_notification_message))
+ .setLargeIcon(Icon.createWithResource(applicationContext, R.drawable.ic_notification))
+ .setSmallIcon(Icon.createWithResource(applicationContext, R.drawable.ic_notification))
+ .setContentIntent(pendingIntent).build()
+ }
+
override suspend fun doWork(): Result {
if (runAttemptCount > 0) {
Log.d(tag, "Android requested retrying but retrying is disabled.".logFmt())
return Result.failure()
}
- val aaptPath =
- Aapt.binary(applicationContext)?.absolutePath ?: throw FileNotFoundException("Could not resolve aapt.")
-
- val frameworkPath =
- applicationContext.cacheDir.resolve("framework").also { it.mkdirs() }.absolutePath
val args = Json.decodeFromString(inputData.getString(ARGS_KEY)!!)
+ try {
+ // This does not always show up for some reason.
+ setForeground(getForegroundInfo())
+ } catch (e: Exception) {
+ Log.d(tag, "Failed to set foreground info:", e)
+ }
+
+ val wakeLock: PowerManager.WakeLock =
+ (applicationContext.getSystemService(Context.POWER_SERVICE) as PowerManager).run {
+ newWakeLock(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, "$tag::Patcher").apply {
+ acquire(10 * 60 * 1000L)
+ Log.d(tag, "Acquired wakelock.")
+ }
+ }
+
+ return try {
+ runPatcher(args)
+ } finally {
+ wakeLock.release()
+ }
+ }
+
+ private suspend fun runPatcher(args: Args): Result {
+ val aaptPath =
+ Aapt.binary(applicationContext)?.absolutePath
+ ?: throw FileNotFoundException("Could not resolve aapt.")
+
+ val frameworkPath = applicationContext.cacheDir.resolve("framework").also { it.mkdirs() }.absolutePath
+
val bundles = sourceRepository.bundles.first()
val integrations = bundles.mapNotNull { (_, bundle) -> bundle.integrations }
val patchList = args.selectedPatches.flatMap { (bundleName, selected) ->
- bundles[bundleName]?.loadPatchesFiltered(args.packageName)?.filter { selected.contains(it.patchName) }
+ bundles[bundleName]?.loadPatchesFiltered(args.packageName)
+ ?.filter { selected.contains(it.patchName) }
?: throw IllegalArgumentException("Patch bundle $bundleName does not exist")
}
@@ -70,7 +127,7 @@ class PatcherWorker(context: Context, parameters: WorkerParameters) : CoroutineW
updateProgress(Progress.Unpacking)
return try {
- Session(applicationContext.cacheDir.path, frameworkPath, aaptPath, File(args.input)) {
+ Session(applicationContext.cacheDir.absolutePath, frameworkPath, aaptPath, File(args.input)) {
updateProgress(it)
}.use { session ->
session.run(File(args.output), patchList, integrations)
@@ -79,7 +136,7 @@ class PatcherWorker(context: Context, parameters: WorkerParameters) : CoroutineW
Log.i(tag, "Patching succeeded".logFmt())
progressManager.success()
Result.success(progressManager.groupsToWorkData())
- } catch (e: Throwable) {
+ } catch (e: Exception) {
Log.e(tag, "Got exception while patching".logFmt(), e)
progressManager.failure()
Result.failure(progressManager.groupsToWorkData())
diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml
deleted file mode 100644
index 07d5da9c..00000000
--- a/app/src/main/res/drawable/ic_launcher_background.xml
+++ /dev/null
@@ -1,170 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml
index 2b068d11..d7092b33 100644
--- a/app/src/main/res/drawable/ic_launcher_foreground.xml
+++ b/app/src/main/res/drawable/ic_launcher_foreground.xml
@@ -2,29 +2,29 @@
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
- android:viewportWidth="108"
- android:viewportHeight="108">
-
-
-
-
-
-
-
-
+ android:viewportWidth="256"
+ android:viewportHeight="256">
+
-
\ No newline at end of file
+ android:pathData="M253.85,4.9C254.32,3.82 254.22,2.57 253.58,1.58C252.93,0.6 251.83,0 250.64,0C243.29,0 230.47,0 225.95,0C224.96,0 224.06,0.59 223.66,1.5C216.03,18.88 144.1,182.7 130.29,214.16C129.89,215.07 128.99,215.66 128,215.66C127.01,215.66 126.11,215.07 125.71,214.16C111.9,182.7 39.97,18.88 32.34,1.5C31.94,0.59 31.04,0 30.05,0C25.53,0 12.71,0 5.36,0C4.17,0 3.07,0.6 2.42,1.58C1.78,2.57 1.68,3.82 2.15,4.9C16.78,38.3 101.47,231.61 111.24,253.9C111.8,255.18 113.06,256 114.45,256C120.29,256 135.71,256 141.55,256C142.94,256 144.2,255.18 144.76,253.9C154.52,231.61 239.22,38.3 253.85,4.9Z"
+ android:fillColor="#ffffff"/>
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_launcher_round.png b/app/src/main/res/drawable/ic_launcher_round.png
new file mode 100644
index 00000000..bef6f587
Binary files /dev/null and b/app/src/main/res/drawable/ic_launcher_round.png differ
diff --git a/app/src/main/res/drawable/ic_notification.png b/app/src/main/res/drawable/ic_notification.png
new file mode 100644
index 00000000..30564097
Binary files /dev/null and b/app/src/main/res/drawable/ic_notification.png differ
diff --git a/app/src/main/res/mipmap-anydpi/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
similarity index 57%
rename from app/src/main/res/mipmap-anydpi/ic_launcher.xml
rename to app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
index eca70cfe..ef49c991 100644
--- a/app/src/main/res/mipmap-anydpi/ic_launcher.xml
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -1,5 +1,6 @@
-
-
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml
deleted file mode 100644
index eca70cfe..00000000
--- a/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 00000000..33b841f9
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp
deleted file mode 100644
index c209e78e..00000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
deleted file mode 100644
index b2dfe3d1..00000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 00000000..b8787842
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp
deleted file mode 100644
index 4f0f1d64..00000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
deleted file mode 100644
index 62b611da..00000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 00000000..3d1462ab
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
deleted file mode 100644
index 948a3070..00000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
deleted file mode 100644
index 1b9a6956..00000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 00000000..a604654d
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
deleted file mode 100644
index 28d4b77f..00000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
deleted file mode 100644
index 9287f508..00000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 00000000..1f59fa1d
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
deleted file mode 100644
index aa7d6427..00000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
deleted file mode 100644
index 9126ae37..00000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp and /dev/null differ
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index f8c6127d..6be58a61 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -7,4 +7,6 @@
#FF018786
#FF000000
#FFFFFFFF
+
+ #1B1B1B
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 6bbea720..8ae3fdd6 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -86,6 +86,8 @@
Patching
Saving
Write patched Apk
+ Patching in progress…
+
More
Donate
Website