Search in sources :

Example 1 with UiccProfile

use of com.android.internal.telephony.uicc.UiccProfile in project android_frameworks_opt_telephony by LineageOS.

the class GsmCdmaPhone method initRatSpecific.

private void initRatSpecific(int precisePhoneType) {
    mPendingMMIs.clear();
    mIccPhoneBookIntManager.updateIccRecords(null);
    mEsn = null;
    mMeid = null;
    mPrecisePhoneType = precisePhoneType;
    logd("Precise phone type " + mPrecisePhoneType);
    TelephonyManager tm = TelephonyManager.from(mContext);
    UiccProfile uiccProfile = getUiccProfile();
    if (isPhoneTypeGsm()) {
        mCi.setPhoneType(PhoneConstants.PHONE_TYPE_GSM);
        tm.setPhoneType(getPhoneId(), PhoneConstants.PHONE_TYPE_GSM);
        if (uiccProfile != null) {
            uiccProfile.setVoiceRadioTech(ServiceState.RIL_RADIO_TECHNOLOGY_UMTS);
        }
    } else {
        mCdmaSubscriptionSource = mCdmaSSM.getCdmaSubscriptionSource();
        // This is needed to handle phone process crashes
        mIsPhoneInEcmState = getInEcmMode();
        if (mIsPhoneInEcmState) {
            // Send a message which will invoke handleExitEmergencyCallbackMode
            mCi.exitEmergencyCallbackMode(null);
        }
        mCi.setPhoneType(PhoneConstants.PHONE_TYPE_CDMA);
        tm.setPhoneType(getPhoneId(), PhoneConstants.PHONE_TYPE_CDMA);
        if (uiccProfile != null) {
            uiccProfile.setVoiceRadioTech(ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT);
        }
        // Sets operator properties by retrieving from build-time system property
        String operatorAlpha = SystemProperties.get("ro.cdma.home.operator.alpha");
        String operatorNumeric = SystemProperties.get(PROPERTY_CDMA_HOME_OPERATOR_NUMERIC);
        logd("init: operatorAlpha='" + operatorAlpha + "' operatorNumeric='" + operatorNumeric + "'");
        if (!TextUtils.isEmpty(operatorAlpha)) {
            logd("init: set 'gsm.sim.operator.alpha' to operator='" + operatorAlpha + "'");
            tm.setSimOperatorNameForPhone(mPhoneId, operatorAlpha);
        }
        if (!TextUtils.isEmpty(operatorNumeric)) {
            logd("init: set 'gsm.sim.operator.numeric' to operator='" + operatorNumeric + "'");
            logd("update icc_operator_numeric=" + operatorNumeric);
            tm.setSimOperatorNumericForPhone(mPhoneId, operatorNumeric);
            // Sets iso country property by retrieving from build-time system property
            String iso = "";
            try {
                iso = MccTable.countryCodeForMcc(operatorNumeric.substring(0, 3));
            } catch (StringIndexOutOfBoundsException ex) {
                Rlog.e(LOG_TAG, "init: countryCodeForMcc error", ex);
            }
            logd("init: set 'gsm.sim.operator.iso-country' to iso=" + iso);
            tm.setSimCountryIsoForPhone(mPhoneId, iso);
            // Skip if the subscription ID is not valid, because it can happen
            // that the SIM is not loaded yet at this point.
            final int subId = getSubId();
            if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
                SubscriptionController.getInstance().setMccMnc(operatorNumeric, subId);
                SubscriptionController.getInstance().setCountryIso(iso, subId);
            }
            // Updates MCC MNC device configuration information
            logd("update mccmnc=" + operatorNumeric);
            MccTable.updateMccMncConfiguration(mContext, operatorNumeric);
        }
        // Sets current entry in the telephony carrier table
        updateCurrentCarrierInProvider(operatorNumeric);
    }
}
Also used : UiccProfile(com.android.internal.telephony.uicc.UiccProfile) TelephonyManager(android.telephony.TelephonyManager)

Example 2 with UiccProfile

use of com.android.internal.telephony.uicc.UiccProfile in project android_frameworks_opt_telephony by LineageOS.

the class GsmCdmaPhone method phoneObjectUpdater.

protected void phoneObjectUpdater(int newVoiceRadioTech) {
    logd("phoneObjectUpdater: newVoiceRadioTech=" + newVoiceRadioTech);
    // Check for a voice over LTE/NR replacement
    if (ServiceState.isPsOnlyTech(newVoiceRadioTech) || (newVoiceRadioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN)) {
        CarrierConfigManager configMgr = (CarrierConfigManager) getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
        PersistableBundle b = configMgr.getConfigForSubId(getSubId());
        if (b != null) {
            int volteReplacementRat = b.getInt(CarrierConfigManager.KEY_VOLTE_REPLACEMENT_RAT_INT);
            logd("phoneObjectUpdater: volteReplacementRat=" + volteReplacementRat);
            if (volteReplacementRat != ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN && // In cdma case, replace rat only if csim or ruim app present
            (ServiceState.isGsm(volteReplacementRat) || isCdmaSubscriptionAppPresent())) {
                newVoiceRadioTech = volteReplacementRat;
            }
        } else {
            loge("phoneObjectUpdater: didn't get volteReplacementRat from carrier config");
        }
    }
    if (mRilVersion == 6 && getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE) {
        /*
             * On v6 RIL, when LTE_ON_CDMA is TRUE, always create CDMALTEPhone
             * irrespective of the voice radio tech reported.
             */
        if (getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
            logd("phoneObjectUpdater: LTE ON CDMA property is set. Use CDMA Phone" + " newVoiceRadioTech=" + newVoiceRadioTech + " mActivePhone=" + getPhoneName());
            return;
        } else {
            logd("phoneObjectUpdater: LTE ON CDMA property is set. Switch to CDMALTEPhone" + " newVoiceRadioTech=" + newVoiceRadioTech + " mActivePhone=" + getPhoneName());
            newVoiceRadioTech = ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT;
        }
    } else {
        // which might send unnecessary attach request to the modem.
        if (isShuttingDown()) {
            logd("Device is shutting down. No need to switch phone now.");
            return;
        }
        boolean matchCdma = ServiceState.isCdma(newVoiceRadioTech);
        boolean matchGsm = ServiceState.isGsm(newVoiceRadioTech);
        if ((matchCdma && getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) || (matchGsm && getPhoneType() == PhoneConstants.PHONE_TYPE_GSM)) {
            // Nothing changed. Keep phone as it is.
            logd("phoneObjectUpdater: No change ignore," + " newVoiceRadioTech=" + newVoiceRadioTech + " mActivePhone=" + getPhoneName());
            return;
        }
        if (!matchCdma && !matchGsm) {
            loge("phoneObjectUpdater: newVoiceRadioTech=" + newVoiceRadioTech + " doesn't match either CDMA or GSM - error! No phone change");
            return;
        }
    }
    if (newVoiceRadioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) {
        // We need some voice phone object to be active always, so never
        // delete the phone without anything to replace it with!
        logd("phoneObjectUpdater: Unknown rat ignore, " + " newVoiceRadioTech=Unknown. mActivePhone=" + getPhoneName());
        return;
    }
    // old power state to off
    boolean oldPowerState = false;
    if (mResetModemOnRadioTechnologyChange) {
        if (mCi.getRadioState() == TelephonyManager.RADIO_POWER_ON) {
            oldPowerState = true;
            logd("phoneObjectUpdater: Setting Radio Power to Off");
            mCi.setRadioPower(false, null);
        }
    }
    switchVoiceRadioTech(newVoiceRadioTech);
    if (mResetModemOnRadioTechnologyChange && oldPowerState) {
        // restore power state
        logd("phoneObjectUpdater: Resetting Radio");
        mCi.setRadioPower(oldPowerState, null);
    }
    // update voice radio tech in UiccProfile
    UiccProfile uiccProfile = getUiccProfile();
    if (uiccProfile != null) {
        uiccProfile.setVoiceRadioTech(newVoiceRadioTech);
    }
    // Send an Intent to the PhoneApp that we had a radio technology change
    Intent intent = new Intent(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
    intent.putExtra(PhoneConstants.PHONE_NAME_KEY, getPhoneName());
    SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhoneId);
    mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
}
Also used : CarrierConfigManager(android.telephony.CarrierConfigManager) PersistableBundle(android.os.PersistableBundle) UiccProfile(com.android.internal.telephony.uicc.UiccProfile) Intent(android.content.Intent)

Example 3 with UiccProfile

use of com.android.internal.telephony.uicc.UiccProfile in project android_frameworks_opt_telephony by LineageOS.

the class GsmCdmaPhoneTest method testGetEmptyIccCard.

@Test
@SmallTest
public void testGetEmptyIccCard() {
    doReturn(null).when(mUiccController).getUiccProfileForPhone(anyInt());
    IccCard iccCard = mPhoneUT.getIccCard();
    // The iccCard should be a dummy object, not null.
    assertTrue(!(iccCard instanceof UiccProfile));
    assertTrue(iccCard != null);
    assertEquals(IccCardConstants.State.UNKNOWN, iccCard.getState());
    assertEquals(null, iccCard.getIccRecords());
    assertEquals(false, iccCard.getIccLockEnabled());
    assertEquals(false, iccCard.getIccFdnEnabled());
    assertEquals(false, iccCard.isApplicationOnIcc(IccCardApplicationStatus.AppType.APPTYPE_SIM));
    assertEquals(false, iccCard.hasIccCard());
    assertEquals(false, iccCard.getIccPin2Blocked());
    assertEquals(false, iccCard.getIccPuk2Blocked());
    Message onComplete = mTestHandler.obtainMessage(EVENT_SET_ICC_LOCK_ENABLED);
    iccCard.setIccLockEnabled(true, "password", onComplete);
    processAllMessages();
    ArgumentCaptor<Message> messageArgumentCaptor = ArgumentCaptor.forClass(Message.class);
    // Verify that message is sent back with exception.
    verify(mTestHandler, times(1)).sendMessageAtTime(messageArgumentCaptor.capture(), anyLong());
    Message message = messageArgumentCaptor.getAllValues().get(0);
    AsyncResult ret = (AsyncResult) message.obj;
    assertEquals(EVENT_SET_ICC_LOCK_ENABLED, message.what);
    assertTrue(ret.exception != null);
}
Also used : UiccProfile(com.android.internal.telephony.uicc.UiccProfile) Message(android.os.Message) AsyncResult(android.os.AsyncResult) FlakyTest(androidx.test.filters.FlakyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 4 with UiccProfile

use of com.android.internal.telephony.uicc.UiccProfile in project android_frameworks_opt_telephony by LineageOS.

the class IccSmsInterfaceManager method getSmsCapacityOnIcc.

public int getSmsCapacityOnIcc() {
    mContext.enforceCallingOrSelfPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, "getSmsCapacityOnIcc");
    int numberOnIcc = 0;
    if (mPhone.getIccRecordsLoaded()) {
        final UiccProfile uiccProfile = UiccController.getInstance().getUiccProfileForPhone(mPhone.getPhoneId());
        if (uiccProfile != null) {
            numberOnIcc = uiccProfile.getIccRecords().getSmsCapacityOnIcc();
        } else {
            loge("uiccProfile is null");
        }
    } else {
        loge("getSmsCapacityOnIcc - aborting, no icc card present.");
    }
    log("getSmsCapacityOnIcc().numberOnIcc = " + numberOnIcc);
    return numberOnIcc;
}
Also used : UiccProfile(com.android.internal.telephony.uicc.UiccProfile)

Example 5 with UiccProfile

use of com.android.internal.telephony.uicc.UiccProfile in project android_frameworks_opt_telephony by LineageOS.

the class ServiceStateTracker method getOperatorBrandOverride.

private String getOperatorBrandOverride() {
    UiccCard card = mPhone.getUiccCard();
    if (card == null)
        return null;
    UiccProfile profile = card.getUiccProfile();
    if (profile == null)
        return null;
    return profile.getOperatorBrandOverride();
}
Also used : UiccCard(com.android.internal.telephony.uicc.UiccCard) UiccProfile(com.android.internal.telephony.uicc.UiccProfile)

Aggregations

UiccProfile (com.android.internal.telephony.uicc.UiccProfile)5 Intent (android.content.Intent)1 AsyncResult (android.os.AsyncResult)1 Message (android.os.Message)1 PersistableBundle (android.os.PersistableBundle)1 CarrierConfigManager (android.telephony.CarrierConfigManager)1 TelephonyManager (android.telephony.TelephonyManager)1 SmallTest (android.test.suitebuilder.annotation.SmallTest)1 FlakyTest (androidx.test.filters.FlakyTest)1 UiccCard (com.android.internal.telephony.uicc.UiccCard)1 Test (org.junit.Test)1