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

Commit d52661e6 authored by Jack Yu's avatar Jack Yu Committed by android-build-merger
Browse files

Merge changes from topic 'dataallow'

am: cbd3dcc9

Change-Id: Id35d6ffd7ed9311bab8b77e4ad16bae69b969d22
parents 004a864f cbd3dcc9
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -22,12 +22,12 @@ import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.telephony.CellInfo;
import android.telephony.PreciseCallState;
import android.telephony.Rlog;
import android.telephony.VoLteServiceState;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.PreciseCallState;
import android.telephony.VoLteServiceState;

import com.android.internal.telephony.PhoneConstantConversions;

@@ -179,14 +179,13 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
            if (mRegistry != null) {
                mRegistry.notifyDataConnectionForSubscriber(subId,
                    PhoneConstantConversions.convertDataState(state),
                    sender.isDataConnectivityPossible(apnType), reason,
                        sender.isDataAllowed(), reason,
                        sender.getActiveApnHost(apnType),
                        apnType,
                        linkProperties,
                        networkCapabilities,
                        ((telephony != null) ? telephony.getDataNetworkType(subId) :
                    TelephonyManager.NETWORK_TYPE_UNKNOWN),
                    roaming);
                                TelephonyManager.NETWORK_TYPE_UNKNOWN), roaming);
            }
        } catch (RemoteException ex) {
            // system process is dead
+2 −12
Original line number Diff line number Diff line
@@ -2732,19 +2732,10 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    /**
     * Report on whether data connectivity is allowed.
     */
    public boolean isDataConnectivityPossible() {
        return isDataConnectivityPossible(PhoneConstants.APN_TYPE_DEFAULT);
    public boolean isDataAllowed() {
        return ((mDcTracker != null) && (mDcTracker.isDataAllowed(null)));
    }

    /**
     * Report on whether data connectivity is allowed for an APN.
     */
    public boolean isDataConnectivityPossible(String apnType) {
        return ((mDcTracker != null) &&
                (mDcTracker.isDataPossible(apnType)));
    }


    /**
     * Action set from carrier signalling broadcast receivers to enable/disable metered apns.
     */
@@ -3488,7 +3479,6 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        pw.println(" getPhoneType()=" + getPhoneType());
        pw.println(" getVoiceMessageCount()=" + getVoiceMessageCount());
        pw.println(" getActiveApnTypes()=" + getActiveApnTypes());
        pw.println(" isDataConnectivityPossible()=" + isDataConnectivityPossible());
        pw.println(" needsOtaServiceProvisioning=" + needsOtaServiceProvisioning());
        pw.flush();
        pw.println("++++++++++++++++++++++++++++++++");
+19 −32
Original line number Diff line number Diff line
@@ -1545,34 +1545,23 @@ public class DataConnection extends StateMachine {

            // verify and get updated information in case these things
            // are obsolete
            {
            ServiceState ss = mPhone.getServiceState();
            final int networkType = ss.getDataNetworkType();
            if (mNetworkInfo.getSubtype() != networkType) {
                    log("DcActiveState with incorrect subtype (" + mNetworkInfo.getSubtype() +
                            ", " + networkType + "), updating.");
                log("DcActiveState with incorrect subtype (" + mNetworkInfo.getSubtype()
                        + ", " + networkType + "), updating.");
            }
            mNetworkInfo.setSubtype(networkType, TelephonyManager.getNetworkTypeName(networkType));
            final boolean roaming = ss.getDataRoaming();
            if (roaming != mNetworkInfo.isRoaming()) {
                    log("DcActiveState with incorrect roaming (" + mNetworkInfo.isRoaming() +
                            ", " + roaming +"), updating.");
                log("DcActiveState with incorrect roaming (" + mNetworkInfo.isRoaming()
                        + ", " + roaming + "), updating.");
            }

            mNetworkInfo.setRoaming(roaming);
            }

            boolean createNetworkAgent = true;
            // If a disconnect is already pending, avoid notifying all of connected
            if (hasMessages(EVENT_DISCONNECT) ||
                    hasMessages(EVENT_DISCONNECT_ALL) ||
                    hasDeferredMessages(EVENT_DISCONNECT) ||
                    hasDeferredMessages(EVENT_DISCONNECT_ALL)) {
                log("DcActiveState: skipping notifyAllOfConnected()");
                createNetworkAgent = false;
            } else {
            // If we were retrying there maybe more than one, otherwise they'll only be one.
            notifyAllOfConnected(Phone.REASON_CONNECTED);
            }

            mPhone.getCallTracker().registerForVoiceCallStarted(getHandler(),
                    DataConnection.EVENT_DATA_CONNECTION_VOICE_CALL_STARTED, null);
@@ -1597,13 +1586,11 @@ public class DataConnection extends StateMachine {
            }
            misc.subscriberId = mPhone.getSubscriberId();

            if (createNetworkAgent) {
            setNetworkRestriction();
            mNetworkAgent = new DcNetworkAgent(getHandler().getLooper(), mPhone.getContext(),
                    "DcNetworkAgent", mNetworkInfo, makeNetworkCapabilities(), mLinkProperties,
                    50, misc);
        }
        }

        @Override
        public void exit() {
+132 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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 java.util.HashSet;

/**
 * The class to describe the reasons of allowing or disallowing to establish a data connection.
 */
public class DataConnectionReasons {
    private HashSet<DataDisallowedReasonType> mDataDisallowedReasonSet = new HashSet<>();
    private DataAllowedReasonType mDataAllowedReason = DataAllowedReasonType.NONE;

    public DataConnectionReasons() {}

    void add(DataDisallowedReasonType reason) {
        // Adding a disallowed reason will clean up the allowed reason because they are
        // mutual exclusive.
        mDataAllowedReason = DataAllowedReasonType.NONE;
        mDataDisallowedReasonSet.add(reason);
    }

    void add(DataAllowedReasonType reason) {
        // Adding an allowed reason will clean up the disallowed reasons because they are
        // mutual exclusive.
        mDataDisallowedReasonSet.clear();

        // Only higher priority allowed reason can overwrite the old one. See
        // DataAllowedReasonType for the oder.
        if (reason.ordinal() > mDataAllowedReason.ordinal()) {
            mDataAllowedReason = reason;
        }
    }

    @Override
    public String toString() {
        StringBuilder reasonStr = new StringBuilder();
        if (mDataDisallowedReasonSet.size() > 0) {
            reasonStr.append("Data disallowed, reasons:");
            for (DataDisallowedReasonType reason : mDataDisallowedReasonSet) {
                reasonStr.append(" ").append(reason);
            }
        } else {
            reasonStr.append("Data allowed, reason:");
            reasonStr.append(" ").append(mDataAllowedReason);
        }
        return reasonStr.toString();
    }

    void copyFrom(DataConnectionReasons reasons) {
        this.mDataDisallowedReasonSet = reasons.mDataDisallowedReasonSet;
        this.mDataAllowedReason = reasons.mDataAllowedReason;
    }

    boolean allowed() {
        return mDataDisallowedReasonSet.size() == 0;
    }

    boolean contains(DataDisallowedReasonType reason) {
        return mDataDisallowedReasonSet.contains(reason);
    }

    boolean contains(DataAllowedReasonType reason) {
        return reason == mDataAllowedReason;
    }

    boolean containsHardDisallowedReasons() {
        for (DataDisallowedReasonType reason : mDataDisallowedReasonSet) {
            if (reason.isHardReason()) {
                return true;
            }
        }
        return false;
    }

    // Disallowed reasons. There could be multiple reasons if data connection is not allowed.
    enum DataDisallowedReasonType {
        // Soft failure reasons. Normally the reasons from users or policy settings.
        DATA_DISABLED(false),                   // Data is disabled by the user or policy.
        ROAMING_DISABLED(false),                // Data roaming is disabled by the user.

        // Belows are all hard failure reasons.
        NOT_ATTACHED(true),
        RECORD_NOT_LOADED(true),
        INVALID_PHONE_STATE(true),
        CONCURRENT_VOICE_DATA_NOT_ALLOWED(true),
        PS_RESTRICTED(true),
        UNDESIRED_POWER_STATE(true),
        INTERNAL_DATA_DISABLED(true),
        DEFAULT_DATA_UNSELECTED(true),
        RADIO_DISABLED_BY_CARRIER(true),
        APN_NOT_CONNECTABLE(true),
        ON_IWLAN(true),
        IN_ECBM(true);

        private boolean mIsHardReason;

        boolean isHardReason() {
            return mIsHardReason;
        }

        DataDisallowedReasonType(boolean isHardReason) {
            mIsHardReason = isHardReason;
        }
    }

    // Data allowed reasons. There will be only one reason if data is allowed.
    enum DataAllowedReasonType {
        // Note that unlike disallowed reasons, we only have one allowed reason every time
        // when we check data is allowed or not. The order of these allowed reasons is very
        // important. The lower ones take precedence over the upper ones.
        NONE,
        NORMAL,
        UNMETERED_APN,
        RESTRICTED_REQUEST,
        EMERGENCY_APN,
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -63,6 +63,13 @@ public class DataEnabledSettings {

    private final RegistrantList mDataEnabledChangedRegistrants = new RegistrantList();

    @Override
    public String toString() {
        return "[mInternalDataEnabled=" + mInternalDataEnabled + ", mUserDataEnabled="
                + mUserDataEnabled + ", mPolicyDataEnabled=" + mPolicyDataEnabled
                + ", mCarrierDataEnabled=" + mCarrierDataEnabled + "]";
    }

    public synchronized void setInternalDataEnabled(boolean enabled) {
        boolean prevDataEnabled = isDataEnabled();
        mInternalDataEnabled = enabled;
Loading