Merge "Use Parcelable CellIdentity instead of CellLocation in AIDL."
This commit is contained in:
@@ -8126,6 +8126,34 @@ package android.telephony {
|
||||
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 {
|
||||
field public static final int ACCESS_ATTEMPT_ALREADY_IN_PROGRESS = 2219; // 0x8ab
|
||||
field public static final int ACCESS_BLOCK = 2087; // 0x827
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.annotation.TestApi;
|
||||
import android.annotation.UnsupportedAppUsage;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerExecutor;
|
||||
import android.os.Looper;
|
||||
@@ -984,8 +983,11 @@ public class PhoneStateListener {
|
||||
() -> mExecutor.execute(() -> psl.onCallForwardingIndicatorChanged(cfi)));
|
||||
}
|
||||
|
||||
public void onCellLocationChanged(Bundle bundle) {
|
||||
CellLocation location = CellLocation.newFromBundle(bundle);
|
||||
public void onCellLocationChanged(CellIdentity cellIdentity) {
|
||||
// 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();
|
||||
if (psl == null) return;
|
||||
|
||||
|
||||
@@ -22,9 +22,6 @@ import android.annotation.SystemApi;
|
||||
import android.annotation.TestApi;
|
||||
import android.content.Context;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerExecutor;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
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
|
||||
*/
|
||||
public void notifyCellLocation(int subId, Bundle cellLocation) {
|
||||
public void notifyCellLocation(int subId, CellIdentity cellLocation) {
|
||||
try {
|
||||
sRegistry.notifyCellLocationForSubscriber(subId, cellLocation);
|
||||
} catch (RemoteException ex) {
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package com.android.internal.telephony;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.telephony.CallAttributes;
|
||||
import android.telephony.CellIdentity;
|
||||
import android.telephony.CellInfo;
|
||||
import android.telephony.DataConnectionRealTimeInfo;
|
||||
import android.telephony.PhoneCapability;
|
||||
@@ -37,8 +37,8 @@ oneway interface IPhoneStateListener {
|
||||
void onMessageWaitingIndicatorChanged(boolean mwi);
|
||||
void onCallForwardingIndicatorChanged(boolean cfi);
|
||||
|
||||
// we use bundle here instead of CellLocation so it can get the right subclass
|
||||
void onCellLocationChanged(in Bundle location);
|
||||
// Uses CellIdentity which is Parcelable here; will convert to CellLocation in client.
|
||||
void onCellLocationChanged(in CellIdentity location);
|
||||
void onCallStateChanged(int state, String incomingNumber);
|
||||
void onDataConnectionStateChanged(int state, int networkType);
|
||||
void onDataActivity(int direction);
|
||||
@@ -63,4 +63,3 @@ oneway interface IPhoneStateListener {
|
||||
void onCallDisconnectCauseChanged(in int disconnectCause, in int preciseDisconnectCause);
|
||||
void onImsCallDisconnectCauseChanged(in ImsReasonInfo imsReasonInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ package com.android.internal.telephony;
|
||||
import android.content.Intent;
|
||||
import android.net.LinkProperties;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.CallQuality;
|
||||
import android.telephony.CellIdentity;
|
||||
import android.telephony.CellInfo;
|
||||
import android.telephony.ims.ImsReasonInfo;
|
||||
import android.telephony.PhoneCapability;
|
||||
@@ -67,9 +67,9 @@ interface ITelephonyRegistry {
|
||||
@UnsupportedAppUsage
|
||||
void notifyDataConnectionFailed(String apnType);
|
||||
void notifyDataConnectionFailedForSubscriber(int phoneId, int subId, String apnType);
|
||||
@UnsupportedAppUsage(maxTargetSdk = 28)
|
||||
void notifyCellLocation(in Bundle cellLocation);
|
||||
void notifyCellLocationForSubscriber(in int subId, in Bundle cellLocation);
|
||||
// Uses CellIdentity which is Parcelable here; will convert to CellLocation in client.
|
||||
void notifyCellLocation(in CellIdentity cellLocation);
|
||||
void notifyCellLocationForSubscriber(in int subId, in CellIdentity cellLocation);
|
||||
@UnsupportedAppUsage
|
||||
void notifyCellInfo(in List<CellInfo> cellInfo);
|
||||
void notifyPreciseCallState(int phoneId, int subId, int ringingCallState,
|
||||
|
||||
@@ -46,6 +46,7 @@ import android.telephony.Annotation.RadioPowerState;
|
||||
import android.telephony.Annotation.SrvccState;
|
||||
import android.telephony.CallAttributes;
|
||||
import android.telephony.CallQuality;
|
||||
import android.telephony.CellIdentity;
|
||||
import android.telephony.CellInfo;
|
||||
import android.telephony.CellLocation;
|
||||
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
|
||||
private int[] mDataConnectionState;
|
||||
|
||||
private Bundle[] mCellLocation;
|
||||
private CellIdentity[] mCellIdentity;
|
||||
|
||||
private int[] mDataConnectionNetworkType;
|
||||
|
||||
@@ -295,7 +296,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
int numPhones = getTelephonyManager().getPhoneCount();
|
||||
for (int sub = 0; sub < numPhones; sub++) {
|
||||
TelephonyRegistry.this.notifyCellLocationForSubscriber(sub,
|
||||
mCellLocation[sub]);
|
||||
mCellIdentity[sub]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -404,7 +405,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
mSignalStrength = copyOf(mSignalStrength, mNumPhones);
|
||||
mMessageWaiting = copyOf(mMessageWaiting, mNumPhones);
|
||||
mCallForwarding = copyOf(mCallForwarding, mNumPhones);
|
||||
mCellLocation = copyOf(mCellLocation, mNumPhones);
|
||||
mCellIdentity = copyOf(mCellIdentity, mNumPhones);
|
||||
mSrvccState = copyOf(mSrvccState, mNumPhones);
|
||||
mPreciseCallState = copyOf(mPreciseCallState, mNumPhones);
|
||||
mForegroundCallState = copyOf(mForegroundCallState, mNumPhones);
|
||||
@@ -439,7 +440,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
mUserMobileDataState[i] = false;
|
||||
mMessageWaiting[i] = false;
|
||||
mCallForwarding[i] = false;
|
||||
mCellLocation[i] = new Bundle();
|
||||
mCellIdentity[i] = null;
|
||||
mCellInfo.add(i, null);
|
||||
mImsReasonInfo.add(i, null);
|
||||
mSrvccState[i] = TelephonyManager.SRVCC_STATE_HANDOVER_NONE;
|
||||
@@ -455,15 +456,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
|
||||
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) {
|
||||
@@ -503,7 +495,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
mSignalStrength = new SignalStrength[numPhones];
|
||||
mMessageWaiting = new boolean[numPhones];
|
||||
mCallForwarding = new boolean[numPhones];
|
||||
mCellLocation = new Bundle[numPhones];
|
||||
mCellIdentity = new CellIdentity[numPhones];
|
||||
mSrvccState = new int[numPhones];
|
||||
mPreciseCallState = new PreciseCallState[numPhones];
|
||||
mForegroundCallState = new int[numPhones];
|
||||
@@ -532,7 +524,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
mUserMobileDataState[i] = false;
|
||||
mMessageWaiting[i] = false;
|
||||
mCallForwarding[i] = false;
|
||||
mCellLocation[i] = new Bundle();
|
||||
mCellIdentity[i] = null;
|
||||
mCellInfo.add(i, null);
|
||||
mImsReasonInfo.add(i, null);
|
||||
mSrvccState[i] = TelephonyManager.SRVCC_STATE_HANDOVER_NONE;
|
||||
@@ -549,14 +541,6 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -839,11 +823,10 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
}
|
||||
if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
|
||||
try {
|
||||
if (DBG_LOC) log("listen: mCellLocation = "
|
||||
+ mCellLocation[phoneId]);
|
||||
if (DBG_LOC) log("listen: mCellIdentity = " + mCellIdentity[phoneId]);
|
||||
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) {
|
||||
remove(r.binder);
|
||||
@@ -1629,11 +1612,13 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyCellLocation(Bundle cellLocation) {
|
||||
notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellLocation);
|
||||
@Override
|
||||
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
|
||||
+ " cellLocation=" + cellLocation);
|
||||
if (!checkNotifyPermission("notifyCellLocation()")) {
|
||||
@@ -1646,7 +1631,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
int phoneId = getPhoneIdFromSubId(subId);
|
||||
synchronized (mRecords) {
|
||||
if (validatePhoneId(phoneId)) {
|
||||
mCellLocation[phoneId] = cellLocation;
|
||||
mCellIdentity[phoneId] = cellLocation;
|
||||
for (Record r : mRecords) {
|
||||
if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) &&
|
||||
idMatch(r.subId, subId, phoneId) &&
|
||||
@@ -1656,7 +1641,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
log("notifyCellLocation: cellLocation=" + cellLocation
|
||||
+ " r=" + r);
|
||||
}
|
||||
r.callback.onCellLocationChanged(new Bundle(cellLocation));
|
||||
r.callback.onCellLocationChanged(cellLocation);
|
||||
} catch (RemoteException ex) {
|
||||
mRemoveList.add(r.binder);
|
||||
}
|
||||
@@ -2093,7 +2078,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
pw.println("mCallForwarding=" + mCallForwarding[i]);
|
||||
pw.println("mDataActivity=" + mDataActivity[i]);
|
||||
pw.println("mDataConnectionState=" + mDataConnectionState[i]);
|
||||
pw.println("mCellLocation=" + mCellLocation[i]);
|
||||
pw.println("mCellIdentity=" + mCellIdentity[i]);
|
||||
pw.println("mCellInfo=" + mCellInfo.get(i));
|
||||
pw.println("mImsCallDisconnectCause=" + mImsReasonInfo.get(i));
|
||||
pw.println("mSrvccState=" + mSrvccState[i]);
|
||||
@@ -2576,10 +2561,13 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
|
||||
if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
|
||||
try {
|
||||
if (DBG_LOC) log("checkPossibleMissNotify: onCellLocationChanged mCellLocation = "
|
||||
+ mCellLocation[phoneId]);
|
||||
if (DBG_LOC) {
|
||||
log("checkPossibleMissNotify: onCellLocationChanged mCellIdentity = "
|
||||
+ mCellIdentity[phoneId]);
|
||||
}
|
||||
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) {
|
||||
mRemoveList.add(r.binder);
|
||||
|
||||
@@ -19,6 +19,7 @@ package android.telephony;
|
||||
import android.annotation.CallSuper;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
@@ -181,7 +182,8 @@ public abstract class CellIdentity implements Parcelable {
|
||||
* @return a CellLocation object for this CellIdentity
|
||||
* @hide
|
||||
*/
|
||||
public abstract CellLocation asCellLocation();
|
||||
@SystemApi
|
||||
public abstract @NonNull CellLocation asCellLocation();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.telephony;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.os.Parcel;
|
||||
import android.telephony.cdma.CdmaCellLocation;
|
||||
|
||||
@@ -198,6 +199,7 @@ public final class CellIdentityCdma extends CellIdentity {
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@Override
|
||||
public CdmaCellLocation asCellLocation() {
|
||||
CdmaCellLocation cl = new CdmaCellLocation();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.telephony;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.UnsupportedAppUsage;
|
||||
import android.os.Parcel;
|
||||
@@ -200,6 +201,7 @@ public final class CellIdentityGsm extends CellIdentity {
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@Override
|
||||
public GsmCellLocation asCellLocation() {
|
||||
GsmCellLocation cl = new GsmCellLocation();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.telephony;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.UnsupportedAppUsage;
|
||||
import android.os.Build;
|
||||
@@ -232,6 +233,7 @@ public final class CellIdentityLte extends CellIdentity {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public GsmCellLocation asCellLocation() {
|
||||
GsmCellLocation cl = new GsmCellLocation();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package android.telephony;
|
||||
|
||||
import android.annotation.IntRange;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.os.Parcel;
|
||||
import android.telephony.gsm.GsmCellLocation;
|
||||
@@ -77,6 +78,7 @@ public final class CellIdentityNr extends CellIdentity {
|
||||
* @return a CellLocation object for this CellIdentity.
|
||||
* @hide
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public CellLocation asCellLocation() {
|
||||
return new GsmCellLocation();
|
||||
|
||||
@@ -171,6 +171,7 @@ public final class CellIdentityTdscdma extends CellIdentity {
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@Override
|
||||
public GsmCellLocation asCellLocation() {
|
||||
GsmCellLocation cl = new GsmCellLocation();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.telephony;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.UnsupportedAppUsage;
|
||||
import android.os.Parcel;
|
||||
@@ -196,6 +197,7 @@ public final class CellIdentityWcdma extends CellIdentity {
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@NonNull
|
||||
@Override
|
||||
public GsmCellLocation asCellLocation() {
|
||||
GsmCellLocation cl = new GsmCellLocation();
|
||||
|
||||
@@ -1867,13 +1867,9 @@ public class TelephonyManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
Bundle bundle = telephony.getCellLocation(mContext.getOpPackageName(), null);
|
||||
if (bundle == null || bundle.isEmpty()) {
|
||||
Rlog.d(TAG, "getCellLocation returning null because CellLocation is unavailable");
|
||||
return null;
|
||||
}
|
||||
|
||||
CellLocation cl = CellLocation.newFromBundle(bundle);
|
||||
CellIdentity cellIdentity = telephony.getCellLocation(mContext.getOpPackageName(),
|
||||
null);
|
||||
CellLocation cl = cellIdentity.asCellLocation();
|
||||
if (cl == null || cl.isEmpty()) {
|
||||
Rlog.d(TAG, "getCellLocation returning null because CellLocation is empty or"
|
||||
+ " phone type doesn't match CellLocation type");
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.service.carrier.CarrierIdentifier;
|
||||
import android.telecom.PhoneAccount;
|
||||
import android.telecom.PhoneAccountHandle;
|
||||
import android.telephony.CarrierRestrictionRules;
|
||||
import android.telephony.CellIdentity;
|
||||
import android.telephony.CellInfo;
|
||||
import android.telephony.ClientRequestStats;
|
||||
import android.telephony.IccOpenLogicalChannelResponse;
|
||||
@@ -305,7 +306,8 @@ interface ITelephony {
|
||||
*/
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user