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

Commit 525dc1a7 authored by Grace Jia's avatar Grace Jia
Browse files

Use public API NotificationManager#matchesCallFilter instead of the

hidden version.

Bug: b/303440370
Test: atest TelecomUnitTestCases
Change-Id: Icb184358bb2c1dd871a196be24bf2c515c3023bd
parent 4e56f447
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@ aconfig_declarations {
      "telecom_call_filtering_flags.aconfig",
      "telecom_incallservice_flags.aconfig",
      "telecom_default_phone_account_flags.aconfig",
      "telecom_callaudioroutestatemachine_flags.aconfig"
      "telecom_callaudioroutestatemachine_flags.aconfig",
      "telecom_resolve_hidden_dependencies.aconfig"
    ],
}
+8 −0
Original line number Diff line number Diff line
package: "com.android.server.telecom.flags"

flag {
    name: "telecom_resolve_hidden_dependencies"
    namespace: "android_platform_telecom"
    description: "Mainland cleanup for hidden dependencies"
    bug: "b/303440370"
}
+16 −7
Original line number Diff line number Diff line
@@ -186,6 +186,7 @@ public class Ringer {
    private final InCallController mInCallController;
    private final VibrationEffectProxy mVibrationEffectProxy;
    private final boolean mIsHapticPlaybackSupportedByDevice;
    private final FeatureFlags mFlags;
    /**
     * For unit testing purposes only; when set, {@link #startRinging(Call, boolean)} will complete
     * the future provided by the test using {@link #setBlockOnRingingFuture(CompletableFuture)}.
@@ -256,6 +257,7 @@ public class Ringer {
                mSystemSettingsUtil.isHapticPlaybackSupported(mContext);

        mAudioManager = mContext.getSystemService(AudioManager.class);
        mFlags = featureFlags;
    }

    @VisibleForTesting
@@ -650,7 +652,13 @@ public class Ringer {
            Log.i(this, "shouldRingForContact: returning computation from DndCallFilter.");
            return !call.isCallSuppressedByDoNotDisturb();
        }
        final Uri contactUri = call.getHandle();
        Uri contactUri = call.getHandle();
        if (mFlags.telecomResolveHiddenDependencies()) {
            if (contactUri == null) {
                contactUri = Uri.EMPTY;
            }
            return mNotificationManager.matchesCallFilter(contactUri);
        } else {
            final Bundle peopleExtras = new Bundle();
            if (contactUri != null) {
                ArrayList<Person> personList = new ArrayList<>();
@@ -659,6 +667,7 @@ public class Ringer {
            }
            return mNotificationManager.matchesCallFilter(peopleExtras);
        }
    }

    private boolean hasExternalRinger(Call foregroundCall) {
        Bundle intentExtras = foregroundCall.getIntentExtras();
+5 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.telecom.tests;

import com.android.server.telecom.flags.FeatureFlags;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;

@@ -57,6 +58,7 @@ import android.location.CountryDetector;
import android.location.LocationManager;
import android.media.AudioDeviceInfo;
import android.media.AudioManager;
import android.net.Uri;
import android.os.BugreportManager;
import android.os.Bundle;
import android.os.DropBoxManager;
@@ -627,8 +629,9 @@ public class ComponentContextFixture implements TestFixture<Context> {

    private TelecomManager mTelecomManager = mock(TelecomManager.class);

    public ComponentContextFixture() {
    public ComponentContextFixture(FeatureFlags featureFlags) {
        MockitoAnnotations.initMocks(this);
        when(featureFlags.telecomResolveHiddenDependencies()).thenReturn(true);
        when(mResources.getConfiguration()).thenReturn(mResourceConfiguration);
        when(mResources.getString(anyInt())).thenReturn("");
        when(mResources.getStringArray(anyInt())).thenReturn(new String[0]);
@@ -711,7 +714,7 @@ public class ComponentContextFixture implements TestFixture<Context> {
            }
        }).when(mAppOpsManager).checkPackage(anyInt(), anyString());

        when(mNotificationManager.matchesCallFilter(any(Bundle.class))).thenReturn(true);
        when(mNotificationManager.matchesCallFilter(any(Uri.class))).thenReturn(true);

        when(mCarrierConfigManager.getConfig()).thenReturn(new PersistableBundle());
        when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(new PersistableBundle());
+3 −2
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ public class MissedInformationTest extends TelecomSystemTest {
        mAdapter = new CallIntentProcessor.AdapterImpl(mCallsManager.getDefaultDialerCache());
        mNotificationManager = spy((NotificationManager) mContext.getSystemService(
                Context.NOTIFICATION_SERVICE));
        when(mFeatureFlags.telecomResolveHiddenDependencies()).thenReturn(true);
        when(mContentResolver.getPackageName()).thenReturn(PACKAGE_NAME);
        when(mContentResolver.acquireProvider(any(String.class))).thenReturn(mContentProvider);
        when(mContentProvider.call(any(String.class), any(String.class),
@@ -358,7 +359,7 @@ public class MissedInformationTest extends TelecomSystemTest {
        setUpIncomingCall();
        doReturn(mNotificationManager).when(mSpyContext)
                .getSystemService(Context.NOTIFICATION_SERVICE);
        doReturn(false).when(mNotificationManager).matchesCallFilter(any(Bundle.class));
        doReturn(false).when(mNotificationManager).matchesCallFilter(any(Uri.class));
        doReturn(false).when(mIncomingCall).wasDndCheckComputedForCall();
        mCallsManager.getRinger().setNotificationManager(mNotificationManager);

@@ -369,7 +370,7 @@ public class MissedInformationTest extends TelecomSystemTest {

        // Wait for ringer attributes build completed
        verify(mNotificationManager, timeout(TEST_TIMEOUT_MILLIS))
                .matchesCallFilter(any(Bundle.class));
                .matchesCallFilter(any(Uri.class));
        mCallsManager.getRinger().waitForAttributesCompletion();

        mCallsManager.markCallAsDisconnected(mIncomingCall,
Loading