Merge change 5344 into donut
* changes: frameworks/base: CDMA voicemail support
This commit is contained in:
@@ -611,6 +611,21 @@ public class TelephonyManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the voice mail count.
|
||||
* <p>
|
||||
* Requires Permission:
|
||||
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
|
||||
* @hide
|
||||
*/
|
||||
public int getVoiceMessageCount() {
|
||||
try {
|
||||
return getITelephony().getVoiceMessageCount();
|
||||
} catch (RemoteException ex) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the alphabetic identifier associated with the voice
|
||||
* mail number.
|
||||
|
||||
@@ -241,7 +241,7 @@ interface ITelephony {
|
||||
/**
|
||||
* Returns the unread count of voicemails
|
||||
*/
|
||||
int getCountVoiceMessages();
|
||||
int getVoiceMessageCount();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ public abstract class IccRecords extends Handler implements IccConstants {
|
||||
* If not available (eg, on an older CPHS SIM) -1 is returned if
|
||||
* getVoiceMessageWaiting() is true
|
||||
*/
|
||||
public int getCountVoiceMessages() {
|
||||
public int getVoiceMessageCount() {
|
||||
return countVoiceMessages;
|
||||
}
|
||||
|
||||
|
||||
@@ -831,7 +831,7 @@ public interface Phone {
|
||||
* Returns unread voicemail count. This count is shown when the voicemail
|
||||
* notification is expanded.<p>
|
||||
*/
|
||||
int getCountVoiceMessages();
|
||||
int getVoiceMessageCount();
|
||||
|
||||
/**
|
||||
* Returns the alpha tag associated with the voice mail number.
|
||||
|
||||
@@ -631,6 +631,11 @@ public abstract class PhoneBase implements Phone {
|
||||
mNotifier.notifyDataActivity(this);
|
||||
}
|
||||
|
||||
public void notifyMessageWaitingIndicator() {
|
||||
// This function is added to send the notification to DefaultPhoneNotifier.
|
||||
mNotifier.notifyMessageWaitingChanged(this);
|
||||
}
|
||||
|
||||
public void notifyDataConnection(String reason) {
|
||||
mNotifier.notifyDataConnection(this, reason);
|
||||
}
|
||||
@@ -638,7 +643,7 @@ public abstract class PhoneBase implements Phone {
|
||||
public abstract String getPhoneName();
|
||||
|
||||
/** @hide */
|
||||
public int getCountVoiceMessages(){
|
||||
public int getVoiceMessageCount(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -435,8 +435,8 @@ public class PhoneProxy extends Handler implements Phone {
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public int getCountVoiceMessages(){
|
||||
return mActivePhone.getCountVoiceMessages();
|
||||
public int getVoiceMessageCount(){
|
||||
return mActivePhone.getVoiceMessageCount();
|
||||
}
|
||||
|
||||
public String getVoiceMailAlphaTag() {
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.internal.telephony.cdma;
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncResult;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@@ -26,6 +27,7 @@ import android.os.Message;
|
||||
import android.os.Registrant;
|
||||
import android.os.RegistrantList;
|
||||
import android.os.SystemProperties;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.CellLocation;
|
||||
import android.telephony.PhoneNumberUtils;
|
||||
@@ -40,6 +42,7 @@ import com.android.internal.telephony.CommandsInterface;
|
||||
import com.android.internal.telephony.Connection;
|
||||
import com.android.internal.telephony.DataConnection;
|
||||
import com.android.internal.telephony.IccCard;
|
||||
import com.android.internal.telephony.IccException;
|
||||
import com.android.internal.telephony.IccFileHandler;
|
||||
import com.android.internal.telephony.IccPhoneBookInterfaceManager;
|
||||
import com.android.internal.telephony.IccSmsInterfaceManager;
|
||||
@@ -65,6 +68,9 @@ public class CDMAPhone extends PhoneBase {
|
||||
|
||||
// Default Emergency Callback Mode exit timer
|
||||
private static final int DEFAULT_ECM_EXIT_TIMER_VALUE = 30000;
|
||||
static final String VM_COUNT_CDMA = "vm_count_key_cdma";
|
||||
private static final String VM_NUMBER_CDMA = "vm_number_key_cdma";
|
||||
private String mVmNumber = null;
|
||||
|
||||
//***** Instance Variables
|
||||
CdmaCallTracker mCT;
|
||||
@@ -147,6 +153,9 @@ public class CDMAPhone extends PhoneBase {
|
||||
// This is needed to handle phone process crashes
|
||||
String inEcm=SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE, "false");
|
||||
mIsPhoneInECMState = inEcm.equals("true");
|
||||
|
||||
// Notify voicemails.
|
||||
notifier.notifyMessageWaitingChanged(this);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
@@ -300,7 +309,7 @@ public class CDMAPhone extends PhoneBase {
|
||||
|
||||
public boolean
|
||||
getMessageWaitingIndicator() {
|
||||
return mRuimRecords.getVoiceMessageWaiting();
|
||||
return (getVoiceMessageCount() > 0);
|
||||
}
|
||||
|
||||
public List<? extends MmiCode>
|
||||
@@ -678,22 +687,33 @@ public class CDMAPhone extends PhoneBase {
|
||||
public void setVoiceMailNumber(String alphaTag,
|
||||
String voiceMailNumber,
|
||||
Message onComplete) {
|
||||
//mSIMRecords.setVoiceMailNumber(alphaTag, voiceMailNumber, onComplete);
|
||||
//TODO: Where do we have to store this value has to be clarified with QC
|
||||
Message resp;
|
||||
mVmNumber = voiceMailNumber;
|
||||
resp = h.obtainMessage(EVENT_SET_VM_NUMBER_DONE, 0, 0, onComplete);
|
||||
mRuimRecords.setVoiceMailNumber(alphaTag, mVmNumber, resp);
|
||||
}
|
||||
|
||||
public String getVoiceMailNumber() {
|
||||
//TODO: Where can we get this value has to be clarified with QC
|
||||
//return mSIMRecords.getVoiceMailNumber();
|
||||
// throw new RuntimeException();
|
||||
return "*86";
|
||||
String number = null;
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
// TODO(Moto): The default value of voicemail number should be read from a system property
|
||||
number = sp.getString(VM_NUMBER_CDMA, "*86");
|
||||
return number;
|
||||
}
|
||||
|
||||
/* Returns Number of Voicemails
|
||||
* @hide
|
||||
*/
|
||||
public int getCountVoiceMessages() {
|
||||
return mRuimRecords.getCountVoiceMessages();
|
||||
public int getVoiceMessageCount() {
|
||||
int voicemailCount = mRuimRecords.getVoiceMessageCount();
|
||||
// If mRuimRecords.getVoiceMessageCount returns zero, then there is possibility
|
||||
// that phone was power cycled and would have lost the voicemail count.
|
||||
// So get the count from preferences.
|
||||
if (voicemailCount == 0) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
voicemailCount = sp.getInt(VM_COUNT_CDMA, 0);
|
||||
}
|
||||
return voicemailCount;
|
||||
}
|
||||
|
||||
public String getVoiceMailAlphaTag() {
|
||||
@@ -820,9 +840,10 @@ public class CDMAPhone extends PhoneBase {
|
||||
mRuimRecords.setVoiceMessageWaiting(1, mwi ? -1 : 0);
|
||||
}
|
||||
|
||||
public void
|
||||
notifyMessageWaitingIndicator() {
|
||||
mNotifier.notifyMessageWaitingChanged(this);
|
||||
/* This function is overloaded to send number of voicemails instead of sending true/false */
|
||||
/*package*/ void
|
||||
updateMessageWaitingIndicator(int mwi) {
|
||||
mRuimRecords.setVoiceMessageWaiting(1, mwi);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -984,6 +1005,19 @@ public class CDMAPhone extends PhoneBase {
|
||||
}
|
||||
break;
|
||||
|
||||
case EVENT_SET_VM_NUMBER_DONE:{
|
||||
ar = (AsyncResult)msg.obj;
|
||||
if (IccException.class.isInstance(ar.exception)) {
|
||||
storeVoiceMailNumber(mVmNumber);
|
||||
ar.exception = null;
|
||||
}
|
||||
onComplete = (Message) ar.userObj;
|
||||
if (onComplete != null) {
|
||||
AsyncResult.forMessage(onComplete, ar.result, ar.exception);
|
||||
onComplete.sendToTarget();
|
||||
}
|
||||
}
|
||||
|
||||
default:{
|
||||
throw new RuntimeException("unexpected event not handled");
|
||||
}
|
||||
@@ -1198,4 +1232,16 @@ public class CDMAPhone extends PhoneBase {
|
||||
int defRoamInd = getServiceState().getCdmaDefaultRoamingIndicator();
|
||||
return mEriManager.getCdmaEriText(roamInd, defRoamInd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the voicemail number in preferences
|
||||
*/
|
||||
private void storeVoiceMailNumber(String number) {
|
||||
// Update the preference value of voicemail number
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putString(VM_NUMBER_CDMA, number);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,11 +20,13 @@ package com.android.internal.telephony.cdma;
|
||||
import android.app.Activity;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ContentValues;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.SQLException;
|
||||
import android.os.AsyncResult;
|
||||
import android.os.Message;
|
||||
import android.provider.Telephony.Sms.Intents;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Config;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -83,27 +85,6 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
|
||||
int teleService = sms.getTeleService();
|
||||
boolean handled = false;
|
||||
|
||||
// Teleservices W(E)MT and VMN are handled together:
|
||||
if ((teleService == SmsEnvelope.TELESERVICE_WMT)
|
||||
|| (teleService == SmsEnvelope.TELESERVICE_WEMT)
|
||||
|| (teleService == SmsEnvelope.TELESERVICE_VMN)) {
|
||||
// From here on we need decoded BD.
|
||||
// Special case the message waiting indicator messages
|
||||
if (sms.isMWISetMessage()) {
|
||||
mCdmaPhone.updateMessageWaitingIndicator(true);
|
||||
handled |= sms.isMwiDontStore();
|
||||
if (Config.LOGD) {
|
||||
Log.d(TAG, "Received voice mail indicator set SMS shouldStore=" + !handled);
|
||||
}
|
||||
} else if (sms.isMWIClearMessage()) {
|
||||
mCdmaPhone.updateMessageWaitingIndicator(false);
|
||||
handled |= sms.isMwiDontStore();
|
||||
if (Config.LOGD) {
|
||||
Log.d(TAG, "Received voice mail indicator clear SMS shouldStore=" + !handled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sms.getUserData() == null) {
|
||||
if (Config.LOGD) {
|
||||
Log.d(TAG, "Received SMS without user data");
|
||||
@@ -116,6 +97,18 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
|
||||
if (SmsEnvelope.TELESERVICE_WAP == teleService){
|
||||
processCdmaWapPdu(sms.getUserData(), sms.messageRef, sms.getOriginatingAddress());
|
||||
return;
|
||||
} else if (SmsEnvelope.TELESERVICE_VMN == teleService) {
|
||||
// handling Voicemail
|
||||
int voicemailCount = sms.getNumOfVoicemails();
|
||||
Log.d(TAG, "Voicemail count=" + voicemailCount);
|
||||
// Store the voicemail count in preferences.
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(
|
||||
((CDMAPhone) mPhone).getContext());
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putInt(CDMAPhone.VM_COUNT_CDMA, voicemailCount);
|
||||
editor.commit();
|
||||
((CDMAPhone) mPhone).updateMessageWaitingIndicator(voicemailCount);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -773,6 +773,12 @@ public class SmsMessage extends SmsMessageBase {
|
||||
return asciiDigit;
|
||||
}
|
||||
|
||||
/** This function shall be called to get the number of voicemails.
|
||||
* @hide
|
||||
*/
|
||||
/*package*/ int getNumOfVoicemails() {
|
||||
return mBearerData.numberOfMessages;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -447,11 +447,6 @@ public class GSMPhone extends PhoneBase {
|
||||
mSIMRecords.setVoiceMessageWaiting(1, mwi ? -1 : 0);
|
||||
}
|
||||
|
||||
public void
|
||||
notifyMessageWaitingIndicator() {
|
||||
mNotifier.notifyMessageWaitingChanged(this);
|
||||
}
|
||||
|
||||
public void
|
||||
notifyCallForwardingIndicator() {
|
||||
mNotifier.notifyCallForwardingChanged(this);
|
||||
|
||||
Reference in New Issue
Block a user