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

Commit 6c806ef8 authored by Amit Mahajan's avatar Amit Mahajan
Browse files

Phone refactor Phase II. Renamed PhoneBase to Phone.

Phone interface has been renamed to PhoneInternalInterface. For
outside world, Phone is now the only handle that should be used
for phone related classes (earlier there were Phone, PhoneBase,
GSMPhone, etc.). Some cleanup is still pending to make sure
technology specific phone is not used outside of telephony at all
(and even within telephony as much as possible).

Bug: 25793157
Change-Id: Ic19b286e6d2580e5537f4f6a8dc8afe39d80a803
parent 404c1499
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ public final class CallManager {
    // Singleton instance
    private static final CallManager INSTANCE = new CallManager();

    // list of registered phones, which are PhoneBase objs
    // list of registered phones, which are Phone objs
    private final ArrayList<Phone> mPhones;

    // list of supported ringing calls
@@ -108,7 +108,7 @@ public final class CallManager {
    // mapping of phones to registered handler instances used for callbacks from RIL
    private final HashMap<Phone, CallManagerHandler> mHandlerMap = new HashMap<>();

    // default phone as the first phone registered, which is PhoneBase obj
    // default phone as the first phone registered, which is Phone obj
    private Phone mDefaultPhone;

    private boolean mSpeedUpAudioForMtCall = false;
@@ -204,10 +204,10 @@ public final class CallManager {
    }

    /**
     * Get the corresponding PhoneBase obj
     * Get the corresponding Phone obj
     *
     * @param phone a Phone object
     * @return the corresponding PhoneBase obj in Phone if Phone
     * @return the corresponding Phone obj in Phone if Phone
     * is a PhoneProxy obj
     * or the Phone itself if Phone is not a PhoneProxy obj
     */
@@ -216,13 +216,13 @@ public final class CallManager {
    }

    /**
     * Check if two phones refer to the same PhoneBase obj
     * Check if two phones refer to the same Phone obj
     *
     * Note: PhoneBase, not PhoneProxy, is to be used inside of CallManager
     * Note: Phone, not PhoneProxy, is to be used inside of CallManager
     *
     * Both PhoneBase and PhoneProxy implement Phone interface, so
     * Both Phone and PhoneProxy implement Phone interface, so
     * they have same phone APIs, such as dial(). The real implementation, for
     * example in GSM,  is in GSMPhone as extend from PhoneBase, so that
     * example in GSM,  is in GSMPhone as extend from Phone, so that
     * foregroundCall.getPhone() returns GSMPhone obj. On the other hand,
     * PhoneFactory.getDefaultPhone() returns PhoneProxy obj, which has a class
     * member of GSMPhone.
@@ -612,7 +612,7 @@ public final class CallManager {
        mHandlerMap.put(phone, handler);

        // for common events supported by all phones
        // The mRegistrantIdentifier passed here, is to identify in the PhoneBase
        // The mRegistrantIdentifier passed here, is to identify in the Phone
        // that the registrants are coming from the CallManager.
        phone.registerForPreciseCallStateChanged(handler, EVENT_PRECISE_CALL_STATE_CHANGED,
                mRegistrantidentifier);
+6 −7
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.os.Handler;
import android.os.Message;
import android.os.SystemProperties;
import android.text.TextUtils;
import com.android.internal.telephony.CommandException;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -200,11 +199,11 @@ public abstract class CallTracker extends Handler {
        return dialString;
    }

    protected String convertNumberIfNecessary(PhoneBase phoneBase, String dialNumber) {
    protected String convertNumberIfNecessary(Phone phone, String dialNumber) {
        if (dialNumber == null) {
            return dialNumber;
        }
        String[] convertMaps = phoneBase.getContext().getResources().getStringArray(
        String[] convertMaps = phone.getContext().getResources().getStringArray(
                com.android.internal.R.array.dial_string_replace);
        log("convertNumberIfNecessary Roaming"
            + " convertMaps.length " + convertMaps.length
@@ -225,7 +224,7 @@ public abstract class CallTracker extends Handler {
                tmpArray = entry[1].split(",");
                if (!TextUtils.isEmpty(entry[0]) && dialNumber.equals(entry[0])) {
                    if (tmpArray.length >= 2 && !TextUtils.isEmpty(tmpArray[1])) {
                        if (compareGid1(phoneBase, tmpArray[1])) {
                        if (compareGid1(phone, tmpArray[1])) {
                            needConvert = true;
                        }
                    } else if (outNumber.isEmpty()) {
@@ -234,7 +233,7 @@ public abstract class CallTracker extends Handler {

                    if (needConvert) {
                        if(!TextUtils.isEmpty(tmpArray[0]) && tmpArray[0].endsWith("MDN")) {
                            String mdn = phoneBase.getLine1Number();
                            String mdn = phone.getLine1Number();
                            if (!TextUtils.isEmpty(mdn) ) {
                                if (mdn.startsWith("+")) {
                                    outNumber = mdn;
@@ -262,8 +261,8 @@ public abstract class CallTracker extends Handler {

    }

    private boolean compareGid1(PhoneBase phoneBase, String serviceGid1) {
        String gid1 = phoneBase.getGroupIdLevel1();
    private boolean compareGid1(Phone phone, String serviceGid1) {
        String gid1 = phone.getGroupIdLevel1();
        int gid_length = serviceGid1.length();
        boolean ret = true;

+3 −3
Original line number Diff line number Diff line
@@ -33,11 +33,11 @@ import android.telephony.SmsCbMessage;
 */
public class CellBroadcastHandler extends WakeLockStateMachine {

    private CellBroadcastHandler(Context context, PhoneBase phone) {
    private CellBroadcastHandler(Context context, Phone phone) {
        this("CellBroadcastHandler", context, phone);
    }

    protected CellBroadcastHandler(String debugTag, Context context, PhoneBase phone) {
    protected CellBroadcastHandler(String debugTag, Context context, Phone phone) {
        super(debugTag, context, phone);
    }

@@ -46,7 +46,7 @@ public class CellBroadcastHandler extends WakeLockStateMachine {
     * @param context the context to use for dispatching Intents
     * @return the new handler
     */
    public static CellBroadcastHandler makeCellBroadcastHandler(Context context, PhoneBase phone) {
    public static CellBroadcastHandler makeCellBroadcastHandler(Context context, Phone phone) {
        CellBroadcastHandler handler = new CellBroadcastHandler(context, phone);
        handler.start();
        return handler;
+2 −52
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ import java.util.regex.Pattern;
/**
 * {@hide}
 */
public class GsmCdmaPhone extends PhoneBase {
public class GsmCdmaPhone extends Phone {
    // NOTE that LOG_TAG here is "GsmCdma", which means that log messages
    // from this file will go into the radio log rather than the main
    // log.  (Use "adb logcat -b radio" to see them.)
@@ -148,7 +148,7 @@ public class GsmCdmaPhone extends PhoneBase {

    //CDMALTE
    /** CdmaLtePhone in addition to RuimRecords available from
     * PhoneBase needs access to SIMRecords and IsimUiccRecords
     * Phone needs access to SIMRecords and IsimUiccRecords
     */
    private SIMRecords mSimRecords;

@@ -395,56 +395,6 @@ public class GsmCdmaPhone extends PhoneBase {
        mCT.migrate(phoneType);
    }

    @Override
    public void dispose() {
        synchronized(PhoneBase.lockForRadioTechnologyChange) {
            super.dispose();

            //Unregister from all former registered events
            mCi.unregisterForAvailable(this); //EVENT_RADIO_AVAILABLE
            unregisterForIccRecordEvents();
            mCi.unregisterForOffOrNotAvailable(this); //EVENT_RADIO_OFF_OR_NOT_AVAILABLE
            mCi.unregisterForOn(this); //EVENT_RADIO_ON
            mSST.unregisterForNetworkAttached(this); //EVENT_REGISTERED_TO_NETWORK
            mCi.unSetOnUSSD(this);
            mCi.unSetOnSuppServiceNotification(this);
            mCi.unSetOnSs(this);
            mCi.unregisterForExitEmergencyCallbackMode(this);
            mContext.unregisterReceiver(mBroadcastReceiver);
            removeCallbacks(mExitEcmRunnable);

            mPendingMMIs.clear();

            if (mSimRecords != null) {
                mSimRecords.unregisterForRecordsLoaded(this);
            }

            //Force all referenced classes to unregister their former registered events
            mCT.dispose();
            //todo: cleanUpAllConnections() and destroyDataConnections() may need to be called on
            // migrate
            mDcTracker.dispose();
            mSST.dispose();
            mIccPhoneBookIntManager.dispose();
            mSubInfo.dispose();
            mEriManager.dispose();
        }
    }

    @Override
    public void removeReferences() {
        logd("removeReferences");
        mSimulatedRadioControl = null;
        mIccPhoneBookIntManager = null;
        mSubInfo = null;
        mCT = null;
        mSST = null;
        mEriManager = null;
        mExitEcmRunnable = null;

        super.removeReferences();
    }

    @Override
    protected void finalize() {
        if(DBG) logd("GsmCdmaPhone finalized");
+2 −4
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.os.AsyncResult;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.ServiceManager;
import android.telephony.Rlog;

import com.android.internal.telephony.uicc.AdnRecord;
@@ -30,7 +29,6 @@ import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
import com.android.internal.telephony.uicc.IccConstants;
import com.android.internal.telephony.uicc.IccFileHandler;
import com.android.internal.telephony.uicc.IccRecords;
import com.android.internal.telephony.uicc.UiccCard;
import com.android.internal.telephony.uicc.UiccCardApplication;

import java.util.List;
@@ -44,7 +42,7 @@ public class IccPhoneBookInterfaceManager {
    static final String LOG_TAG = "IccPhoneBookIM";
    protected static final boolean DBG = true;

    protected PhoneBase mPhone;
    protected Phone mPhone;
    private   UiccCardApplication mCurrentApp = null;
    protected AdnRecordCache mAdnCache;
    protected final Object mLock = new Object();
@@ -114,7 +112,7 @@ public class IccPhoneBookInterfaceManager {
        }
    };

    public IccPhoneBookInterfaceManager(PhoneBase phone) {
    public IccPhoneBookInterfaceManager(Phone phone) {
        this.mPhone = phone;
        IccRecords r = phone.mIccRecords.get();
        if (r != null) {
Loading