Wiring up RTP Transport.
- Add support for loading config.xml values pertinent to
ImsPhoneCallTracker on phone initialiation.
- Add support for new shell command "d2d send -t type -v value"; this
lets us test sending D2D comms messages.
- More logging!
Test: Performed test of new adb shell command and verified that logs
indicate proper passthrough of messages.
Test: Added unit tests to verify that the D2D communicator will be set up
in a TelephonyConnection when it's an IMS connection and D2D comms is
enabled.
Bug: 163085177
Change-Id: I042e7da030e6dd41d2c20f095416185a14194213
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index ed719b6..f5bfe10 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -16,6 +16,11 @@
package com.android.phone;
+import static com.android.internal.telephony.d2d.Communicator.MESSAGE_CALL_AUDIO_CODEC;
+import static com.android.internal.telephony.d2d.Communicator.MESSAGE_CALL_RADIO_ACCESS_TYPE;
+import static com.android.internal.telephony.d2d.Communicator.MESSAGE_DEVICE_BATTERY_STATE;
+import static com.android.internal.telephony.d2d.Communicator.MESSAGE_DEVICE_NETWORK_COVERAGE;
+
import android.content.Context;
import android.os.Binder;
import android.os.PersistableBundle;
@@ -31,6 +36,7 @@
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
+import com.android.internal.telephony.d2d.Communicator;
import com.android.internal.telephony.emergency.EmergencyNumberTracker;
import com.android.internal.telephony.util.TelephonyUtils;
import com.android.modules.utils.BasicShellCommandHandler;
@@ -93,6 +99,9 @@
private static final String SRC_SET_CARRIER_ENABLED = "set-carrier-enabled";
private static final String SRC_GET_CARRIER_ENABLED = "get-carrier-enabled";
+ private static final String D2D_SUBCOMMAND = "d2d";
+ private static final String D2D_SEND = "send";
+
// Take advantage of existing methods that already contain permissions checks when possible.
private final ITelephony mInterface;
@@ -175,6 +184,8 @@
return handleEndBlockSuppressionCommand();
case GBA_SUBCOMMAND:
return handleGbaCommand();
+ case D2D_SUBCOMMAND:
+ return handleD2dCommand();
case SINGLE_REGISTATION_CONFIG:
return handleSingleRegistrationConfigCommand();
default: {
@@ -210,6 +221,23 @@
onHelpCc();
onHelpGba();
onHelpSrc();
+ onHelpD2D();
+ }
+
+ private void onHelpD2D() {
+ PrintWriter pw = getOutPrintWriter();
+ pw.println("D2D Comms Commands:");
+ pw.println(" d2d send TYPE VALUE");
+ pw.println(" Sends a D2D message of specified type and value.");
+ pw.println(" Type: " + MESSAGE_CALL_RADIO_ACCESS_TYPE + " - "
+ + Communicator.messageToString(MESSAGE_CALL_RADIO_ACCESS_TYPE));
+ pw.println(" Type: " + MESSAGE_CALL_AUDIO_CODEC + " - " + Communicator.messageToString(
+ MESSAGE_CALL_AUDIO_CODEC));
+ pw.println(" Type: " + MESSAGE_DEVICE_BATTERY_STATE + " - "
+ + Communicator.messageToString(
+ MESSAGE_DEVICE_BATTERY_STATE));
+ pw.println(" Type: " + MESSAGE_DEVICE_NETWORK_COVERAGE + " - "
+ + Communicator.messageToString(MESSAGE_DEVICE_NETWORK_COVERAGE));
}
private void onHelpIms() {
@@ -540,6 +568,64 @@
return -1;
}
+ private int handleD2dCommand() {
+ String arg = getNextArg();
+ if (arg == null) {
+ onHelpD2D();
+ return 0;
+ }
+
+ switch (arg) {
+ case D2D_SEND: {
+ return handleD2dSendCommand();
+ }
+ }
+
+ return -1;
+ }
+
+ private int handleD2dSendCommand() {
+ PrintWriter errPw = getErrPrintWriter();
+ String opt;
+ int messageType = -1;
+ int messageValue = -1;
+
+
+ String arg = getNextArg();
+ if (arg == null) {
+ onHelpD2D();
+ return 0;
+ }
+ try {
+ messageType = Integer.parseInt(arg);
+ } catch (NumberFormatException e) {
+ errPw.println("message type must be a valid integer");
+ return -1;
+ }
+
+ arg = getNextArg();
+ if (arg == null) {
+ onHelpD2D();
+ return 0;
+ }
+ try {
+ messageValue = Integer.parseInt(arg);
+ } catch (NumberFormatException e) {
+ errPw.println("message value must be a valid integer");
+ return -1;
+ }
+
+ try {
+ mInterface.sendDeviceToDeviceMessage(messageType, messageValue);
+ } catch (RemoteException e) {
+ Log.w(LOG_TAG, "d2d send error: " + e.getMessage());
+ errPw.println("Exception: " + e.getMessage());
+ return -1;
+ }
+
+ return 0;
+ }
+
// ims set-ims-service
private int handleImsSetServiceCommand() {
PrintWriter errPw = getErrPrintWriter();