fix: more android 34 fixes

This commit is contained in:
Ax333l
2023-10-20 22:59:16 +02:00
committed by oSumAtrIX
parent 1dd6738964
commit 7fb1e27617
4 changed files with 33 additions and 8 deletions

View File

@@ -6,7 +6,9 @@ import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.pm.ServiceInfo
import android.graphics.drawable.Icon
import android.os.Build
import android.os.PowerManager
import android.util.Log
import android.view.WindowManager
@@ -71,7 +73,12 @@ class PatcherWorker(
private fun String.logFmt() = "$logPrefix $this"
}
override suspend fun getForegroundInfo() = ForegroundInfo(1, createNotification())
override suspend fun getForegroundInfo() =
ForegroundInfo(
1,
createNotification(),
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE else 0
)
private fun createNotification(): Notification {
val notificationIntent = Intent(applicationContext, PatcherWorker::class.java)

View File

@@ -11,6 +11,7 @@ import android.util.Log
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.core.content.ContextCompat
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import app.revanced.manager.R
@@ -83,8 +84,10 @@ class InstalledAppInfoViewModel(
override fun onReceive(context: Context?, intent: Intent?) {
when (intent?.action) {
UninstallService.APP_UNINSTALL_ACTION -> {
val extraStatus = intent.getIntExtra(UninstallService.EXTRA_UNINSTALL_STATUS, -999)
val extraStatusMessage = intent.getStringExtra(UninstallService.EXTRA_UNINSTALL_STATUS_MESSAGE)
val extraStatus =
intent.getIntExtra(UninstallService.EXTRA_UNINSTALL_STATUS, -999)
val extraStatusMessage =
intent.getStringExtra(UninstallService.EXTRA_UNINSTALL_STATUS_MESSAGE)
if (extraStatus == PackageInstaller.STATUS_SUCCESS) {
viewModelScope.launch {
@@ -113,9 +116,11 @@ class InstalledAppInfoViewModel(
}
}
app.registerReceiver(
ContextCompat.registerReceiver(
app,
uninstallBroadcastReceiver,
IntentFilter(UninstallService.APP_UNINSTALL_ACTION)
IntentFilter(UninstallService.APP_UNINSTALL_ACTION),
ContextCompat.RECEIVER_NOT_EXPORTED
)
}

View File

@@ -13,6 +13,7 @@ import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.core.content.ContextCompat
import androidx.lifecycle.ViewModel
import androidx.lifecycle.map
import androidx.lifecycle.viewModelScope
@@ -162,10 +163,10 @@ class InstallerViewModel(
}
init {
app.registerReceiver(installBroadcastReceiver, IntentFilter().apply {
ContextCompat.registerReceiver(app, installBroadcastReceiver, IntentFilter().apply {
addAction(InstallService.APP_INSTALL_ACTION)
addAction(UninstallService.APP_UNINSTALL_ACTION)
})
}, ContextCompat.RECEIVER_NOT_EXPORTED)
}
fun exportLogs(context: Context) {