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

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

Snap for 10052121 from f1002487 to udc-release

Change-Id: I1a2e896c912294cc097a0b3cf3106fb7feb3cff2
parents 323cd3f8 f1002487
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -172,6 +172,8 @@ public class GsmCdmaPhone extends Phone {
    // Key used to read/write the SIM IMSI used for storing the voice mail
    private static final String VM_SIM_IMSI = "vm_sim_imsi_key";
    /** List of Registrants to receive Supplementary Service Notifications. */
    // Key used to read/write the current sub Id. Updated on SIM loaded.
    public static final String CURR_SUBID = "curr_subid";
    private RegistrantList mSsnRegistrants = new RegistrantList();

    //CDMA
@@ -420,6 +422,17 @@ public class GsmCdmaPhone extends Phone {
                int newPreferredTtyMode = intent.getIntExtra(
                        TelecomManager.EXTRA_TTY_PREFERRED_MODE, TelecomManager.TTY_MODE_OFF);
                updateUiTtyMode(newPreferredTtyMode);
            } else if (TelephonyManager.ACTION_SIM_APPLICATION_STATE_CHANGED.equals(action)) {
                if (mPhoneId == intent.getIntExtra(
                        SubscriptionManager.EXTRA_SLOT_INDEX,
                        SubscriptionManager.INVALID_SIM_SLOT_INDEX)) {
                    int simState = intent.getIntExtra(TelephonyManager.EXTRA_SIM_STATE,
                            TelephonyManager.SIM_STATE_UNKNOWN);
                    if (simState == TelephonyManager.SIM_STATE_LOADED
                            && currentSlotSubIdChanged()) {
                        setNetworkSelectionModeAutomatic(null);
                    }
                }
            }
        }
    };
@@ -482,6 +495,7 @@ public class GsmCdmaPhone extends Phone {
                CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
        filter.addAction(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED);
        filter.addAction(TelecomManager.ACTION_TTY_PREFERRED_MODE_CHANGED);
        filter.addAction(TelephonyManager.ACTION_SIM_APPLICATION_STATE_CHANGED);
        mContext.registerReceiver(mBroadcastReceiver, filter,
                android.Manifest.permission.MODIFY_PHONE_STATE, null, Context.RECEIVER_EXPORTED);

@@ -3541,6 +3555,27 @@ public class GsmCdmaPhone extends Phone {
        }
    }

    /**
     * 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.
     *
     * @return {@code true} if current slot mapping changed; {@code false} otherwise.
     */
    private boolean currentSlotSubIdChanged() {
        SharedPreferences sp =
                PreferenceManager.getDefaultSharedPreferences(mContext);
        int storedSubId = sp.getInt(CURR_SUBID + mPhoneId, -1);
        boolean changed = storedSubId != getSubId();
        if (changed) {
            // Update stored subId
            SharedPreferences.Editor editor = sp.edit();
            editor.putInt(CURR_SUBID + mPhoneId, getSubId());
            editor.apply();
        }
        Rlog.d(LOG_TAG, "currentSlotSubIdChanged: changed=" + changed);
        return changed;
    }

    public UiccCardApplication getUiccCardApplication() {
        if (isPhoneTypeGsm()) {
            return mUiccController.getUiccCardApplication(mPhoneId, UiccController.APP_FAM_3GPP);
+3 −2
Original line number Diff line number Diff line
@@ -1437,8 +1437,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    @UnsupportedAppUsage
    public void setNetworkSelectionModeAutomatic(Message response) {
        Rlog.d(LOG_TAG, "setNetworkSelectionModeAutomatic, querying current mode");
        // we don't want to do this unecesarily - it acutally causes
        // the radio to repeate network selection and is costly
        // we don't want to do this unnecessarily - it actually causes
        // the radio to repeat network selection and is costly
        // first check if we're already in automatic mode
        Message msg = obtainMessage(EVENT_CHECK_FOR_NETWORK_AUTOMATIC);
        msg.obj = response;
@@ -1471,6 +1471,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        nsm.operatorAlphaShort = "";

        if (doAutomatic) {
            Rlog.d(LOG_TAG, "setNetworkSelectionModeAutomatic - set network selection auto");
            Message msg = obtainMessage(EVENT_SET_NETWORK_AUTOMATIC_COMPLETE, nsm);
            mCi.setNetworkSelectionModeAutomatic(msg);
        } else {
+28 −7
Original line number Diff line number Diff line
@@ -22,8 +22,10 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.telephony.TelephonyManager;

import com.android.internal.telephony.IIntegerConsumer;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.satellite.SatelliteController;
import com.android.telephony.Rlog;

import java.util.ArrayList;
@@ -44,7 +46,7 @@ public class RadioOnHelper implements RadioOnStateListener.Callback {
    private RadioOnStateListener.Callback mCallback;
    private List<RadioOnStateListener> mListeners;
    private List<RadioOnStateListener> mInProgressListeners;
    private boolean mIsRadioOnCallingEnabled;
    private boolean mIsRadioReady;

    public RadioOnHelper(Context context) {
        mContext = context;
@@ -72,9 +74,9 @@ public class RadioOnHelper implements RadioOnStateListener.Callback {
     * class.
     *
     * This method kicks off the following sequence:
     * - Power on the radio for each Phone
     * - Listen for radio events telling us the radio has come up.
     * - Retry if we've gone a significant amount of time without any response from the radio.
     * - Power on the radio for each Phone and disable the satellite modem
     * - Listen for events telling us the radio has come up or the satellite modem is disabled.
     * - Retry if we've gone a significant amount of time without any response.
     * - Finally, clean up any leftover state.
     *
     * This method is safe to call from any thread, since it simply posts a message to the
@@ -87,7 +89,7 @@ public class RadioOnHelper implements RadioOnStateListener.Callback {
        setupListeners();
        mCallback = callback;
        mInProgressListeners.clear();
        mIsRadioOnCallingEnabled = false;
        mIsRadioReady = false;
        for (int i = 0; i < TelephonyManager.from(mContext).getActiveModemCount(); i++) {
            Phone phone = PhoneFactory.getPhone(i);
            if (phone == null) {
@@ -101,6 +103,9 @@ public class RadioOnHelper implements RadioOnStateListener.Callback {
                    && phone == phoneForEmergencyCall, timeoutCallbackInterval);
        }
        powerOnRadio(forEmergencyCall, phoneForEmergencyCall, isTestEmergencyNumber);
        if (SatelliteController.getInstance().isSatelliteEnabled()) {
            powerOffSatellite(phoneForEmergencyCall);
        }
    }

    /**
@@ -141,16 +146,32 @@ public class RadioOnHelper implements RadioOnStateListener.Callback {
        }
    }

    /**
     * Attempt to power off the satellite modem. We'll eventually get an
     * onSatelliteModemStateChanged() callback when the satellite modem is successfully disabled.
     */
    private void powerOffSatellite(Phone phoneForEmergencyCall) {
        SatelliteController satelliteController = SatelliteController.getInstance();
        satelliteController.requestSatelliteEnabled(phoneForEmergencyCall.getSubId(),
                false /* enableSatellite */, false /* enableDemoMode */,
                new IIntegerConsumer.Stub() {
                    @Override
                    public void accept(int result) {

                    }
                });
    }

    /**
     * This method is called from multiple Listeners on the Main Looper. Synchronization is not
     * necessary.
     */
    @Override
    public void onComplete(RadioOnStateListener listener, boolean isRadioReady) {
        mIsRadioOnCallingEnabled |= isRadioReady;
        mIsRadioReady |= isRadioReady;
        mInProgressListeners.remove(listener);
        if (mCallback != null && mInProgressListeners.isEmpty()) {
            mCallback.onComplete(null, mIsRadioOnCallingEnabled);
            mCallback.onComplete(null, mIsRadioReady);
        }
    }

+73 −7
Original line number Diff line number Diff line
@@ -21,10 +21,14 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.satellite.ISatelliteStateCallback;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.SomeArgs;
import com.android.internal.telephony.IIntegerConsumer;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.satellite.SatelliteController;
import com.android.telephony.Rlog;

import java.util.Locale;
@@ -37,7 +41,8 @@ public class RadioOnStateListener {

    public interface Callback {
        /**
         * Receives the result of the RadioOnStateListener's attempt to turn on the radio.
         * Receives the result of the RadioOnStateListener's attempt to turn on the radio
         * and turn off the satellite modem.
         */
        void onComplete(RadioOnStateListener listener, boolean isRadioReady);

@@ -86,6 +91,8 @@ public class RadioOnStateListener {
    public static final int MSG_RADIO_OFF_OR_NOT_AVAILABLE = 5;
    public static final int MSG_IMS_CAPABILITY_CHANGED = 6;
    public static final int MSG_TIMEOUT_ONTIMEOUT_CALLBACK = 7;
    @VisibleForTesting
    public static final int MSG_SATELLITE_ENABLED_CHANGED = 8;

    private final Handler mHandler = new Handler(Looper.getMainLooper()) {
        @Override
@@ -123,6 +130,10 @@ public class RadioOnStateListener {
                    break;
                case MSG_TIMEOUT_ONTIMEOUT_CALLBACK:
                    onTimeoutCallbackTimeout();
                    break;
                case MSG_SATELLITE_ENABLED_CHANGED:
                    onSatelliteEnabledChanged();
                    break;
                default:
                    Rlog.w(TAG, String.format(Locale.getDefault(),
                        "handleMessage: unexpected message: %d.", msg.what));
@@ -131,8 +142,17 @@ public class RadioOnStateListener {
        }
    };

    private final ISatelliteStateCallback mSatelliteCallback = new ISatelliteStateCallback.Stub() {
        @Override
        public void onSatelliteModemStateChanged(int state) {
            mHandler.obtainMessage(MSG_SATELLITE_ENABLED_CHANGED).sendToTarget();
        }
    };

    private Callback mCallback; // The callback to notify upon completion.
    private Phone mPhone; // The phone that will attempt to place the call.
    // SatelliteController instance to check whether satellite has been disabled.
    private SatelliteController mSatelliteController;
    private boolean mForEmergencyCall; // Whether radio is being turned on for emergency call.
    // Whether this phone is selected to place emergency call. Can be true only if
    // mForEmergencyCall is true.
@@ -146,6 +166,7 @@ public class RadioOnStateListener {
     *
     * This method kicks off the following sequence:
     * - Listen for the service state change event telling us the radio has come up.
     * - Listen for the satellite state changed event telling us the satellite service is disabled.
     * - Retry if we've gone {@link #TIME_BETWEEN_RETRIES_MILLIS} without any response from the
     *   radio.
     * - Finally, clean up any leftover state.
@@ -156,7 +177,7 @@ public class RadioOnStateListener {
     */
    public void waitForRadioOn(Phone phone, Callback callback,
            boolean forEmergencyCall, boolean isSelectedPhoneForEmergencyCall,
            int onTimeoutCallbackInverval) {
            int onTimeoutCallbackInterval) {
        Rlog.d(TAG, "waitForRadioOn: Phone " + phone.getPhoneId());

        if (mPhone != null) {
@@ -169,7 +190,7 @@ public class RadioOnStateListener {
        args.arg2 = callback;
        args.arg3 = forEmergencyCall;
        args.arg4 = isSelectedPhoneForEmergencyCall;
        args.argi1 = onTimeoutCallbackInverval;
        args.argi1 = onTimeoutCallbackInterval;
        mHandler.obtainMessage(MSG_START_SEQUENCE, args).sendToTarget();
    }

@@ -182,6 +203,7 @@ public class RadioOnStateListener {
            boolean forEmergencyCall, boolean isSelectedPhoneForEmergencyCall,
            int onTimeoutCallbackInterval) {
        Rlog.d(TAG, "startSequenceInternal: Phone " + phone.getPhoneId());
        mSatelliteController = SatelliteController.getInstance();

        // First of all, clean up any state left over from a prior RadioOn call sequence. This
        // ensures that we'll behave sanely if another startTurnOnRadioSequence() comes in while
@@ -198,9 +220,14 @@ public class RadioOnStateListener {
        // Register for RADIO_OFF to handle cases where emergency call is dialed before
        // we receive UNSOL_RESPONSE_RADIO_STATE_CHANGED with RADIO_OFF.
        registerForRadioOff();
        // Next step: when the SERVICE_STATE_CHANGED event comes in, we'll retry the call; see
        // onServiceStateChanged(). But also, just in case, start a timer to make sure we'll retry
        // the call even if the SERVICE_STATE_CHANGED event never comes in for some reason.
        if (mSatelliteController.isSatelliteEnabled()) {
            // Register for satellite modem state changed to notify when satellite is disabled.
            registerForSatelliteEnabledChanged();
        }
        // Next step: when the SERVICE_STATE_CHANGED or SATELLITE_ENABLED_CHANGED event comes in,
        // we'll retry the call; see onServiceStateChanged() and onSatelliteEnabledChanged().
        // But also, just in case, start a timer to make sure we'll retry the call even if the
        // SERVICE_STATE_CHANGED or SATELLITE_ENABLED_CHANGED events never come in for some reason.
        startRetryTimer();
        registerForImsCapabilityChanged();
        startOnTimeoutCallbackTimer();
@@ -292,6 +319,19 @@ public class RadioOnStateListener {
        }
    }

    private void onSatelliteEnabledChanged() {
        if (mPhone == null) {
            return;
        }
        if (isOkToCall(mPhone.getServiceState().getState(),
                mPhone.isVoiceOverCellularImsEnabled())) {
            onComplete(true);
            cleanup();
        } else {
            Rlog.d(TAG, "onSatelliteEnabledChanged: not ready to call yet, keep waiting.");
        }
    }

    /**
     * Callback to see if it is okay to call yet, given the current conditions.
     */
@@ -348,9 +388,20 @@ public class RadioOnStateListener {
                Rlog.w(TAG, "Hit MAX_NUM_RETRIES; giving up.");
                cleanup();
            } else {
                Rlog.d(TAG, "Trying (again) to turn on the radio.");
                Rlog.d(TAG, "Trying (again) to turn the radio on and satellite modem off.");
                mPhone.setRadioPower(true, mForEmergencyCall, mSelectedPhoneForEmergencyCall,
                        false);
                if (mSatelliteController.isSatelliteEnabled()) {
                    mSatelliteController.requestSatelliteEnabled(mPhone.getSubId(),
                            false /* enableSatellite */, false /* enableDemoMode */,
                            new IIntegerConsumer.Stub() {
                                @Override
                                public void accept(int result) {
                                    mHandler.obtainMessage(MSG_SATELLITE_ENABLED_CHANGED)
                                            .sendToTarget();
                                }
                            });
                }
                startRetryTimer();
            }
        }
@@ -383,6 +434,7 @@ public class RadioOnStateListener {
        unregisterForServiceStateChanged();
        unregisterForRadioOff();
        unregisterForRadioOn();
        unregisterForSatelliteEnabledChanged();
        cancelRetryTimer();
        unregisterForImsCapabilityChanged();

@@ -442,6 +494,20 @@ public class RadioOnStateListener {
        mHandler.removeMessages(MSG_RADIO_ON); // Clean up any pending messages too
    }

    private void registerForSatelliteEnabledChanged() {
        mSatelliteController.registerForSatelliteModemStateChanged(
                mPhone.getSubId(), mSatelliteCallback);
    }

    private void unregisterForSatelliteEnabledChanged() {
        int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
        if (mPhone != null) {
            subId = mPhone.getSubId();
        }
        mSatelliteController.unregisterForSatelliteModemStateChanged(subId, mSatelliteCallback);
        mHandler.removeMessages(MSG_SATELLITE_ENABLED_CHANGED);
    }

    private void registerForImsCapabilityChanged() {
        unregisterForImsCapabilityChanged();
        mPhone.getServiceStateTracker()
+9 −2
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.content.pm.ServiceInfo;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.PersistableBundle;
@@ -130,6 +131,7 @@ public class ImsResolver implements ImsServiceController.ImsServiceControllerCal

    // Delay between dynamic ImsService queries.
    private static final int DELAY_DYNAMIC_QUERY_MS = 5000;
    private static final HandlerThread sHandlerThread = new HandlerThread(TAG);

    private static ImsResolver sInstance;

@@ -139,9 +141,9 @@ public class ImsResolver implements ImsServiceController.ImsServiceControllerCal
    public static void make(Context context, String defaultMmTelPackageName,
            String defaultRcsPackageName, int numSlots, ImsFeatureBinderRepository repo) {
        if (sInstance == null) {
            Looper looper = Looper.getMainLooper();
            sHandlerThread.start();
            sInstance = new ImsResolver(context, defaultMmTelPackageName, defaultRcsPackageName,
                    numSlots, repo, looper);
                    numSlots, repo, sHandlerThread.getLooper());
        }
    }

@@ -630,8 +632,13 @@ public class ImsResolver implements ImsServiceController.ImsServiceControllerCal

    /**
     * Needs to be called after the constructor to kick off the process of binding to ImsServices.
     * Should be run on the handler thread of ImsResolver
     */
    public void initialize() {
        mHandler.post(()-> initializeInternal());
    }

    private void initializeInternal() {
        mEventLog.log("Initializing");
        Log.i(TAG, "Initializing cache.");
        PhoneConfigurationManager.registerForMultiSimConfigChange(mHandler,
Loading