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

Commit edee6bce authored by Xin Li's avatar Xin Li
Browse files

Merge pi-dev-plus-aosp-without-vendor into stage-aosp-master

Bug: 79597307
Change-Id: If62c534641075928c9724583e9c7b1be00491adb
parents 3fec3b7e 8c38ac09
Loading
Loading
Loading
Loading
+167 −0
Original line number Diff line number Diff line
@@ -476,6 +476,96 @@ enum RilErrno {

  // LCE service not supported
  RIL_E_LCE_NOT_SUPPORTED_NEW = 37;

  // Not sufficient memory to process the request
  RIL_E_NO_MEMORY = 38;

  // Modem hit unexpected error scenario while handling this request
  RIL_E_INTERNAL_ERR = 39;

  // Hit platform or system error
  RIL_E_SYSTEM_ERR = 40;

  // Vendor RIL got unexpected or incorrect response from modem for this request
  RIL_E_MODEM_ERR = 41;

  // Unexpected request for the current state
  RIL_E_INVALID_STATE = 42;

  // Not sufficient resource to process the request
  RIL_E_NO_RESOURCES = 43;

  // Received error from SIM card
  RIL_E_SIM_ERR = 44;

  // Received invalid arguments in request
  RIL_E_INVALID_ARGUMENTS = 45;

  // Cannot process the request in current SIM state
  RIL_E_INVALID_SIM_STATE = 46;

  // Cannot process the request in current Modem state
  RIL_E_INVALID_MODEM_STATE = 47;

  // Received invalid call id in request
  RIL_E_INVALID_CALL_ID = 48;

  // ACK received when there is no SMS to ack
  RIL_E_NO_SMS_TO_ACK = 49;

  // Received error from network
  RIL_E_NETWORK_ERR = 50;

  // Operation denied due to overly-frequent requests
  RIL_E_REQUEST_RATE_LIMITED = 51;

  // SIM is busy
  RIL_E_SIM_BUSY = 52;

  // The target EF is full
  RIL_E_SIM_FULL = 53;

  // Request is rejected by network
  RIL_E_NETWORK_REJECT = 54;

  // Not allowed the request now
  RIL_E_OPERATION_NOT_ALLOWED = 55;

  // The request record is empty
  RIL_E_EMPTY_RECORD = 56;

  // Invalid sms format
  RIL_E_INVALID_SMS_FORMAT = 57;

  // Message not encoded properly
  RIL_E_ENCODING_ERR = 58;

  // SMSC address specified is invalid
  RIL_E_INVALID_SMSC_ADDRESS = 59;

  // No such entry present to perform the request
  RIL_E_NO_SUCH_ENTRY = 60;

  // Network is not ready to perform the request
  RIL_E_NETWORK_NOT_READY = 61;

  // Device does not have this value provisioned
  RIL_E_NOT_PROVISIONED = 62;

  // Device does not have subscription
  RIL_E_NO_SUBSCRIPTION = 63;

  // Network cannot be found
  RIL_E_NO_NETWORK_FOUND = 64;

  // Operation cannot be performed because the device is currently in use
  RIL_E_DEVICE_IN_USE = 65;

  // Operation aborted
  RIL_E_ABORTED = 66;

  // Invalid response sent by vendor code
  RIL_E_INVALID_RESPONSE = 67;
}

// PDP_type values in TS 27.007 section 10.1.1.
@@ -553,6 +643,9 @@ message TelephonyEvent {

    // Carrier Identification Matching Event
    CARRIER_ID_MATCHING = 13;

    // Carrier Key Change event.
    CARRIER_KEY_CHANGED = 14;
  }

  // Setup a packet data connection
@@ -743,6 +836,26 @@ message TelephonyEvent {
    optional RilDataCall call = 3;
  }

  // Carrier Key Change Event.
  message CarrierKeyChange {

    enum KeyType {

      // Key Type Unknown.
      UNKNOWN = 0;
      // Key Type for WLAN.
      WLAN = 1;
      // Key Type for EPDG.
      EPDG = 2;
    }

    // Key type of the Encryption key.
    optional KeyType key_type = 1;

    // Whether the download was successful or not.
    optional bool isDownloadSuccessful = 2;
  }

  // Deactivate packet data connection
  message RilDeactivateDataCall {

@@ -850,6 +963,9 @@ message TelephonyEvent {

  // Carrier id matching event
  optional CarrierIdMatching carrier_id_matching = 16;

  // Carrier key change
  optional CarrierKeyChange carrier_key_change = 17;
}

enum TimeInterval {
@@ -1199,6 +1315,9 @@ message SmsSession {

      // Notification about received SMS
      SMS_RECEIVED = 8;

      // CB message received
      CB_SMS_RECEIVED = 9;
    }

    // Formats used to encode SMS messages
@@ -1224,6 +1343,51 @@ message SmsSession {
      SMS_IMS = 3;
    }

    message CBMessage {
      // CB message format
      optional Format msg_format = 1;

      // CB message priority
      optional CBPriority msg_priority = 2;

      // Type of CB msg
      optional CBMessageType msg_type = 3;

      // Service category of CB message
      optional int32 service_category = 4;
    }

    enum CBMessageType {
      // Unknown type
      TYPE_UNKNOWN = 0;

      // ETWS CB msg
      ETWS = 1;

      // CMAS CB msg
      CMAS = 2;

      // CB msg other than ETWS and CMAS
      OTHER = 3;
    }

    enum CBPriority {
      // Unknown priority
      PRIORITY_UNKNOWN = 0;

      // NORMAL priority
      NORMAL = 1;

      // Interactive priority
      INTERACTIVE = 2;

      // Urgent priority
      URGENT = 3;

      // Emergency priority
      EMERGENCY = 4;
    }

    // Event type
    optional Type type = 1;

@@ -1261,6 +1425,9 @@ message SmsSession {

    // Numeric ID
    optional int32 ril_request_id = 12;

    // Cellbroadcast message content
    optional CBMessage cell_broadcast_message = 13;
  }

  // Time when session has started, in minutes since epoch,
+2 −0
Original line number Diff line number Diff line
@@ -211,11 +211,13 @@ public class CarrierIdentifier extends Handler {
                    if (mIccRecords != null) {
                        logd("Removing stale icc objects.");
                        mIccRecords.unregisterForRecordsLoaded(this);
                        mIccRecords.unregisterForRecordsOverride(this);
                        mIccRecords = null;
                    }
                    if (newIccRecords != null) {
                        logd("new Icc object");
                        newIccRecords.registerForRecordsLoaded(this, SIM_LOAD_EVENT, null);
                        newIccRecords.registerForRecordsOverride(this, SIM_LOAD_EVENT, null);
                        mIccRecords = newIccRecords;
                    }
                }
+24 −15
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;

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

import java.util.Date;

/**
@@ -50,30 +52,30 @@ public class CarrierInfoManager {
    /**
     * Returns Carrier specific information that will be used to encrypt the IMSI and IMPI.
     * @param keyType whether the key is being used for WLAN or ePDG.
     * @param mContext
     * @param context
     * @return ImsiEncryptionInfo which contains the information, including the public key, to be
     *         used for encryption.
     */
    public static ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int keyType,
                                                                     Context mContext) {
                                                                     Context context) {
        String mcc = "";
        String mnc = "";
        final TelephonyManager telephonyManager =
                (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
        String networkOperator = telephonyManager.getNetworkOperator();
        if (!TextUtils.isEmpty(networkOperator)) {
            mcc = networkOperator.substring(0, 3);
            mnc = networkOperator.substring(3);
                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String simOperator = telephonyManager.getSimOperator();
        if (!TextUtils.isEmpty(simOperator)) {
            mcc = simOperator.substring(0, 3);
            mnc = simOperator.substring(3);
            Log.i(LOG_TAG, "using values for mnc, mcc: " + mnc + "," + mcc);
        } else {
            Log.e(LOG_TAG, "Invalid networkOperator: " + networkOperator);
            Log.e(LOG_TAG, "Invalid networkOperator: " + simOperator);
            return null;
        }
        Cursor findCursor = null;
        try {
            // In the current design, MVNOs are not supported. If we decide to support them,
            // we'll need to add to this CL.
            ContentResolver mContentResolver = mContext.getContentResolver();
            ContentResolver mContentResolver = context.getContentResolver();
            String[] columns = {Telephony.CarrierColumns.PUBLIC_KEY,
                    Telephony.CarrierColumns.EXPIRATION_TIME,
                    Telephony.CarrierColumns.KEY_IDENTIFIER};
@@ -107,12 +109,13 @@ public class CarrierInfoManager {
    /**
     * Inserts or update the Carrier Key in the database
     * @param imsiEncryptionInfo ImsiEncryptionInfo object.
     * @param mContext Context.
     * @param context Context.
     */
    public static void updateOrInsertCarrierKey(ImsiEncryptionInfo imsiEncryptionInfo,
                                                Context mContext) {
                                                Context context, int phoneId) {
        byte[] keyBytes = imsiEncryptionInfo.getPublicKey().getEncoded();
        ContentResolver mContentResolver = mContext.getContentResolver();
        ContentResolver mContentResolver = context.getContentResolver();
        TelephonyMetrics tm = TelephonyMetrics.getInstance();
        // In the current design, MVNOs are not supported. If we decide to support them,
        // we'll need to add to this CL.
        ContentValues contentValues = new ContentValues();
@@ -125,6 +128,7 @@ public class CarrierInfoManager {
        contentValues.put(Telephony.CarrierColumns.PUBLIC_KEY, keyBytes);
        contentValues.put(Telephony.CarrierColumns.EXPIRATION_TIME,
                imsiEncryptionInfo.getExpirationTime().getTime());
        boolean downloadSuccessfull = true;
        try {
            Log.i(LOG_TAG, "Inserting imsiEncryptionInfo into db");
            mContentResolver.insert(Telephony.CarrierColumns.CONTENT_URI, contentValues);
@@ -145,12 +149,17 @@ public class CarrierInfoManager {
                                String.valueOf(imsiEncryptionInfo.getKeyType())});
                if (nRows == 0) {
                    Log.d(LOG_TAG, "Error updating values:" + imsiEncryptionInfo);
                    downloadSuccessfull = false;
                }
            } catch (Exception ex) {
                Log.d(LOG_TAG, "Error updating values:" + imsiEncryptionInfo + ex);
                downloadSuccessfull = false;
            }
        }  catch (Exception e) {
            Log.d(LOG_TAG, "Error inserting/updating values:" + imsiEncryptionInfo + e);
            downloadSuccessfull = false;
        } finally {
            tm.writeCarrierKeyEvent(phoneId, imsiEncryptionInfo.getKeyType(), downloadSuccessfull);
        }
    }

@@ -162,12 +171,12 @@ public class CarrierInfoManager {
     *        {@link java.security.PublicKey} and the Key Identifier.
     *        The keyIdentifier Attribute value pair that helps a server locate
     *        the private key to decrypt the permanent identity.
     * @param mContext Context.
     * @param context Context.
     */
    public static void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo,
                                                       Context mContext) {
                                                       Context context, int phoneId) {
        Log.i(LOG_TAG, "inserting carrier key: " + imsiEncryptionInfo);
        updateOrInsertCarrierKey(imsiEncryptionInfo, mContext);
        updateOrInsertCarrierKey(imsiEncryptionInfo, context, phoneId);
        //todo send key to modem. Will be done in a subsequent CL.
    }

+88 −13
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.os.Handler;
import android.os.Message;
import android.os.PersistableBundle;
@@ -30,6 +31,8 @@ import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.util.NotificationChannelController;
@@ -38,6 +41,7 @@ import java.util.HashMap;
import java.util.Map;



/**
 * This contains Carrier specific logic based on the states/events
 * managed in ServiceStateTracker.
@@ -53,18 +57,70 @@ public class CarrierServiceStateTracker extends Handler {
    private static final int UNINITIALIZED_DELAY_VALUE = -1;
    private Phone mPhone;
    private ServiceStateTracker mSST;

    private final Map<Integer, NotificationType> mNotificationTypeMap = new HashMap<>();
    private int mPreviousSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    public static final int NOTIFICATION_PREF_NETWORK = 1000;
    public static final int NOTIFICATION_EMERGENCY_NETWORK = 1001;

    private final Map<Integer, NotificationType> mNotificationTypeMap = new HashMap<>();

    public CarrierServiceStateTracker(Phone phone, ServiceStateTracker sst) {
        this.mPhone = phone;
        this.mSST = sst;
        phone.getContext().registerReceiver(mBroadcastReceiver, new IntentFilter(
                CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
        // Listen for subscriber changes
        SubscriptionManager.from(mPhone.getContext()).addOnSubscriptionsChangedListener(
                new OnSubscriptionsChangedListener(this.getLooper()) {
                    @Override
                    public void onSubscriptionsChanged() {
                        int subId = mPhone.getSubId();
                        if (mPreviousSubId != subId) {
                            mPreviousSubId = subId;
                            registerPrefNetworkModeObserver();
                        }
                    }
                });

        registerNotificationTypes();
        registerPrefNetworkModeObserver();
    }

    private ContentObserver mPrefNetworkModeObserver = new ContentObserver(this) {
        @Override
        public void onChange(boolean selfChange) {
            handlePrefNetworkModeChanged();
        }
    };

    /**
     * Return preferred network mode observer
     */
    @VisibleForTesting
    public ContentObserver getContentObserver() {
        return mPrefNetworkModeObserver;
    }

    private void registerPrefNetworkModeObserver() {
        int subId = mPhone.getSubId();
        unregisterPrefNetworkModeObserver();
        if (SubscriptionManager.isValidSubscriptionId(subId)) {
            mPhone.getContext().getContentResolver().registerContentObserver(
                    Settings.Global.getUriFor(Settings.Global.PREFERRED_NETWORK_MODE + subId),
                    true,
                    mPrefNetworkModeObserver);
        }
    }

    private void unregisterPrefNetworkModeObserver() {
        mPhone.getContext().getContentResolver().unregisterContentObserver(
                mPrefNetworkModeObserver);
    }

    /**
     * Returns mNotificationTypeMap
     */
    @VisibleForTesting
    public Map<Integer, NotificationType> getNotificationTypeMap() {
        return mNotificationTypeMap;
    }

    private void registerNotificationTypes() {
@@ -152,6 +208,18 @@ public class CarrierServiceStateTracker extends Handler {
    private void handleConfigChanges() {
        for (Map.Entry<Integer, NotificationType> entry : mNotificationTypeMap.entrySet()) {
            NotificationType notificationType = entry.getValue();
            evaluateSendingMessageOrCancelNotification(notificationType);
        }
    }

    private void handlePrefNetworkModeChanged() {
        NotificationType notificationType = mNotificationTypeMap.get(NOTIFICATION_PREF_NETWORK);
        if (notificationType != null) {
            evaluateSendingMessageOrCancelNotification(notificationType);
        }
    }

    private void evaluateSendingMessageOrCancelNotification(NotificationType notificationType) {
        if (evaluateSendingMessage(notificationType)) {
            Message notificationMsg = obtainMessage(notificationType.getTypeId(), null);
            Rlog.i(LOG_TAG, "starting timer for notifications." + notificationType.getTypeId());
@@ -161,7 +229,6 @@ public class CarrierServiceStateTracker extends Handler {
            Rlog.i(LOG_TAG, "canceling notifications: " + notificationType.getTypeId());
        }
    }
    }

    /**
     * This method adds a level of indirection, and was created so we can unit the class.
@@ -201,6 +268,7 @@ public class CarrierServiceStateTracker extends Handler {
            CarrierConfigManager carrierConfigManager = (CarrierConfigManager)
                    context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
            PersistableBundle b = carrierConfigManager.getConfigForSubId(mPhone.getSubId());

            for (Map.Entry<Integer, NotificationType> entry : mNotificationTypeMap.entrySet()) {
                NotificationType notificationType = entry.getValue();
                notificationType.setDelay(b);
@@ -239,6 +307,13 @@ public class CarrierServiceStateTracker extends Handler {
        getNotificationManager(context).cancel(notificationId);
    }

    /**
     * Dispose the CarrierServiceStateTracker.
     */
    public void dispose() {
        unregisterPrefNetworkModeObserver();
    }

    /**
     * Class that defines the different types of notifications.
     */
@@ -293,7 +368,7 @@ public class CarrierServiceStateTracker extends Handler {
            }
            this.mDelay = bundle.getInt(
                    CarrierConfigManager.KEY_PREF_NETWORK_NOTIFICATION_DELAY_INT);
            Rlog.i(LOG_TAG, "reading time to delay notification emergency: " + mDelay);
            Rlog.i(LOG_TAG, "reading time to delay notification pref network: " + mDelay);
        }

        public int getDelay() {
+8 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import android.provider.Telephony;
import android.telephony.SmsCbMessage;
import android.telephony.SubscriptionManager;

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

/**
 * Dispatch new Cell Broadcasts to receivers. Acquires a private wakelock until the broadcast
 * completes and our result receiver is called.
@@ -82,6 +84,12 @@ public class CellBroadcastHandler extends WakeLockStateMachine {
        String receiverPermission;
        int appOp;

        // Log Cellbroadcast msg received event
        TelephonyMetrics metrics = TelephonyMetrics.getInstance();
        metrics.writeNewCBSms(mPhone.getPhoneId(), message.getMessageFormat(),
                message.getMessagePriority(), message.isCmasMessage(), message.isEtwsMessage(),
                message.getServiceCategory());

        Intent intent;
        if (message.isEmergencyMessage()) {
            log("Dispatching emergency SMS CB, SmsCbMessage is: " + message);
Loading