Platform: Switch all extensions to property access syntax
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -116,7 +116,7 @@ fun Context.getStyledAttributeColor(id: Int): Int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Context.isIgnoringBatteryOptimizations(): Boolean {
|
fun Context.isIgnoringBatteryOptimizations(): Boolean {
|
||||||
return if (isMAndAbove()) {
|
return if (isMAndAbove) {
|
||||||
(getSystemService<PowerManager>())?.isIgnoringBatteryOptimizations(packageName) ?: true
|
(getSystemService<PowerManager>())?.isIgnoringBatteryOptimizations(packageName) ?: true
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
@@ -124,7 +124,7 @@ fun Context.isIgnoringBatteryOptimizations(): Boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Context.areNotificationsEnabled(): Boolean {
|
fun Context.areNotificationsEnabled(): Boolean {
|
||||||
return if (isNAndAbove()) {
|
return if (isNAndAbove) {
|
||||||
getSystemService<NotificationManager>()!!.areNotificationsEnabled()
|
getSystemService<NotificationManager>()!!.areNotificationsEnabled()
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
@@ -136,7 +136,7 @@ fun Context.checkManifestPermission(permission: String): Boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Context.isExternalStorageAccessible(): Boolean {
|
fun Context.isExternalStorageAccessible(): Boolean {
|
||||||
return if (isRAndAbove()) {
|
return if (isRAndAbove) {
|
||||||
Environment.isExternalStorageManager()
|
Environment.isExternalStorageManager()
|
||||||
} else {
|
} else {
|
||||||
checkManifestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
checkManifestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
@@ -144,7 +144,7 @@ fun Context.isExternalStorageAccessible(): Boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Context.isDomainVerified(domain: String): Boolean {
|
fun Context.isDomainVerified(domain: String): Boolean {
|
||||||
return if (isSAndAbove()) {
|
return if (isSAndAbove) {
|
||||||
val domainVerificationManager = getSystemService<DomainVerificationManager>()
|
val domainVerificationManager = getSystemService<DomainVerificationManager>()
|
||||||
val userState = domainVerificationManager!!.getDomainVerificationUserState(packageName)
|
val userState = domainVerificationManager!!.getDomainVerificationUserState(packageName)
|
||||||
val domainMap = userState?.hostToStateMap?.filterKeys { it == domain }
|
val domainMap = userState?.hostToStateMap?.filterKeys { it == domain }
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ fun PackageInfo.isValidApp(packageManager: PackageManager): Boolean {
|
|||||||
if (this.applicationInfo!!.loadLabel(packageManager).startsWith(this.packageName)) return false
|
if (this.applicationInfo!!.loadLabel(packageManager).startsWith(this.packageName)) return false
|
||||||
|
|
||||||
return when {
|
return when {
|
||||||
isQAndAbove() -> {
|
isQAndAbove -> {
|
||||||
Process.isApplicationUid(this.applicationInfo!!.uid) &&
|
Process.isApplicationUid(this.applicationInfo!!.uid) &&
|
||||||
!this.applicationInfo!!.isResourceOverlay && !this.isApex
|
!this.applicationInfo!!.isResourceOverlay && !this.isApex
|
||||||
}
|
}
|
||||||
isNAndAbove() -> Process.isApplicationUid(this.applicationInfo!!.uid)
|
isNAndAbove -> Process.isApplicationUid(this.applicationInfo!!.uid)
|
||||||
else -> this.versionName != null
|
else -> this.versionName != null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import androidx.annotation.RequiresApi
|
|||||||
import com.aurora.store.BuildConfig
|
import com.aurora.store.BuildConfig
|
||||||
|
|
||||||
fun PackageManager.getInstallerPackageNameCompat(packageName: String): String? {
|
fun PackageManager.getInstallerPackageNameCompat(packageName: String): String? {
|
||||||
return if (isRAndAbove()) {
|
return if (isRAndAbove) {
|
||||||
getInstallSourceInfo(packageName).installingPackageName
|
getInstallSourceInfo(packageName).installingPackageName
|
||||||
} else {
|
} else {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
@@ -19,11 +19,11 @@ fun PackageManager.getUpdateOwnerPackageNameCompat(packageName: String): String?
|
|||||||
// https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setRequireUserAction(int)
|
// https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setRequireUserAction(int)
|
||||||
val installSourceInfo = getInstallSourceInfo(packageName)
|
val installSourceInfo = getInstallSourceInfo(packageName)
|
||||||
return when {
|
return when {
|
||||||
isUAndAbove() -> {
|
isUAndAbove -> {
|
||||||
// If update ownership is null, we can still silently update it if we installed it
|
// If update ownership is null, we can still silently update it if we installed it
|
||||||
installSourceInfo.updateOwnerPackageName ?: installSourceInfo.installingPackageName
|
installSourceInfo.updateOwnerPackageName ?: installSourceInfo.installingPackageName
|
||||||
}
|
}
|
||||||
isSAndAbove() -> installSourceInfo.installingPackageName
|
isSAndAbove -> installSourceInfo.installingPackageName
|
||||||
else -> if (packageName == BuildConfig.APPLICATION_ID) BuildConfig.APPLICATION_ID else null
|
else -> if (packageName == BuildConfig.APPLICATION_ID) BuildConfig.APPLICATION_ID else null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,89 +24,65 @@ import android.annotation.SuppressLint
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
fun isMAndAbove(): Boolean {
|
val isMAndAbove: Boolean
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||||
}
|
|
||||||
|
|
||||||
fun isNAndAbove(): Boolean {
|
val isNAndAbove: Boolean
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
|
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
|
||||||
}
|
|
||||||
|
|
||||||
fun isOAndAbove(): Boolean {
|
val isOAndAbove: Boolean
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||||
}
|
|
||||||
|
|
||||||
fun isOMR1AndAbove(): Boolean {
|
val isPAndAbove: Boolean
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
|
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P
|
||||||
}
|
|
||||||
|
|
||||||
fun isPAndAbove(): Boolean {
|
val isQAndAbove: Boolean
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.P
|
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
||||||
}
|
|
||||||
|
|
||||||
fun isQAndAbove(): Boolean {
|
val isRAndAbove: Boolean
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
|
||||||
}
|
|
||||||
|
|
||||||
fun isRAndAbove(): Boolean {
|
val isSAndAbove: Boolean
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
|
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
||||||
}
|
|
||||||
|
|
||||||
fun isSAndAbove(): Boolean {
|
val isTAndAbove: Boolean
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
|
||||||
}
|
|
||||||
|
|
||||||
fun isTAndAbove(): Boolean {
|
val isUAndAbove: Boolean
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
|
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE
|
||||||
}
|
|
||||||
|
|
||||||
fun isUAndAbove(): Boolean {
|
val isVAndAbove: Boolean
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE
|
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM
|
||||||
}
|
|
||||||
|
|
||||||
fun isVAndAbove(): Boolean {
|
val isMIUI: Boolean
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM
|
get() = !getSystemProperty("ro.miui.ui.version.name").isNullOrBlank()
|
||||||
}
|
|
||||||
|
|
||||||
fun isMIUI(): Boolean {
|
val isHuawei: Boolean
|
||||||
return getSystemProperty("ro.miui.ui.version.name").isNotEmpty()
|
get() = Build.MANUFACTURER.lowercase(Locale.getDefault()).contains("huawei")
|
||||||
}
|
|
||||||
|
|
||||||
fun isHuawei(): Boolean {
|
|
||||||
return Build.MANUFACTURER.lowercase(Locale.getDefault()).contains("huawei")
|
|
||||||
|| Build.HARDWARE.lowercase(Locale.getDefault()).contains("kirin")
|
|| Build.HARDWARE.lowercase(Locale.getDefault()).contains("kirin")
|
||||||
|| Build.HARDWARE.lowercase(Locale.getDefault()).contains("hi3")
|
|| Build.HARDWARE.lowercase(Locale.getDefault()).contains("hi3")
|
||||||
}
|
|
||||||
|
|
||||||
fun getMIUIVersion(): String {
|
@get:SuppressLint("PrivateApi")
|
||||||
val version = getSystemProperty("ro.miui.ui.version.name")
|
val isMiuiOptimizationDisabled: Boolean
|
||||||
val versionCode = getSystemProperty("ro.miui.ui.version.code")
|
get() {
|
||||||
return if (version.isNotEmpty() && versionCode.isNotEmpty())
|
return if ("0" == getSystemProperty("persist.sys.miui_optimization")) {
|
||||||
"$version.$versionCode"
|
true
|
||||||
else
|
} else try {
|
||||||
"unknown"
|
Class.forName("android.miui.AppOpsUtils")
|
||||||
}
|
.getDeclaredMethod("isXOptMode")
|
||||||
|
.invoke(null) as Boolean
|
||||||
@SuppressLint("PrivateApi")
|
} catch (_: java.lang.Exception) {
|
||||||
fun isMiuiOptimizationDisabled(): Boolean {
|
false
|
||||||
if ("0" == getSystemProperty("persist.sys.miui_optimization")) {
|
}
|
||||||
return true
|
|
||||||
} else try {
|
|
||||||
return Class.forName("android.miui.AppOpsUtils")
|
|
||||||
.getDeclaredMethod("isXOptMode")
|
|
||||||
.invoke(null) as Boolean
|
|
||||||
} catch (e: java.lang.Exception) {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("PrivateApi")
|
@SuppressLint("PrivateApi")
|
||||||
fun getSystemProperty(key: String): String {
|
private fun getSystemProperty(key: String): String? {
|
||||||
return try {
|
return try {
|
||||||
Class.forName("android.os.SystemProperties")
|
Class.forName("android.os.SystemProperties")
|
||||||
.getDeclaredMethod("get", String::class.java)
|
.getDeclaredMethod("get", String::class.java)
|
||||||
.invoke(null, key) as String
|
.invoke(null, key) as String
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
""
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class AuroraApp : Application(), Configuration.Provider, ImageLoaderFactory {
|
|||||||
DynamicColors.applyToActivitiesIfAvailable(this)
|
DynamicColors.applyToActivitiesIfAvailable(this)
|
||||||
|
|
||||||
// Required for Shizuku installer
|
// Required for Shizuku installer
|
||||||
if (isPAndAbove()) HiddenApiBypass.addHiddenApiExemptions("I", "L")
|
if (isPAndAbove) HiddenApiBypass.addHiddenApiExemptions("I", "L")
|
||||||
|
|
||||||
//Create Notification Channels
|
//Create Notification Channels
|
||||||
NotificationUtil.createNotificationChannel(this)
|
NotificationUtil.createNotificationChannel(this)
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ class UpdateHelper @Inject constructor(
|
|||||||
.setRequiredNetworkType(NetworkType.UNMETERED)
|
.setRequiredNetworkType(NetworkType.UNMETERED)
|
||||||
.setRequiresBatteryNotLow(true)
|
.setRequiresBatteryNotLow(true)
|
||||||
|
|
||||||
if (isMAndAbove()) constraints.setRequiresDeviceIdle(true)
|
if (isMAndAbove) constraints.setRequiresDeviceIdle(true)
|
||||||
|
|
||||||
return PeriodicWorkRequestBuilder<UpdateWorker>(
|
return PeriodicWorkRequestBuilder<UpdateWorker>(
|
||||||
repeatInterval = updateCheckInterval,
|
repeatInterval = updateCheckInterval,
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class AppInstaller @Inject constructor(
|
|||||||
installers.add(AMInstaller.getInstallerInfo(context))
|
installers.add(AMInstaller.getInstallerInfo(context))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOAndAbove() && hasShizukuOrSui(context)) {
|
if (isOAndAbove && hasShizukuOrSui(context)) {
|
||||||
installers.add(ShizukuInstaller.getInstallerInfo(context))
|
installers.add(ShizukuInstaller.getInstallerInfo(context))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ class AppInstaller @Inject constructor(
|
|||||||
return when (getCurrentInstaller(context)) {
|
return when (getCurrentInstaller(context)) {
|
||||||
Installer.SESSION -> {
|
Installer.SESSION -> {
|
||||||
// Silent install cannot be done on initial install and below A12
|
// Silent install cannot be done on initial install and below A12
|
||||||
if (!PackageUtil.isInstalled(context, packageName) || !isSAndAbove()) return false
|
if (!PackageUtil.isInstalled(context, packageName) || !isSAndAbove) return false
|
||||||
|
|
||||||
// We cannot do silent updates if we are not the update owner
|
// We cannot do silent updates if we are not the update owner
|
||||||
if (context.packageManager.getUpdateOwnerPackageNameCompat(packageName) != BuildConfig.APPLICATION_ID) return false
|
if (context.packageManager.getUpdateOwnerPackageNameCompat(packageName) != BuildConfig.APPLICATION_ID) return false
|
||||||
@@ -127,7 +127,7 @@ class AppInstaller @Inject constructor(
|
|||||||
Installer.ROOT -> hasRootAccess()
|
Installer.ROOT -> hasRootAccess()
|
||||||
Installer.SERVICE -> false // Deprecated
|
Installer.SERVICE -> false // Deprecated
|
||||||
Installer.AM -> false // We cannot check if AppManager has ability to auto-update
|
Installer.AM -> false // We cannot check if AppManager has ability to auto-update
|
||||||
Installer.SHIZUKU -> isOAndAbove() && hasShizukuOrSui(context) && hasShizukuPerm()
|
Installer.SHIZUKU -> isOAndAbove && hasShizukuOrSui(context) && hasShizukuPerm()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ class AppInstaller @Inject constructor(
|
|||||||
val intent = Intent().apply {
|
val intent = Intent().apply {
|
||||||
data = Uri.fromParts("package", packageName, null)
|
data = Uri.fromParts("package", packageName, null)
|
||||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
if (isPAndAbove()) {
|
if (isPAndAbove) {
|
||||||
action = Intent.ACTION_DELETE
|
action = Intent.ACTION_DELETE
|
||||||
} else {
|
} else {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
@@ -211,7 +211,7 @@ class AppInstaller @Inject constructor(
|
|||||||
Installer.SERVICE -> if (hasAuroraService(context)) serviceInstaller else defaultInstaller
|
Installer.SERVICE -> if (hasAuroraService(context)) serviceInstaller else defaultInstaller
|
||||||
Installer.AM -> if (hasAppManager(context)) amInstaller else defaultInstaller
|
Installer.AM -> if (hasAppManager(context)) amInstaller else defaultInstaller
|
||||||
Installer.SHIZUKU -> {
|
Installer.SHIZUKU -> {
|
||||||
if (isOAndAbove() && hasShizukuOrSui(context) && hasShizukuPerm()) {
|
if (isOAndAbove && hasShizukuOrSui(context) && hasShizukuPerm()) {
|
||||||
shizukuInstaller
|
shizukuInstaller
|
||||||
} else {
|
} else {
|
||||||
defaultInstaller
|
defaultInstaller
|
||||||
|
|||||||
@@ -206,19 +206,19 @@ class SessionInstaller @Inject constructor(
|
|||||||
return SessionParams(SessionParams.MODE_FULL_INSTALL).apply {
|
return SessionParams(SessionParams.MODE_FULL_INSTALL).apply {
|
||||||
setAppPackageName(packageName)
|
setAppPackageName(packageName)
|
||||||
setInstallLocation(PackageInfo.INSTALL_LOCATION_AUTO)
|
setInstallLocation(PackageInfo.INSTALL_LOCATION_AUTO)
|
||||||
if (isNAndAbove()) {
|
if (isNAndAbove) {
|
||||||
setOriginatingUid(Process.myUid())
|
setOriginatingUid(Process.myUid())
|
||||||
}
|
}
|
||||||
if (isOAndAbove()) {
|
if (isOAndAbove) {
|
||||||
setInstallReason(PackageManager.INSTALL_REASON_USER)
|
setInstallReason(PackageManager.INSTALL_REASON_USER)
|
||||||
}
|
}
|
||||||
if (isSAndAbove()) {
|
if (isSAndAbove) {
|
||||||
setRequireUserAction(SessionParams.USER_ACTION_NOT_REQUIRED)
|
setRequireUserAction(SessionParams.USER_ACTION_NOT_REQUIRED)
|
||||||
}
|
}
|
||||||
if (isTAndAbove()) {
|
if (isTAndAbove) {
|
||||||
setPackageSource(PACKAGE_SOURCE_STORE)
|
setPackageSource(PACKAGE_SOURCE_STORE)
|
||||||
}
|
}
|
||||||
if (isUAndAbove()) {
|
if (isUAndAbove) {
|
||||||
setInstallerPackageName(context.packageName)
|
setInstallerPackageName(context.packageName)
|
||||||
setRequestUpdateOwnership(true)
|
setRequestUpdateOwnership(true)
|
||||||
setApplicationEnabledSettingPersistent()
|
setApplicationEnabledSettingPersistent()
|
||||||
|
|||||||
@@ -87,11 +87,11 @@ class ShizukuInstaller @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val packageInstaller: PackageInstaller? by lazy {
|
private val packageInstaller: PackageInstaller? by lazy {
|
||||||
if (isSAndAbove()) {
|
if (isSAndAbove) {
|
||||||
Refine.unsafeCast<PackageInstaller>(
|
Refine.unsafeCast<PackageInstaller>(
|
||||||
PackageInstallerHidden(iPackageInstaller, "com.android.vending", null, 0)
|
PackageInstallerHidden(iPackageInstaller, "com.android.vending", null, 0)
|
||||||
)
|
)
|
||||||
} else if (isOAndAbove()) {
|
} else if (isOAndAbove) {
|
||||||
Refine.unsafeCast<PackageInstaller>(
|
Refine.unsafeCast<PackageInstaller>(
|
||||||
PackageInstallerHidden(iPackageInstaller, "com.android.vending", 0)
|
PackageInstallerHidden(iPackageInstaller, "com.android.vending", 0)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class BlacklistProvider @Inject constructor(
|
|||||||
set(value) = Preferences.putString(context, PREFERENCE_BLACKLIST, gson.toJson(value))
|
set(value) = Preferences.putString(context, PREFERENCE_BLACKLIST, gson.toJson(value))
|
||||||
get() {
|
get() {
|
||||||
return try {
|
return try {
|
||||||
val rawBlacklist = if (isNAndAbove()) {
|
val rawBlacklist = if (isNAndAbove) {
|
||||||
val refMethod = Context::class.java.getDeclaredMethod(
|
val refMethod = Context::class.java.getDeclaredMethod(
|
||||||
"getSharedPreferences",
|
"getSharedPreferences",
|
||||||
File::class.java,
|
File::class.java,
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class NativeDeviceInfoProvider(val context: Context) {
|
|||||||
setProperty("SimOperator", "38")
|
setProperty("SimOperator", "38")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHuawei() && !isExport)
|
if (isHuawei && !isExport)
|
||||||
stripHuaweiProperties(properties)
|
stripHuaweiProperties(properties)
|
||||||
|
|
||||||
return properties
|
return properties
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class PermissionProvider(private val fragment: Fragment) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
PermissionType.POST_NOTIFICATIONS -> {
|
PermissionType.POST_NOTIFICATIONS -> {
|
||||||
if (isTAndAbove()) {
|
if (isTAndAbove) {
|
||||||
permissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
|
permissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ class PermissionProvider(private val fragment: Fragment) :
|
|||||||
PermissionType.INSTALL_UNKNOWN_APPS -> PackageUtil.canRequestPackageInstalls(context)
|
PermissionType.INSTALL_UNKNOWN_APPS -> PackageUtil.canRequestPackageInstalls(context)
|
||||||
|
|
||||||
PermissionType.POST_NOTIFICATIONS -> {
|
PermissionType.POST_NOTIFICATIONS -> {
|
||||||
if (isTAndAbove()) {
|
if (isTAndAbove) {
|
||||||
context.checkManifestPermission(Manifest.permission.POST_NOTIFICATIONS)
|
context.checkManifestPermission(Manifest.permission.POST_NOTIFICATIONS)
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
@@ -107,7 +107,7 @@ class PermissionProvider(private val fragment: Fragment) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
PermissionType.DOZE_WHITELIST -> {
|
PermissionType.DOZE_WHITELIST -> {
|
||||||
if (isMAndAbove()) context.isIgnoringBatteryOptimizations() else true
|
if (isMAndAbove) context.isIgnoringBatteryOptimizations() else true
|
||||||
}
|
}
|
||||||
|
|
||||||
PermissionType.APP_LINKS -> context.isDomainVerified("play.google.com") &&
|
PermissionType.APP_LINKS -> context.isDomainVerified("play.google.com") &&
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class MigrationReceiver : BroadcastReceiver() {
|
|||||||
|
|
||||||
// 63 -> 64
|
// 63 -> 64
|
||||||
if (currentVersion == 2) {
|
if (currentVersion == 2) {
|
||||||
if (isOAndAbove()) {
|
if (isOAndAbove) {
|
||||||
with(context.getSystemService<NotificationManager>()!!) { // !1189
|
with(context.getSystemService<NotificationManager>()!!) { // !1189
|
||||||
deleteNotificationChannel("NOTIFICATION_CHANNEL_GENERAL")
|
deleteNotificationChannel("NOTIFICATION_CHANNEL_GENERAL")
|
||||||
deleteNotificationChannel("NOTIFICATION_CHANNEL_ALERT")
|
deleteNotificationChannel("NOTIFICATION_CHANNEL_ALERT")
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class UnarchivePackageReceiver: BroadcastReceiver() {
|
|||||||
lateinit var downloadHelper: DownloadHelper
|
lateinit var downloadHelper: DownloadHelper
|
||||||
|
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
if (isVAndAbove() && context != null && intent?.action == Intent.ACTION_UNARCHIVE_PACKAGE) {
|
if (isVAndAbove && context != null && intent?.action == Intent.ACTION_UNARCHIVE_PACKAGE) {
|
||||||
val packageName = intent.getStringExtra(EXTRA_UNARCHIVE_PACKAGE_NAME)!!
|
val packageName = intent.getStringExtra(EXTRA_UNARCHIVE_PACKAGE_NAME)!!
|
||||||
Log.i(TAG, "Received request to unarchive $packageName")
|
Log.i(TAG, "Received request to unarchive $packageName")
|
||||||
|
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ class DownloadWorker @AssistedInject constructor(
|
|||||||
withContext(NonCancellable) {
|
withContext(NonCancellable) {
|
||||||
Log.i(TAG, "Failed downloading ${download.packageName}")
|
Log.i(TAG, "Failed downloading ${download.packageName}")
|
||||||
val cancelReasons = listOf(STOP_REASON_USER, STOP_REASON_CANCELLED_BY_APP)
|
val cancelReasons = listOf(STOP_REASON_USER, STOP_REASON_CANCELLED_BY_APP)
|
||||||
if (isSAndAbove() && stopReason in cancelReasons) {
|
if (isSAndAbove && stopReason in cancelReasons) {
|
||||||
notifyStatus(DownloadStatus.CANCELLED)
|
notifyStatus(DownloadStatus.CANCELLED)
|
||||||
} else {
|
} else {
|
||||||
notifyStatus(DownloadStatus.FAILED)
|
notifyStatus(DownloadStatus.FAILED)
|
||||||
@@ -222,7 +222,7 @@ class DownloadWorker @AssistedInject constructor(
|
|||||||
private fun purchase(packageName: String, versionCode: Int, offerType: Int): List<GPlayFile> {
|
private fun purchase(packageName: String, versionCode: Int, offerType: Int): List<GPlayFile> {
|
||||||
try {
|
try {
|
||||||
// Android 9.0+ supports key rotation, so purchase with latest certificate's hash
|
// Android 9.0+ supports key rotation, so purchase with latest certificate's hash
|
||||||
return if (isPAndAbove() && download.isInstalled) {
|
return if (isPAndAbove && download.isInstalled) {
|
||||||
purchaseHelper.purchase(
|
purchaseHelper.purchase(
|
||||||
packageName,
|
packageName,
|
||||||
versionCode,
|
versionCode,
|
||||||
@@ -349,7 +349,7 @@ class DownloadWorker @AssistedInject constructor(
|
|||||||
NotificationUtil.getDownloadNotification(appContext)
|
NotificationUtil.getDownloadNotification(appContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
return if (isQAndAbove()) {
|
return if (isQAndAbove) {
|
||||||
ForegroundInfo(NOTIFICATION_ID, notification, FOREGROUND_SERVICE_TYPE_DATA_SYNC)
|
ForegroundInfo(NOTIFICATION_ID, notification, FOREGROUND_SERVICE_TYPE_DATA_SYNC)
|
||||||
} else {
|
} else {
|
||||||
ForegroundInfo(NOTIFICATION_ID, notification)
|
ForegroundInfo(NOTIFICATION_ID, notification)
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ object CertUtil {
|
|||||||
private fun getX509Certificates(context: Context, packageName: String): List<X509Certificate> {
|
private fun getX509Certificates(context: Context, packageName: String): List<X509Certificate> {
|
||||||
return try {
|
return try {
|
||||||
val packageInfo = getPackageInfoWithSignature(context, packageName)
|
val packageInfo = getPackageInfoWithSignature(context, packageName)
|
||||||
if (isPAndAbove()) {
|
if (isPAndAbove) {
|
||||||
if (packageInfo.signingInfo!!.hasMultipleSigners()) {
|
if (packageInfo.signingInfo!!.hasMultipleSigners()) {
|
||||||
packageInfo.signingInfo!!.apkContentsSigners.map { it.generateX509Certificate() }
|
packageInfo.signingInfo!!.apkContentsSigners.map { it.generateX509Certificate() }
|
||||||
} else {
|
} else {
|
||||||
@@ -140,7 +140,7 @@ object CertUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getPackageInfoWithSignature(context: Context, packageName: String): PackageInfo {
|
private fun getPackageInfoWithSignature(context: Context, packageName: String): PackageInfo {
|
||||||
return if (isPAndAbove()) {
|
return if (isPAndAbove) {
|
||||||
getPackageInfo(context, packageName, PackageManager.GET_SIGNING_CERTIFICATES)
|
getPackageInfo(context, packageName, PackageManager.GET_SIGNING_CERTIFICATES)
|
||||||
} else {
|
} else {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ object PackageUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun isSharedLibrary(context: Context, packageName: String): Boolean {
|
fun isSharedLibrary(context: Context, packageName: String): Boolean {
|
||||||
return if (isOAndAbove()) {
|
return if (isOAndAbove) {
|
||||||
getAllSharedLibraries(context).any { it.name == packageName }
|
getAllSharedLibraries(context).any { it.name == packageName }
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
@@ -72,9 +72,9 @@ object PackageUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun isSharedLibraryInstalled(context: Context, packageName: String, versionCode: Int): Boolean {
|
fun isSharedLibraryInstalled(context: Context, packageName: String, versionCode: Int): Boolean {
|
||||||
return if (isOAndAbove()) {
|
return if (isOAndAbove) {
|
||||||
val sharedLibraries = getAllSharedLibraries(context)
|
val sharedLibraries = getAllSharedLibraries(context)
|
||||||
if (isPAndAbove()) {
|
if (isPAndAbove) {
|
||||||
sharedLibraries.any {
|
sharedLibraries.any {
|
||||||
it.name == packageName && it.longVersion == versionCode.toLong()
|
it.name == packageName && it.longVersion == versionCode.toLong()
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ object PackageUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getInstallUnknownAppsIntent(): Intent {
|
fun getInstallUnknownAppsIntent(): Intent {
|
||||||
return if (isOAndAbove()) {
|
return if (isOAndAbove) {
|
||||||
Intent(
|
Intent(
|
||||||
Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES,
|
Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES,
|
||||||
Uri.parse("package:${BuildConfig.APPLICATION_ID}")
|
Uri.parse("package:${BuildConfig.APPLICATION_ID}")
|
||||||
@@ -159,7 +159,7 @@ object PackageUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun canRequestPackageInstalls(context: Context): Boolean {
|
fun canRequestPackageInstalls(context: Context): Boolean {
|
||||||
return if (isOAndAbove()) {
|
return if (isOAndAbove) {
|
||||||
context.packageManager.canRequestPackageInstalls()
|
context.packageManager.canRequestPackageInstalls()
|
||||||
} else {
|
} else {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
@@ -174,7 +174,7 @@ object PackageUtil {
|
|||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun getPackageInfo(context: Context, packageName: String, flags: Int = 0): PackageInfo {
|
fun getPackageInfo(context: Context, packageName: String, flags: Int = 0): PackageInfo {
|
||||||
return if (isTAndAbove()) {
|
return if (isTAndAbove) {
|
||||||
context.packageManager.getPackageInfo(
|
context.packageManager.getPackageInfo(
|
||||||
packageName,
|
packageName,
|
||||||
PackageInfoFlags.of(flags.toLong())
|
PackageInfoFlags.of(flags.toLong())
|
||||||
@@ -200,9 +200,9 @@ object PackageUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getAllSharedLibraries(context: Context, flags: Int = 0): List<SharedLibraryInfo> {
|
private fun getAllSharedLibraries(context: Context, flags: Int = 0): List<SharedLibraryInfo> {
|
||||||
return if (isTAndAbove()) {
|
return if (isTAndAbove) {
|
||||||
context.packageManager.getSharedLibraries(PackageInfoFlags.of(flags.toLong()))
|
context.packageManager.getSharedLibraries(PackageInfoFlags.of(flags.toLong()))
|
||||||
} else if (isOAndAbove()) {
|
} else if (isOAndAbove) {
|
||||||
context.packageManager.getSharedLibraries(flags)
|
context.packageManager.getSharedLibraries(flags)
|
||||||
} else {
|
} else {
|
||||||
emptyList()
|
emptyList()
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class PermissionsFragment : BaseFragment<FragmentOnboardingPermissionsBinding>()
|
|||||||
Permission(
|
Permission(
|
||||||
PermissionType.INSTALL_UNKNOWN_APPS,
|
PermissionType.INSTALL_UNKNOWN_APPS,
|
||||||
getString(R.string.onboarding_permission_installer),
|
getString(R.string.onboarding_permission_installer),
|
||||||
if (isOAndAbove()) {
|
if (isOAndAbove) {
|
||||||
getString(R.string.onboarding_permission_installer_desc)
|
getString(R.string.onboarding_permission_installer_desc)
|
||||||
} else {
|
} else {
|
||||||
getString(R.string.onboarding_permission_installer_legacy_desc)
|
getString(R.string.onboarding_permission_installer_legacy_desc)
|
||||||
@@ -57,7 +57,7 @@ class PermissionsFragment : BaseFragment<FragmentOnboardingPermissionsBinding>()
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (isRAndAbove()) {
|
if (isRAndAbove) {
|
||||||
permissions.add(
|
permissions.add(
|
||||||
Permission(
|
Permission(
|
||||||
PermissionType.STORAGE_MANAGER,
|
PermissionType.STORAGE_MANAGER,
|
||||||
@@ -77,7 +77,7 @@ class PermissionsFragment : BaseFragment<FragmentOnboardingPermissionsBinding>()
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMAndAbove()) {
|
if (isMAndAbove) {
|
||||||
permissions.add(
|
permissions.add(
|
||||||
Permission(
|
Permission(
|
||||||
PermissionType.DOZE_WHITELIST,
|
PermissionType.DOZE_WHITELIST,
|
||||||
@@ -88,7 +88,7 @@ class PermissionsFragment : BaseFragment<FragmentOnboardingPermissionsBinding>()
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTAndAbove()) {
|
if (isTAndAbove) {
|
||||||
permissions.add(
|
permissions.add(
|
||||||
Permission(
|
Permission(
|
||||||
PermissionType.POST_NOTIFICATIONS,
|
PermissionType.POST_NOTIFICATIONS,
|
||||||
@@ -99,7 +99,7 @@ class PermissionsFragment : BaseFragment<FragmentOnboardingPermissionsBinding>()
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSAndAbove()) {
|
if (isSAndAbove) {
|
||||||
permissions.add(
|
permissions.add(
|
||||||
Permission(
|
Permission(
|
||||||
PermissionType.APP_LINKS,
|
PermissionType.APP_LINKS,
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class InstallerFragment : BaseFragment<FragmentInstallerBinding>() {
|
|||||||
|
|
||||||
installerId = Preferences.getInteger(requireContext(), PREFERENCE_INSTALLER_ID)
|
installerId = Preferences.getInteger(requireContext(), PREFERENCE_INSTALLER_ID)
|
||||||
|
|
||||||
if (isOAndAbove() && AppInstaller.hasShizukuOrSui(requireContext())) {
|
if (isOAndAbove && AppInstaller.hasShizukuOrSui(requireContext())) {
|
||||||
Shizuku.addBinderReceivedListenerSticky(shizukuAliveListener)
|
Shizuku.addBinderReceivedListenerSticky(shizukuAliveListener)
|
||||||
Shizuku.addBinderDeadListener(shizukuDeadListener)
|
Shizuku.addBinderDeadListener(shizukuDeadListener)
|
||||||
Shizuku.addRequestPermissionResultListener(shizukuResultListener)
|
Shizuku.addRequestPermissionResultListener(shizukuResultListener)
|
||||||
@@ -102,13 +102,13 @@ class InstallerFragment : BaseFragment<FragmentInstallerBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMIUI() && !isMiuiOptimizationDisabled()) {
|
if (isMIUI && !isMiuiOptimizationDisabled) {
|
||||||
findNavController().navigate(R.id.deviceMiuiSheet)
|
findNavController().navigate(R.id.deviceMiuiSheet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
if (isOAndAbove() && AppInstaller.hasShizukuOrSui(requireContext())) {
|
if (isOAndAbove && AppInstaller.hasShizukuOrSui(requireContext())) {
|
||||||
Shizuku.removeBinderReceivedListener(shizukuAliveListener)
|
Shizuku.removeBinderReceivedListener(shizukuAliveListener)
|
||||||
Shizuku.removeBinderDeadListener(shizukuDeadListener)
|
Shizuku.removeBinderDeadListener(shizukuDeadListener)
|
||||||
Shizuku.removeRequestPermissionResultListener(shizukuResultListener)
|
Shizuku.removeRequestPermissionResultListener(shizukuResultListener)
|
||||||
@@ -119,7 +119,7 @@ class InstallerFragment : BaseFragment<FragmentInstallerBinding>() {
|
|||||||
private fun save(installerId: Int) {
|
private fun save(installerId: Int) {
|
||||||
when (installerId) {
|
when (installerId) {
|
||||||
0 -> {
|
0 -> {
|
||||||
if (isMIUI() && !isMiuiOptimizationDisabled()) {
|
if (isMIUI && !isMiuiOptimizationDisabled) {
|
||||||
findNavController().navigate(R.id.deviceMiuiSheet)
|
findNavController().navigate(R.id.deviceMiuiSheet)
|
||||||
}
|
}
|
||||||
this.installerId = installerId
|
this.installerId = installerId
|
||||||
@@ -163,7 +163,7 @@ class InstallerFragment : BaseFragment<FragmentInstallerBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
5 -> {
|
5 -> {
|
||||||
if (isOAndAbove() && AppInstaller.hasShizukuOrSui(requireContext())) {
|
if (isOAndAbove && AppInstaller.hasShizukuOrSui(requireContext())) {
|
||||||
if (shizukuAlive && AppInstaller.hasShizukuPerm()) {
|
if (shizukuAlive && AppInstaller.hasShizukuPerm()) {
|
||||||
this.installerId = installerId
|
this.installerId = installerId
|
||||||
save(PREFERENCE_INSTALLER_ID, installerId)
|
save(PREFERENCE_INSTALLER_ID, installerId)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class UIPreference : BasePreferenceFragment() {
|
|||||||
setPreferencesFromResource(R.xml.preferences_ui, rootKey)
|
setPreferencesFromResource(R.xml.preferences_ui, rootKey)
|
||||||
|
|
||||||
findPreference<Preference>("PREFERENCE_APP_LANGUAGE")?.apply {
|
findPreference<Preference>("PREFERENCE_APP_LANGUAGE")?.apply {
|
||||||
if (isTAndAbove()) {
|
if (isTAndAbove) {
|
||||||
summary = Locale.getDefault().displayName
|
summary = Locale.getDefault().displayName
|
||||||
setOnPreferenceClickListener {
|
setOnPreferenceClickListener {
|
||||||
startActivity(Intent(Settings.ACTION_APP_LOCALE_SETTINGS).apply {
|
startActivity(Intent(Settings.ACTION_APP_LOCALE_SETTINGS).apply {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class NetworkDialogSheet : BaseDialogSheet<SheetNetworkBinding>() {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.btnAction.setOnClickListener {
|
binding.btnAction.setOnClickListener {
|
||||||
if (isQAndAbove()) {
|
if (isQAndAbove) {
|
||||||
startActivity(Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY))
|
startActivity(Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY))
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class NetworkViewModel @Inject constructor(
|
|||||||
val networkRequest = NetworkRequest.Builder()
|
val networkRequest = NetworkRequest.Builder()
|
||||||
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||||
|
|
||||||
if (isMAndAbove()) {
|
if (isMAndAbove) {
|
||||||
networkRequest.addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
|
networkRequest.addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user