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

Commit 629410aa authored by arunvoddu's avatar arunvoddu
Browse files

AIDL IRadioModemIndication#onImeiMappingChanged() implementation for the...

AIDL IRadioModemIndication#onImeiMappingChanged() implementation for the change in the IMEI wrt sim slot

Bug: 294127356
Test: atest verified
Change-Id: I4fcc5c1403b8dfdf56d525a954140fef6d0d8522
parent c7b2a23e
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ public abstract class BaseCommands implements CommandsInterface {
    protected RegistrantList mConnectionSetupFailureRegistrants = new RegistrantList();
    protected RegistrantList mNotifyAnbrRegistrants = new RegistrantList();
    protected RegistrantList mTriggerImsDeregistrationRegistrants = new RegistrantList();
    protected RegistrantList mImeiInfoRegistrants = new RegistrantList();

    @UnsupportedAppUsage
    protected Registrant mGsmSmsRegistrant;
@@ -1174,4 +1175,12 @@ public abstract class BaseCommands implements CommandsInterface {
    public void unregisterForTriggerImsDeregistration(Handler h) {
        mTriggerImsDeregistrationRegistrants.remove(h);
    }

    /**
     * Register to listen for the changes in the primary IMEI with respect to the sim slot.
     */
    @Override
    public void registerForImeiMappingChanged(Handler h, int what, Object obj) {
        mImeiInfoRegistrants.add(h, what, obj);
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -1734,6 +1734,12 @@ public interface CommandsInterface {
     */
    public void getImei(Message response);

    /**
     * Register to listen for the changes in the primary IMEI with respect to the sim slot.
     */

    public void registerForImeiMappingChanged(Handler h, int what, Object obj);

    /**
     * Request the device MDN / H_SID / H_NID / MIN.
     * "response" is const char **
+24 −13
Original line number Diff line number Diff line
@@ -514,6 +514,7 @@ public class GsmCdmaPhone extends Phone {
        mCDM = new CarrierKeyDownloadManager(this);
        mCIM = new CarrierInfoManager();

        mCi.registerForImeiMappingChanged(this, EVENT_IMEI_MAPPING_CHANGED, null);
        initializeCarrierApps();
    }

@@ -3170,19 +3171,7 @@ public class GsmCdmaPhone extends Phone {
            }
            break;
            case EVENT_GET_DEVICE_IMEI_DONE :
                ar = (AsyncResult)msg.obj;
                if (ar.exception != null || ar.result == null) {
                    loge("Exception received : " + ar.exception);
                    break;
                }
                ImeiInfo imeiInfo = (ImeiInfo) ar.result;
                if (!TextUtils.isEmpty(imeiInfo.imei)) {
                    mImeiType = imeiInfo.type;
                    mImei = imeiInfo.imei;
                    mImeiSv = imeiInfo.svn;
                } else {
                    // TODO Report telephony anomaly
                }
                parseImeiInfo(msg);
                break;
            case EVENT_GET_DEVICE_IDENTITY_DONE:{
                ar = (AsyncResult)msg.obj;
@@ -3668,11 +3657,33 @@ public class GsmCdmaPhone extends Phone {
                    rsp.sendToTarget();
                }
                break;

            case EVENT_IMEI_MAPPING_CHANGED:
                logd("EVENT_GET_DEVICE_IMEI_CHANGE_DONE phoneId = " + getPhoneId());
                parseImeiInfo(msg);
                break;

            default:
                super.handleMessage(msg);
        }
    }

    private void parseImeiInfo(Message msg) {
        AsyncResult ar = (AsyncResult)msg.obj;
        if (ar.exception != null || ar.result == null) {
            loge("parseImeiInfo :: Exception received : " + ar.exception);
            return;
        }
        ImeiInfo imeiInfo = (ImeiInfo) ar.result;
        if (!TextUtils.isEmpty(imeiInfo.imei)) {
            mImeiType = imeiInfo.type;
            mImei = imeiInfo.imei;
            mImeiSv = imeiInfo.svn;
        } else {
            loge("parseImeiInfo :: IMEI value is empty");
        }
    }

    /**
     * Check if a different SIM is inserted at this slot from the last time. Storing last subId
     * in SharedPreference for now to detect SIM change.
+16 −0
Original line number Diff line number Diff line
@@ -19,12 +19,14 @@ package com.android.internal.telephony;
import static android.telephony.TelephonyManager.HAL_SERVICE_MODEM;

import static com.android.internal.telephony.RILConstants.RIL_UNSOL_HARDWARE_CONFIG_CHANGED;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_IMEI_MAPPING_CHANGED;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_MODEM_RESTART;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RADIO_CAPABILITY;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED;
import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RIL_CONNECTED;

import android.hardware.radio.modem.IRadioModemIndication;
import android.hardware.radio.modem.ImeiInfo;
import android.os.AsyncResult;

import java.util.ArrayList;
@@ -132,4 +134,18 @@ public class ModemIndication extends IRadioModemIndication.Stub {
    public int getInterfaceVersion() {
        return IRadioModemIndication.VERSION;
    }

    /**
     * Indicates when there is a change in the IMEI with respect to the sim slot.
     *
     * @param imeiInfo IMEI information
     */
    public void onImeiMappingChanged(int indicationType, ImeiInfo imeiInfo) {
        mRil.processIndication(HAL_SERVICE_MODEM, indicationType);

        if (mRil.isLogOrTrace()) {
            mRil.unsljLogMore(RIL_UNSOL_IMEI_MAPPING_CHANGED, "ImeiMappingChanged");
        }
        mRil.notifyRegistrantsImeiMappingChanged(imeiInfo);
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -253,8 +253,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    protected static final int EVENT_TRIGGER_NOTIFY_ANBR = 68;
    protected static final int EVENT_GET_N1_MODE_ENABLED_DONE = 69;
    protected static final int EVENT_SET_N1_MODE_ENABLED_DONE = 70;

    protected static final int EVENT_LAST = EVENT_SET_N1_MODE_ENABLED_DONE;
    protected static final int EVENT_IMEI_MAPPING_CHANGED = 71;
    protected static final int EVENT_LAST = EVENT_IMEI_MAPPING_CHANGED;

    // For shared prefs.
    private static final String GSM_ROAMING_LIST_OVERRIDE_PREFIX = "gsm_roaming_list_";
Loading