OplusEuicc: Switch to PackageManager.getApplicationInfo()

Change-Id: Iccd792d147d61d324170ba4e3e2aa1b5a6910274
This commit is contained in:
LuK1337
2024-11-01 16:21:31 +01:00
committed by Bruno Martins
parent 1d143e35bc
commit 85febec1b5

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 The LineageOS Project
* Copyright (C) 2021-2024 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
@@ -8,7 +8,7 @@ package org.lineageos.euicc
import android.content.Context
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.content.pm.PackageManager.PackageInfoFlags
import android.content.pm.PackageManager.ApplicationInfoFlags
import android.util.Log
object EuiccDisabler {
@@ -25,14 +25,14 @@ object EuiccDisabler {
)
private fun isInstalled(pm: PackageManager, pkgName: String) = runCatching {
val info = pm.getPackageInfo(pkgName, PackageInfoFlags.of(0))
info.applicationInfo.flags and ApplicationInfo.FLAG_INSTALLED != 0
val info = pm.getApplicationInfo(pkgName, ApplicationInfoFlags.of(0))
info.flags and ApplicationInfo.FLAG_INSTALLED != 0
}.getOrDefault(false)
private fun isInstalledAndEnabled(pm: PackageManager, pkgName: String) = runCatching {
val info = pm.getPackageInfo(pkgName, PackageInfoFlags.of(0))
Log.d(TAG, "package $pkgName installed, enabled = ${info.applicationInfo.enabled}")
info.applicationInfo.enabled
val info = pm.getApplicationInfo(pkgName, ApplicationInfoFlags.of(0))
Log.d(TAG, "package $pkgName installed, enabled = ${info.enabled}")
info.enabled
}.getOrDefault(false)
fun enableOrDisableEuicc(context: Context) {