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

Commit 615fe026 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9084753 from 58f10822 to tm-qpr1-release

Change-Id: Ie154286837a6e76f6562fbfc5e5a1937b561cfb2
parents babb6b67 58f10822
Loading
Loading
Loading
Loading
+39 −2
Original line number Diff line number Diff line
@@ -28,6 +28,9 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.app.PendingIntent;
import android.app.compat.CompatChanges;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledSince;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ContentResolver;
import android.content.ContentValues;
@@ -162,6 +165,15 @@ public class SubscriptionController extends ISub.Stub {
    protected TelephonyManager mTelephonyManager;
    protected UiccController mUiccController;

    /**
     * Apps targeting on Android T and beyond will get an empty list if there is no access to device
     * identifiers nor has carrier privileges when calling
     * SubscriptionManager#getSubscriptionsInGroup.
     */
    @ChangeId
    @EnabledSince(targetSdkVersion = Build.VERSION_CODES.TIRAMISU)
    public static final long REQUIRE_DEVICE_IDENTIFIERS_FOR_GROUP_UUID = 213902861L;

    private AppOpsManager mAppOps;

    // Allows test mocks to avoid SELinux failures on invalidate calls.
@@ -3965,10 +3977,20 @@ public class SubscriptionController extends ISub.Stub {
     * Get subscriptionInfo list of subscriptions that are in the same group of given subId.
     * See {@link #createSubscriptionGroup(int[], String)} for more details.
     *
     * Caller will either have {@link android.Manifest.permission#READ_PHONE_STATE}
     * permission or had carrier privilege permission on the subscription.
     * Caller must have {@link android.Manifest.permission#READ_PHONE_STATE}
     * or carrier privilege permission on the subscription.
     * {@link TelephonyManager#hasCarrierPrivileges(int)}
     *
     * <p>Starting with API level 33, the caller needs READ_PHONE_STATE and access to device
     * identifiers to get the list of subscriptions associated with a group UUID.
     * This method can be invoked if one of the following requirements is met:
     * <ul>
     *     <li>If the app has carrier privilege permission.
     *     {@link TelephonyManager#hasCarrierPrivileges()}
     *     <li>If the app has {@link android.Manifest.permission#READ_PHONE_STATE} and
     *     access to device identifiers.
     * </ul>
     *
     * @throws SecurityException if the caller doesn't meet the requirements
     *             outlined above.
     *
@@ -3995,6 +4017,21 @@ public class SubscriptionController extends ISub.Stub {
            Binder.restoreCallingIdentity(identity);
        }

        // If the calling app neither has carrier privileges nor READ_PHONE_STATE and access to
        // device identifiers, it will return an empty list.
        if (CompatChanges.isChangeEnabled(
                REQUIRE_DEVICE_IDENTIFIERS_FOR_GROUP_UUID, Binder.getCallingUid())) {
            try {
                if (!TelephonyPermissions.checkCallingOrSelfReadDeviceIdentifiers(mContext,
                        callingPackage, callingFeatureId, "getSubscriptionsInGroup")) {
                    EventLog.writeEvent(0x534e4554, "213902861", Binder.getCallingUid());
                    return new ArrayList<>();
                }
            } catch (SecurityException e) {
                EventLog.writeEvent(0x534e4554, "213902861", Binder.getCallingUid());
                return new ArrayList<>();
            }
        }
        return subInfoList.stream().filter(info -> {
            if (!groupUuid.equals(info.getGroupUuid())) return false;
            int subId = info.getSubscriptionId();
+0 −30
Original line number Diff line number Diff line
@@ -365,18 +365,12 @@ public class AccessNetworksManager extends Handler {
            }

            List<QualifiedNetworks> qualifiedNetworksList = new ArrayList<>();
            // For anomaly report, only track frequent HO between cellular and IWLAN
            boolean isRequestedNetworkOnIwlan = Arrays.stream(qualifiedNetworkTypes)
                    .anyMatch(network -> network == AccessNetworkType.IWLAN);
            int satisfiedApnTypes = 0;
            for (int apnType : SUPPORTED_APN_TYPES) {
                if ((apnTypes & apnType) == apnType) {
                    // skip the APN anomaly detection if not using the T data stack
                    if (mDataConfigManager != null) {
                        satisfiedApnTypes |= apnType;
                        if (isRequestedNetworkOnIwlan) {
                            trackFrequentApnTypeChange(apnType);
                        }
                    }

                    if (mAvailableNetworks.get(apnType) != null) {
@@ -428,30 +422,6 @@ public class AccessNetworksManager extends Handler {
        }
    }

    /**
     * Called when receiving preferred transport change request for a specific apnType.
     *
     * @param apnType The requested apnType.
     */
    private void trackFrequentApnTypeChange(@ApnSetting.ApnType int apnType) {
        DataNetworkController dnc = mPhone.getDataNetworkController();
        // ignore the report when no existing network request
        if (!dnc.isCapabilityRequestExisting(DataUtils.apnTypeToNetworkCapability(apnType))) return;
        SlidingWindowEventCounter counter = mApnTypeToQnsChangeNetworkCounter.get(apnType);
        if (counter == null) {
            counter = new SlidingWindowEventCounter(
                    mDataConfigManager.getAnomalyQnsChangeThreshold().timeWindow,
                    mDataConfigManager.getAnomalyQnsChangeThreshold().eventNumOccurrence);
            mApnTypeToQnsChangeNetworkCounter.put(apnType, counter);
        }
        if (counter.addOccurrence()) {
            reportAnomaly("QNS requested network change for "
                            + ApnSetting.getApnTypeString(apnType) + " "
                            + counter.getFrequencyString(),
                    "3e89a3df-3524-45fa-b5f2-b8911abc7d56");
        }
    }

    /**
     * Access networks manager callback. This should be only used by {@link DataNetworkController}.
     */
+0 −18
Original line number Diff line number Diff line
@@ -233,11 +233,6 @@ public class DataConfigManager extends Handler {
     */
    private EventFrequency mNetworkUnwantedAnomalyReportThreshold;

    /**
     * Anomaly report thresholds for frequent APN type change at {@link AccessNetworksManager}
     */
    private EventFrequency mQnsFrequentApnTypeChangeAnomalyReportThreshold;

    /**
     * {@code true} if enabled anomaly detection for param when QNS wants to change preferred
     * network at {@link AccessNetworksManager}.
@@ -421,8 +416,6 @@ public class DataConfigManager extends Handler {
                properties.getString(KEY_ANOMALY_NETWORK_UNWANTED, null), 0, 12);
        mSetupDataCallAnomalyReportThreshold = parseSlidingWindowCounterThreshold(
                properties.getString(KEY_ANOMALY_SETUP_DATA_CALL_FAILURE, null), 0, 12);
        mQnsFrequentApnTypeChangeAnomalyReportThreshold = parseSlidingWindowCounterThreshold(
                properties.getString(KEY_ANOMALY_QNS_CHANGE_NETWORK, null), 0, 5);
        mIsInvalidQnsParamAnomalyReportEnabled = properties.getBoolean(
                KEY_ANOMALY_QNS_PARAM, false);
        mNetworkConnectingTimeout = properties.getInt(
@@ -868,15 +861,6 @@ public class DataConfigManager extends Handler {
        return mImsReleaseRequestAnomalyReportThreshold;
    }

    /**
     * Anomaly report thresholds for frequent QNS change of preferred network
     * at {@link AccessNetworksManager}
     * @return EventFrequency to trigger the anomaly report
     */
    public @NonNull EventFrequency getAnomalyQnsChangeThreshold() {
        return mQnsFrequentApnTypeChangeAnomalyReportThreshold;
    }

    /**
     * @return {@code true} if enabled anomaly report for invalid param when QNS wants to change
     * preferred network at {@link AccessNetworksManager}.
@@ -1292,8 +1276,6 @@ public class DataConfigManager extends Handler {
        pw.println("mSetupDataCallAnomalyReport=" + mSetupDataCallAnomalyReportThreshold);
        pw.println("mNetworkUnwantedAnomalyReport=" + mNetworkUnwantedAnomalyReportThreshold);
        pw.println("mImsReleaseRequestAnomalyReport=" + mImsReleaseRequestAnomalyReportThreshold);
        pw.println("mQnsFrequentApnTypeChangeAnomalyReportThreshold="
                + mQnsFrequentApnTypeChangeAnomalyReportThreshold);
        pw.println("mIsInvalidQnsParamAnomalyReportEnabled="
                + mIsInvalidQnsParamAnomalyReportEnabled);
        pw.println("mNetworkConnectingTimeout=" + mNetworkConnectingTimeout);
+23 −0
Original line number Diff line number Diff line
@@ -2451,6 +2451,29 @@ public class DataNetwork extends StateMachine {
                reportAnomaly("Invalid DataCallResponse detected",
                        "1f273e9d-b09c-46eb-ad1c-421d01f61164");
            }
            if (mDataProfile.getApnSetting() != null && mPhone.getServiceState().getDataRegState()
                    == ServiceState.STATE_IN_SERVICE) {
                boolean isRoaming = mPhone.getServiceState().getDataRoamingFromRegistration();
                int protocol = isRoaming ? mDataProfile.getApnSetting().getRoamingProtocol()
                        : mDataProfile.getApnSetting().getProtocol();
                if (protocol == ApnSetting.PROTOCOL_IP) {
                    if (response.getAddresses().stream().anyMatch(
                            la -> la.getAddress() instanceof java.net.Inet6Address)) {
                        loge("Invalid DataCallResponse. Requested IPv4 but got IPv6 address. "
                                + response);
                        reportAnomaly("RIL reported mismatched IP type. Requested IPv6 "
                                + "but got IPv4 address.", "7744f920-fb64-4db0-ba47-de0eae485a7f");
                    }
                } else if (protocol == ApnSetting.PROTOCOL_IPV6) {
                    if (response.getAddresses().stream().anyMatch(
                            la -> la.getAddress() instanceof java.net.Inet4Address)) {
                        loge("Invalid DataCallResponse. Requested IPv6 but got IPv4 address. "
                                + response);
                        reportAnomaly("RIL reported mismatched IP type. Requested IPv4 "
                                + "but got IPv6 address.", "7744f920-fb64-4db0-ba47-de0eae485a7f");
                    }
                }
            }
        } else if (!DataFailCause.isFailCauseExisting(failCause)) { // Setup data failed.
            loge("Invalid DataFailCause in " + response);
            reportAnomaly("Invalid DataFailCause: (0x" + Integer.toHexString(failCause)
+12 −14
Original line number Diff line number Diff line
@@ -2103,18 +2103,6 @@ public class DataNetworkController extends Handler {
        return mAllNetworkRequestList.contains(networkRequest);
    }

    /**
     * Check if a request for the capability currently exists. Note this method id not thread safe
     * so can be only called within the modules in {@link com.android.internal.telephony.data}.
     *
     * @param capability Network capability to check
     * @return {@code true} if the request for the capability exists.
     */
    public boolean isCapabilityRequestExisting(@NetCapability int capability) {
        return mAllNetworkRequestList.stream()
                .anyMatch(request -> request.hasCapability(capability));
    }

    /**
     * Check if there are existing networks having the same interface name.
     *
@@ -2514,7 +2502,7 @@ public class DataNetworkController extends Handler {
        logl("onDataNetworkSetupDataFailed: " + dataNetwork + ", cause="
                + DataFailCause.toString(cause) + ", retryDelayMillis=" + retryDelayMillis + "ms.");
        mDataNetworkList.remove(dataNetwork);
        trackSetupDataCallFailure(dataNetwork.getTransport());
        trackSetupDataCallFailure(dataNetwork.getTransport(), cause);
        if (mAnyDataNetworkExisting && mDataNetworkList.isEmpty()) {
            mPendingTearDownAllNetworks = false;
            mAnyDataNetworkExisting = false;
@@ -2539,8 +2527,10 @@ public class DataNetworkController extends Handler {
     * {@link AccessNetworkConstants.TransportType} data service.
     *
     * @param transport The transport of the data service.
     * @param cause The fail cause
     */
    private void trackSetupDataCallFailure(@TransportType int transport) {
    private void trackSetupDataCallFailure(@TransportType int transport,
            @DataFailureCause int cause) {
        switch (transport) {
            case AccessNetworkConstants.TRANSPORT_TYPE_WWAN:
                // Skip when poor signal strength
@@ -2548,6 +2538,10 @@ public class DataNetworkController extends Handler {
                        <= CellSignalStrength.SIGNAL_STRENGTH_POOR) {
                    return;
                }
                if (cause == DataFailCause.ERROR_UNSPECIFIED || cause == DataFailCause.UNKNOWN) {
                    reportAnomaly("RIL set up data call fails: unknown/unspecified error",
                            "ce7d1465-d8e4-404a-b76f-de2c60bee843");
                }
                if (mSetupDataCallWwanFailureCounter.addOccurrence()) {
                    reportAnomaly("RIL fails setup data call request "
                                    + mSetupDataCallWwanFailureCounter.getFrequencyString(),
@@ -2555,6 +2549,10 @@ public class DataNetworkController extends Handler {
                }
                break;
            case AccessNetworkConstants.TRANSPORT_TYPE_WLAN:
                if (cause == DataFailCause.ERROR_UNSPECIFIED || cause == DataFailCause.UNKNOWN) {
                    reportAnomaly("IWLAN set up data call fails: unknown/unspecified error",
                            "a16fc15c-815b-4908-b8e6-5f3bc7cbc20b");
                }
                if (mSetupDataCallWlanFailureCounter.addOccurrence()) {
                    reportAnomaly("IWLAN data service fails setup data call request "
                                    + mSetupDataCallWlanFailureCounter.getFrequencyString(),
Loading