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

Commit fb885aee authored by Xin Li's avatar Xin Li Committed by Gerrit Code Review
Browse files

Merge "Merge Android 13 QPR1"

parents 8d5dd538 b4cf7280
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ option java_outer_classname = "PersistAtomsProto";

// Holds atoms to store on persist storage in case of power cycle or process crash.
// NOTE: using int64 rather than google.protobuf.Timestamp for timestamps simplifies implementation.
// Next id: 50
// Next id: 53
message PersistAtoms {
    /* Aggregated RAT usage during the call. */
    repeated VoiceCallRatUsage voice_call_rat_usage = 1;
@@ -177,6 +177,9 @@ message PersistAtoms {

    /* Timestamp of last network_requests_v2 pull. */
    optional int64 network_requests_v2_pull_timestamp_millis = 51;

    /* Unmetered networks information. */
    repeated UnmeteredNetworks unmetered_networks = 52;
}

// The canonical versions of the following enums live in:
@@ -245,6 +248,10 @@ message IncomingSms {
    optional bool is_esim = 12;
    optional int32 carrier_id = 13;
    optional int64 message_id = 14;
    optional int32 count = 15;

    // Internal use only
    optional int32 hashCode = 10001;
}

message OutgoingSms {
@@ -262,6 +269,10 @@ message OutgoingSms {
    optional int64 message_id = 12;
    optional int32 retry_id = 13;
    optional int64 interval_millis = 14;
    optional int32 count = 15;

    // Internal use only
    optional int32 hashCode = 10001;
}

message CarrierIdMismatch {
@@ -292,6 +303,7 @@ message DataCallSession {
    optional bool ongoing = 18;
    optional int32 band_at_end = 19;
    repeated int32 handover_failure_causes = 20;
    repeated int32 handover_failure_rat = 21;
}

message CellularServiceState {
@@ -498,3 +510,9 @@ message GbaEvent {
    optional int32 failed_reason = 4;
    optional int32 count = 5;
}

message UnmeteredNetworks {
    optional int32 phone_id = 1;
    optional int32 carrier_id = 2;
    optional int64 unmetered_networks_bitmask = 3;
}
+22 −136
Original line number Diff line number Diff line
@@ -20,21 +20,14 @@ import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.content.SharedPreferences;
import android.database.ContentObserver;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.Message;
import android.os.PersistableBundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.telephony.RadioAccessFamily;
@@ -44,14 +37,12 @@ import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager.NetworkTypeBitMask;
import android.telephony.ims.ImsMmTelManager;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.util.ArrayUtils;
import com.android.internal.telephony.util.NotificationChannelController;
import com.android.telephony.Rlog;

import java.lang.CharSequence;
import java.util.HashMap;
import java.util.Map;

@@ -74,10 +65,6 @@ public class CarrierServiceStateTracker extends Handler {
    private ServiceStateTracker mSST;
    private final Map<Integer, NotificationType> mNotificationTypeMap = new HashMap<>();
    private int mPreviousSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    private static final String WFC_IMS_ENABLED = SubscriptionManager.WFC_IMS_ENABLED;
    private static final String EMERGENCY_NOTIFICATION_PACKAGE = "com.android.phone";
    private static final String EMERGENCY_NOTIFICATION_ACTIVITY
            = "com.android.phone.LimitedServiceActivity";
    public static final int NOTIFICATION_PREF_NETWORK = 1000;
    public static final int NOTIFICATION_EMERGENCY_NETWORK = 1001;

@@ -110,9 +97,6 @@ public class CarrierServiceStateTracker extends Handler {
        }
    }

    private WfcSettingObserver mWfcSettingObserver;
    private SharedPreferences mPreferences;

    public CarrierServiceStateTracker(Phone phone, ServiceStateTracker sst) {
        this.mPhone = phone;
        this.mSST = sst;
@@ -120,8 +104,6 @@ public class CarrierServiceStateTracker extends Handler {
                TelephonyManager.class).createForSubscriptionId(mPhone.getSubId());
        phone.getContext().registerReceiver(mBroadcastReceiver, new IntentFilter(
                CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
        phone.getContext().registerReceiver(mBroadcastReceiver, new IntentFilter(
                Intent.ACTION_LOCALE_CHANGED));
        // Listen for subscriber changes
        SubscriptionManager.from(mPhone.getContext()).addOnSubscriptionsChangedListener(
                new OnSubscriptionsChangedListener(this.getLooper()) {
@@ -133,20 +115,16 @@ public class CarrierServiceStateTracker extends Handler {
                            mTelephonyManager = mTelephonyManager.createForSubscriptionId(
                                    mPhone.getSubId());
                            registerAllowedNetworkTypesListener();
                            registerWfcSettingObserver();
                        }
                    }
                });

        mWfcSettingObserver = new WfcSettingObserver();
        mPreferences = PreferenceManager.getDefaultSharedPreferences(mPhone.getContext());
        registerNotificationTypes();
        mAllowedNetworkType = RadioAccessFamily.getNetworkTypeFromRaf(
                (int) mPhone.getAllowedNetworkTypes(
                        TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER));
        mAllowedNetworkTypesListener = new AllowedNetworkTypesListener();
        registerAllowedNetworkTypesListener();
        registerWfcSettingObserver();
    }

    /**
@@ -184,8 +162,7 @@ public class CarrierServiceStateTracker extends Handler {
        mNotificationTypeMap.put(NOTIFICATION_PREF_NETWORK,
                new PrefNetworkNotification(NOTIFICATION_PREF_NETWORK));
        mNotificationTypeMap.put(NOTIFICATION_EMERGENCY_NETWORK,
                new EmergencyNetworkNotification(NOTIFICATION_EMERGENCY_NETWORK,
                mPhone.getContext()));
                new EmergencyNetworkNotification(NOTIFICATION_EMERGENCY_NETWORK));
    }

    @Override
@@ -374,32 +351,18 @@ public class CarrierServiceStateTracker extends Handler {
    private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            switch (intent.getAction()) {
                case CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED:
            CarrierConfigManager carrierConfigManager = (CarrierConfigManager)
                    context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
            PersistableBundle b = carrierConfigManager.getConfigForSubId(mPhone.getSubId());

                    for (Map.Entry<Integer, NotificationType> entry :
                            mNotificationTypeMap.entrySet()) {
            for (Map.Entry<Integer, NotificationType> entry : mNotificationTypeMap.entrySet()) {
                NotificationType notificationType = entry.getValue();
                notificationType.setDelay(b);
            }
            handleConfigChanges();
                    break;
                case Intent.ACTION_LOCALE_CHANGED:
                    // Upon receiving the locale change broadcast, update the notification's
                    // language
                    handleImsCapabilitiesChanged();
                    break;
            }
        }
    };

    private void unregisterBroadcastReceiver() {
        mPhone.getContext().unregisterReceiver(mBroadcastReceiver);
    }

    /**
     * Post a notification to the NotificationManager for changing network type.
     */
@@ -413,6 +376,7 @@ public class CarrierServiceStateTracker extends Handler {
        Notification.Builder builder = getNotificationBuilder(notificationType);
        // set some common attributes
        builder.setWhen(System.currentTimeMillis())
                .setAutoCancel(true)
                .setSmallIcon(com.android.internal.R.drawable.stat_sys_warning)
                .setColor(context.getResources().getColor(
                       com.android.internal.R.color.system_notification_accent_color));
@@ -435,8 +399,6 @@ public class CarrierServiceStateTracker extends Handler {
     */
    public void dispose() {
        unregisterAllowedNetworkTypesListener();
        unregisterWfcSettingObserver();
        unregisterBroadcastReceiver();
    }

    /**
@@ -551,7 +513,6 @@ public class CarrierServiceStateTracker extends Handler {
            CharSequence details = res.getText(
                    com.android.internal.R.string.NetworkPreferenceSwitchSummary);
            return new Notification.Builder(context)
                    .setAutoCancel(true)
                    .setContentTitle(title)
                    .setStyle(new Notification.BigTextStyle().bigText(details))
                    .setContentText(details)
@@ -567,12 +528,10 @@ public class CarrierServiceStateTracker extends Handler {
    public class EmergencyNetworkNotification implements NotificationType {

        private final int mTypeId;
        private Context mContext;
        private int mDelay = UNINITIALIZED_DELAY_VALUE;

        EmergencyNetworkNotification(int typeId, Context context) {
            mTypeId = typeId;
            mContext = context;
        EmergencyNetworkNotification(int typeId) {
            this.mTypeId = typeId;
        }

        /** sets the interval by which the message is delayed.
@@ -586,10 +545,6 @@ public class CarrierServiceStateTracker extends Handler {
            this.mDelay = bundle.getInt(
                    CarrierConfigManager.KEY_EMERGENCY_NOTIFICATION_DELAY_INT);
            Rlog.i(LOG_TAG, "reading time to delay notification emergency: " + mDelay);
            if (mDelay == UNINITIALIZED_DELAY_VALUE) {
                unregisterWfcSettingObserver();
                return;
            }
        }

        public int getDelay() {
@@ -614,9 +569,8 @@ public class CarrierServiceStateTracker extends Handler {
        public boolean sendMessage() {
            Rlog.i(LOG_TAG, "EmergencyNetworkNotification: sendMessage() w/values: "
                    + "," + mDelay + "," + isPhoneRegisteredForWifiCalling() + ","
                    + mSST.isRadioOn() + "," + getEmergencyNotificationPreference());
            if (mDelay == UNINITIALIZED_DELAY_VALUE || !isPhoneRegisteredForWifiCalling() ||
                    getEmergencyNotificationPreference())  {
                    + mSST.isRadioOn());
            if (mDelay == UNINITIALIZED_DELAY_VALUE || !isPhoneRegisteredForWifiCalling()) {
                return false;
            }
            return true;
@@ -626,86 +580,18 @@ public class CarrierServiceStateTracker extends Handler {
         * Builds a partial notificaiton builder, and returns it.
         */
        public Notification.Builder getNotificationBuilder() {
            Intent notifyIntent = new Intent(TelephonyIntents.ACTION_VOWIFI_ENABLED);
            notifyIntent.putExtra(PhoneConstants.PHONE_KEY, mPhone.getPhoneId());
            notifyIntent.setComponent(new ComponentName(EMERGENCY_NOTIFICATION_PACKAGE,
                    EMERGENCY_NOTIFICATION_ACTIVITY));
            // Set the Activity to start in a new, empty task
            notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                    | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            // Create the PendingIntent
            PendingIntent emergencyIntent = PendingIntent.getActivity(
                    mContext, mPhone.getPhoneId(), notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT
                    | PendingIntent.FLAG_IMMUTABLE);
            CharSequence title = mContext.getText(
            Context context = mPhone.getContext();
            Resources res = SubscriptionManager.getResourcesForSubId(context, mPhone.getSubId());
            CharSequence title = res.getText(
                    com.android.internal.R.string.EmergencyCallWarningTitle);
            String details = String.format(mContext.getResources().getString(
                    com.android.internal.R.string.EmergencyCallWarningSummary),
                    mSST.getServiceProviderNameOrPlmn().trim());
            boolean isCancellable = (mDelay == UNINITIALIZED_DELAY_VALUE) ? true : false;
            return new Notification.Builder(mContext)
                    .setAutoCancel(isCancellable)
                    .setOngoing(true)
            CharSequence details = res.getText(
                    com.android.internal.R.string.EmergencyCallWarningSummary);
            return new Notification.Builder(context)
                    .setContentTitle(title)
                    .setStyle(new Notification.BigTextStyle().bigText(details))
                    .setContentText(details)
                    .setChannel(NotificationChannelController.CHANNEL_ID_WFC)
                    .setVisibility(Notification.VISIBILITY_PUBLIC)
                    .setContentIntent(emergencyIntent);
                    .setFlag(Notification.FLAG_NO_CLEAR, true)
                    .setChannelId(NotificationChannelController.CHANNEL_ID_WFC);
        }
    }

    private class WfcSettingObserver extends ContentObserver {

        WfcSettingObserver() {
            super(null);
        }

        @Override
        public void onChange(boolean selfChange) {
            final boolean wfcSetting;
            int subId = mPhone.getSubId();
            ImsMmTelManager mgr = ImsMmTelManager.createForSubscriptionId(subId);
            wfcSetting = mgr.isVoWiFiSettingEnabled();
            if (!wfcSetting) {
                // Reset Do not show again preference if user disables WFC setting
                // so that notification shows up again when WFC is re-enabled
                resetEmergencyNotificationPreference();
            }
            Rlog.i(LOG_TAG, "WfcSetting onChange on subId:" + subId + " " + wfcSetting
                    + " " + getEmergencyNotificationPreference());
        }
    }

    private void registerWfcSettingObserver() {
        int subId = mPhone.getSubId();
        unregisterWfcSettingObserver();
        if (SubscriptionManager.isValidSubscriptionId(subId)) {
            Uri uri = getUriForWfcEnableSetting();
            Rlog.d(LOG_TAG,"registerWfcSettingObserver " + uri.toString());
            mPhone.getContext().getContentResolver().registerContentObserver(
                    uri, false, mWfcSettingObserver);
        }
    }

    private void unregisterWfcSettingObserver() {
        mPhone.getContext().getContentResolver().unregisterContentObserver(
                mWfcSettingObserver);
    }

    private void resetEmergencyNotificationPreference() {
        mPreferences.edit().putBoolean(Phone.KEY_DO_NOT_SHOW_LIMITED_SERVICE_ALERT
                + mPhone.getSubId(), false).apply();
    }

    private Uri getUriForWfcEnableSetting() {
        Uri uri = Uri.withAppendedPath(SubscriptionManager.getUriForSubscriptionId(
                mPhone.getSubId()), WFC_IMS_ENABLED);
        return uri;
    }

    private boolean getEmergencyNotificationPreference() {
        return mPreferences.getBoolean(Phone.KEY_DO_NOT_SHOW_LIMITED_SERVICE_ALERT
                    + mPhone.getSubId(), false);
    }
}
+16 −0
Original line number Diff line number Diff line
@@ -500,6 +500,14 @@ public class CellularNetworkService extends NetworkService {
            final String rplmn = regResult.registeredPlmn;
            final int reasonForDenial = regResult.reasonForDenial;

            if (regState == NetworkRegistrationInfo.REGISTRATION_STATE_DENIED
                    && reasonForDenial
                    == android.hardware.radio.network.RegistrationFailCause.NONE) {
                AnomalyReporter.reportAnomaly(
                        UUID.fromString("62ed270f-e139-418a-a427-8bcc1bca8f20"),
                            "RIL Missing Reg Fail Reason", mPhone.getCarrierId());
            }

            int networkType = ServiceState.rilRadioTechnologyToNetworkType(regResult.rat);
            if (networkType == TelephonyManager.NETWORK_TYPE_LTE_CA) {
                networkType = TelephonyManager.NETWORK_TYPE_LTE;
@@ -582,6 +590,14 @@ public class CellularNetworkService extends NetworkService {
            networkType =
                    getNetworkTypeForCellIdentity(networkType, cellIdentity, mPhone.getCarrierId());

            if (regState == NetworkRegistrationInfo.REGISTRATION_STATE_DENIED
                    && reasonForDenial
                    == android.hardware.radio.network.RegistrationFailCause.NONE) {
                AnomalyReporter.reportAnomaly(
                        UUID.fromString("62ed270f-e139-418a-a427-8bcc1bca8f20"),
                            "RIL Missing Reg Fail Reason", mPhone.getCarrierId());
            }

            // Conditional parameters for specific RANs
            boolean cssSupported = false;
            int roamingIndicator = 0;
+10 −7
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ public class DataIndication extends IRadioDataIndication.Stub {
            android.hardware.radio.data.SetupDataCallResult[] dcList) {
        mRil.processIndication(RIL.DATA_SERVICE, indicationType);

        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_DATA_CALL_LIST_CHANGED, dcList);
        if (mRil.isLogOrTrace()) mRil.unsljLogRet(RIL_UNSOL_DATA_CALL_LIST_CHANGED, dcList);
        ArrayList<DataCallResponse> response = RILUtils.convertHalDataCallResultList(dcList);
        mRil.mDataCallListChangedRegistrants.notifyRegistrants(
                new AsyncResult(null, response, null));
@@ -70,9 +70,10 @@ public class DataIndication extends IRadioDataIndication.Stub {
            android.hardware.radio.data.KeepaliveStatus halStatus) {
        mRil.processIndication(RIL.DATA_SERVICE, indicationType);

        if (RIL.RILJ_LOGD) {
            mRil.unsljLogRet(RIL_UNSOL_KEEPALIVE_STATUS, "handle=" + halStatus.sessionHandle
                    + " code=" +  halStatus.code);
        if (mRil.isLogOrTrace()) {
            mRil.unsljLogRet(
                    RIL_UNSOL_KEEPALIVE_STATUS,
                    "handle=" + halStatus.sessionHandle + " code=" + halStatus.code);
        }

        KeepaliveStatus ks = new KeepaliveStatus(
@@ -90,7 +91,7 @@ public class DataIndication extends IRadioDataIndication.Stub {

        PcoData response = new PcoData(pco.cid, pco.bearerProto, pco.pcoId, pco.contents);

        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_PCO_DATA, response);
        if (mRil.isLogOrTrace()) mRil.unsljLogRet(RIL_UNSOL_PCO_DATA, response);

        mRil.mPcoDataRegistrants.notifyRegistrants(new AsyncResult(null, response, null));
    }
@@ -106,7 +107,7 @@ public class DataIndication extends IRadioDataIndication.Stub {
        mRil.processIndication(RIL.DATA_SERVICE, indicationType);
        DataProfile response = RILUtils.convertToDataProfile(dpi);

        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_UNTHROTTLE_APN, response);
        if (mRil.isLogOrTrace()) mRil.unsljLogRet(RIL_UNSOL_UNTHROTTLE_APN, response);

        mRil.mApnUnthrottledRegistrants.notifyRegistrants(new AsyncResult(null, response, null));
    }
@@ -120,7 +121,9 @@ public class DataIndication extends IRadioDataIndication.Stub {
    public void slicingConfigChanged(int indicationType,
            android.hardware.radio.data.SlicingConfig slicingConfig) throws RemoteException {
        mRil.processIndication(RIL.DATA_SERVICE, indicationType);
        if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_SLICING_CONFIG_CHANGED, slicingConfig);
        if (mRil.isLogOrTrace()) {
            mRil.unsljLogRet(RIL_UNSOL_SLICING_CONFIG_CHANGED, slicingConfig);
        }
        NetworkSlicingConfig ret = RILUtils.convertHalSlicingConfig(slicingConfig);
        mRil.mSlicingConfigChangedRegistrants.notifyRegistrants(
                new AsyncResult(null, ret, null));
+8 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.internal.telephony;

import android.os.Build;

import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.telephony.Rlog;

@@ -53,6 +55,12 @@ public class DebugService {
                    log("Saving atoms..");
                    PhoneFactory.getMetricsCollector().getAtomsStorage().flushAtoms();
                    return;
                case "--clearatoms":
                    if (Build.IS_DEBUGGABLE) {
                        log("Clearing atoms..");
                        PhoneFactory.getMetricsCollector().getAtomsStorage().clearAtoms();
                    }
                    return;
            }
        }
        log("Dump telephony.");
Loading