Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88a5163b authored by Qing Zhong's avatar Qing Zhong Committed by Android (Google) Code Review
Browse files

Merge "Do not show network notifications on Wear device." into main

parents 24f99898 7d8b3920
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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));
+14 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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 =
@@ -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());