Merge "Migrate convertHalCellIdentityToCellIdentity()" am: b50e6ceeb0 am: eeaba5f024
Change-Id: Iddee535691122b59b2ece88f3c11f44b05110cee
diff --git a/proto/src/telephony.proto b/proto/src/telephony.proto
index 7e823b5..dac6668 100644
--- a/proto/src/telephony.proto
+++ b/proto/src/telephony.proto
@@ -242,6 +242,17 @@
optional string numeric = 3;
}
+ message NetworkRegistrationInfo {
+ // Network domain
+ optional Domain domain = 1;
+
+ // Network transport
+ optional Transport transport = 2;
+
+ // Radio access technology
+ optional RadioAccessTechnology rat = 3;
+ }
+
// Roaming type
enum RoamingType {
@@ -302,6 +313,29 @@
NR_STATE_CONNECTED = 3;
}
+ // Domain type
+ enum Domain {
+ // Unknown
+ DOMAIN_UNKNOWN = 0;
+
+ // Circuit switching domain
+ DOMAIN_CS = 1;
+
+ // Packet switching domain
+ DOMAIN_PS = 2;
+ }
+
+ enum Transport {
+ // Unknown
+ TRANSPORT_UNKNOWN = 0;
+
+ // Transport type for Wireless Wide Area Networks (i.e. Cellular)
+ TRANSPORT_WWAN = 1;
+
+ // Transport type for Wireless Local Area Networks (i.e. Wifi)
+ TRANSPORT_WLAN = 2;
+ }
+
// Current registered operator
optional TelephonyOperator voice_operator = 1;
@@ -328,6 +362,9 @@
// Current NR state
optional NrState nr_state = 9;
+
+ // Network registration info
+ repeated NetworkRegistrationInfo networkRegistrationInfo = 10;
}
// Radio access families
diff --git a/src/java/com/android/internal/telephony/CellBroadcastHandler.java b/src/java/com/android/internal/telephony/CellBroadcastHandler.java
index 05e92ba..bb4131b 100644
--- a/src/java/com/android/internal/telephony/CellBroadcastHandler.java
+++ b/src/java/com/android/internal/telephony/CellBroadcastHandler.java
@@ -314,13 +314,13 @@
}
private static final class LocationRequester {
- private static final String TAG = LocationRequester.class.getSimpleName();
+ private static final String TAG = CellBroadcastHandler.class.getSimpleName();
/**
* Use as the default maximum wait time if the cell broadcast doesn't specify the value.
- * Most of the location request should be responded within 20 seconds.
+ * Most of the location request should be responded within 30 seconds.
*/
- private static final int DEFAULT_MAXIMUM_WAIT_TIME_SEC = 20;
+ private static final int DEFAULT_MAXIMUM_WAIT_TIME_SEC = 30;
/**
* Trigger this event when the {@link LocationManager} is not responded within the given
@@ -372,6 +372,11 @@
callback.onLocationUpdate(location);
}
mCallbacks.clear();
+
+ for (LocationListener listener : mLocationListenerList) {
+ mLocationManager.removeUpdates(listener);
+ }
+ mLocationListenerList.clear();
}
private void requestLocationUpdateInternal(@NonNull LocationUpdateCallback callback,
@@ -398,8 +403,27 @@
for (String provider : LOCATION_PROVIDERS) {
if (mLocationManager.isProviderEnabled(provider)) {
- mLocationManager.requestSingleUpdate(provider, mLocationListener, mLooper);
- break;
+ LocationListener listener = new LocationListener() {
+ @Override
+ public void onLocationChanged(Location location) {
+ mLocationListenerList.remove(this);
+ mLocationHandler.removeMessages(EVENT_LOCATION_REQUEST_TIMEOUT);
+ onLocationUpdate(new LatLng(location.getLatitude(),
+ location.getLongitude()));
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {}
+
+ @Override
+ public void onProviderEnabled(String provider) {}
+
+ @Override
+ public void onProviderDisabled(String provider) {}
+ };
+ mLocationListenerList.add(listener);
+ Log.d(TAG, "Request location single update from " + provider);
+ mLocationManager.requestSingleUpdate(provider, listener, mLooper);
}
}
}
@@ -418,22 +442,7 @@
== PackageManager.PERMISSION_GRANTED;
}
- private final LocationListener mLocationListener = new LocationListener() {
- @Override
- public void onLocationChanged(Location location) {
- mLocationHandler.removeMessages(EVENT_LOCATION_REQUEST_TIMEOUT);
- onLocationUpdate(new LatLng(location.getLatitude(), location.getLongitude()));
- }
-
- @Override
- public void onStatusChanged(String provider, int status, Bundle extras) {}
-
- @Override
- public void onProviderEnabled(String provider) {}
-
- @Override
- public void onProviderDisabled(String provider) {}
- };
+ private final List<LocationListener> mLocationListenerList = new ArrayList<>();
private final class LocationHandler extends Handler {
LocationHandler(Looper looper) {
diff --git a/src/java/com/android/internal/telephony/VisualVoicemailSmsFilter.java b/src/java/com/android/internal/telephony/VisualVoicemailSmsFilter.java
index 657d6bc..3ea5fc2 100644
--- a/src/java/com/android/internal/telephony/VisualVoicemailSmsFilter.java
+++ b/src/java/com/android/internal/telephony/VisualVoicemailSmsFilter.java
@@ -143,6 +143,7 @@
return false;
}
+ String clientPrefix = settings.clientPrefix;
FullMessage fullMessage = getFullMessage(pdus, format);
if (fullMessage == null) {
@@ -152,6 +153,10 @@
String asciiMessage = parseAsciiPduMessage(pdus);
WrappedMessageData messageData = VisualVoicemailSmsParser
.parseAlternativeFormat(asciiMessage);
+ if (messageData == null) {
+ Log.i(TAG, "Attempt to parse ascii PDU");
+ messageData = VisualVoicemailSmsParser.parse(clientPrefix, asciiMessage);
+ }
if (messageData != null) {
sendVvmSmsBroadcast(context, settings, phoneAccountHandle, messageData, null);
}
@@ -161,7 +166,6 @@
}
String messageBody = fullMessage.fullMessageBody;
- String clientPrefix = settings.clientPrefix;
WrappedMessageData messageData = VisualVoicemailSmsParser
.parse(clientPrefix, messageBody);
if (messageData != null) {
diff --git a/src/java/com/android/internal/telephony/dataconnection/DataConnection.java b/src/java/com/android/internal/telephony/dataconnection/DataConnection.java
index 749e79e..0d564c4 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DataConnection.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DataConnection.java
@@ -421,8 +421,7 @@
return getCurrentState() == mDisconnectingState;
}
- @VisibleForTesting
- public boolean isActive() {
+ boolean isActive() {
return getCurrentState() == mActiveState;
}
diff --git a/src/java/com/android/internal/telephony/gsm/GsmCellBroadcastHandler.java b/src/java/com/android/internal/telephony/gsm/GsmCellBroadcastHandler.java
index e8297fc..6162ad1 100644
--- a/src/java/com/android/internal/telephony/gsm/GsmCellBroadcastHandler.java
+++ b/src/java/com/android/internal/telephony/gsm/GsmCellBroadcastHandler.java
@@ -19,13 +19,18 @@
import static com.android.internal.telephony.gsm.SmsCbConstants.MESSAGE_ID_CMAS_GEO_FENCING_TRIGGER;
import android.compat.annotation.UnsupportedAppUsage;
+import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.res.Resources;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncResult;
import android.os.Message;
+import android.os.SystemClock;
import android.provider.Telephony.CellBroadcasts;
import android.telephony.CbGeoUtils.Geometry;
import android.telephony.CellLocation;
@@ -40,6 +45,7 @@
import com.android.internal.telephony.gsm.GsmSmsCbMessage.GeoFencingTriggerMessage;
import com.android.internal.telephony.gsm.GsmSmsCbMessage.GeoFencingTriggerMessage.CellBroadcastIdentity;
+import java.text.DateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -59,9 +65,29 @@
private final HashMap<SmsCbConcatInfo, byte[][]> mSmsCbPageMap =
new HashMap<SmsCbConcatInfo, byte[][]>(4);
+ private long mLastAirplaneModeTime = 0;
+
protected GsmCellBroadcastHandler(Context context, Phone phone) {
super("GsmCellBroadcastHandler", context, phone);
phone.mCi.setOnNewGsmBroadcastSms(getHandler(), EVENT_NEW_SMS_MESSAGE, null);
+
+ IntentFilter intentFilter = new IntentFilter();
+ intentFilter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
+ mContext.registerReceiver(
+ new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ switch (intent.getAction()) {
+ case Intent.ACTION_AIRPLANE_MODE_CHANGED:
+ boolean airplaneModeOn = intent.getBooleanExtra("state", false);
+ if (airplaneModeOn) {
+ mLastAirplaneModeTime = System.currentTimeMillis();
+ }
+ break;
+ }
+
+ }
+ }, intentFilter);
}
@Override
@@ -94,8 +120,13 @@
final List<SmsCbMessage> cbMessages = new ArrayList<>();
final List<Uri> cbMessageUris = new ArrayList<>();
- // Only consider the cell broadcast received within 24 hours.
long lastReceivedTime = System.currentTimeMillis() - DateUtils.DAY_IN_MILLIS;
+ Resources res = mContext.getResources();
+ if (res.getBoolean(com.android.internal.R.bool.reset_geo_fencing_check_after_boot_or_apm)) {
+ lastReceivedTime = Long.max(lastReceivedTime, mLastAirplaneModeTime);
+ lastReceivedTime = Long.max(lastReceivedTime,
+ System.currentTimeMillis() - SystemClock.elapsedRealtime());
+ }
// Find the cell broadcast message identify by the message identifier and serial number
// and is not broadcasted.
@@ -123,6 +154,9 @@
}
}
+ log("Found " + cbMessages.size() + " messages since "
+ + DateFormat.getDateTimeInstance().format(lastReceivedTime));
+
List<Geometry> commonBroadcastArea = new ArrayList<>();
if (geoFencingTriggerMessage.shouldShareBroadcastArea()) {
for (SmsCbMessage msg : cbMessages) {
diff --git a/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java b/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java
index ae081a7..5856fbd 100644
--- a/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java
+++ b/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java
@@ -42,8 +42,10 @@
import android.os.SystemClock;
import android.os.SystemProperties;
import android.provider.Telephony.Sms.Intents;
+import android.telephony.AccessNetworkConstants;
import android.telephony.CallQuality;
import android.telephony.DisconnectCause;
+import android.telephony.NetworkRegistrationInfo;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.SmsManager;
@@ -448,6 +450,11 @@
+ " NR Frequency Range " + event.serviceState.nrFrequencyRange
+ " NR State " + event.serviceState.nrState
+ ")");
+ for (int i = 0; i < event.serviceState.networkRegistrationInfo.length; i++) {
+ pw.print("reg info: domain="
+ + event.serviceState.networkRegistrationInfo[i].domain
+ + ", rat=" + event.serviceState.networkRegistrationInfo[i].rat);
+ }
} else {
pw.print(telephonyEventToString(event.type));
}
@@ -920,6 +927,26 @@
ssProto.dataOperator.numeric = serviceState.getOperatorNumeric();
}
+ // Log PS WWAN only because CS WWAN would be exactly the same as voiceRat, and PS WLAN
+ // would be always IWLAN in the rat field.
+ // Note that we intentionally do not log reg state because it changes too frequently that
+ // will grow the proto size too much.
+ List<TelephonyServiceState.NetworkRegistrationInfo> nriList = new ArrayList<>();
+ NetworkRegistrationInfo nri = serviceState.getNetworkRegistrationInfo(
+ NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
+ if (nri != null) {
+ TelephonyServiceState.NetworkRegistrationInfo nriProto =
+ new TelephonyServiceState.NetworkRegistrationInfo();
+ nriProto.domain = TelephonyServiceState.Domain.DOMAIN_PS;
+ nriProto.transport = TelephonyServiceState.Transport.TRANSPORT_WWAN;
+ nriProto.rat = ServiceState.networkTypeToRilRadioTechnology(
+ nri.getAccessNetworkTechnology());
+ nriList.add(nriProto);
+ ssProto.networkRegistrationInfo =
+ new TelephonyServiceState.NetworkRegistrationInfo[nriList.size()];
+ nriList.toArray(ssProto.networkRegistrationInfo);
+ }
+
ssProto.voiceRat = serviceState.getRilVoiceRadioTechnology();
ssProto.dataRat = serviceState.getRilDataRadioTechnology();
ssProto.channelNumber = serviceState.getChannelNumber();
diff --git a/tests/telephonytests/src/com/android/internal/telephony/VisualVoicemailSmsParserTest.java b/tests/telephonytests/src/com/android/internal/telephony/VisualVoicemailSmsParserTest.java
index 12a4655..13fa2d6 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/VisualVoicemailSmsParserTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/VisualVoicemailSmsParserTest.java
@@ -16,7 +16,9 @@
package com.android.internal.telephony;
import android.test.suitebuilder.annotation.SmallTest;
+
import com.android.internal.telephony.VisualVoicemailSmsParser.WrappedMessageData;
+
import junit.framework.TestCase;
public class VisualVoicemailSmsParserTest extends TestCase {
diff --git a/tests/telephonytests/src/com/android/internal/telephony/dataconnection/TelephonyNetworkFactoryTest.java b/tests/telephonytests/src/com/android/internal/telephony/dataconnection/TelephonyNetworkFactoryTest.java
index a4bc00e..820f463 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/dataconnection/TelephonyNetworkFactoryTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/dataconnection/TelephonyNetworkFactoryTest.java
@@ -29,7 +29,6 @@
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import android.net.NetworkCapabilities;
@@ -58,7 +57,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.Mockito;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -74,9 +72,6 @@
@Mock
private RadioConfig mMockRadioConfig;
- @Mock
- private DataConnection mDataConnection;
-
private String mTestName = "";
private final ArrayList<NetworkRequest> mNetworkRequestList = new ArrayList<>();
@@ -353,41 +348,4 @@
h.sendMessage(h.obtainMessage(5, ar));
processAllMessages();
}
-
- /**
- * Test handover when the data connection is being connected.
- */
- @Test
- @SmallTest
- public void testHandoverActivatingData() throws Exception {
- createMockedTelephonyComponents();
- doReturn(0).when(mSubscriptionController).getSubIdUsingPhoneId(0);
- mTelephonyNetworkFactoryUT.mInternalHandler.sendEmptyMessage(
- TelephonyNetworkFactory.EVENT_SUBSCRIPTION_CHANGED);
-
- activatePhoneInPhoneSwitcher(0, true);
- makeDefaultInternetRequest();
-
- makeSubSpecificMmsRequest(0);
- processAllMessages();
-
- Field f = TelephonyNetworkFactory.class.getDeclaredField("mInternalHandler");
- f.setAccessible(true);
- Handler h = (Handler) f.get(mTelephonyNetworkFactoryUT);
-
- HandoverCallback handoverCallback = mock(HandoverCallback.class);
- Mockito.reset(mDcTracker);
- doReturn(mDataConnection).when(mDcTracker).getDataConnectionByApnType(anyString());
- doReturn(false).when(mDataConnection).isActive();
-
- HandoverParams hp = new HandoverParams(ApnSetting.TYPE_MMS,
- AccessNetworkConstants.TRANSPORT_TYPE_WLAN, handoverCallback);
- AsyncResult ar = new AsyncResult(null, hp, null);
- h.sendMessage(h.obtainMessage(5, ar));
- processAllMessages();
-
- verify(mDcTracker, times(1)).releaseNetwork(any(), eq(1));
- verify(mDcTracker, times(1)).requestNetwork(any(), eq(1), any());
- }
-
}