Merge change 5344 into donut

* changes:
  frameworks/base: CDMA voicemail support
This commit is contained in:
Android (Google) Code Review
2009-06-25 00:09:18 -07:00
10 changed files with 104 additions and 44 deletions

View File

@@ -611,6 +611,21 @@ public class TelephonyManager {
return null; 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 * Retrieves the alphabetic identifier associated with the voice
* mail number. * mail number.

View File

@@ -241,7 +241,7 @@ interface ITelephony {
/** /**
* Returns the unread count of voicemails * Returns the unread count of voicemails
*/ */
int getCountVoiceMessages(); int getVoiceMessageCount();
} }

View File

@@ -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 * If not available (eg, on an older CPHS SIM) -1 is returned if
* getVoiceMessageWaiting() is true * getVoiceMessageWaiting() is true
*/ */
public int getCountVoiceMessages() { public int getVoiceMessageCount() {
return countVoiceMessages; return countVoiceMessages;
} }

View File

@@ -831,7 +831,7 @@ public interface Phone {
* Returns unread voicemail count. This count is shown when the voicemail * Returns unread voicemail count. This count is shown when the voicemail
* notification is expanded.<p> * notification is expanded.<p>
*/ */
int getCountVoiceMessages(); int getVoiceMessageCount();
/** /**
* Returns the alpha tag associated with the voice mail number. * Returns the alpha tag associated with the voice mail number.

View File

@@ -631,6 +631,11 @@ public abstract class PhoneBase implements Phone {
mNotifier.notifyDataActivity(this); mNotifier.notifyDataActivity(this);
} }
public void notifyMessageWaitingIndicator() {
// This function is added to send the notification to DefaultPhoneNotifier.
mNotifier.notifyMessageWaitingChanged(this);
}
public void notifyDataConnection(String reason) { public void notifyDataConnection(String reason) {
mNotifier.notifyDataConnection(this, reason); mNotifier.notifyDataConnection(this, reason);
} }
@@ -638,7 +643,7 @@ public abstract class PhoneBase implements Phone {
public abstract String getPhoneName(); public abstract String getPhoneName();
/** @hide */ /** @hide */
public int getCountVoiceMessages(){ public int getVoiceMessageCount(){
return 0; return 0;
} }

View File

@@ -435,8 +435,8 @@ public class PhoneProxy extends Handler implements Phone {
} }
/** @hide */ /** @hide */
public int getCountVoiceMessages(){ public int getVoiceMessageCount(){
return mActivePhone.getCountVoiceMessages(); return mActivePhone.getVoiceMessageCount();
} }
public String getVoiceMailAlphaTag() { public String getVoiceMailAlphaTag() {

View File

@@ -19,6 +19,7 @@ package com.android.internal.telephony.cdma;
import android.app.ActivityManagerNative; import android.app.ActivityManagerNative;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncResult; import android.os.AsyncResult;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
@@ -26,6 +27,7 @@ import android.os.Message;
import android.os.Registrant; import android.os.Registrant;
import android.os.RegistrantList; import android.os.RegistrantList;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.preference.PreferenceManager;
import android.provider.Settings; import android.provider.Settings;
import android.telephony.CellLocation; import android.telephony.CellLocation;
import android.telephony.PhoneNumberUtils; 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.Connection;
import com.android.internal.telephony.DataConnection; import com.android.internal.telephony.DataConnection;
import com.android.internal.telephony.IccCard; import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.IccException;
import com.android.internal.telephony.IccFileHandler; import com.android.internal.telephony.IccFileHandler;
import com.android.internal.telephony.IccPhoneBookInterfaceManager; import com.android.internal.telephony.IccPhoneBookInterfaceManager;
import com.android.internal.telephony.IccSmsInterfaceManager; import com.android.internal.telephony.IccSmsInterfaceManager;
@@ -65,6 +68,9 @@ public class CDMAPhone extends PhoneBase {
// Default Emergency Callback Mode exit timer // Default Emergency Callback Mode exit timer
private static final int DEFAULT_ECM_EXIT_TIMER_VALUE = 30000; 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 //***** Instance Variables
CdmaCallTracker mCT; CdmaCallTracker mCT;
@@ -147,6 +153,9 @@ public class CDMAPhone extends PhoneBase {
// This is needed to handle phone process crashes // This is needed to handle phone process crashes
String inEcm=SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE, "false"); String inEcm=SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE, "false");
mIsPhoneInECMState = inEcm.equals("true"); mIsPhoneInECMState = inEcm.equals("true");
// Notify voicemails.
notifier.notifyMessageWaitingChanged(this);
} }
public void dispose() { public void dispose() {
@@ -300,7 +309,7 @@ public class CDMAPhone extends PhoneBase {
public boolean public boolean
getMessageWaitingIndicator() { getMessageWaitingIndicator() {
return mRuimRecords.getVoiceMessageWaiting(); return (getVoiceMessageCount() > 0);
} }
public List<? extends MmiCode> public List<? extends MmiCode>
@@ -678,22 +687,33 @@ public class CDMAPhone extends PhoneBase {
public void setVoiceMailNumber(String alphaTag, public void setVoiceMailNumber(String alphaTag,
String voiceMailNumber, String voiceMailNumber,
Message onComplete) { Message onComplete) {
//mSIMRecords.setVoiceMailNumber(alphaTag, voiceMailNumber, onComplete); Message resp;
//TODO: Where do we have to store this value has to be clarified with QC mVmNumber = voiceMailNumber;
resp = h.obtainMessage(EVENT_SET_VM_NUMBER_DONE, 0, 0, onComplete);
mRuimRecords.setVoiceMailNumber(alphaTag, mVmNumber, resp);
} }
public String getVoiceMailNumber() { public String getVoiceMailNumber() {
//TODO: Where can we get this value has to be clarified with QC String number = null;
//return mSIMRecords.getVoiceMailNumber(); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
// throw new RuntimeException(); // TODO(Moto): The default value of voicemail number should be read from a system property
return "*86"; number = sp.getString(VM_NUMBER_CDMA, "*86");
return number;
} }
/* Returns Number of Voicemails /* Returns Number of Voicemails
* @hide * @hide
*/ */
public int getCountVoiceMessages() { public int getVoiceMessageCount() {
return mRuimRecords.getCountVoiceMessages(); 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() { public String getVoiceMailAlphaTag() {
@@ -820,9 +840,10 @@ public class CDMAPhone extends PhoneBase {
mRuimRecords.setVoiceMessageWaiting(1, mwi ? -1 : 0); mRuimRecords.setVoiceMessageWaiting(1, mwi ? -1 : 0);
} }
public void /* This function is overloaded to send number of voicemails instead of sending true/false */
notifyMessageWaitingIndicator() { /*package*/ void
mNotifier.notifyMessageWaitingChanged(this); updateMessageWaitingIndicator(int mwi) {
mRuimRecords.setVoiceMessageWaiting(1, mwi);
} }
/** /**
@@ -984,6 +1005,19 @@ public class CDMAPhone extends PhoneBase {
} }
break; 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:{ default:{
throw new RuntimeException("unexpected event not handled"); throw new RuntimeException("unexpected event not handled");
} }
@@ -1198,4 +1232,16 @@ public class CDMAPhone extends PhoneBase {
int defRoamInd = getServiceState().getCdmaDefaultRoamingIndicator(); int defRoamInd = getServiceState().getCdmaDefaultRoamingIndicator();
return mEriManager.getCdmaEriText(roamInd, defRoamInd); 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();
}
} }

View File

@@ -20,11 +20,13 @@ package com.android.internal.telephony.cdma;
import android.app.Activity; import android.app.Activity;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.SharedPreferences;
import android.database.Cursor; import android.database.Cursor;
import android.database.SQLException; import android.database.SQLException;
import android.os.AsyncResult; import android.os.AsyncResult;
import android.os.Message; import android.os.Message;
import android.provider.Telephony.Sms.Intents; import android.provider.Telephony.Sms.Intents;
import android.preference.PreferenceManager;
import android.util.Config; import android.util.Config;
import android.util.Log; import android.util.Log;
@@ -83,27 +85,6 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
int teleService = sms.getTeleService(); int teleService = sms.getTeleService();
boolean handled = false; 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 (sms.getUserData() == null) {
if (Config.LOGD) { if (Config.LOGD) {
Log.d(TAG, "Received SMS without user data"); Log.d(TAG, "Received SMS without user data");
@@ -116,6 +97,18 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
if (SmsEnvelope.TELESERVICE_WAP == teleService){ if (SmsEnvelope.TELESERVICE_WAP == teleService){
processCdmaWapPdu(sms.getUserData(), sms.messageRef, sms.getOriginatingAddress()); processCdmaWapPdu(sms.getUserData(), sms.messageRef, sms.getOriginatingAddress());
return; 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;
} }
/** /**

View File

@@ -773,6 +773,12 @@ public class SmsMessage extends SmsMessageBase {
return asciiDigit; return asciiDigit;
} }
/** This function shall be called to get the number of voicemails.
* @hide
*/
/*package*/ int getNumOfVoicemails() {
return mBearerData.numberOfMessages;
}
} }

View File

@@ -447,11 +447,6 @@ public class GSMPhone extends PhoneBase {
mSIMRecords.setVoiceMessageWaiting(1, mwi ? -1 : 0); mSIMRecords.setVoiceMessageWaiting(1, mwi ? -1 : 0);
} }
public void
notifyMessageWaitingIndicator() {
mNotifier.notifyMessageWaitingChanged(this);
}
public void public void
notifyCallForwardingIndicator() { notifyCallForwardingIndicator() {
mNotifier.notifyCallForwardingChanged(this); mNotifier.notifyCallForwardingChanged(this);