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

Commit 8607aff3 authored by qing's avatar qing Committed by Qing Zhong
Browse files

Skip incoming caller info fetching based on config

Incoming caller fetching is not needed at some devices (like wear) and it will consumes significant CPU cycles during incoming call, and may potentially slow down wear dialer lauch.
Make it configurable per device setting.

Bug: 330907736
Test: Unit test and e2e test works
Change-Id: I5ae85fa96cfb466baa854181975ea2484c67b8b0
parent 5377c6be
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -82,4 +82,7 @@

    <!-- System bluetooth stack package name -->
    <string name="system_bluetooth_stack">com.android.bluetooth</string>

    <!-- When true, skip fetching incoming caller info -->
    <bool name="skip_incoming_caller_info_query">false</bool>
</resources>
+5 −1
Original line number Diff line number Diff line
@@ -1589,7 +1589,11 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
                mIsTestEmergencyCall = mHandle != null &&
                        isTestEmergencyCall(mHandle.getSchemeSpecificPart());
            }
            if (!mContext.getResources().getBoolean(R.bool.skip_incoming_caller_info_query)) {
                startCallerInfoLookup();
            } else  {
                Log.i(this, "skip incoming caller info lookup");
            }
            for (Listener l : mListeners) {
                l.onHandleChanged(this);
            }
+16 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import static org.mockito.Mockito.when;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
@@ -126,6 +127,9 @@ public class CallTest extends TelecomTestCase {
        doReturn(new ComponentName(mContext, CallTest.class))
                .when(mMockConnectionService).getComponentName();
        doReturn(UserHandle.CURRENT).when(mMockCallsManager).getCurrentUserHandle();
        Resources mockResources = mContext.getResources();
        when(mockResources.getBoolean(R.bool.skip_incoming_caller_info_query))
                .thenReturn(false);
        EmergencyCallHelper helper = mock(EmergencyCallHelper.class);
        doReturn(helper).when(mMockCallsManager).getEmergencyCallHelper();
    }
@@ -621,6 +625,18 @@ public class CallTest extends TelecomTestCase {
        assertEquals(call.getHandle(), call.getContactUri());
    }

    @Test
    @SmallTest
    public void testGetFromCallerInfo_skipLookup() {
        Resources mockResources = mContext.getResources();
        when(mockResources.getBoolean(R.bool.skip_incoming_caller_info_query))
                .thenReturn(true);

        createCall("1");

        verify(mMockCallerInfoLookupHelper, never()).startLookup(any(), any());
    }

    @Test
    @SmallTest
    public void testOriginalCallIntent() {
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.OutcomeReceiver;
@@ -108,6 +109,7 @@ public class TransactionTests extends TelecomTestCase {
        super.setUp();
        MockitoAnnotations.initMocks(this);
        Mockito.when(mMockCall1.getId()).thenReturn(CALL_ID_1);
        Mockito.when(mMockContext.getResources()).thenReturn(Mockito.mock(Resources.class));
    }

    @Override