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

Commit f8787648 authored by fionaxu's avatar fionaxu
Browse files

reset carrier actions on sim loaded

There are some use cases where carriers activate SIM's data service by
updating EF files with an ICC refresh event. Slightly different from hot
sim swap, this might not go through the complete SIM loading procedure
and won't recreate any new Icc Record as well.
- Move carrier action reset to recordsLoaded event handler which handles
both ICC refresh and hot sim swap.
- refactor carrier action reset from individual modules to carrier
action agent

Bug: 36154348
Test: Manual
Change-Id: I7af8b1d956ba7dfa1efdc8858b49903f24382dbe
parent 6e2e2c1d
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -15,6 +15,10 @@
 */
package com.android.internal.telephony;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Message;
@@ -25,7 +29,6 @@ import android.util.LocalLog;
import android.util.Log;

import com.android.internal.util.IndentingPrintWriter;

import java.io.FileDescriptor;
import java.io.PrintWriter;

@@ -49,6 +52,7 @@ public class CarrierActionAgent extends Handler {
    /** A list of carrier actions */
    public static final int CARRIER_ACTION_SET_METERED_APNS_ENABLED      = 0;
    public static final int CARRIER_ACTION_SET_RADIO_ENABLED             = 1;
    public static final int CARRIER_ACTION_RESET                         = 2;

    /** Member variables */
    private final Phone mPhone;
@@ -62,9 +66,24 @@ public class CarrierActionAgent extends Handler {
    private Boolean mCarrierActionOnMeteredApnEnabled = true;
    private Boolean mCarrierActionOnRadioEnabled = true;

    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            final String action = intent.getAction();
            if (TelephonyIntents.ACTION_SIM_STATE_CHANGED.equals(action)){
                if (IccCardConstants.INTENT_VALUE_ICC_LOADED.equals(
                        intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE))) {
                    sendEmptyMessage(CARRIER_ACTION_RESET);
                }
            }
        }
    };

    /** Constructor */
    public CarrierActionAgent(Phone phone) {
        mPhone = phone;
        mPhone.getContext().registerReceiver(mReceiver,
                new IntentFilter(TelephonyIntents.ACTION_SIM_STATE_CHANGED));
        if (DBG) log("Creating CarrierActionAgent");
    }

@@ -86,6 +105,11 @@ public class CarrierActionAgent extends Handler {
                mRadioEnableRegistrants.notifyRegistrants(
                        new AsyncResult(null, mCarrierActionOnRadioEnabled, null));
                break;
            case CARRIER_ACTION_RESET:
                log("CARRIER_ACTION_RESET");
                carrierActionSetMeteredApnsEnabled(true);
                carrierActionSetRadioEnabled(true);
                break;
            default:
                loge("Unknown carrier action: " + msg.what);
        }
+0 −4
Original line number Diff line number Diff line
@@ -4066,10 +4066,6 @@ public class DcTracker extends Handler {
                    mIccRecords.set(newIccRecords);
                    newIccRecords.registerForRecordsLoaded(
                            this, DctConstants.EVENT_RECORDS_LOADED, null);
                    // reset carrier actions on sim loaded
                    final ServiceStateTracker sst = mPhone.getServiceStateTracker();
                    sst.setRadioPowerFromCarrier(true);
                    mDataEnabledSettings.setCarrierDataEnabled(true);
                }
            } else {
                onSimNotReady();