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

Commit 3f1f22b6 authored by Nathan Harold's avatar Nathan Harold Committed by Gerrit Code Review
Browse files

Merge "Make getAllCellInfo Asynchronous"

parents 62de98e1 5e7ecaa8
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.telephony.CellInfo;
import android.telephony.CellLocation;
import android.telephony.PhoneCapability;
import android.telephony.PhysicalChannelConfig;
import android.telephony.PreciseCallState;
@@ -208,10 +209,10 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
    }

    @Override
    public void notifyCellLocation(Phone sender) {
    public void notifyCellLocation(Phone sender, CellLocation cl) {
        int subId = sender.getSubId();
        Bundle data = new Bundle();
        sender.getCellLocation().fillInNotifierBundle(data);
        cl.fillInNotifierBundle(data);
        try {
            if (mRegistry != null) {
                mRegistry.notifyCellLocationForSubscriber(subId, data);
+9 −9
Original line number Diff line number Diff line
@@ -66,8 +66,6 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.UssdResponse;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
import android.text.TextUtils;
import android.util.Log;

@@ -434,11 +432,8 @@ public class GsmCdmaPhone extends Phone {
    }

    @Override
    public CellLocation getCellLocation(WorkSource workSource) {
        CellLocation l = mSST.getCellLocation(workSource);
        if (l != null) return l;
        if (getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) return new CdmaCellLocation();
        return new GsmCellLocation();
    public void getCellLocation(WorkSource workSource, Message rspMsg) {
        mSST.requestCellLocation(workSource, rspMsg);
    }

    @Override
@@ -653,8 +648,13 @@ public class GsmCdmaPhone extends Phone {
        super.notifyServiceStateChangedP(ss);
    }

    public void notifyLocationChanged() {
        mNotifier.notifyCellLocation(this);
    /**
     * Notify that the CellLocation has changed.
     *
     * @param cl the new CellLocation
     */
    public void notifyLocationChanged(CellLocation cl) {
        mNotifier.notifyCellLocation(this, cl);
    }

    @Override
+2 −3
Original line number Diff line number Diff line
@@ -338,9 +338,8 @@ public class LocaleTracker extends Handler {
            return;
        }

        // Get all cell info. Passing null to use default worksource, which indicates the original
        // request is from telephony internally.
        mCellInfo = mPhone.getAllCellInfo(null);
        // FIXME: This needs to use the async version of getAllCellInfo()
        mCellInfo = mPhone.getAllCellInfo();
        msg = "getCellInfo: cell info=" + mCellInfo;
        if (DBG) log(msg);
        mLocalLog.log(msg);
+23 −41
Original line number Diff line number Diff line
@@ -41,9 +41,7 @@ import android.provider.Settings;
import android.service.carrier.CarrierIdentifier;
import android.telecom.VideoProfile;
import android.telephony.CarrierConfigManager;
import android.telephony.CellIdentityCdma;
import android.telephony.CellInfo;
import android.telephony.CellInfoCdma;
import android.telephony.CellLocation;
import android.telephony.ClientRequestStats;
import android.telephony.ImsiEncryptionInfo;
@@ -1690,50 +1688,34 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return (r != null) ? r.getRecordsLoaded() : false;
    }

    /**
     * @return the last known CellInfo
     */
    public List<CellInfo> getAllCellInfo() {
        return getServiceStateTracker().getAllCellInfo();
    }

    /**
     * @param workSource calling WorkSource
     * @return all available cell information or null if none.
     * @param rspMsg the response message containing the cell info
     */
    public List<CellInfo> getAllCellInfo(WorkSource workSource) {
        List<CellInfo> cellInfoList = getServiceStateTracker().getAllCellInfo(workSource);
        return privatizeCellInfoList(cellInfoList);
    public void getAllCellInfo(WorkSource workSource, Message rspMsg) {
        getServiceStateTracker().requestAllCellInfo(workSource, rspMsg);
    }

    /**
     * @return the current cell location if known
     */
    public CellLocation getCellLocation() {
        return getCellLocation(null);
    }

    /**
     * Clear CDMA base station lat/long values if location setting is disabled.
     * @param cellInfoList the original cell info list from the RIL
     * @return the original list with CDMA lat/long cleared if necessary
     */
    private List<CellInfo> privatizeCellInfoList(List<CellInfo> cellInfoList) {
        if (cellInfoList == null) return null;
        int mode = Settings.Secure.getInt(getContext().getContentResolver(),
                Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
        if (mode == Settings.Secure.LOCATION_MODE_OFF) {
            ArrayList<CellInfo> privateCellInfoList = new ArrayList<CellInfo>(cellInfoList.size());
            // clear lat/lon values for location privacy
            for (CellInfo c : cellInfoList) {
                if (c instanceof CellInfoCdma) {
                    CellInfoCdma cellInfoCdma = (CellInfoCdma) c;
                    CellIdentityCdma cellIdentity = cellInfoCdma.getCellIdentity();
                    CellIdentityCdma maskedCellIdentity = new CellIdentityCdma(
                            cellIdentity.getNetworkId(),
                            cellIdentity.getSystemId(),
                            cellIdentity.getBasestationId(),
                            Integer.MAX_VALUE, Integer.MAX_VALUE);
                    CellInfoCdma privateCellInfoCdma = new CellInfoCdma(cellInfoCdma);
                    privateCellInfoCdma.setCellIdentity(maskedCellIdentity);
                    privateCellInfoList.add(privateCellInfoCdma);
                } else {
                    privateCellInfoList.add(c);
        return getServiceStateTracker().getCellLocation();
    }
            }
            cellInfoList = privateCellInfoList;
        }
        return cellInfoList;

    /**
     * @param workSource calling WorkSource
     * @param rspMsg the response message containing the cell location
     */
    public void getCellLocation(WorkSource workSource, Message rspMsg) {
        getServiceStateTracker().requestCellLocation(workSource, rspMsg);
    }

    /**
@@ -2195,7 +2177,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    }

    public void notifyCellInfo(List<CellInfo> cellInfo) {
        mNotifier.notifyCellInfo(this, privatizeCellInfoList(cellInfo));
        mNotifier.notifyCellInfo(this, cellInfo);
    }

    /** Notify {@link PhysicalChannelConfig} changes. */
+0 −8
Original line number Diff line number Diff line
@@ -21,9 +21,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.ResultReceiver;
import android.os.WorkSource;
import android.telecom.VideoProfile;
import android.telephony.CellLocation;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.NetworkScanRequest;
import android.telephony.ServiceState;
@@ -255,12 +253,6 @@ public interface PhoneInternalInterface {
     */
    ServiceState getServiceState();

    /**
     * Get the current CellLocation.
     * @param workSource calling WorkSource
     */
    CellLocation getCellLocation(WorkSource workSource);

    /**
     * Get the current DataState. No change notification exists at this
     * interface -- use
Loading