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

Unverified Commit a00904af authored by Michael Bestas's avatar Michael Bestas
Browse files

Merge tag 'android-12.1.0_r7' into staging/lineage-19.1_merge-android-12.1.0_r7

Android 12.1.0 Release 7 (SQ3A.220605.009.A1)

# -----BEGIN PGP SIGNATURE-----
#
# iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCYp57OgAKCRDorT+BmrEO
# eMg5AJwL8HSiFyoING161XwCtBw4+Qfm2wCdHgLhGPKuL2tf7m4CedAPMl8r4l4=
# =kLUO
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Jun  7 01:10:02 2022 EEST
# gpg:                using DSA key 4340D13570EF945E83810964E8AD3F819AB10E78
# gpg: Good signature from "The Android Open Source Project <initial-contribution@android.com>" [marginal]
# gpg: initial-contribution@android.com: Verified 1172 signatures in the past
#      7 months.  Encrypted 4 messages in the past 4 months.
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 4340 D135 70EF 945E 8381  0964 E8AD 3F81 9AB1 0E78

# By Jack Yu (2) and others
# Via Android Build Coastguard Worker (5) and Tim Lin (1)
* tag 'android-12.1.0_r7':
  Allow silent eCall redial over WiFi when IMS REG not on IWLAN
  Added network agent auto clean up logic
  SEND_TO_INCALL null pointer exception fix
  Release wakelock if setRadioCapability is not supported
  DO NOT MERGE Provided temp solution for 5G+ icon not shown

Change-Id: Id612995428bc1c2419f585a6cfbd570bd682c24b
parents a6bc00af 98a78953
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.net.QosFilter;
import android.net.QosSessionAttributes;
import android.net.SocketKeepalive;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.telephony.AccessNetworkConstants;
import android.telephony.AccessNetworkConstants.TransportType;
@@ -41,6 +42,7 @@ import android.telephony.data.QosBearerSession;
import android.util.LocalLog;
import android.util.SparseArray;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.DctConstants;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.RILConstants;
@@ -79,6 +81,8 @@ public class DcNetworkAgent extends NetworkAgent {

    private final Phone mPhone;

    private final Handler mHandler;

    private int mTransportType;

    private NetworkCapabilities mNetworkCapabilities;
@@ -99,7 +103,10 @@ public class DcNetworkAgent extends NetworkAgent {
    private static final long NETWORK_UNWANTED_ANOMALY_WINDOW_MS = TimeUnit.MINUTES.toMillis(5);
    private static final int NETWORK_UNWANTED_ANOMALY_NUM_OCCURRENCES =  12;

    DcNetworkAgent(DataConnection dc, Phone phone, int score, NetworkAgentConfig config,
    private static final int EVENT_UNWANTED_TIMEOUT = 1;

    @VisibleForTesting
    public DcNetworkAgent(DataConnection dc, Phone phone, int score, NetworkAgentConfig config,
            NetworkProvider networkProvider, int transportType) {
        super(phone.getContext(), dc.getHandler().getLooper(), "DcNetworkAgent",
                dc.getNetworkCapabilities(), dc.getLinkProperties(), score, config,
@@ -108,6 +115,18 @@ public class DcNetworkAgent extends NetworkAgent {
        mId = getNetwork().getNetId();
        mTag = "DcNetworkAgent" + "-" + mId;
        mPhone = phone;
        mHandler = new Handler(dc.getHandler().getLooper()) {
            @Override
            public void handleMessage(Message msg) {
                if (msg.what == EVENT_UNWANTED_TIMEOUT) {
                    loge("onNetworkUnwanted timed out. Perform silent de-register.");
                    logd("Unregister from connectivity service. " + sInterfaceNames.get(mId)
                            + " removed.");
                    sInterfaceNames.remove(mId);
                    DcNetworkAgent.this.unregister();
                }
            }
        };
        mNetworkCapabilities = dc.getNetworkCapabilities();
        mTransportType = transportType;
        mDataConnection = dc;
@@ -200,6 +219,7 @@ public class DcNetworkAgent extends NetworkAgent {

    @Override
    public synchronized void onNetworkUnwanted() {
        mHandler.sendEmptyMessageDelayed(EVENT_UNWANTED_TIMEOUT, TimeUnit.SECONDS.toMillis(30));
        trackNetworkUnwanted();
        if (mDataConnection == null) {
            loge("onNetworkUnwanted found called on no-owner DcNetworkAgent!");
@@ -353,6 +373,7 @@ public class DcNetworkAgent extends NetworkAgent {
    public synchronized void unregister(DataConnection dc) {
        if (!isOwned(dc, "unregister")) return;

        mHandler.removeMessages(EVENT_UNWANTED_TIMEOUT);
        logd("Unregister from connectivity service. " + sInterfaceNames.get(mId) + " removed.");
        sInterfaceNames.remove(mId);
        super.unregister();
+1 −1
Original line number Diff line number Diff line
@@ -2492,7 +2492,7 @@ public class ImsPhone extends ImsPhoneBase {
            imsDialArgsBuilder = ImsPhone.ImsDialArgs.Builder.from(dialArgs);

            Bundle extras = new Bundle(dialArgs.intentExtras);
            if (causeCode == CallFailCause.EMC_REDIAL_ON_VOWIFI && isWifiCallingEnabled()) {
            if (causeCode == CallFailCause.EMC_REDIAL_ON_VOWIFI) {
                extras.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE,
                        String.valueOf(ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN));
                logd("trigger VoWifi emergency call");
+24 −0
Original line number Diff line number Diff line
@@ -128,7 +128,16 @@ public class ImsRttTextHandler extends Handler {
                mReaderThread.start();
                break;
            case SEND_TO_INCALL:
                if (msg.obj == null) {
                    Rlog.e(LOG_TAG, "RTT msg.obj is null. Ignoring.");
                    return;
                }
                String messageToIncall = (String) msg.obj;
                if (mRttTextStream == null) {
                    Rlog.e(LOG_TAG, "RTT text stream is null. Writing to in-call buffer.");
                    mBufferedTextToIncall.append(messageToIncall);
                    return;
                }
                try {
                    mRttTextStream.write(messageToIncall);
                } catch (IOException e) {
@@ -216,6 +225,21 @@ public class ImsRttTextHandler extends Handler {
        mReadNotifier = latch;
    }

    @VisibleForTesting
    public StringBuffer getBufferedTextToIncall() {
        return mBufferedTextToIncall;
    }

    @VisibleForTesting
    public void setRttTextStream(Connection.RttTextStream rttTextStream) {
        mRttTextStream = rttTextStream;
    }

    @VisibleForTesting
    public int getSendToIncall() {
        return SEND_TO_INCALL;
    }

    public String getNetworkBufferText() {
        return mBufferedTextToNetwork.toString();
    }
+118 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.telephony.dataconnection;

import static junit.framework.Assert.assertEquals;

import static org.mockito.Mockito.doReturn;

import android.net.ConnectivityManager;
import android.net.LinkProperties;
import android.net.NetworkAgent;
import android.net.NetworkAgentConfig;
import android.net.NetworkInfo;
import android.net.NetworkProvider;
import android.os.Looper;
import android.telephony.AccessNetworkConstants;
import android.telephony.TelephonyManager;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;

import com.android.internal.telephony.TelephonyTest;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;

import java.lang.reflect.Field;

@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
public class DcNetworkAgentTest extends TelephonyTest {

    private DcNetworkAgent mDcNetworkAgent;
    private DataConnection mDc;
    private DcController mDcc;
    private DcFailBringUp mDcFailBringUp;

    @Mock
    private DataServiceManager mDataServiceManager;
    @Mock
    private DcTesterFailBringUpAll mDcTesterFailBringUpAll;
    @Mock
    private NetworkProvider mNetworkProvider;

    @Before
    public void setUp() throws Exception {
        super.setUp(getClass().getSimpleName());
        logd("+Setup!");
        if (Looper.myLooper() == null) {
            Looper.prepare();
        }

        final NetworkAgentConfig.Builder configBuilder = new NetworkAgentConfig.Builder();
        configBuilder.setLegacyType(ConnectivityManager.TYPE_MOBILE);
        configBuilder.setLegacyTypeName("MOBILE");
        configBuilder.setLegacySubType(TelephonyManager.NETWORK_TYPE_LTE);
        configBuilder.setLegacySubTypeName("LTE");
        configBuilder.setLegacyExtraInfo("apn");

        doReturn("fake.action_detached").when(mPhone).getActionDetached();
        mDcFailBringUp = new DcFailBringUp();
        mDcFailBringUp.saveParameters(0, 0, -2);
        doReturn(mDcFailBringUp).when(mDcTesterFailBringUpAll).getDcFailBringUp();

        mDcc = DcController.makeDcc(mPhone, mDcTracker, mDataServiceManager, Looper.myLooper(),
                "");
        mDc = DataConnection.makeDataConnection(mPhone, 0, mDcTracker, mDataServiceManager,
                mDcTesterFailBringUpAll, mDcc);

        LinkProperties linkProperties = new LinkProperties();
        linkProperties.setInterfaceName("fake_iface");
        Field field = DataConnection.class.getDeclaredField("mLinkProperties");
        field.setAccessible(true);
        field.set(mDc, linkProperties);

        mDcNetworkAgent = new DcNetworkAgent(mDc, mPhone, 45, configBuilder.build(),
                mNetworkProvider, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        logd("-Setup!");
    }

    @After
    public void tearDown() throws Exception {
        super.tearDown();
    }

    private void verifyDisconnected() throws Exception {
        Field field = NetworkAgent.class.getDeclaredField("mNetworkInfo");
        field.setAccessible(true);
        NetworkInfo networkInfo = (NetworkInfo) field.get(mDcNetworkAgent);
        assertEquals(NetworkInfo.DetailedState.DISCONNECTED, networkInfo.getDetailedState());
    }

    @Test
    public void testUnwantedTimeout() throws Exception {
        mDcNetworkAgent.markConnected();
        mDcNetworkAgent.onNetworkUnwanted();
        processAllMessages();
        moveTimeForward(60000);
        processAllMessages();
        verifyDisconnected();
    }
}
+38 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.internal.telephony.imsphone;
import static com.android.internal.telephony.TelephonyTestUtils.waitForMs;

import android.os.HandlerThread;
import android.os.Message;
import android.os.ParcelFileDescriptor;
import android.telecom.Connection;

@@ -41,6 +42,7 @@ import java.util.concurrent.TimeUnit;
public class ImsRttTextHandlerTest extends TelephonyTest {
    private static final int TEST_TIMEOUT = 1000;
    private static final int READ_BUFFER_SIZE = 1000;
    private static final String SHORT_TEXT = "Hello, World!";
    private static final String LONG_TEXT = "No Soldier shall, in time of peace be quartered in " +
            "any house, without the consent of the Owner, nor in time of war, but in a manner to " +
            "be prescribed by law.";
@@ -223,6 +225,42 @@ public class ImsRttTextHandlerTest extends TelephonyTest {
        Assert.assertEquals(LONG_TEXT, readAll(mPipeFromHandler));
    }

    /**
     * Test {@link ImsRttTextHandler#handleMessage(Message)} SEND_TO_INCALL case.  Specifically,
     * test SEND_IN_CALL does not throw an exception when given a null msg.obj.
     */
    @Test
    public void testHandleMessageCaseSendToInCallWithNullMsgObj() {
        // Create a Message object
        Message msg = new Message();
        // Set the message what to SEND_TO_INCALL
        msg.setWhat(mRttTextHandler.getSendToIncall());
        // Set the message object to null
        msg.obj = null;
        // Call handleMessage with the null msg and ensure no Exception is thrown
        mRttTextHandler.handleMessage(msg);
    }

    /**
     * Test {@link ImsRttTextHandler#handleMessage(Message)} SEND_TO_INCALL case.  If
     * mRttTextStream is null, then text should be written to mBufferedTextToIncall.
     */
    @Test
    public void testHandleMessageWithRttTextStreamNull() {
        // Ensure the buffer is empty
        Assert.assertEquals("", mRttTextHandler.getBufferedTextToIncall().toString());
        // Simulate the stream was never initialized or null
        mRttTextHandler.setRttTextStream(null);
        // Wait for change to take action
        waitForHandlerAction(mRttTextHandler, TEST_TIMEOUT);
        // Send text to In Call
        mRttTextHandler.sendToInCall(SHORT_TEXT);
        // Wait for change to take action
        waitForHandlerAction(mRttTextHandler, TEST_TIMEOUT);
        // Assert the text was written to the buffer
        Assert.assertEquals(SHORT_TEXT, mRttTextHandler.getBufferedTextToIncall().toString());
    }

    @After
    public void tearDown() throws Exception {
        mPipeFromHandler.close();