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

Commit 8968f9f6 authored by Kazuhiro Ondo's avatar Kazuhiro Ondo Committed by Wink Saville
Browse files

Check different CellLocation type in GsmDataConnectionTracker

Addressing phone app crash in GsmDataConnectionTracker when CDMALTEPhone
is used. CDMALTEPhone uses CDMA SST so getCellLocation() was returning
an instance of CdmaCellLocation. This was causing a crash when GsmDCT
type casts the instance as GsmCellLocation.

This patch tries to check the instance type before retrieving corresponding
cell id.

Change-Id: I6ac9cd4dc078552dc58d4d9350494a7b608c2b98
parent 5203a5bc
Loading
Loading
Loading
Loading
+20 −9
Original line number Diff line number Diff line
@@ -38,8 +38,10 @@ import android.os.SystemClock;
import android.os.SystemProperties;
import android.provider.Settings;
import android.provider.Telephony;
import android.telephony.CellLocation;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
import android.text.TextUtils;
import android.util.EventLog;
@@ -995,9 +997,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
                Log.i(LOG_TAG, "PDP connection has dropped. Reconnecting");

                // Add an event log when the network drops PDP
                int cid = -1;
                GsmCellLocation loc = ((GsmCellLocation)mPhone.getCellLocation());
                if (loc != null) cid = loc.getCid();
                int cid = getCellLocationId();
                EventLog.writeEvent(EventLogTags.PDP_NETWORK_DROP, cid,
                        TelephonyManager.getDefault().getNetworkType());

@@ -1018,9 +1018,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
                                    + " Reconnecting");

                    // Log the network drop on the event log.
                    int cid = -1;
                    GsmCellLocation loc = ((GsmCellLocation)mPhone.getCellLocation());
                    if (loc != null) cid = loc.getCid();
                    int cid = getCellLocationId();
                    EventLog.writeEvent(EventLogTags.PDP_NETWORK_DROP, cid,
                            TelephonyManager.getDefault().getNetworkType());

@@ -1522,10 +1520,9 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
            }
            if (cause.isEventLoggable()) {
                // Log this failure to the Event Logs.
                GsmCellLocation loc = ((GsmCellLocation)mPhone.getCellLocation());
                int cid = getCellLocationId();
                EventLog.writeEvent(EventLogTags.PDP_SETUP_FAIL,
                        cause.ordinal(), loc != null ? loc.getCid() : -1,
                        TelephonyManager.getDefault().getNetworkType());
                        cause.ordinal(), cid, TelephonyManager.getDefault().getNetworkType());
            }

            // Count permanent failures and remove the APN we just tried
@@ -1984,6 +1981,20 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
        }
    }

    private int getCellLocationId() {
        int cid = -1;
        CellLocation loc = mPhone.getCellLocation();

        if (loc != null) {
            if (loc instanceof GsmCellLocation) {
                cid = ((GsmCellLocation)loc).getCid();
            } else if (loc instanceof CdmaCellLocation) {
                cid = ((CdmaCellLocation)loc).getBaseStationId();
            }
        }
        return cid;
    }

    @Override
    public boolean isAnyActiveDataConnections() {
        return isConnected();