summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Chen <refuhoo@google.com>2020-11-11 18:37:19 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-11-11 18:37:19 +0000
commitae774f631bf1324f0c8d5c3cc6f78fa68cb7ae4b (patch)
tree72bac137683a7b5268cca5f9a5f0cd21b95d8e16
parentabe80492a6288d0059b0c247ad9518b1e808e7e1 (diff)
parentdefa8ace37f96bbb01e24d9f1bd6f5995d96caa0 (diff)
downloadMms-ae774f631bf1324f0c8d5c3cc6f78fa68cb7ae4b.tar.gz
Restructure CarrierMessagingServiceWrapper with better interfaces. am: 11e94fe5ab am: defa8ace37
Original change: https://android-review.googlesource.com/c/platform/packages/services/Mms/+/1493173 Change-Id: I2573409c7b5ec35ff54d351aeef114dc8e54950c
-rw-r--r--src/com/android/mms/service/DownloadRequest.java18
-rw-r--r--src/com/android/mms/service/MmsRequest.java4
-rw-r--r--src/com/android/mms/service/SendRequest.java17
3 files changed, 26 insertions, 13 deletions
diff --git a/src/com/android/mms/service/DownloadRequest.java b/src/com/android/mms/service/DownloadRequest.java
index e4d386e..96be5fd 100644
--- a/src/com/android/mms/service/DownloadRequest.java
+++ b/src/com/android/mms/service/DownloadRequest.java
@@ -277,14 +277,21 @@ public class DownloadRequest extends MmsRequest {
/**
* Downloads the MMS through through the carrier app.
*/
- private final class CarrierDownloadManager extends CarrierMessagingServiceWrapper {
+ private final class CarrierDownloadManager {
// Initialized in downloadMms
private volatile CarrierDownloadCompleteCallback mCarrierDownloadCallback;
+ private final CarrierMessagingServiceWrapper mCarrierMessagingServiceWrapper =
+ new CarrierMessagingServiceWrapper();
+
+ void disposeConnection(Context context) {
+ mCarrierMessagingServiceWrapper.disposeConnection(context);
+ }
void downloadMms(Context context, String carrierMessagingServicePackage,
CarrierDownloadCompleteCallback carrierDownloadCallback) {
mCarrierDownloadCallback = carrierDownloadCallback;
- if (bindToCarrierMessagingService(context, carrierMessagingServicePackage)) {
+ if (mCarrierMessagingServiceWrapper.bindToCarrierMessagingService(
+ context, carrierMessagingServicePackage, ()->onServiceReady())) {
LogUtil.v("bindService() for carrier messaging service succeeded. messageId: "
+ mMessageId);
} else {
@@ -295,11 +302,10 @@ public class DownloadRequest extends MmsRequest {
}
}
- @Override
- public void onServiceReady() {
+ private void onServiceReady() {
try {
- downloadMms(mContentUri, mSubId, Uri.parse(mLocationUrl),
- mCarrierDownloadCallback);
+ mCarrierMessagingServiceWrapper.downloadMms(
+ mContentUri, mSubId, Uri.parse(mLocationUrl), mCarrierDownloadCallback);
} catch (RuntimeException e) {
LogUtil.e("Exception downloading MMS for messageId " + mMessageId
+ " using the carrier messaging service: " + e, e);
diff --git a/src/com/android/mms/service/MmsRequest.java b/src/com/android/mms/service/MmsRequest.java
index e7b7bf4..15c80db 100644
--- a/src/com/android/mms/service/MmsRequest.java
+++ b/src/com/android/mms/service/MmsRequest.java
@@ -23,7 +23,7 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.service.carrier.CarrierMessagingService;
-import android.service.carrier.CarrierMessagingServiceWrapper.CarrierMessagingCallbackWrapper;
+import android.service.carrier.CarrierMessagingServiceWrapper.CarrierMessagingCallback;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -356,7 +356,7 @@ public abstract class MmsRequest {
/**
* Base class for handling carrier app send / download result.
*/
- protected abstract class CarrierMmsActionCallback extends CarrierMessagingCallbackWrapper {
+ protected abstract class CarrierMmsActionCallback implements CarrierMessagingCallback {
@Override
public void onSendSmsComplete(int result, int messageRef) {
LogUtil.e("Unexpected onSendSmsComplete call for messageId " + mMessageId
diff --git a/src/com/android/mms/service/SendRequest.java b/src/com/android/mms/service/SendRequest.java
index e4d1d55..c159cbb 100644
--- a/src/com/android/mms/service/SendRequest.java
+++ b/src/com/android/mms/service/SendRequest.java
@@ -393,14 +393,21 @@ public class SendRequest extends MmsRequest {
/**
* Sends the MMS through through the carrier app.
*/
- private final class CarrierSendManager extends CarrierMessagingServiceWrapper {
+ private final class CarrierSendManager {
// Initialized in sendMms
private volatile CarrierSendCompleteCallback mCarrierSendCompleteCallback;
+ private final CarrierMessagingServiceWrapper mCarrierMessagingServiceWrapper =
+ new CarrierMessagingServiceWrapper();
+
+ void disposeConnection(Context context) {
+ mCarrierMessagingServiceWrapper.disposeConnection(context);
+ }
void sendMms(Context context, String carrierMessagingServicePackage,
CarrierSendCompleteCallback carrierSendCompleteCallback) {
mCarrierSendCompleteCallback = carrierSendCompleteCallback;
- if (bindToCarrierMessagingService(context, carrierMessagingServicePackage)) {
+ if (mCarrierMessagingServiceWrapper.bindToCarrierMessagingService(
+ context, carrierMessagingServicePackage, () -> onServiceReady())) {
LogUtil.v("bindService() for carrier messaging service succeeded. messageId: "
+ mMessageId);
} else {
@@ -412,14 +419,14 @@ public class SendRequest extends MmsRequest {
}
}
- @Override
- public void onServiceReady() {
+ private void onServiceReady() {
try {
Uri locationUri = null;
if (mLocationUrl != null) {
locationUri = Uri.parse(mLocationUrl);
}
- sendMms(mPduUri, mSubId, locationUri, mCarrierSendCompleteCallback);
+ mCarrierMessagingServiceWrapper.sendMms(
+ mPduUri, mSubId, locationUri, mCarrierSendCompleteCallback);
} catch (RuntimeException e) {
LogUtil.e("Exception sending MMS using the carrier messaging service. messageId: "
+ mMessageId + e, e);