diff options
| author | Zoey Chen <zoeychen@google.com> | 2021-02-22 21:28:03 +0800 |
|---|---|---|
| committer | Zoey Chen <zoeychen@google.com> | 2021-02-26 14:09:22 +0800 |
| commit | f0c9776277b201c7f148ceaead49e5c63c308a09 (patch) | |
| tree | af8de5b30c5a354d4ca30eaf6d022273ec95d4f9 /src/com | |
| parent | 0131a8e6d3fd8277fe3e610949cab712347963d0 (diff) | |
| download | platform_packages_services_Mms-f0c9776277b201c7f148ceaead49e5c63c308a09.tar.gz platform_packages_services_Mms-f0c9776277b201c7f148ceaead49e5c63c308a09.tar.bz2 platform_packages_services_Mms-f0c9776277b201c7f148ceaead49e5c63c308a09.zip | |
[Telephony] Use TelephonyCallback instead of PhoneStateListener part6
Since the redesign of PhoneStateListener, use TelephonyCallback to get the callback of EVENT_*
Bug: 167684594
Test: make
Change-Id: If3fe3d5a20af94276cd1ac31232d1c4fb14a0fe6
Diffstat (limited to 'src/com')
| -rw-r--r-- | src/com/android/mms/service/MmsRequest.java | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/com/android/mms/service/MmsRequest.java b/src/com/android/mms/service/MmsRequest.java index db0d874..64e10af 100644 --- a/src/com/android/mms/service/MmsRequest.java +++ b/src/com/android/mms/service/MmsRequest.java @@ -16,7 +16,6 @@ package com.android.mms.service; -import android.annotation.NonNull; import android.app.Activity; import android.app.PendingIntent; import android.content.Context; @@ -28,9 +27,9 @@ import android.os.Bundle; import android.service.carrier.CarrierMessagingService; import android.service.carrier.CarrierMessagingServiceWrapper.CarrierMessagingCallback; import android.telephony.AnomalyReporter; -import android.telephony.MmsManager; import android.telephony.PhoneStateListener; import android.telephony.PreciseDataConnectionState; +import android.telephony.TelephonyCallback; import android.telephony.data.ApnSetting; import android.telephony.ims.feature.MmTelFeature; import android.telephony.ims.ImsMmTelManager; @@ -107,8 +106,8 @@ public abstract class MmsRequest { protected long mMessageId; protected int mLastConnectionFailure; - class MonitorPhoneStateListener extends PhoneStateListener - implements PhoneStateListener.PreciseDataConnectionStateChangedListener { + class MonitorTelephonyCallback extends TelephonyCallback implements + TelephonyCallback.PreciseDataConnectionStateListener { @Override public void onPreciseDataConnectionStateChanged( PreciseDataConnectionState connectionState) { @@ -193,9 +192,9 @@ public abstract class MmsRequest { // Try multiple times of MMS HTTP request, depending on the error. for (int i = 0; i < RETRY_TIMES; i++) { httpStatusCode = 0; // Clear for retry. - PhoneStateListener connectionStateListener = new MonitorPhoneStateListener(); + MonitorTelephonyCallback connectionStateCallback = new MonitorTelephonyCallback(); try { - listenToDataConnectionState(connectionStateListener); + listenToDataConnectionState(connectionStateCallback); networkManager.acquireNetwork(requestId); final String apnName = networkManager.getApnName(); LogUtil.d(requestId, "APN name is " + apnName); @@ -241,7 +240,7 @@ public abstract class MmsRequest { result = SmsManager.MMS_ERROR_UNSPECIFIED; break; } finally { - stopListeningToDataConnectionState(connectionStateListener); + stopListeningToDataConnectionState(connectionStateCallback); } try { Thread.sleep(retryDelaySecs * 1000, 0/*nano*/); @@ -252,16 +251,17 @@ public abstract class MmsRequest { processResult(context, result, response, httpStatusCode, /* handledByCarrierApp= */ false); } - private void listenToDataConnectionState(PhoneStateListener connectionStateListener) { + private void listenToDataConnectionState(MonitorTelephonyCallback connectionStateCallback) { final TelephonyManager telephonyManager = mContext.getSystemService( TelephonyManager.class).createForSubscriptionId(mSubId); - telephonyManager.registerPhoneStateListener(r -> r.run(), connectionStateListener); + telephonyManager.registerTelephonyCallback(r -> r.run(), connectionStateCallback); } - private void stopListeningToDataConnectionState(PhoneStateListener connectionStateListener) { + private void stopListeningToDataConnectionState( + MonitorTelephonyCallback connectionStateCallback) { final TelephonyManager telephonyManager = mContext.getSystemService( TelephonyManager.class).createForSubscriptionId(mSubId); - telephonyManager.unregisterPhoneStateListener(connectionStateListener); + telephonyManager.unregisterTelephonyCallback(connectionStateCallback); } /** |
