Loading src/java/com/android/internal/telephony/CarrierServiceStateTracker.java +6 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.Resources; import android.os.Handler; import android.os.HandlerExecutor; Loading Loading @@ -153,7 +154,11 @@ public class CarrierServiceStateTracker extends Handler { } }); if (!mPhone.getContext().getPackageManager().hasSystemFeature( PackageManager.FEATURE_WATCH)) { registerNotificationTypes(); } mAllowedNetworkType = RadioAccessFamily.getNetworkTypeFromRaf( (int) mPhone.getAllowedNetworkTypes( TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER)); Loading tests/telephonytests/src/com/android/internal/telephony/CarrierServiceStateTrackerTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.app.Notification; import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Message; import android.os.PersistableBundle; import android.telephony.CarrierConfigManager; Loading Loading @@ -82,6 +83,7 @@ public class CarrierServiceStateTrackerTest extends TelephonyTest { mBundle = mContextFixture.getCarrierConfigBundle(); when(mPhone.getSubId()).thenReturn(SUB_ID); when(mCarrierConfigManager.getConfigForSubId(anyInt(), any())).thenReturn(mBundle); doReturn(false).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_WATCH); // Capture listener to emulate the carrier config change notification used later ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> listenerArgumentCaptor = Loading Loading @@ -303,6 +305,18 @@ public class CarrierServiceStateTrackerTest extends TelephonyTest { eq(SUB_ID), isA(Notification.class)); } /** Verifies notification map is empty when device is watch. */ @Test @SmallTest public void testNotificationMapWhenDeviceIsWatch() { doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_WATCH); CarrierServiceStateTracker tracker = new CarrierServiceStateTracker(mPhone, mSST); assertTrue(tracker.getNotificationTypeMap().isEmpty()); } private void sendMessageOnHandler(int messageWhat) { Message notificationMsg = mSpyCarrierSST.obtainMessage(messageWhat, null); doReturn(true).when(mSpyCarrierSST).evaluateSendingMessage(any()); Loading Loading
src/java/com/android/internal/telephony/CarrierServiceStateTracker.java +6 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.Resources; import android.os.Handler; import android.os.HandlerExecutor; Loading Loading @@ -153,7 +154,11 @@ public class CarrierServiceStateTracker extends Handler { } }); if (!mPhone.getContext().getPackageManager().hasSystemFeature( PackageManager.FEATURE_WATCH)) { registerNotificationTypes(); } mAllowedNetworkType = RadioAccessFamily.getNetworkTypeFromRaf( (int) mPhone.getAllowedNetworkTypes( TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER)); Loading
tests/telephonytests/src/com/android/internal/telephony/CarrierServiceStateTrackerTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.app.Notification; import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Message; import android.os.PersistableBundle; import android.telephony.CarrierConfigManager; Loading Loading @@ -82,6 +83,7 @@ public class CarrierServiceStateTrackerTest extends TelephonyTest { mBundle = mContextFixture.getCarrierConfigBundle(); when(mPhone.getSubId()).thenReturn(SUB_ID); when(mCarrierConfigManager.getConfigForSubId(anyInt(), any())).thenReturn(mBundle); doReturn(false).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_WATCH); // Capture listener to emulate the carrier config change notification used later ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> listenerArgumentCaptor = Loading Loading @@ -303,6 +305,18 @@ public class CarrierServiceStateTrackerTest extends TelephonyTest { eq(SUB_ID), isA(Notification.class)); } /** Verifies notification map is empty when device is watch. */ @Test @SmallTest public void testNotificationMapWhenDeviceIsWatch() { doReturn(true).when(mPackageManager).hasSystemFeature(PackageManager.FEATURE_WATCH); CarrierServiceStateTracker tracker = new CarrierServiceStateTracker(mPhone, mSST); assertTrue(tracker.getNotificationTypeMap().isEmpty()); } private void sendMessageOnHandler(int messageWhat) { Message notificationMsg = mSpyCarrierSST.obtainMessage(messageWhat, null); doReturn(true).when(mSpyCarrierSST).evaluateSendingMessage(any()); Loading