Add PhoneSubInfo.getCompleteVoiceMailNumber.
PhoneSubInfo.getVoiceMailNumber now returns only the network portion of the voicemail number. Use the new method PhoneSubInfo.getCompleteVoiceMailNumber to get the netowrk portion and the post dial portion. Bug: 2881483 Change-Id: I7637d4fa0ffa046b4eebc4d599719bb668c940b5
This commit is contained in:
@@ -135,9 +135,9 @@ public class PhoneNumberUtils
|
||||
}
|
||||
|
||||
// TODO: We don't check for SecurityException here (requires
|
||||
// READ_PHONE_STATE permission).
|
||||
// CALL_PRIVILEGED permission).
|
||||
if (scheme.equals("voicemail")) {
|
||||
return TelephonyManager.getDefault().getVoiceMailNumber();
|
||||
return TelephonyManager.getDefault().getCompleteVoiceMailNumber();
|
||||
}
|
||||
|
||||
if (context == null) {
|
||||
|
||||
@@ -658,6 +658,25 @@ public class TelephonyManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the complete voice mail number. Return null if it is unavailable.
|
||||
* <p>
|
||||
* Requires Permission:
|
||||
* {@link android.Manifest.permission#CALL_PRIVILEGED CALL_PRIVILEGED}
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public String getCompleteVoiceMailNumber() {
|
||||
try {
|
||||
return getSubscriberInfo().getCompleteVoiceMailNumber();
|
||||
} catch (RemoteException ex) {
|
||||
return null;
|
||||
} catch (NullPointerException ex) {
|
||||
// This could happen before phone restarts due to crashing
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the voice mail count. Return 0 if unavailable.
|
||||
* <p>
|
||||
|
||||
@@ -58,6 +58,11 @@ interface IPhoneSubInfo {
|
||||
*/
|
||||
String getVoiceMailNumber();
|
||||
|
||||
/**
|
||||
* Retrieves the complete voice mail number.
|
||||
*/
|
||||
String getCompleteVoiceMailNumber();
|
||||
|
||||
/**
|
||||
* Retrieves the alpha identifier associated with the voice mail number.
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.io.PrintWriter;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Binder;
|
||||
import android.telephony.PhoneNumberUtils;
|
||||
import android.util.Log;
|
||||
|
||||
public class PhoneSubInfo extends IPhoneSubInfo.Stub {
|
||||
@@ -29,6 +30,9 @@ public class PhoneSubInfo extends IPhoneSubInfo.Stub {
|
||||
private Context mContext;
|
||||
private static final String READ_PHONE_STATE =
|
||||
android.Manifest.permission.READ_PHONE_STATE;
|
||||
private static final String CALL_PRIVILEGED =
|
||||
// TODO Add core/res/AndriodManifest.xml#READ_PRIVILEGED_PHONE_STATE
|
||||
android.Manifest.permission.CALL_PRIVILEGED;
|
||||
|
||||
public PhoneSubInfo(Phone phone) {
|
||||
mPhone = phone;
|
||||
@@ -101,7 +105,22 @@ public class PhoneSubInfo extends IPhoneSubInfo.Stub {
|
||||
*/
|
||||
public String getVoiceMailNumber() {
|
||||
mContext.enforceCallingOrSelfPermission(READ_PHONE_STATE, "Requires READ_PHONE_STATE");
|
||||
return (String) mPhone.getVoiceMailNumber();
|
||||
String number = PhoneNumberUtils.extractNetworkPortion(mPhone.getVoiceMailNumber());
|
||||
Log.d(LOG_TAG, "VM: PhoneSubInfo.getVoiceMailNUmber: "); // + number);
|
||||
return number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the compelete voice mail number.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public String getCompleteVoiceMailNumber() {
|
||||
mContext.enforceCallingOrSelfPermission(CALL_PRIVILEGED,
|
||||
"Requires CALL_PRIVILEGED");
|
||||
String number = mPhone.getVoiceMailNumber();
|
||||
Log.d(LOG_TAG, "VM: PhoneSubInfo.getCompleteVoiceMailNUmber: "); // + number);
|
||||
return number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,6 +81,13 @@ public class PhoneSubInfoProxy extends IPhoneSubInfo.Stub {
|
||||
return mPhoneSubInfo.getVoiceMailNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the complete voice mail number.
|
||||
*/
|
||||
public String getCompleteVoiceMailNumber() {
|
||||
return mPhoneSubInfo.getCompleteVoiceMailNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the alpha identifier associated with the voice mail number.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user