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

Commit b2e0096b authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5704917 from f7a27e50 to qt-c2f2-release

Change-Id: I5e1232315ebdfa436ec7405e1a22f2d9a8afc009
parents c42056bc f7a27e50
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ public class LocaleTracker extends Handler {
    /** Count of invalid cell info we've got so far. Will reset once we get a successful one */
    private int mFailCellInfoCount;

    /** The ISO-3166 code of device's current country */
    /** The ISO-3166 two-letter code of device's current country */
    @Nullable
    private String mCurrentCountryIso;

+23 −3
Original line number Diff line number Diff line
@@ -2631,9 +2631,7 @@ public class ServiceStateTracker extends Handler {
                showPlmn = true;

                // Force display no service
                final boolean forceDisplayNoService = mPhone.getContext().getResources().getBoolean(
                        com.android.internal.R.bool.config_display_no_service_when_sim_unready)
                        && !mIsSimReady;
                final boolean forceDisplayNoService = shouldForceDisplayNoService() && !mIsSimReady;
                if (!forceDisplayNoService && Phone.isEmergencyCallOnly()) {
                    // No service but emergency call allowed
                    plmn = Resources.getSystem().
@@ -2744,6 +2742,28 @@ public class ServiceStateTracker extends Handler {
        log("updateSpnDisplayLegacy-");
    }

    /**
     * Checks whether force to display "no service" to the user based on the current country.
     *
     * This method should only be used when SIM is unready.
     *
     * @return {@code True} if "no service" should be displayed.
     */
    public boolean shouldForceDisplayNoService() {
        String[] countriesWithNoService = mPhone.getContext().getResources().getStringArray(
                com.android.internal.R.array.config_display_no_service_when_sim_unready);
        if (ArrayUtils.isEmpty(countriesWithNoService)) {
            return false;
        }
        String currentCountry = mLocaleTracker.getCurrentCountry();
        for (String country : countriesWithNoService) {
            if (country.equalsIgnoreCase(currentCountry)) {
                return true;
            }
        }
        return false;
    }

    protected void setPowerStateToDesired() {
        if (DBG) {
            String tmpLog = "mDeviceShuttingDown=" + mDeviceShuttingDown +
+2 −3
Original line number Diff line number Diff line
@@ -377,9 +377,8 @@ public class CarrierDisplayNameResolver {
        String plmn = null;
        boolean isSimReady = mPhone.getUiccCardApplication() != null
                && mPhone.getUiccCardApplication().getState() == AppState.APPSTATE_READY;
        boolean forceDisplayNoService = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_display_no_service_when_sim_unready)
                && !isSimReady;
        boolean forceDisplayNoService =
                mPhone.getServiceStateTracker().shouldForceDisplayNoService() && !isSimReady;
        ServiceState ss = getServiceState();
        if (ss.getVoiceRegState() == ServiceState.STATE_POWER_OFF
                || forceDisplayNoService || !Phone.isEmergencyCallOnly()) {
+42 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.net.NetworkPolicyManager.OVERRIDE_UNMETERED;
import android.annotation.IntDef;
import android.annotation.Nullable;
import android.app.PendingIntent;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.KeepalivePacketData;
import android.net.LinkAddress;
@@ -38,11 +39,13 @@ import android.net.SocketKeepalive;
import android.net.StringNetworkSpecifier;
import android.os.AsyncResult;
import android.os.Message;
import android.os.PersistableBundle;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.provider.Telephony;
import android.telephony.AccessNetworkConstants;
import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.CarrierConfigManager;
import android.telephony.DataFailCause;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.Rlog;
@@ -50,6 +53,7 @@ import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.data.ApnSetting;
import android.telephony.data.ApnSetting.ApnType;
import android.telephony.data.DataCallResponse;
import android.telephony.data.DataProfile;
import android.telephony.data.DataService;
@@ -1975,6 +1979,12 @@ public class DataConnection extends StateMachine {
                    log("Transfer network agent successfully.");
                    mNetworkAgent = mHandoverSourceNetworkAgent;
                    mNetworkAgent.acquireOwnership(DataConnection.this, mTransportType);

                    // TODO: Should evaluate mDisabledApnTypeBitMask again after handover. We don't
                    // do it now because connectivity service does not support dynamically removing
                    // immutable capabilities.

                    // Update the capability after handover
                    mNetworkAgent.sendNetworkCapabilities(getNetworkCapabilities(),
                            DataConnection.this);
                    mNetworkAgent.sendLinkProperties(mLinkProperties, DataConnection.this);
@@ -1989,6 +1999,9 @@ public class DataConnection extends StateMachine {
                        mPhone.getPhoneId());
                final int factorySerialNumber = (null == factory)
                        ? NetworkFactory.SerialNumber.NONE : factory.getSerialNumber();

                mDisabledApnTypeBitMask |= getDisallowedApnTypes();

                mNetworkAgent = DcNetworkAgent.createDcNetworkAgent(DataConnection.this,
                        mPhone, mNetworkInfo, mScore, misc, factorySerialNumber, mTransportType);
            }
@@ -2743,6 +2756,33 @@ public class DataConnection extends StateMachine {
                == NetworkRegistrationInfo.NR_STATE_CONNECTED;
    }

    /**
     * @return The disallowed APN types bitmask
     */
    private @ApnType int getDisallowedApnTypes() {
        CarrierConfigManager configManager = (CarrierConfigManager)
                mPhone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
        int apnTypesBitmask = 0;
        if (configManager != null) {
            PersistableBundle bundle = configManager.getConfigForSubId(mSubId);
            if (bundle != null) {
                String key = (mTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                        ? CarrierConfigManager.KEY_CARRIER_WWAN_DISALLOWED_APN_TYPES_STRING_ARRAY
                        : CarrierConfigManager.KEY_CARRIER_WLAN_DISALLOWED_APN_TYPES_STRING_ARRAY;
                if (bundle.getStringArray(key) != null) {
                    String disallowedApnTypesString =
                            TextUtils.join(",", bundle.getStringArray(key));
                    if (!TextUtils.isEmpty(disallowedApnTypesString)) {
                        apnTypesBitmask = ApnSetting.getApnTypesBitmaskFromString(
                                disallowedApnTypesString);
                    }
                }
            }
        }

        return apnTypesBitmask;
    }

    private void dumpToLog() {
        dump(null, new PrintWriter(new StringWriter(0)) {
            @Override
@@ -2827,6 +2867,8 @@ public class DataConnection extends StateMachine {
        pw.println("mSubscriptionOverride=" + Integer.toHexString(mSubscriptionOverride));
        pw.println("mRestrictedNetworkOverride=" + mRestrictedNetworkOverride);
        pw.println("mUnmeteredUseOnly=" + mUnmeteredUseOnly);
        pw.println("disallowedApnTypes="
                + ApnSetting.getApnTypesStringFromBitmask(getDisallowedApnTypes()));
        pw.println("mInstanceNumber=" + mInstanceNumber);
        pw.println("mAc=" + mAc);
        pw.println("mScore=" + mScore);
+25 −3
Original line number Diff line number Diff line
@@ -299,9 +299,10 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        mBundle.putStringArray(CarrierConfigManager.KEY_PNN_OVERRIDE_STRING_ARRAY,
                CARRIER_CONFIG_PNN);

        // Do not force display "No service" when sim is not ready
        mContextFixture.putBooleanResource(
                com.android.internal.R.bool.config_display_no_service_when_sim_unready, false);
        // Do not force display "No service" when sim is not ready in any locales
        mContextFixture.putStringArrayResource(
                com.android.internal.R.array.config_display_no_service_when_sim_unready,
                new String[0]);

        logd("ServiceStateTrackerTest -Setup!");
    }
@@ -2279,6 +2280,27 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        assertThat(b.getBoolean(TelephonyIntents.EXTRA_SHOW_PLMN)).isTrue();
    }

    @Test
    public void testShouldForceDisplayNoService_forceBasedOnLocale() {
        // set up unaffected locale (US) and clear the resource
        doReturn("us").when(mLocaleTracker).getCurrentCountry();
        mContextFixture.putStringArrayResource(
                com.android.internal.R.array.config_display_no_service_when_sim_unready,
                new String[0]);
        assertFalse(sst.shouldForceDisplayNoService());

        // set up the resource to include Germany
        mContextFixture.putStringArrayResource(
                com.android.internal.R.array.config_display_no_service_when_sim_unready,
                new String[]{"de"});
        doReturn("us").when(mLocaleTracker).getCurrentCountry();
        assertFalse(sst.shouldForceDisplayNoService());

        // mock the locale to Germany
        doReturn("de").when(mLocaleTracker).getCurrentCountry();
        assertTrue(sst.shouldForceDisplayNoService());
    }

    private Bundle getExtrasFromLastSpnUpdateIntent() {
        // Verify the spn update notification was sent
        ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
Loading