Provide an API to make USSD calls and read the responses.

Test: will be added in a subsequent CL.
Bug: 30973910
Change-Id: Ibf622e154f3f987be547f4f85e15891d4e382118
This commit is contained in:
pkanwar
2016-11-06 20:11:45 -08:00
parent 5f181618d9
commit d570f63b72
5 changed files with 61 additions and 43 deletions

View File

@@ -11800,14 +11800,14 @@ package android.graphics {
method public deprecated boolean clipRegion(android.graphics.Region);
method public void concat(android.graphics.Matrix);
method public void drawARGB(int, int, int, int);
method public void drawArc(float, float, float, float, float, float, boolean, android.graphics.Paint);
method public void drawArc(android.graphics.RectF, float, float, boolean, android.graphics.Paint);
method public void drawArc(float, float, float, float, float, float, boolean, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, float, float, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, android.graphics.Matrix, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.Rect, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.RectF, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.Rect, android.graphics.Paint);
method public deprecated void drawBitmap(int[], int, int, float, float, int, int, boolean, android.graphics.Paint);
method public deprecated void drawBitmap(int[], int, int, int, int, int, int, boolean, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, android.graphics.Matrix, android.graphics.Paint);
method public void drawBitmapMesh(android.graphics.Bitmap, int, int, float[], int, int[], int, android.graphics.Paint);
method public void drawCircle(float, float, float, android.graphics.Paint);
method public void drawColor(int);
@@ -11815,28 +11815,28 @@ package android.graphics {
method public void drawLine(float, float, float, float, android.graphics.Paint);
method public void drawLines(float[], int, int, android.graphics.Paint);
method public void drawLines(float[], android.graphics.Paint);
method public void drawOval(float, float, float, float, android.graphics.Paint);
method public void drawOval(android.graphics.RectF, android.graphics.Paint);
method public void drawOval(float, float, float, float, android.graphics.Paint);
method public void drawPaint(android.graphics.Paint);
method public void drawPath(android.graphics.Path, android.graphics.Paint);
method public void drawPicture(android.graphics.Picture);
method public void drawPicture(android.graphics.Picture, android.graphics.Rect);
method public void drawPicture(android.graphics.Picture, android.graphics.RectF);
method public void drawPicture(android.graphics.Picture, android.graphics.Rect);
method public void drawPoint(float, float, android.graphics.Paint);
method public void drawPoints(float[], int, int, android.graphics.Paint);
method public void drawPoints(float[], android.graphics.Paint);
method public deprecated void drawPosText(char[], int, int, float[], android.graphics.Paint);
method public deprecated void drawPosText(java.lang.String, float[], android.graphics.Paint);
method public void drawRGB(int, int, int);
method public void drawRect(float, float, float, float, android.graphics.Paint);
method public void drawRect(android.graphics.Rect, android.graphics.Paint);
method public void drawRect(android.graphics.RectF, android.graphics.Paint);
method public void drawRoundRect(float, float, float, float, float, float, android.graphics.Paint);
method public void drawRect(android.graphics.Rect, android.graphics.Paint);
method public void drawRect(float, float, float, float, android.graphics.Paint);
method public void drawRoundRect(android.graphics.RectF, float, float, android.graphics.Paint);
method public void drawRoundRect(float, float, float, float, float, float, android.graphics.Paint);
method public void drawText(char[], int, int, float, float, android.graphics.Paint);
method public void drawText(java.lang.CharSequence, int, int, float, float, android.graphics.Paint);
method public void drawText(java.lang.String, float, float, android.graphics.Paint);
method public void drawText(java.lang.String, int, int, float, float, android.graphics.Paint);
method public void drawText(java.lang.CharSequence, int, int, float, float, android.graphics.Paint);
method public void drawTextOnPath(char[], int, int, android.graphics.Path, float, float, android.graphics.Paint);
method public void drawTextOnPath(java.lang.String, android.graphics.Path, float, float, android.graphics.Paint);
method public void drawTextRun(char[], int, int, int, int, float, float, boolean, android.graphics.Paint);
@@ -37566,6 +37566,7 @@ package android.telephony {
method public void listen(android.telephony.PhoneStateListener, int);
method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
method public void sendUssdRequest(java.lang.String, android.telephony.TelephonyManager.OnReceiveUssdResponseCallback, android.os.Handler);
method public void sendUssdRequest(java.lang.String, int, android.telephony.TelephonyManager.OnReceiveUssdResponseCallback, android.os.Handler);
method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String);
method public boolean setOperatorBrandOverride(java.lang.String);
method public boolean setPreferredNetworkTypeToGlobal();

View File

@@ -12251,14 +12251,14 @@ package android.graphics {
method public deprecated boolean clipRegion(android.graphics.Region);
method public void concat(android.graphics.Matrix);
method public void drawARGB(int, int, int, int);
method public void drawArc(float, float, float, float, float, float, boolean, android.graphics.Paint);
method public void drawArc(android.graphics.RectF, float, float, boolean, android.graphics.Paint);
method public void drawArc(float, float, float, float, float, float, boolean, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, float, float, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, android.graphics.Matrix, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.Rect, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.RectF, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.Rect, android.graphics.Paint);
method public deprecated void drawBitmap(int[], int, int, float, float, int, int, boolean, android.graphics.Paint);
method public deprecated void drawBitmap(int[], int, int, int, int, int, int, boolean, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, android.graphics.Matrix, android.graphics.Paint);
method public void drawBitmapMesh(android.graphics.Bitmap, int, int, float[], int, int[], int, android.graphics.Paint);
method public void drawCircle(float, float, float, android.graphics.Paint);
method public void drawColor(int);
@@ -12266,28 +12266,28 @@ package android.graphics {
method public void drawLine(float, float, float, float, android.graphics.Paint);
method public void drawLines(float[], int, int, android.graphics.Paint);
method public void drawLines(float[], android.graphics.Paint);
method public void drawOval(float, float, float, float, android.graphics.Paint);
method public void drawOval(android.graphics.RectF, android.graphics.Paint);
method public void drawOval(float, float, float, float, android.graphics.Paint);
method public void drawPaint(android.graphics.Paint);
method public void drawPath(android.graphics.Path, android.graphics.Paint);
method public void drawPicture(android.graphics.Picture);
method public void drawPicture(android.graphics.Picture, android.graphics.Rect);
method public void drawPicture(android.graphics.Picture, android.graphics.RectF);
method public void drawPicture(android.graphics.Picture, android.graphics.Rect);
method public void drawPoint(float, float, android.graphics.Paint);
method public void drawPoints(float[], int, int, android.graphics.Paint);
method public void drawPoints(float[], android.graphics.Paint);
method public deprecated void drawPosText(char[], int, int, float[], android.graphics.Paint);
method public deprecated void drawPosText(java.lang.String, float[], android.graphics.Paint);
method public void drawRGB(int, int, int);
method public void drawRect(float, float, float, float, android.graphics.Paint);
method public void drawRect(android.graphics.Rect, android.graphics.Paint);
method public void drawRect(android.graphics.RectF, android.graphics.Paint);
method public void drawRoundRect(float, float, float, float, float, float, android.graphics.Paint);
method public void drawRect(android.graphics.Rect, android.graphics.Paint);
method public void drawRect(float, float, float, float, android.graphics.Paint);
method public void drawRoundRect(android.graphics.RectF, float, float, android.graphics.Paint);
method public void drawRoundRect(float, float, float, float, float, float, android.graphics.Paint);
method public void drawText(char[], int, int, float, float, android.graphics.Paint);
method public void drawText(java.lang.CharSequence, int, int, float, float, android.graphics.Paint);
method public void drawText(java.lang.String, float, float, android.graphics.Paint);
method public void drawText(java.lang.String, int, int, float, float, android.graphics.Paint);
method public void drawText(java.lang.CharSequence, int, int, float, float, android.graphics.Paint);
method public void drawTextOnPath(char[], int, int, android.graphics.Path, float, float, android.graphics.Paint);
method public void drawTextOnPath(java.lang.String, android.graphics.Path, float, float, android.graphics.Paint);
method public void drawTextRun(char[], int, int, int, int, float, float, boolean, android.graphics.Paint);
@@ -40709,6 +40709,7 @@ package android.telephony {
method public boolean needsOtaServiceProvisioning();
method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
method public void sendUssdRequest(java.lang.String, android.telephony.TelephonyManager.OnReceiveUssdResponseCallback, android.os.Handler);
method public void sendUssdRequest(java.lang.String, int, android.telephony.TelephonyManager.OnReceiveUssdResponseCallback, android.os.Handler);
method public void setDataEnabled(boolean);
method public void setDataEnabled(int, boolean);
method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String);

View File

@@ -11818,14 +11818,14 @@ package android.graphics {
method public deprecated boolean clipRegion(android.graphics.Region);
method public void concat(android.graphics.Matrix);
method public void drawARGB(int, int, int, int);
method public void drawArc(float, float, float, float, float, float, boolean, android.graphics.Paint);
method public void drawArc(android.graphics.RectF, float, float, boolean, android.graphics.Paint);
method public void drawArc(float, float, float, float, float, float, boolean, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, float, float, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, android.graphics.Matrix, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.Rect, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.RectF, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.Rect, android.graphics.Paint);
method public deprecated void drawBitmap(int[], int, int, float, float, int, int, boolean, android.graphics.Paint);
method public deprecated void drawBitmap(int[], int, int, int, int, int, int, boolean, android.graphics.Paint);
method public void drawBitmap(android.graphics.Bitmap, android.graphics.Matrix, android.graphics.Paint);
method public void drawBitmapMesh(android.graphics.Bitmap, int, int, float[], int, int[], int, android.graphics.Paint);
method public void drawCircle(float, float, float, android.graphics.Paint);
method public void drawColor(int);
@@ -11833,28 +11833,28 @@ package android.graphics {
method public void drawLine(float, float, float, float, android.graphics.Paint);
method public void drawLines(float[], int, int, android.graphics.Paint);
method public void drawLines(float[], android.graphics.Paint);
method public void drawOval(float, float, float, float, android.graphics.Paint);
method public void drawOval(android.graphics.RectF, android.graphics.Paint);
method public void drawOval(float, float, float, float, android.graphics.Paint);
method public void drawPaint(android.graphics.Paint);
method public void drawPath(android.graphics.Path, android.graphics.Paint);
method public void drawPicture(android.graphics.Picture);
method public void drawPicture(android.graphics.Picture, android.graphics.Rect);
method public void drawPicture(android.graphics.Picture, android.graphics.RectF);
method public void drawPicture(android.graphics.Picture, android.graphics.Rect);
method public void drawPoint(float, float, android.graphics.Paint);
method public void drawPoints(float[], int, int, android.graphics.Paint);
method public void drawPoints(float[], android.graphics.Paint);
method public deprecated void drawPosText(char[], int, int, float[], android.graphics.Paint);
method public deprecated void drawPosText(java.lang.String, float[], android.graphics.Paint);
method public void drawRGB(int, int, int);
method public void drawRect(float, float, float, float, android.graphics.Paint);
method public void drawRect(android.graphics.Rect, android.graphics.Paint);
method public void drawRect(android.graphics.RectF, android.graphics.Paint);
method public void drawRoundRect(float, float, float, float, float, float, android.graphics.Paint);
method public void drawRect(android.graphics.Rect, android.graphics.Paint);
method public void drawRect(float, float, float, float, android.graphics.Paint);
method public void drawRoundRect(android.graphics.RectF, float, float, android.graphics.Paint);
method public void drawRoundRect(float, float, float, float, float, float, android.graphics.Paint);
method public void drawText(char[], int, int, float, float, android.graphics.Paint);
method public void drawText(java.lang.CharSequence, int, int, float, float, android.graphics.Paint);
method public void drawText(java.lang.String, float, float, android.graphics.Paint);
method public void drawText(java.lang.String, int, int, float, float, android.graphics.Paint);
method public void drawText(java.lang.CharSequence, int, int, float, float, android.graphics.Paint);
method public void drawTextOnPath(char[], int, int, android.graphics.Path, float, float, android.graphics.Paint);
method public void drawTextOnPath(java.lang.String, android.graphics.Path, float, float, android.graphics.Paint);
method public void drawTextRun(char[], int, int, int, int, float, float, boolean, android.graphics.Paint);
@@ -37648,6 +37648,7 @@ package android.telephony {
method public void listen(android.telephony.PhoneStateListener, int);
method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
method public void sendUssdRequest(java.lang.String, android.telephony.TelephonyManager.OnReceiveUssdResponseCallback, android.os.Handler);
method public void sendUssdRequest(java.lang.String, int, android.telephony.TelephonyManager.OnReceiveUssdResponseCallback, android.os.Handler);
method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String);
method public boolean setOperatorBrandOverride(java.lang.String);
method public boolean setPreferredNetworkTypeToGlobal();

View File

@@ -4650,32 +4650,46 @@ public class TelephonyManager {
/* <p>Requires permission:
* @link android.Manifest.permission#CALL_PHONE}
* @param ussdRequest the USSD command to be executed.
* @param wrappedCallback receives a callback result.
*/
@RequiresPermission(android.Manifest.permission.CALL_PHONE)
public void sendUssdRequest(String ussdRequest,
final OnReceiveUssdResponseCallback callback, Handler handler) {
checkNotNull(callback, "OnReceiveUssdResponseCallback cannot be null.");
sendUssdRequest(ussdRequest, getSubId(), callback, handler);
}
ResultReceiver wrappedCallback = new ResultReceiver(handler) {
@Override
protected void onReceiveResult(int resultCode, Bundle ussdResponse) {
Rlog.d(TAG, "USSD:" + resultCode);
checkNotNull(ussdResponse, "ussdResponse cannot be null.");
UssdResponse response = ussdResponse.getParcelable(USSD_RESPONSE);
/* <p>Requires permission:
* @link android.Manifest.permission#CALL_PHONE}
* @param subId The subscription to use.
* @param ussdRequest the USSD command to be executed.
* @param wrappedCallback receives a callback result.
*/
@RequiresPermission(android.Manifest.permission.CALL_PHONE)
public void sendUssdRequest(String ussdRequest, int subId,
final OnReceiveUssdResponseCallback callback, Handler handler) {
checkNotNull(callback, "OnReceiveUssdResponseCallback cannot be null.");
if (resultCode == USSD_RETURN_SUCCESS) {
callback.onReceiveUssdResponse(response.getUssdRequest(),
response.getReturnMessage());
} else {
callback.onReceiveUssdResponseFailed(response.getUssdRequest(), resultCode);
}
}
ResultReceiver wrappedCallback = new ResultReceiver(handler) {
@Override
protected void onReceiveResult(int resultCode, Bundle ussdResponse) {
Rlog.d(TAG, "USSD:" + resultCode);
checkNotNull(ussdResponse, "ussdResponse cannot be null.");
UssdResponse response = ussdResponse.getParcelable(USSD_RESPONSE);
if (resultCode == USSD_RETURN_SUCCESS) {
callback.onReceiveUssdResponse(response.getUssdRequest(),
response.getReturnMessage());
} else {
callback.onReceiveUssdResponseFailed(response.getUssdRequest(), resultCode);
}
}
};
try {
ITelephony telephony = getITelephony();
if (telephony != null) {
telephony.handleUssdRequest(ussdRequest, wrappedCallback);
telephony.handleUssdRequest(subId, ussdRequest, wrappedCallback);
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#sendUSSDCode", e);

View File

@@ -275,10 +275,11 @@ interface ITelephony {
/**
* Handles USSD commands.
*
* @param subId The subscription to use.
* @param ussdRequest the USSD command to be executed.
* @param wrappedCallback receives a callback result.
*/
void handleUssdRequest(String ussdRequest, in ResultReceiver wrappedCallback);
void handleUssdRequest(int subId, String ussdRequest, in ResultReceiver wrappedCallback);
/**
* Handles PIN MMI commands (PIN/PIN2/PUK/PUK2), which are initiated