Merge "Provide an API to make USSD calls and read the responses." am: f02b7b7ba6
am: 4ef0e826c4
Change-Id: I478837412fb4c76ac8d18fed5a5c441bf2d835b3
This commit is contained in:
@@ -38226,6 +38226,7 @@ package android.telephony {
|
|||||||
method public boolean isWorldPhone();
|
method public boolean isWorldPhone();
|
||||||
method public void listen(android.telephony.PhoneStateListener, int);
|
method public void listen(android.telephony.PhoneStateListener, int);
|
||||||
method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
|
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 setDataEnabled(boolean);
|
method public void setDataEnabled(boolean);
|
||||||
method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String);
|
method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String);
|
||||||
method public boolean setOperatorBrandOverride(java.lang.String);
|
method public boolean setOperatorBrandOverride(java.lang.String);
|
||||||
@@ -38300,6 +38301,12 @@ package android.telephony {
|
|||||||
field public static final java.lang.String VVM_TYPE_OMTP = "vvm_type_omtp";
|
field public static final java.lang.String VVM_TYPE_OMTP = "vvm_type_omtp";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static abstract class TelephonyManager.OnReceiveUssdResponseCallback {
|
||||||
|
ctor public TelephonyManager.OnReceiveUssdResponseCallback();
|
||||||
|
method public void onReceiveUssdResponse(java.lang.String, java.lang.CharSequence);
|
||||||
|
method public void onReceiveUssdResponseFailed(java.lang.String, int);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
package android.telephony.cdma {
|
package android.telephony.cdma {
|
||||||
|
|||||||
@@ -41451,6 +41451,7 @@ package android.telephony {
|
|||||||
method public void listen(android.telephony.PhoneStateListener, int);
|
method public void listen(android.telephony.PhoneStateListener, int);
|
||||||
method public boolean needsOtaServiceProvisioning();
|
method public boolean needsOtaServiceProvisioning();
|
||||||
method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
|
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 int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>);
|
method public int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>);
|
||||||
method public void setDataEnabled(boolean);
|
method public void setDataEnabled(boolean);
|
||||||
method public void setDataEnabled(int, boolean);
|
method public void setDataEnabled(int, boolean);
|
||||||
@@ -41546,6 +41547,12 @@ package android.telephony {
|
|||||||
field public static final java.lang.String VVM_TYPE_OMTP = "vvm_type_omtp";
|
field public static final java.lang.String VVM_TYPE_OMTP = "vvm_type_omtp";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static abstract class TelephonyManager.OnReceiveUssdResponseCallback {
|
||||||
|
ctor public TelephonyManager.OnReceiveUssdResponseCallback();
|
||||||
|
method public void onReceiveUssdResponse(java.lang.String, java.lang.CharSequence);
|
||||||
|
method public void onReceiveUssdResponseFailed(java.lang.String, int);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
package android.telephony.cdma {
|
package android.telephony.cdma {
|
||||||
|
|||||||
@@ -38325,6 +38325,7 @@ package android.telephony {
|
|||||||
method public boolean isWorldPhone();
|
method public boolean isWorldPhone();
|
||||||
method public void listen(android.telephony.PhoneStateListener, int);
|
method public void listen(android.telephony.PhoneStateListener, int);
|
||||||
method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
|
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 setDataEnabled(boolean);
|
method public void setDataEnabled(boolean);
|
||||||
method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String);
|
method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String);
|
||||||
method public boolean setOperatorBrandOverride(java.lang.String);
|
method public boolean setOperatorBrandOverride(java.lang.String);
|
||||||
@@ -38399,6 +38400,12 @@ package android.telephony {
|
|||||||
field public static final java.lang.String VVM_TYPE_OMTP = "vvm_type_omtp";
|
field public static final java.lang.String VVM_TYPE_OMTP = "vvm_type_omtp";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static abstract class TelephonyManager.OnReceiveUssdResponseCallback {
|
||||||
|
ctor public TelephonyManager.OnReceiveUssdResponseCallback();
|
||||||
|
method public void onReceiveUssdResponse(java.lang.String, java.lang.CharSequence);
|
||||||
|
method public void onReceiveUssdResponseFailed(java.lang.String, int);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
package android.telephony.cdma {
|
package android.telephony.cdma {
|
||||||
|
|||||||
@@ -16,8 +16,11 @@
|
|||||||
|
|
||||||
package android.telephony;
|
package android.telephony;
|
||||||
|
|
||||||
|
import static com.android.internal.util.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
|
import android.annotation.RequiresPermission;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.annotation.SdkConstant;
|
import android.annotation.SdkConstant;
|
||||||
import android.annotation.SdkConstant.SdkConstantType;
|
import android.annotation.SdkConstant.SdkConstantType;
|
||||||
@@ -28,12 +31,13 @@ import android.content.Intent;
|
|||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.BatteryStats;
|
import android.os.BatteryStats;
|
||||||
import android.os.ResultReceiver;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.provider.Settings.SettingNotFoundException;
|
import android.provider.Settings.SettingNotFoundException;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.os.PersistableBundle;
|
import android.os.PersistableBundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.os.ResultReceiver;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.service.carrier.CarrierIdentifier;
|
import android.service.carrier.CarrierIdentifier;
|
||||||
@@ -838,6 +842,29 @@ public class TelephonyManager {
|
|||||||
*/
|
*/
|
||||||
public static final String VVM_TYPE_CVVM = "vvm_type_cvvm";
|
public static final String VVM_TYPE_CVVM = "vvm_type_cvvm";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final String USSD_RESPONSE = "USSD_RESPONSE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* USSD return code success.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final int USSD_RETURN_SUCCESS = 100;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* USSD return code for failure case.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final int USSD_RETURN_FAILURE = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* USSD return code for failure case.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final int USSD_ERROR_SERVICE_UNAVAIL = -2;
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Device Info
|
// Device Info
|
||||||
@@ -4965,6 +4992,56 @@ public class TelephonyManager {
|
|||||||
return new int[0];
|
return new int[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static abstract class OnReceiveUssdResponseCallback {
|
||||||
|
/**
|
||||||
|
** Called when USSD has succeeded.
|
||||||
|
**/
|
||||||
|
public void onReceiveUssdResponse(String request, CharSequence response) {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
** Called when USSD has failed.
|
||||||
|
**/
|
||||||
|
public void onReceiveUssdResponseFailed(String request, int failureCode) {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* <p>Requires permission:
|
||||||
|
* @link android.Manifest.permission#CALL_PHONE}
|
||||||
|
*/
|
||||||
|
@RequiresPermission(android.Manifest.permission.CALL_PHONE)
|
||||||
|
public void sendUssdRequest(String ussdRequest,
|
||||||
|
final OnReceiveUssdResponseCallback callback, Handler handler) {
|
||||||
|
checkNotNull(callback, "OnReceiveUssdResponseCallback cannot be null.");
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(TAG, "Error calling ITelephony#sendUSSDCode", e);
|
||||||
|
UssdResponse response = new UssdResponse(ussdRequest, "");
|
||||||
|
Bundle returnData = new Bundle();
|
||||||
|
returnData.putParcelable(USSD_RESPONSE, response);
|
||||||
|
wrappedCallback.send(USSD_ERROR_SERVICE_UNAVAIL, returnData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@SystemApi
|
@SystemApi
|
||||||
public boolean handlePinMmi(String dialString) {
|
public boolean handlePinMmi(String dialString) {
|
||||||
|
|||||||
20
telephony/java/android/telephony/UssdResponse.aidl
Normal file
20
telephony/java/android/telephony/UssdResponse.aidl
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
**
|
||||||
|
** Copyright 2007, The Android Open Source Project
|
||||||
|
**
|
||||||
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
** you may not use this file except in compliance with the License.
|
||||||
|
** You may obtain a copy of the License at
|
||||||
|
**
|
||||||
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
**
|
||||||
|
** Unless required by applicable law or agreed to in writing, software
|
||||||
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
** See the License for the specific language governing permissions and
|
||||||
|
** limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.telephony;
|
||||||
|
|
||||||
|
parcelable UssdResponse;
|
||||||
80
telephony/java/android/telephony/UssdResponse.java
Normal file
80
telephony/java/android/telephony/UssdResponse.java
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.telephony;
|
||||||
|
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the Ussd response, including
|
||||||
|
* the message and the return code.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public final class UssdResponse implements Parcelable {
|
||||||
|
private CharSequence mReturnMessage;
|
||||||
|
private String mUssdRequest;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement the Parcelable interface
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeString(mUssdRequest);
|
||||||
|
TextUtils.writeToParcel(mReturnMessage, dest, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUssdRequest() {
|
||||||
|
return mUssdRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharSequence getReturnMessage() {
|
||||||
|
return mReturnMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement the Parcelable interface
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * Initialize the object from the request and return message.
|
||||||
|
*/
|
||||||
|
public UssdResponse(String ussdRequest, CharSequence returnMessage) {
|
||||||
|
mUssdRequest = ussdRequest;
|
||||||
|
mReturnMessage = returnMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Parcelable.Creator<UssdResponse> CREATOR = new Creator<UssdResponse>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UssdResponse createFromParcel(Parcel in) {
|
||||||
|
String request = in.readString();
|
||||||
|
CharSequence message = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||||
|
return new UssdResponse(request, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UssdResponse[] newArray(int size) {
|
||||||
|
return new UssdResponse[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -273,6 +273,15 @@ interface ITelephony {
|
|||||||
*/
|
*/
|
||||||
boolean handlePinMmi(String dialString);
|
boolean handlePinMmi(String dialString);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles USSD commands.
|
||||||
|
*
|
||||||
|
* @param ussdRequest the USSD command to be executed.
|
||||||
|
* @param wrappedCallback receives a callback result.
|
||||||
|
*/
|
||||||
|
void handleUssdRequest(String ussdRequest, in ResultReceiver wrappedCallback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles PIN MMI commands (PIN/PIN2/PUK/PUK2), which are initiated
|
* Handles PIN MMI commands (PIN/PIN2/PUK/PUK2), which are initiated
|
||||||
* without SEND (so <code>dial</code> is not appropriate) for
|
* without SEND (so <code>dial</code> is not appropriate) for
|
||||||
|
|||||||
Reference in New Issue
Block a user