Merge "Notify CellLocation whenever ACTION_USER_SWITCHED" into sc-dev

This commit is contained in:
Amit Mahajan
2021-03-30 17:42:08 +00:00
committed by Android (Google) Code Review
2 changed files with 17 additions and 13 deletions

View File

@@ -61,7 +61,6 @@ interface ITelephonyRegistry {
void notifyDataConnectionForSubscriber(
int phoneId, int subId, in PreciseDataConnectionState preciseState);
// 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);

View File

@@ -418,10 +418,15 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
switch (msg.what) {
case MSG_USER_SWITCHED: {
if (VDBG) log("MSG_USER_SWITCHED userId=" + msg.arg1);
int numPhones = getTelephonyManager().getPhoneCount();
for (int sub = 0; sub < numPhones; sub++) {
TelephonyRegistry.this.notifyCellLocationForSubscriber(sub,
mCellIdentity[sub]);
int numPhones = getTelephonyManager().getActiveModemCount();
for (int phoneId = 0; phoneId < numPhones; phoneId++) {
int[] subIds = SubscriptionManager.getSubId(phoneId);
int subId =
(subIds != null) && (subIds.length > 0)
? subIds[0]
: SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
TelephonyRegistry.this.notifyCellLocationForSubscriber(
subId, mCellIdentity[phoneId], true /* hasUserSwitched */);
}
break;
}
@@ -1946,20 +1951,20 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
@Override
public void notifyCellLocation(CellIdentity cellLocation) {
notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellLocation);
public void notifyCellLocationForSubscriber(int subId, CellIdentity cellIdentity) {
notifyCellLocationForSubscriber(subId, cellIdentity, false /* hasUserSwitched */);
}
@Override
public void notifyCellLocationForSubscriber(int subId, CellIdentity cellIdentity) {
log("notifyCellLocationForSubscriber: subId=" + subId
+ " cellIdentity=" + cellIdentity);
private void notifyCellLocationForSubscriber(int subId, CellIdentity cellIdentity,
boolean hasUserSwitched) {
log("notifyCellLocationForSubscriber: subId=" + subId + " cellIdentity=" + cellIdentity);
if (!checkNotifyPermission("notifyCellLocation()")) {
return;
}
int phoneId = getPhoneIdFromSubId(subId);
synchronized (mRecords) {
if (validatePhoneId(phoneId) && !Objects.equals(cellIdentity, mCellIdentity[phoneId])) {
if (validatePhoneId(phoneId)
&& (hasUserSwitched || !Objects.equals(cellIdentity, mCellIdentity[phoneId]))) {
mCellIdentity[phoneId] = cellIdentity;
for (Record r : mRecords) {
if (validateEventAndUserLocked(
@@ -2620,7 +2625,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
final int recordCount = mRecords.size();
pw.println("last known state:");
pw.increaseIndent();
for (int i = 0; i < getTelephonyManager().getPhoneCount(); i++) {
for (int i = 0; i < getTelephonyManager().getActiveModemCount(); i++) {
pw.println("Phone Id=" + i);
pw.increaseIndent();
pw.println("mCallState=" + mCallState[i]);