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