MAP: use getSystemService to get TelephonyManager
replaced TelephonyManager.getDefault() with
getSystemService(Context.TELEPHONY_SERVICE).
Bug: 140562205
Test: Manual
Change-Id: Id44e2054df305854183daceb94aba00f700e05ed
diff --git a/android/app/src/com/android/bluetooth/map/BluetoothMapContent.java b/android/app/src/com/android/bluetooth/map/BluetoothMapContent.java
index 2cda124..e91e2db 100644
--- a/android/app/src/com/android/bluetooth/map/BluetoothMapContent.java
+++ b/android/app/src/com/android/bluetooth/map/BluetoothMapContent.java
@@ -3709,9 +3709,10 @@
if (charset == MAP_MESSAGE_CHARSET_NATIVE) {
if (type == 1) { //Inbox
message.setSmsBodyPdus(
- BluetoothMapSmsPdu.getDeliverPdus(msgBody, phone, time));
+ BluetoothMapSmsPdu.getDeliverPdus(mContext, msgBody, phone, time));
} else {
- message.setSmsBodyPdus(BluetoothMapSmsPdu.getSubmitPdus(msgBody, phone));
+ message.setSmsBodyPdus(
+ BluetoothMapSmsPdu.getSubmitPdus(mContext, msgBody, phone));
}
} else /*if (charset == MAP_MESSAGE_CHARSET_UTF8)*/ {
message.setSmsBody(msgBody);
diff --git a/android/app/src/com/android/bluetooth/map/BluetoothMapSmsPdu.java b/android/app/src/com/android/bluetooth/map/BluetoothMapSmsPdu.java
index f6af8db..1a536a2 100644
--- a/android/app/src/com/android/bluetooth/map/BluetoothMapSmsPdu.java
+++ b/android/app/src/com/android/bluetooth/map/BluetoothMapSmsPdu.java
@@ -16,6 +16,7 @@
import static android.telephony.TelephonyManager.PHONE_TYPE_CDMA;
+import android.content.Context;
import android.telephony.PhoneNumberUtils;
import android.telephony.SmsMessage;
import android.telephony.TelephonyManager;
@@ -502,14 +503,14 @@
return sConcatenatedRef;
}
- public static ArrayList<SmsPdu> getSubmitPdus(String messageText, String address) {
+ public static ArrayList<SmsPdu> getSubmitPdus(Context context, String messageText,
+ String address) {
/* Use the generic GSM/CDMA SMS Message functionality within Android to generate the
* SMS PDU's as once generated to send the SMS message.
*/
- int activePhone = TelephonyManager.getDefault()
- .getCurrentPhoneType(); // TODO: Change to use: ((TelephonyManager)myContext
- // .getSystemService(Context.TELEPHONY_SERVICE))
+ int activePhone = context.getSystemService(TelephonyManager.class)
+ .getCurrentPhoneType();
int phoneType;
GsmAlphabet.TextEncodingDetails ted = (PHONE_TYPE_CDMA == activePhone)
? com.android.internal.telephony.cdma.SmsMessage.calculateLength(
@@ -607,8 +608,9 @@
* @param date The delivery time stamp.
* @return
*/
- public static ArrayList<SmsPdu> getDeliverPdus(String messageText, String address, long date) {
- ArrayList<SmsPdu> deliverPdus = getSubmitPdus(messageText, address);
+ public static ArrayList<SmsPdu> getDeliverPdus(Context context, String messageText,
+ String address, long date) {
+ ArrayList<SmsPdu> deliverPdus = getSubmitPdus(context, messageText, address);
/*
* For CDMA the only difference between deliver and submit pdus are the messageType,