Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec13c490 authored by Eugene Susla's avatar Eugene Susla
Browse files

Fix carrier privileged exemption to consider all sim cards

Test: presubmit
Bug: 153607914
Change-Id: I98d15a4c726cc019e693799e4ecc94400b64f8d5
parent 1710572e
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -24,26 +24,27 @@ import com.android.permissioncontroller.PermissionControllerApplication
 * A LiveData which represents the carrier privileged status for a package
 *
 * @param app The current application
 * @param uid The uid of the package
 * @param packageName The name of the package
 */
class CarrierPrivilegedStatusLiveData private constructor(
    private val app: Application,
    private val uid: Int
    private val packageName: String
) : SmartUpdateMediatorLiveData<Int>() {

    val telephonyManager = app.getSystemService(TelephonyManager::class.java)!!

    override fun onUpdate() {
        value = telephonyManager.getCarrierPrivilegeStatus(uid)
        value = telephonyManager.checkCarrierPrivilegesForPackageAnyPhone(packageName)
    }

    /**
     * Repository for [CarrierPrivilegedStatusLiveData].
     * <p> Key value is a package uid, value is its corresponding LiveData.
     * <p> Key value is a package name, value is its corresponding LiveData of
     * [android.telephony.Annotation.CarrierPrivilegeStatus]
     */
    companion object
        : DataRepository<Int, CarrierPrivilegedStatusLiveData>() {
        override fun newValue(key: Int): CarrierPrivilegedStatusLiveData {
        : DataRepository<String, CarrierPrivilegedStatusLiveData>() {
        override fun newValue(key: String): CarrierPrivilegedStatusLiveData {
            return CarrierPrivilegedStatusLiveData(PermissionControllerApplication.get(), key)
        }
    }
+1 −2
Original line number Diff line number Diff line
@@ -114,7 +114,6 @@ import com.android.permissioncontroller.permission.utils.Utils.PROPERTY_AUTO_REV
import com.android.permissioncontroller.permission.utils.Utils.PROPERTY_AUTO_REVOKE_UNUSED_THRESHOLD_MILLIS
import com.android.permissioncontroller.permission.utils.application
import com.android.permissioncontroller.permission.utils.forEachInParallel
import com.android.permissioncontroller.permission.utils.getUid
import com.android.permissioncontroller.permission.utils.updatePermissionFlags
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.GlobalScope
@@ -461,7 +460,7 @@ suspend fun isPackageAutoRevokePermanentlyExempt(
        }
        return true
    }
    val carrierPrivilegedStatus = CarrierPrivilegedStatusLiveData[user.getUid(pkg.uid)]
    val carrierPrivilegedStatus = CarrierPrivilegedStatusLiveData[pkg.packageName]
            .getInitializedValue()
    if (carrierPrivilegedStatus != CARRIER_PRIVILEGE_STATUS_HAS_ACCESS &&
            carrierPrivilegedStatus != CARRIER_PRIVILEGE_STATUS_NO_ACCESS) {