Merge "Use Parcelable CellIdentity instead of CellLocation in AIDL."

This commit is contained in:
Meng Wang
2020-01-10 04:25:45 +00:00
committed by Gerrit Code Review
15 changed files with 90 additions and 61 deletions

View File

@@ -8126,6 +8126,34 @@ package android.telephony {
field public static final String CELL_BROADCAST_SERVICE_INTERFACE = "android.telephony.CellBroadcastService"; field public static final String CELL_BROADCAST_SERVICE_INTERFACE = "android.telephony.CellBroadcastService";
} }
public abstract class CellIdentity implements android.os.Parcelable {
method @NonNull public abstract android.telephony.CellLocation asCellLocation();
}
public final class CellIdentityCdma extends android.telephony.CellIdentity {
method @NonNull public android.telephony.cdma.CdmaCellLocation asCellLocation();
}
public final class CellIdentityGsm extends android.telephony.CellIdentity {
method @NonNull public android.telephony.gsm.GsmCellLocation asCellLocation();
}
public final class CellIdentityLte extends android.telephony.CellIdentity {
method @NonNull public android.telephony.gsm.GsmCellLocation asCellLocation();
}
public final class CellIdentityNr extends android.telephony.CellIdentity {
method @NonNull public android.telephony.CellLocation asCellLocation();
}
public final class CellIdentityTdscdma extends android.telephony.CellIdentity {
method @NonNull public android.telephony.gsm.GsmCellLocation asCellLocation();
}
public final class CellIdentityWcdma extends android.telephony.CellIdentity {
method @NonNull public android.telephony.gsm.GsmCellLocation asCellLocation();
}
public final class DataFailCause { public final class DataFailCause {
field public static final int ACCESS_ATTEMPT_ALREADY_IN_PROGRESS = 2219; // 0x8ab field public static final int ACCESS_ATTEMPT_ALREADY_IN_PROGRESS = 2219; // 0x8ab
field public static final int ACCESS_BLOCK = 2087; // 0x827 field public static final int ACCESS_BLOCK = 2087; // 0x827

View File

@@ -24,7 +24,6 @@ import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage; import android.annotation.UnsupportedAppUsage;
import android.os.Binder; import android.os.Binder;
import android.os.Build; import android.os.Build;
import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.HandlerExecutor; import android.os.HandlerExecutor;
import android.os.Looper; import android.os.Looper;
@@ -984,8 +983,11 @@ public class PhoneStateListener {
() -> mExecutor.execute(() -> psl.onCallForwardingIndicatorChanged(cfi))); () -> mExecutor.execute(() -> psl.onCallForwardingIndicatorChanged(cfi)));
} }
public void onCellLocationChanged(Bundle bundle) { public void onCellLocationChanged(CellIdentity cellIdentity) {
CellLocation location = CellLocation.newFromBundle(bundle); // There is no system/public API to create an CellIdentity in system server,
// so the server pass a null to indicate an empty initial location.
CellLocation location =
cellIdentity == null ? CellLocation.getEmpty() : cellIdentity.asCellLocation();
PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); PhoneStateListener psl = mPhoneStateListenerWeakRef.get();
if (psl == null) return; if (psl == null) return;

View File

@@ -22,9 +22,6 @@ import android.annotation.SystemApi;
import android.annotation.TestApi; import android.annotation.TestApi;
import android.content.Context; import android.content.Context;
import android.os.Binder; import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ServiceManager; import android.os.ServiceManager;
import android.telephony.Annotation.CallState; import android.telephony.Annotation.CallState;
@@ -642,10 +639,14 @@ public class TelephonyRegistryManager {
} }
/** /**
* TODO change from bundle to CellLocation? * Notify {@link android.telephony.CellLocation} changed.
*
* <p>To be compatible with {@link TelephonyRegistry}, use {@link CellIdentity} which is
* parcelable, and convert to CellLocation in client code.
*
* @hide * @hide
*/ */
public void notifyCellLocation(int subId, Bundle cellLocation) { public void notifyCellLocation(int subId, CellIdentity cellLocation) {
try { try {
sRegistry.notifyCellLocationForSubscriber(subId, cellLocation); sRegistry.notifyCellLocationForSubscriber(subId, cellLocation);
} catch (RemoteException ex) { } catch (RemoteException ex) {

View File

@@ -16,8 +16,8 @@
package com.android.internal.telephony; package com.android.internal.telephony;
import android.os.Bundle;
import android.telephony.CallAttributes; import android.telephony.CallAttributes;
import android.telephony.CellIdentity;
import android.telephony.CellInfo; import android.telephony.CellInfo;
import android.telephony.DataConnectionRealTimeInfo; import android.telephony.DataConnectionRealTimeInfo;
import android.telephony.PhoneCapability; import android.telephony.PhoneCapability;
@@ -37,8 +37,8 @@ oneway interface IPhoneStateListener {
void onMessageWaitingIndicatorChanged(boolean mwi); void onMessageWaitingIndicatorChanged(boolean mwi);
void onCallForwardingIndicatorChanged(boolean cfi); void onCallForwardingIndicatorChanged(boolean cfi);
// we use bundle here instead of CellLocation so it can get the right subclass // Uses CellIdentity which is Parcelable here; will convert to CellLocation in client.
void onCellLocationChanged(in Bundle location); void onCellLocationChanged(in CellIdentity location);
void onCallStateChanged(int state, String incomingNumber); void onCallStateChanged(int state, String incomingNumber);
void onDataConnectionStateChanged(int state, int networkType); void onDataConnectionStateChanged(int state, int networkType);
void onDataActivity(int direction); void onDataActivity(int direction);
@@ -63,4 +63,3 @@ oneway interface IPhoneStateListener {
void onCallDisconnectCauseChanged(in int disconnectCause, in int preciseDisconnectCause); void onCallDisconnectCauseChanged(in int disconnectCause, in int preciseDisconnectCause);
void onImsCallDisconnectCauseChanged(in ImsReasonInfo imsReasonInfo); void onImsCallDisconnectCauseChanged(in ImsReasonInfo imsReasonInfo);
} }

View File

@@ -19,8 +19,8 @@ package com.android.internal.telephony;
import android.content.Intent; import android.content.Intent;
import android.net.LinkProperties; import android.net.LinkProperties;
import android.net.NetworkCapabilities; import android.net.NetworkCapabilities;
import android.os.Bundle;
import android.telephony.CallQuality; import android.telephony.CallQuality;
import android.telephony.CellIdentity;
import android.telephony.CellInfo; import android.telephony.CellInfo;
import android.telephony.ims.ImsReasonInfo; import android.telephony.ims.ImsReasonInfo;
import android.telephony.PhoneCapability; import android.telephony.PhoneCapability;
@@ -67,9 +67,9 @@ interface ITelephonyRegistry {
@UnsupportedAppUsage @UnsupportedAppUsage
void notifyDataConnectionFailed(String apnType); void notifyDataConnectionFailed(String apnType);
void notifyDataConnectionFailedForSubscriber(int phoneId, int subId, String apnType); void notifyDataConnectionFailedForSubscriber(int phoneId, int subId, String apnType);
@UnsupportedAppUsage(maxTargetSdk = 28) // Uses CellIdentity which is Parcelable here; will convert to CellLocation in client.
void notifyCellLocation(in Bundle cellLocation); void notifyCellLocation(in CellIdentity cellLocation);
void notifyCellLocationForSubscriber(in int subId, in Bundle cellLocation); void notifyCellLocationForSubscriber(in int subId, in CellIdentity cellLocation);
@UnsupportedAppUsage @UnsupportedAppUsage
void notifyCellInfo(in List<CellInfo> cellInfo); void notifyCellInfo(in List<CellInfo> cellInfo);
void notifyPreciseCallState(int phoneId, int subId, int ringingCallState, void notifyPreciseCallState(int phoneId, int subId, int ringingCallState,

View File

@@ -46,6 +46,7 @@ import android.telephony.Annotation.RadioPowerState;
import android.telephony.Annotation.SrvccState; import android.telephony.Annotation.SrvccState;
import android.telephony.CallAttributes; import android.telephony.CallAttributes;
import android.telephony.CallQuality; import android.telephony.CallQuality;
import android.telephony.CellIdentity;
import android.telephony.CellInfo; import android.telephony.CellInfo;
import android.telephony.CellLocation; import android.telephony.CellLocation;
import android.telephony.DataFailCause; import android.telephony.DataFailCause;
@@ -207,7 +208,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
// Connection state of default APN type data (i.e. internet) of phones // Connection state of default APN type data (i.e. internet) of phones
private int[] mDataConnectionState; private int[] mDataConnectionState;
private Bundle[] mCellLocation; private CellIdentity[] mCellIdentity;
private int[] mDataConnectionNetworkType; private int[] mDataConnectionNetworkType;
@@ -295,7 +296,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
int numPhones = getTelephonyManager().getPhoneCount(); int numPhones = getTelephonyManager().getPhoneCount();
for (int sub = 0; sub < numPhones; sub++) { for (int sub = 0; sub < numPhones; sub++) {
TelephonyRegistry.this.notifyCellLocationForSubscriber(sub, TelephonyRegistry.this.notifyCellLocationForSubscriber(sub,
mCellLocation[sub]); mCellIdentity[sub]);
} }
break; break;
} }
@@ -404,7 +405,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mSignalStrength = copyOf(mSignalStrength, mNumPhones); mSignalStrength = copyOf(mSignalStrength, mNumPhones);
mMessageWaiting = copyOf(mMessageWaiting, mNumPhones); mMessageWaiting = copyOf(mMessageWaiting, mNumPhones);
mCallForwarding = copyOf(mCallForwarding, mNumPhones); mCallForwarding = copyOf(mCallForwarding, mNumPhones);
mCellLocation = copyOf(mCellLocation, mNumPhones); mCellIdentity = copyOf(mCellIdentity, mNumPhones);
mSrvccState = copyOf(mSrvccState, mNumPhones); mSrvccState = copyOf(mSrvccState, mNumPhones);
mPreciseCallState = copyOf(mPreciseCallState, mNumPhones); mPreciseCallState = copyOf(mPreciseCallState, mNumPhones);
mForegroundCallState = copyOf(mForegroundCallState, mNumPhones); mForegroundCallState = copyOf(mForegroundCallState, mNumPhones);
@@ -439,7 +440,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mUserMobileDataState[i] = false; mUserMobileDataState[i] = false;
mMessageWaiting[i] = false; mMessageWaiting[i] = false;
mCallForwarding[i] = false; mCallForwarding[i] = false;
mCellLocation[i] = new Bundle(); mCellIdentity[i] = null;
mCellInfo.add(i, null); mCellInfo.add(i, null);
mImsReasonInfo.add(i, null); mImsReasonInfo.add(i, null);
mSrvccState[i] = TelephonyManager.SRVCC_STATE_HANDOVER_NONE; mSrvccState[i] = TelephonyManager.SRVCC_STATE_HANDOVER_NONE;
@@ -455,15 +456,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE; mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mPreciseDataConnectionStates.add(new HashMap<String, PreciseDataConnectionState>()); mPreciseDataConnectionStates.add(new HashMap<String, PreciseDataConnectionState>());
} }
// Note that location can be null for non-phone builds like
// like the generic one.
CellLocation location = CellLocation.getEmpty();
if (location != null) {
for (int i = oldNumPhones; i < mNumPhones; i++) {
location.fillInNotifierBundle(mCellLocation[i]);
}
}
} }
private void cutListToSize(List list, int size) { private void cutListToSize(List list, int size) {
@@ -503,7 +495,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mSignalStrength = new SignalStrength[numPhones]; mSignalStrength = new SignalStrength[numPhones];
mMessageWaiting = new boolean[numPhones]; mMessageWaiting = new boolean[numPhones];
mCallForwarding = new boolean[numPhones]; mCallForwarding = new boolean[numPhones];
mCellLocation = new Bundle[numPhones]; mCellIdentity = new CellIdentity[numPhones];
mSrvccState = new int[numPhones]; mSrvccState = new int[numPhones];
mPreciseCallState = new PreciseCallState[numPhones]; mPreciseCallState = new PreciseCallState[numPhones];
mForegroundCallState = new int[numPhones]; mForegroundCallState = new int[numPhones];
@@ -532,7 +524,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mUserMobileDataState[i] = false; mUserMobileDataState[i] = false;
mMessageWaiting[i] = false; mMessageWaiting[i] = false;
mCallForwarding[i] = false; mCallForwarding[i] = false;
mCellLocation[i] = new Bundle(); mCellIdentity[i] = null;
mCellInfo.add(i, null); mCellInfo.add(i, null);
mImsReasonInfo.add(i, null); mImsReasonInfo.add(i, null);
mSrvccState[i] = TelephonyManager.SRVCC_STATE_HANDOVER_NONE; mSrvccState[i] = TelephonyManager.SRVCC_STATE_HANDOVER_NONE;
@@ -549,14 +541,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
mPreciseDataConnectionStates.add(new HashMap<String, PreciseDataConnectionState>()); mPreciseDataConnectionStates.add(new HashMap<String, PreciseDataConnectionState>());
} }
// Note that location can be null for non-phone builds like
// like the generic one.
if (location != null) {
for (int i = 0; i < numPhones; i++) {
location.fillInNotifierBundle(mCellLocation[i]);
}
}
mAppOps = mContext.getSystemService(AppOpsManager.class); mAppOps = mContext.getSystemService(AppOpsManager.class);
} }
@@ -839,11 +823,10 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) { if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
try { try {
if (DBG_LOC) log("listen: mCellLocation = " if (DBG_LOC) log("listen: mCellIdentity = " + mCellIdentity[phoneId]);
+ mCellLocation[phoneId]);
if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) { if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) {
r.callback.onCellLocationChanged( // null will be translated to empty CellLocation object in client.
new Bundle(mCellLocation[phoneId])); r.callback.onCellLocationChanged(mCellIdentity[phoneId]);
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
remove(r.binder); remove(r.binder);
@@ -1629,11 +1612,13 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
} }
public void notifyCellLocation(Bundle cellLocation) { @Override
notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellLocation); public void notifyCellLocation(CellIdentity cellLocation) {
notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellLocation);
} }
public void notifyCellLocationForSubscriber(int subId, Bundle cellLocation) { @Override
public void notifyCellLocationForSubscriber(int subId, CellIdentity cellLocation) {
log("notifyCellLocationForSubscriber: subId=" + subId log("notifyCellLocationForSubscriber: subId=" + subId
+ " cellLocation=" + cellLocation); + " cellLocation=" + cellLocation);
if (!checkNotifyPermission("notifyCellLocation()")) { if (!checkNotifyPermission("notifyCellLocation()")) {
@@ -1646,7 +1631,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
int phoneId = getPhoneIdFromSubId(subId); int phoneId = getPhoneIdFromSubId(subId);
synchronized (mRecords) { synchronized (mRecords) {
if (validatePhoneId(phoneId)) { if (validatePhoneId(phoneId)) {
mCellLocation[phoneId] = cellLocation; mCellIdentity[phoneId] = cellLocation;
for (Record r : mRecords) { for (Record r : mRecords) {
if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) && if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) &&
idMatch(r.subId, subId, phoneId) && idMatch(r.subId, subId, phoneId) &&
@@ -1656,7 +1641,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
log("notifyCellLocation: cellLocation=" + cellLocation log("notifyCellLocation: cellLocation=" + cellLocation
+ " r=" + r); + " r=" + r);
} }
r.callback.onCellLocationChanged(new Bundle(cellLocation)); r.callback.onCellLocationChanged(cellLocation);
} catch (RemoteException ex) { } catch (RemoteException ex) {
mRemoveList.add(r.binder); mRemoveList.add(r.binder);
} }
@@ -2093,7 +2078,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
pw.println("mCallForwarding=" + mCallForwarding[i]); pw.println("mCallForwarding=" + mCallForwarding[i]);
pw.println("mDataActivity=" + mDataActivity[i]); pw.println("mDataActivity=" + mDataActivity[i]);
pw.println("mDataConnectionState=" + mDataConnectionState[i]); pw.println("mDataConnectionState=" + mDataConnectionState[i]);
pw.println("mCellLocation=" + mCellLocation[i]); pw.println("mCellIdentity=" + mCellIdentity[i]);
pw.println("mCellInfo=" + mCellInfo.get(i)); pw.println("mCellInfo=" + mCellInfo.get(i));
pw.println("mImsCallDisconnectCause=" + mImsReasonInfo.get(i)); pw.println("mImsCallDisconnectCause=" + mImsReasonInfo.get(i));
pw.println("mSrvccState=" + mSrvccState[i]); pw.println("mSrvccState=" + mSrvccState[i]);
@@ -2576,10 +2561,13 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) { if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
try { try {
if (DBG_LOC) log("checkPossibleMissNotify: onCellLocationChanged mCellLocation = " if (DBG_LOC) {
+ mCellLocation[phoneId]); log("checkPossibleMissNotify: onCellLocationChanged mCellIdentity = "
+ mCellIdentity[phoneId]);
}
if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) { if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) {
r.callback.onCellLocationChanged(new Bundle(mCellLocation[phoneId])); // null will be translated to empty CellLocation object in client.
r.callback.onCellLocationChanged(mCellIdentity[phoneId]);
} }
} catch (RemoteException ex) { } catch (RemoteException ex) {
mRemoveList.add(r.binder); mRemoveList.add(r.binder);

View File

@@ -19,6 +19,7 @@ package android.telephony;
import android.annotation.CallSuper; import android.annotation.CallSuper;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.text.TextUtils; import android.text.TextUtils;
@@ -181,7 +182,8 @@ public abstract class CellIdentity implements Parcelable {
* @return a CellLocation object for this CellIdentity * @return a CellLocation object for this CellIdentity
* @hide * @hide
*/ */
public abstract CellLocation asCellLocation(); @SystemApi
public abstract @NonNull CellLocation asCellLocation();
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {

View File

@@ -16,6 +16,7 @@
package android.telephony; package android.telephony;
import android.annotation.NonNull;
import android.os.Parcel; import android.os.Parcel;
import android.telephony.cdma.CdmaCellLocation; import android.telephony.cdma.CdmaCellLocation;
@@ -198,6 +199,7 @@ public final class CellIdentityCdma extends CellIdentity {
} }
/** @hide */ /** @hide */
@NonNull
@Override @Override
public CdmaCellLocation asCellLocation() { public CdmaCellLocation asCellLocation() {
CdmaCellLocation cl = new CdmaCellLocation(); CdmaCellLocation cl = new CdmaCellLocation();

View File

@@ -16,6 +16,7 @@
package android.telephony; package android.telephony;
import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage; import android.annotation.UnsupportedAppUsage;
import android.os.Parcel; import android.os.Parcel;
@@ -200,6 +201,7 @@ public final class CellIdentityGsm extends CellIdentity {
} }
/** @hide */ /** @hide */
@NonNull
@Override @Override
public GsmCellLocation asCellLocation() { public GsmCellLocation asCellLocation() {
GsmCellLocation cl = new GsmCellLocation(); GsmCellLocation cl = new GsmCellLocation();

View File

@@ -16,6 +16,7 @@
package android.telephony; package android.telephony;
import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage; import android.annotation.UnsupportedAppUsage;
import android.os.Build; import android.os.Build;
@@ -232,6 +233,7 @@ public final class CellIdentityLte extends CellIdentity {
* *
* @hide * @hide
*/ */
@NonNull
@Override @Override
public GsmCellLocation asCellLocation() { public GsmCellLocation asCellLocation() {
GsmCellLocation cl = new GsmCellLocation(); GsmCellLocation cl = new GsmCellLocation();

View File

@@ -17,6 +17,7 @@
package android.telephony; package android.telephony;
import android.annotation.IntRange; import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.os.Parcel; import android.os.Parcel;
import android.telephony.gsm.GsmCellLocation; import android.telephony.gsm.GsmCellLocation;
@@ -77,6 +78,7 @@ public final class CellIdentityNr extends CellIdentity {
* @return a CellLocation object for this CellIdentity. * @return a CellLocation object for this CellIdentity.
* @hide * @hide
*/ */
@NonNull
@Override @Override
public CellLocation asCellLocation() { public CellLocation asCellLocation() {
return new GsmCellLocation(); return new GsmCellLocation();

View File

@@ -171,6 +171,7 @@ public final class CellIdentityTdscdma extends CellIdentity {
} }
/** @hide */ /** @hide */
@NonNull
@Override @Override
public GsmCellLocation asCellLocation() { public GsmCellLocation asCellLocation() {
GsmCellLocation cl = new GsmCellLocation(); GsmCellLocation cl = new GsmCellLocation();

View File

@@ -16,6 +16,7 @@
package android.telephony; package android.telephony;
import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage; import android.annotation.UnsupportedAppUsage;
import android.os.Parcel; import android.os.Parcel;
@@ -196,6 +197,7 @@ public final class CellIdentityWcdma extends CellIdentity {
} }
/** @hide */ /** @hide */
@NonNull
@Override @Override
public GsmCellLocation asCellLocation() { public GsmCellLocation asCellLocation() {
GsmCellLocation cl = new GsmCellLocation(); GsmCellLocation cl = new GsmCellLocation();

View File

@@ -1867,13 +1867,9 @@ public class TelephonyManager {
return null; return null;
} }
Bundle bundle = telephony.getCellLocation(mContext.getOpPackageName(), null); CellIdentity cellIdentity = telephony.getCellLocation(mContext.getOpPackageName(),
if (bundle == null || bundle.isEmpty()) { null);
Rlog.d(TAG, "getCellLocation returning null because CellLocation is unavailable"); CellLocation cl = cellIdentity.asCellLocation();
return null;
}
CellLocation cl = CellLocation.newFromBundle(bundle);
if (cl == null || cl.isEmpty()) { if (cl == null || cl.isEmpty()) {
Rlog.d(TAG, "getCellLocation returning null because CellLocation is empty or" Rlog.d(TAG, "getCellLocation returning null because CellLocation is empty or"
+ " phone type doesn't match CellLocation type"); + " phone type doesn't match CellLocation type");

View File

@@ -30,6 +30,7 @@ import android.service.carrier.CarrierIdentifier;
import android.telecom.PhoneAccount; import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle; import android.telecom.PhoneAccountHandle;
import android.telephony.CarrierRestrictionRules; import android.telephony.CarrierRestrictionRules;
import android.telephony.CellIdentity;
import android.telephony.CellInfo; import android.telephony.CellInfo;
import android.telephony.ClientRequestStats; import android.telephony.ClientRequestStats;
import android.telephony.IccOpenLogicalChannelResponse; import android.telephony.IccOpenLogicalChannelResponse;
@@ -305,7 +306,8 @@ interface ITelephony {
*/ */
boolean isDataConnectivityPossible(int subId); boolean isDataConnectivityPossible(int subId);
Bundle getCellLocation(String callingPkg, String callingFeatureId); // Uses CellIdentity which is Parcelable here; will convert to CellLocation in client.
CellIdentity getCellLocation(String callingPkg, String callingFeatureId);
/** /**
* Returns the ISO country code equivalent of the current registered * Returns the ISO country code equivalent of the current registered