Search in sources :

Example 16 with Phone

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

the class IccCardProxy method handleMessage.

@Override
public void handleMessage(Message msg) {
    switch(msg.what) {
        case EVENT_RADIO_OFF_OR_UNAVAILABLE:
            mRadioState = mCi.getRadioState();
            updateExternalState();
            break;
        case EVENT_RADIO_ON:
            mRadioState = RadioState.RADIO_ON;
            if (!mInitialized) {
                updateQuietMode();
            } else {
                // updateQuietMode() triggers ICC_CHANGED, which eventually
                // calls updateExternalState; thus, we don't need this in the
                // above case
                updateExternalState();
            }
            break;
        case EVENT_ICC_CHANGED:
            if (mInitialized) {
                updateIccAvailability();
            }
            break;
        case EVENT_ICC_ABSENT:
            mAbsentRegistrants.notifyRegistrants();
            setExternalState(State.ABSENT);
            break;
        case EVENT_ICC_LOCKED:
            processLockedState();
            break;
        case EVENT_APP_READY:
            setExternalState(State.READY);
            break;
        case EVENT_RECORDS_LOADED:
            // Update the MCC/MNC.
            if (mIccRecords != null) {
                Phone currentPhone = PhoneFactory.getPhone(mPhoneId);
                String operator = currentPhone.getOperatorNumeric();
                log("operator=" + operator + " mPhoneId=" + mPhoneId);
                if (!TextUtils.isEmpty(operator)) {
                    mTelephonyManager.setSimOperatorNumericForPhone(mPhoneId, operator);
                    String countryCode = operator.substring(0, 3);
                    if (countryCode != null) {
                        mTelephonyManager.setSimCountryIsoForPhone(mPhoneId, MccTable.countryCodeForMcc(Integer.parseInt(countryCode)));
                    } else {
                        loge("EVENT_RECORDS_LOADED Country code is null");
                    }
                } else {
                    loge("EVENT_RECORDS_LOADED Operator name is null");
                }
            }
            if (mUiccCard != null && !mUiccCard.areCarrierPriviligeRulesLoaded()) {
                mUiccCard.registerForCarrierPrivilegeRulesLoaded(this, EVENT_CARRIER_PRIVILEGES_LOADED, null);
            } else {
                onRecordsLoaded();
            }
            break;
        case EVENT_IMSI_READY:
            broadcastIccStateChangedIntent(IccCardConstants.INTENT_VALUE_ICC_IMSI, null);
            break;
        case EVENT_NETWORK_LOCKED:
            mNetworkLockedRegistrants.notifyRegistrants();
            setExternalState(State.NETWORK_LOCKED);
            break;
        case EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED:
            updateQuietMode();
            break;
        case EVENT_SUBSCRIPTION_ACTIVATED:
            log("EVENT_SUBSCRIPTION_ACTIVATED");
            onSubscriptionActivated();
            break;
        case EVENT_SUBSCRIPTION_DEACTIVATED:
            log("EVENT_SUBSCRIPTION_DEACTIVATED");
            onSubscriptionDeactivated();
            break;
        case EVENT_ICC_RECORD_EVENTS:
            if ((mCurrentAppType == UiccController.APP_FAM_3GPP) && (mIccRecords != null)) {
                AsyncResult ar = (AsyncResult) msg.obj;
                int eventCode = (Integer) ar.result;
                if (eventCode == SIMRecords.EVENT_SPN) {
                    mTelephonyManager.setSimOperatorNameForPhone(mPhoneId, mIccRecords.getServiceProviderName());
                }
            }
            break;
        case EVENT_CARRIER_PRIVILEGES_LOADED:
            log("EVENT_CARRIER_PRIVILEGES_LOADED");
            if (mUiccCard != null) {
                mUiccCard.unregisterForCarrierPrivilegeRulesLoaded(this);
            }
            onRecordsLoaded();
            break;
        default:
            loge("Unhandled message with number: " + msg.what);
            break;
    }
}
Also used : Phone(com.android.internal.telephony.Phone) AsyncResult(android.os.AsyncResult)

Example 17 with Phone

use of com.android.internal.telephony.Phone in project android_packages_apps_Settings by SudaMod.

the class SimStatus method updatePhoneInfos.

private void updatePhoneInfos() {
    if (mSir != null) {
        // TODO: http://b/23763013
        final Phone phone = PhoneFactory.getPhone(SubscriptionManager.getPhoneId(mSir.getSubscriptionId()));
        if (UserManager.get(getContext()).isAdminUser() && SubscriptionManager.isValidSubscriptionId(mSir.getSubscriptionId())) {
            if (phone == null) {
                Log.e(TAG, "Unable to locate a phone object for the given Subscription ID.");
                return;
            }
            mPhone = phone;
            // To avoid register multiple listeners when user changes the tab.
            if (mPhoneStateListener != null && mTelephonyManager != null) {
                mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
                mPhoneStateListener = null;
            }
            mPhoneStateListener = new PhoneStateListener(mSir.getSubscriptionId()) {

                @Override
                public void onDataConnectionStateChanged(int state) {
                    updateDataState();
                    updateNetworkType();
                }

                @Override
                public void onSignalStrengthsChanged(SignalStrength signalStrength) {
                    updateSignalStrength(signalStrength);
                }

                @Override
                public void onServiceStateChanged(ServiceState serviceState) {
                    updateServiceState(serviceState);
                }
            };
        }
    }
}
Also used : ServiceState(android.telephony.ServiceState) Phone(com.android.internal.telephony.Phone) PhoneStateListener(android.telephony.PhoneStateListener) SignalStrength(android.telephony.SignalStrength)

Example 18 with Phone

use of com.android.internal.telephony.Phone in project android_packages_apps_Settings by SudaMod.

the class ImeiInformation method setPreferenceValue.

private void setPreferenceValue(int phoneId) {
    final Phone phone = PhoneFactory.getPhone(phoneId);
    if (phone != null) {
        if (phone.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
            setSummaryText(KEY_MEID_NUMBER, phone.getMeid());
            setSummaryText(KEY_MIN_NUMBER, phone.getCdmaMin());
            if (getResources().getBoolean(R.bool.config_msid_enable)) {
                findPreference(KEY_MIN_NUMBER).setTitle(R.string.status_msid_number);
            }
            setSummaryText(KEY_PRL_VERSION, phone.getCdmaPrlVersion());
            if (phone.getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE) {
                // Show ICC ID and IMEI for LTE device
                setSummaryText(KEY_ICC_ID, phone.getIccSerialNumber());
                setSummaryTextAsDigit(KEY_IMEI, phone.getImei());
                setSummaryTextAsDigit(KEY_IMEI_SV, phone.getDeviceSvn());
            } else {
                // device is not GSM/UMTS, do not display GSM/UMTS features
                // check Null in case no specified preference in overlay xml
                removePreferenceFromScreen(KEY_IMEI_SV);
                removePreferenceFromScreen(KEY_IMEI);
                removePreferenceFromScreen(KEY_ICC_ID);
            }
        } else {
            setSummaryTextAsDigit(KEY_IMEI, phone.getImei());
            setSummaryTextAsDigit(KEY_IMEI_SV, phone.getDeviceSvn());
            // device is not CDMA, do not display CDMA features
            // check Null in case no specified preference in overlay xml
            removePreferenceFromScreen(KEY_PRL_VERSION);
            removePreferenceFromScreen(KEY_MEID_NUMBER);
            removePreferenceFromScreen(KEY_MIN_NUMBER);
            removePreferenceFromScreen(KEY_ICC_ID);
        }
    }
}
Also used : Phone(com.android.internal.telephony.Phone)

Example 19 with Phone

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

the class MetricsCollector method pullSupportedRadioAccessFamily.

private static int pullSupportedRadioAccessFamily(List<StatsEvent> data) {
    long rafSupported = 0L;
    try {
        // The bitmask is defined in android.telephony.TelephonyManager.NetworkTypeBitMask
        for (Phone phone : PhoneFactory.getPhones()) {
            rafSupported |= phone.getRadioAccessFamily();
        }
    } catch (IllegalStateException e) {
        // Phones have not been made yet
        return StatsManager.PULL_SKIP;
    }
    StatsEvent e = StatsEvent.newBuilder().setAtomId(SUPPORTED_RADIO_ACCESS_FAMILY).writeLong(rafSupported).build();
    data.add(e);
    return StatsManager.PULL_SUCCESS;
}
Also used : Phone(com.android.internal.telephony.Phone) StatsEvent(android.util.StatsEvent)

Example 20 with Phone

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

the class VendorSubscriptionController method setUiccApplicationsEnabled.

@Override
public int setUiccApplicationsEnabled(boolean enabled, int subId) {
    if (DBG)
        logd("[setUiccApplicationsEnabled]+ enabled:" + enabled + " subId:" + subId);
    ContentValues value = new ContentValues(1);
    value.put(SubscriptionManager.UICC_APPLICATIONS_ENABLED, enabled);
    int result = mContext.getContentResolver().update(SubscriptionManager.getUriForSubscriptionId(subId), value, null, null);
    // Refresh the Cache of Active Subscription Info List
    refreshCachedActiveSubscriptionInfoList();
    notifySubscriptionInfoChanged();
    if (isActiveSubId(subId)) {
        Phone phone = PhoneFactory.getPhone(getPhoneId(subId));
        phone.enableUiccApplications(enabled, Message.obtain(mSubscriptionHandler, EVENT_UICC_APPS_ENABLEMENT_DONE, enabled));
    }
    return result;
}
Also used : ContentValues(android.content.ContentValues) Phone(com.android.internal.telephony.Phone)

Aggregations

Phone (com.android.internal.telephony.Phone)21 PhoneStateListener (android.telephony.PhoneStateListener)7 ServiceState (android.telephony.ServiceState)7 SignalStrength (android.telephony.SignalStrength)7 ContentValues (android.content.ContentValues)1 AsyncResult (android.os.AsyncResult)1 PersistableBundle (android.os.PersistableBundle)1 CarrierConfigManager (android.telephony.CarrierConfigManager)1 SubscriptionInfo (android.telephony.SubscriptionInfo)1 StatsEvent (android.util.StatsEvent)1 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)1 SubscriptionController (com.android.internal.telephony.SubscriptionController)1