/** * Returns a resource ID for a label to use when displaying the "device id" of the current device. * (This is currently used as the title of the "device id" dialog.) * * <p>This is specific to the device's telephony technology: the device id is called "IMEI" on GSM * phones and "MEID" on CDMA phones. TODO: ultimately this name should come directly from the * telephony layer. */ /* package */ static int getDeviceIdLabel(Phone phone) { if (phone.getPhoneType() == Phone.PHONE_TYPE_GSM) { return R.string.imei; } else if (phone.getPhoneType() == Phone.PHONE_TYPE_CDMA) { return R.string.meid; } else { Log.w(LOG_TAG, "getDeviceIdLabel: no known label for phone " + phone.getPhoneName()); return 0; } }
/* package */ Call onNewRingingConnection(Connection conn) { Log.i(TAG, "onNewRingingConnection"); final Call call = getCallFromMap(mCallMap, conn, true); if (call != null) { Phone phone = conn.getCall().getPhone(); if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM && mNextGsmCallIsForwarded) { call.setForwarded(true); mNextGsmCallIsForwarded = false; } updateCallFromConnection(call, conn, false); for (int i = 0; i < mListeners.size(); ++i) { mListeners.get(i).onIncoming(call); } if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) { int subscription = conn.getCall().getPhone().getSubscription(); Log.i(TAG, "Setting Active sub : '" + subscription + "'"); PhoneUtils.setActiveSubscription(subscription); // if any local hold tones are playing then they need to be stoped. final MSimCallNotifier notifier = (MSimCallNotifier) PhoneGlobals.getInstance().notifier; notifier.manageLocalCallWaitingTone(); } } PhoneGlobals.getInstance().updateWakeState(); return call; }
/** * On GSM devices, we never use short tones. On CDMA devices, it depends upon the settings. TODO: * I don't think this has anything to do with GSM versus CDMA, should we be looking only at the * setting? */ /* package */ static boolean useShortDtmfTones(Phone phone, Context context) { int toneType; int phoneType = phone.getPhoneType(); if (phoneType == Phone.PHONE_TYPE_GSM) { return false; } else if (phoneType == Phone.PHONE_TYPE_CDMA) { if (TelephonyManager.getDefault().isMultiSimEnabled()) { toneType = android.provider.Settings.System.getInt( context.getContentResolver(), Settings.System.DTMF_TONE_TYPE_WHEN_DIALING, MSimCallFeaturesSetting.DTMF_TONE_TYPE_NORMAL); } else { toneType = android.provider.Settings.System.getInt( context.getContentResolver(), Settings.System.DTMF_TONE_TYPE_WHEN_DIALING, CallFeaturesSetting.DTMF_TONE_TYPE_NORMAL); } if (toneType == CallFeaturesSetting.DTMF_TONE_TYPE_NORMAL) { return true; } else { return false; } } else if (phoneType == Phone.PHONE_TYPE_SIP) { return false; } else { throw new IllegalStateException("Unexpected phone type: " + phoneType); } }
/** * Get phone by slotId * * @param phone * @param slotId * @return */ public static Phone getPhoneBySlotId(Phone phone, int slotId) { Phone selectedPhone = phone; boolean isSipPhone = phone.getPhoneType() == PhoneConstants.PHONE_TYPE_SIP; if (GeminiUtils.isGeminiSupport() && !isSipPhone) { selectedPhone = ((GeminiPhone) phone).getPhonebyId(slotId); } PhoneLog.d(TAG, "[getPhoneBySlotId], selectedPhone = " + selectedPhone); return selectedPhone; }
/** * Logs a call to the call log based on the connection object passed in. * * @param c The connection object for the call being logged. * @param callLogType The type of call log entry. * @param slotId The slot id for the call being logged. */ public void logCall(Connection c, int callLogType, int slotId) { final String number = c.getAddress(); final long date = c.getCreateTime(); final long duration = c.getDurationMillis(); final Phone phone = c.getCall().getPhone(); final CallerInfo ci = getCallerInfoFromConnection(c); // May be null. final String logNumber = getLogNumber(c, ci); if (DBG) { log( "- onDisconnect(): logNumber set to:" + PhoneUtils.toLogSafePhoneNumber(logNumber) + ", number set to: " + PhoneUtils.toLogSafePhoneNumber(number)); } /// M: @{ mPhoneType = phone.getPhoneType(); mIsComing = c.isIncoming(); if (FeatureOption.MTK_VT3G324M_SUPPORT) { mVtCall = c.isVideo() ? 1 : 0; } PhoneLog.d(LOG_TAG, "number=" + number + ", duration=" + duration + ", isVT=" + mVtCall); /// @} /// M: For ALPS00114062 @{ // show every connection's last time of conference call. if (needToShowCallTime(c, duration)) { Toast.makeText( mApplication.getApplicationContext(), formatDuration((int) (duration / 1000)), Toast.LENGTH_SHORT) .show(); } /// @} // TODO: In getLogNumber we use the presentation from // the connection for the CNAP. Should we use the one // below instead? (comes from caller info) // For international calls, 011 needs to be logged as + final int presentation = getPresentation(c, ci); final boolean isOtaspNumber = TelephonyCapabilities.supportsOtasp(phone) && phone.isOtaSpNumber(number); // Don't log OTASP calls. if (!isOtaspNumber) { logCall(ci, logNumber, presentation, callLogType, date, duration, slotId); } }
/** * Becasue of support G+C, the GeminiPhone may contains CDMAPhone, so must get the exactly phone * type: * * @param phone * @return */ public static int getPhoneType(Phone phone, int slotId) { Assert.assertNotNull(phone); int phoneType = PhoneConstants.PHONE_TYPE_NONE; if (GeminiUtils.isGeminiSupport() && phone instanceof GeminiPhone) { if (GeminiUtils.isValidSlot(slotId)) { phoneType = ((GeminiPhone) phone).getPhonebyId(slotId).getPhoneType(); } } else { phoneType = phone.getPhoneType(); } PhoneLog.d(TAG, "getPhoneType, slotId:" + slotId + ", phoneType:" + phoneType); return phoneType; }
private void updatePreference() { if (mPhone.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) { // only show area info when SIM country is Brazil if ("br".equals(mTelephonyManager.getSimCountryIso(mUtility.getSubId()))) { mShowLatestAreaInfo = true; } } String rawNumber = mPhone.getLine1Number(); // may be null or empty String formattedNumber = null; if (!TextUtils.isEmpty(rawNumber)) { formattedNumber = PhoneNumberUtils.formatNumber(rawNumber); } // If formattedNumber is null or empty, it'll display as "Unknown". setSummaryText(KEY_PHONE_NUMBER, formattedNumber); if (!mShowLatestAreaInfo) { removePreferenceFromScreen(KEY_LATEST_AREA_INFO); } }
public int getActivePhoneType() { return mPhone.getPhoneType(); }
/** Returns a mask of capabilities for the connection such as merge, hold, etc. */ private int getCapabilitiesFor(Connection connection, Call call, boolean isForConference) { final boolean callIsActive = (call.getState() == Call.State.ACTIVE); final boolean callIsBackground = (call.getState() == Call.State.ONHOLD); final Phone phone = connection.getCall().getPhone(); boolean canAddCall = false; boolean canMergeCall = false; boolean canSwapCall = false; boolean canRespondViaText = false; boolean canMute = false; boolean canAddParticipant = false; boolean canModifyCall = false; boolean voicePrivacy = false; final boolean supportHold; final boolean canHold; final boolean genericConf = isForConference && (connection.getCall().getPhone().getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA); if (!MSimTelephonyManager.getDefault().isMultiSimEnabled()) { supportHold = PhoneUtils.okToSupportHold(mCallManager); canHold = (supportHold ? PhoneUtils.okToHoldCall(mCallManager) : false); // only applies to active calls if (callIsActive) { canMergeCall = PhoneUtils.okToMergeCalls(mCallManager); canSwapCall = PhoneUtils.okToSwapCalls(mCallManager); } canAddCall = PhoneUtils.okToAddCall(mCallManager); } else { final int subscription = call.getSubscription(); supportHold = PhoneUtils.okToSupportHold(mCallManager, subscription); canHold = (supportHold ? PhoneUtils.okToHoldCall(mCallManager, subscription) : false); // only applies to active calls if (callIsActive) { canMergeCall = PhoneUtils.okToMergeCalls(mCallManager, subscription); canSwapCall = PhoneUtils.okToSwapCalls(mCallManager, subscription); } canAddCall = PhoneUtils.okToAddCall(mCallManager, subscription); } if (callIsActive || callIsBackground) { canModifyCall = PhoneUtils.isVTModifyAllowed(connection); } canAddParticipant = PhoneUtils.canAddParticipant(mCallManager) && canAddCall; // "Mute": only enabled when the foreground call is ACTIVE. // (It's meaningless while on hold, or while DIALING/ALERTING.) // It's also explicitly disabled during emergency calls or if // emergency callback mode (ECM) is active. boolean isEmergencyCall = false; if (connection != null) { isEmergencyCall = PhoneNumberUtils.isLocalEmergencyNumber(connection.getAddress(), phone.getContext()); } boolean isECM = PhoneUtils.isPhoneInEcm(phone); if (isEmergencyCall || isECM) { // disable "Mute" item canMute = false; } else { canMute = callIsActive; } canRespondViaText = RejectWithTextMessageManager.allowRespondViaSmsForCall(call, connection); // special rules section! // CDMA always has Add if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) { canAddCall = true; } // Voice Privacy for CDMA if ((phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) && mVoicePrivacyState) { voicePrivacy = true; } int retval = 0x0; if (canHold) { retval |= Capabilities.HOLD; } if (supportHold) { retval |= Capabilities.SUPPORT_HOLD; } if (canAddCall) { retval |= Capabilities.ADD_CALL; } if (canMergeCall) { retval |= Capabilities.MERGE_CALLS; } if (canSwapCall) { retval |= Capabilities.SWAP_CALLS; } if (canRespondViaText) { retval |= Capabilities.RESPOND_VIA_TEXT; } if (canMute) { retval |= Capabilities.MUTE; } if (canAddParticipant) { retval |= Capabilities.ADD_PARTICIPANT; } if (genericConf) { retval |= Capabilities.GENERIC_CONFERENCE; } if (canModifyCall) { retval |= Capabilities.MODIFY_CALL; } if (voicePrivacy) { retval |= Capabilities.VOICE_PRIVACY; } return retval; }
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); PhoneApp app = PhoneApp.getInstance(); addPreferencesFromResource(R.xml.msim_network_settings); mSubscription = getIntent().getIntExtra(SUBSCRIPTION_KEY, app.getDefaultSubscription()); log("Settings onCreate subscription =" + mSubscription); mPhone = app.getPhone(mSubscription); mHandler = new MyHandler(); // get UI object references PreferenceScreen prefSet = getPreferenceScreen(); mButtonPreferredNetworkMode = (ListPreference) prefSet.findPreference(BUTTON_PREFERED_NETWORK_MODE); boolean isLteOnCdma = mPhone.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE; if (getResources().getBoolean(R.bool.world_phone) == true) { if (SystemProperties.getBoolean("ro.monkey", false)) { prefSet.removePreference(mButtonPreferredNetworkMode); } else { // set the listener for the mButtonPreferredNetworkMode list // preference so we can issue change Preferred Network Mode. mButtonPreferredNetworkMode.setOnPreferenceChangeListener(this); // Get the networkMode from Settings.System and displays it int settingsNetworkMode = android.provider.Settings.Secure.getInt( mPhone.getContext().getContentResolver(), android.provider.Settings.Secure.PREFERRED_NETWORK_MODE, preferredNetworkMode); mButtonPreferredNetworkMode.setValue(Integer.toString(settingsNetworkMode)); mCdmaOptions = new CdmaOptions(this, prefSet, mPhone); mGsmUmtsOptions = new GsmUmtsOptions(this, prefSet, mSubscription); } } else { if (!isLteOnCdma) { prefSet.removePreference(mButtonPreferredNetworkMode); } int phoneType = mPhone.getPhoneType(); if (phoneType == Phone.PHONE_TYPE_CDMA) { mCdmaOptions = new CdmaOptions(this, prefSet, mPhone); if (isLteOnCdma) { mButtonPreferredNetworkMode.setOnPreferenceChangeListener(this); mButtonPreferredNetworkMode.setEntries(R.array.preferred_network_mode_choices_lte); mButtonPreferredNetworkMode.setEntryValues(R.array.preferred_network_mode_values_lte); int settingsNetworkMode = android.provider.Settings.Secure.getInt( mPhone.getContext().getContentResolver(), android.provider.Settings.Secure.PREFERRED_NETWORK_MODE, preferredNetworkMode); mButtonPreferredNetworkMode.setValue(Integer.toString(settingsNetworkMode)); } } else if (phoneType == Phone.PHONE_TYPE_GSM) { mGsmUmtsOptions = new GsmUmtsOptions(this, prefSet, mSubscription); } else { throw new IllegalStateException("Unexpected phone type: " + phoneType); } } }
/** * Return true if the current phone supports ECM ("Emergency Callback Mode"), which is a feature * where the device goes into a special state for a short period of time after making an outgoing * emergency call. * * <p>(On current devices, that state lasts 5 minutes. It prevents data usage by other apps, to * avoid conflicts with any possible incoming calls. It also puts up a notification in the status * bar, showing a countdown while ECM is active, and allowing the user to exit ECM.) * * <p>Currently this is assumed to be true for CDMA phones, and false otherwise. * * <p>TODO: This capability should really be exposed by the telephony layer, since it depends on * the underlying telephony technology. (Or, is this actually carrier-specific? Is it VZW-only?) */ /* package */ static boolean supportsEcm(Phone phone) { return (phone.getPhoneType() == Phone.PHONE_TYPE_CDMA); }
/** * Return true if the current phone supports distinct "Answer & Hold" and "Answer & End" behaviors * in the call-waiting scenario. If so, the in-call UI may provide separate buttons or menu items * for these two actions. * * <p>Currently this is assumed to be true on GSM phones and false otherwise. (In particular, CDMA * has no concept of explicitly managing the background call, or "putting a call on hold.") * * <p>TODO: This capability should really be exposed by the telephony layer, since it depends on * the underlying telephony technology. * * <p>TODO: It might be better to expose this capability in a more generic form, like maybe * "supportsExplicitMultipleLineManagement()" rather than focusing specifically on call-waiting * behavior. */ /* package */ static boolean supportsAnswerAndHold(Phone phone) { return ((phone.getPhoneType() == Phone.PHONE_TYPE_GSM) || (phone.getPhoneType() == Phone.PHONE_TYPE_SIP)); }
/** * Return true if the current phone supports the ability to explicitly manage the state of a * conference call (i.e. view the participants, and hangup or separate individual callers.) * * <p>The in-call screen's "Manage conference" UI is available only on devices that support this * feature. * * <p>Currently this is assumed to be true on GSM phones and false otherwise. TODO: This * capability should really be exposed by the telephony layer, since it depends on the underlying * telephony technology. */ /* package */ static boolean supportsConferenceCallManagement(Phone phone) { return ((phone.getPhoneType() == Phone.PHONE_TYPE_GSM) || (phone.getPhoneType() == Phone.PHONE_TYPE_SIP)); }
/** * Return true if this phone allows the user to select which network to use. * * <p>Currently this is assumed to be true only on GSM phones. * * <p>TODO: Should CDMA phones allow this as well? */ /* package */ static boolean supportsNetworkSelection(Phone phone) { return (phone.getPhoneType() == Phone.PHONE_TYPE_GSM); }