Merge "listByInterface -> listManifestByInterface"
diff --git a/config/hiddenapi-greylist.txt b/config/hiddenapi-greylist.txt
index eade053e..8ccbc907 100644
--- a/config/hiddenapi-greylist.txt
+++ b/config/hiddenapi-greylist.txt
@@ -1546,8 +1546,6 @@
Lcom/android/internal/telephony/Sms7BitEncodingTranslator;->mTranslationTableCDMA:Landroid/util/SparseIntArray;
Lcom/android/internal/telephony/Sms7BitEncodingTranslator;->mTranslationTableCommon:Landroid/util/SparseIntArray;
Lcom/android/internal/telephony/Sms7BitEncodingTranslator;->mTranslationTableGSM:Landroid/util/SparseIntArray;
-Lcom/android/internal/telephony/Sms7BitEncodingTranslator;->translate(Ljava/lang/CharSequence;)Ljava/lang/String;
-Lcom/android/internal/telephony/Sms7BitEncodingTranslator;->useCdmaFormatForMoSms()Z
Lcom/android/internal/telephony/SmsApplication$SmsApplicationData;->mApplicationName:Ljava/lang/String;
Lcom/android/internal/telephony/SmsApplication;->configurePreferredActivity(Landroid/content/pm/PackageManager;Landroid/content/ComponentName;I)V
Lcom/android/internal/telephony/SmsApplication;->getApplicationCollection(Landroid/content/Context;)Ljava/util/Collection;
diff --git a/core/java/android/net/NetworkAgent.java b/core/java/android/net/NetworkAgent.java
index 1edea55..2ff6043 100644
--- a/core/java/android/net/NetworkAgent.java
+++ b/core/java/android/net/NetworkAgent.java
@@ -178,7 +178,21 @@
*/
public static final int EVENT_SOCKET_KEEPALIVE = BASE + 13;
- // TODO: move the above 2 constants down so they are in order once merge conflicts are resolved
+ /**
+ * Sent by ConnectivityService to inform this network transport of signal strength thresholds
+ * that when crossed should trigger a system wakeup and a NetworkCapabilities update.
+ *
+ * obj = int[] describing signal strength thresholds.
+ */
+ public static final int CMD_SET_SIGNAL_STRENGTH_THRESHOLDS = BASE + 14;
+
+ /**
+ * Sent by ConnectivityService to the NeworkAgent to inform the agent to avoid
+ * automatically reconnecting to this network (e.g. via autojoin). Happens
+ * when user selects "No" option on the "Stay connected?" dialog box.
+ */
+ public static final int CMD_PREVENT_AUTOMATIC_RECONNECT = BASE + 15;
+
/**
* Sent by the KeepaliveTracker to NetworkAgent to add a packet filter.
*
@@ -198,21 +212,6 @@
*/
public static final int CMD_REMOVE_KEEPALIVE_PACKET_FILTER = BASE + 17;
- /**
- * Sent by ConnectivityService to inform this network transport of signal strength thresholds
- * that when crossed should trigger a system wakeup and a NetworkCapabilities update.
- *
- * obj = int[] describing signal strength thresholds.
- */
- public static final int CMD_SET_SIGNAL_STRENGTH_THRESHOLDS = BASE + 14;
-
- /**
- * Sent by ConnectivityService to the NeworkAgent to inform the agent to avoid
- * automatically reconnecting to this network (e.g. via autojoin). Happens
- * when user selects "No" option on the "Stay connected?" dialog box.
- */
- public static final int CMD_PREVENT_AUTOMATIC_RECONNECT = BASE + 15;
-
// TODO : remove these two constructors. They are a stopgap measure to help sheperding a number
// of dependent changes that would conflict throughout the automerger graph. Having these
// temporarily helps with the process of going through with all these dependent changes across
diff --git a/packages/CaptivePortalLogin/Android.bp b/packages/CaptivePortalLogin/Android.bp
index 732acca..c9183f6 100644
--- a/packages/CaptivePortalLogin/Android.bp
+++ b/packages/CaptivePortalLogin/Android.bp
@@ -14,12 +14,11 @@
// limitations under the License.
//
-android_app {
- name: "CaptivePortalLogin",
+java_defaults {
+ name: "CaptivePortalLoginDefaults",
srcs: ["src/**/*.java"],
sdk_version: "system_current",
min_sdk_version: "28",
- certificate: "networkstack",
static_libs: [
"android-support-v4",
"metrics-constants-protos",
@@ -27,3 +26,18 @@
],
manifest: "AndroidManifest.xml",
}
+
+android_app {
+ name: "CaptivePortalLogin",
+ defaults: ["CaptivePortalLoginDefaults"],
+ certificate: "networkstack",
+}
+
+// Alternative CaptivePortalLogin signed with the platform cert, to use
+// with InProcessNetworkStack.
+android_app {
+ name: "PlatformCaptivePortalLogin",
+ defaults: ["CaptivePortalLoginDefaults"],
+ certificate: "platform",
+ overrides: ["CaptivePortalLogin"],
+}
diff --git a/packages/ExtShared/Android.bp b/packages/ExtShared/Android.bp
new file mode 100644
index 0000000..a9823b9
--- /dev/null
+++ b/packages/ExtShared/Android.bp
@@ -0,0 +1,25 @@
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_app {
+ name: "ExtShared",
+ srcs: ["src/**/*.java"],
+ sdk_version: "current",
+ certificate: "platform",
+ aaptflags: ["--shared-lib"],
+ export_package_resources: true,
+ optimize: {
+ proguard_flags_files: ["proguard.proguard"],
+ },
+}
diff --git a/packages/ExtShared/Android.mk b/packages/ExtShared/Android.mk
deleted file mode 100644
index 7dbf79f..0000000
--- a/packages/ExtShared/Android.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright (C) 2016 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := ExtShared
-LOCAL_SDK_VERSION := current
-
-LOCAL_CERTIFICATE := platform
-
-LOCAL_AAPT_FLAGS := --shared-lib
-
-LOCAL_EXPORT_PACKAGE_RESOURCES := true
-
-LOCAL_PROGUARD_FLAG_FILES := proguard.proguard
-
-include $(BUILD_PACKAGE)
\ No newline at end of file
diff --git a/packages/NetworkPermissionConfig/Android.bp b/packages/NetworkPermissionConfig/Android.bp
index d0d3276..6e50459 100644
--- a/packages/NetworkPermissionConfig/Android.bp
+++ b/packages/NetworkPermissionConfig/Android.bp
@@ -14,15 +14,28 @@
// limitations under the License.
//
-// Stub APK to define permissions for NetworkStack
-android_app {
- name: "NetworkPermissionConfig",
+java_defaults {
+ name: "NetworkPermissionConfigDefaults",
// TODO: mark app as hasCode=false in manifest once soong stops complaining about apps without
// a classes.dex.
srcs: ["src/**/*.java"],
platform_apis: true,
min_sdk_version: "28",
- certificate: "networkstack",
privileged: true,
manifest: "AndroidManifest.xml",
}
+
+// Stub APK to define permissions for NetworkStack
+android_app {
+ name: "NetworkPermissionConfig",
+ defaults: ["NetworkPermissionConfigDefaults"],
+ certificate: "networkstack",
+}
+
+// Alternative stub APK signed with platform certificate. To use with InProcessNetworkStack.
+android_app {
+ name: "PlatformNetworkPermissionConfig",
+ defaults: ["NetworkPermissionConfigDefaults"],
+ certificate: "platform",
+ overrides: ["NetworkPermissionConfig"],
+}
diff --git a/packages/NetworkStack/Android.bp b/packages/NetworkStack/Android.bp
index 9c8efe6..e15526a 100644
--- a/packages/NetworkStack/Android.bp
+++ b/packages/NetworkStack/Android.bp
@@ -98,8 +98,6 @@
optimize: {
proguard_flags_files: ["proguard.flags"],
},
- // The permission configuration *must* be included to ensure security of the device
- required: ["NetworkPermissionConfig"],
}
// Non-updatable network stack running in the system server process for devices not using the module
@@ -108,6 +106,10 @@
defaults: ["NetworkStackAppCommon"],
certificate: "platform",
manifest: "AndroidManifest_InProcess.xml",
+ // InProcessNetworkStack is a replacement for NetworkStack
+ overrides: ["NetworkStack"],
+ // The permission configuration *must* be included to ensure security of the device
+ required: ["PlatformNetworkPermissionConfig"],
}
// Updatable network stack packaged as an application
@@ -117,6 +119,8 @@
certificate: "networkstack",
manifest: "AndroidManifest.xml",
use_embedded_native_libs: true,
+ // The permission configuration *must* be included to ensure security of the device
+ required: ["NetworkPermissionConfig"],
}
genrule {
diff --git a/packages/NetworkStack/AndroidManifest.xml b/packages/NetworkStack/AndroidManifest.xml
index 3b39cee..de45784 100644
--- a/packages/NetworkStack/AndroidManifest.xml
+++ b/packages/NetworkStack/AndroidManifest.xml
@@ -37,7 +37,9 @@
<uses-permission android:name="android.permission.READ_DEVICE_CONFIG" />
<!-- Signature permission defined in NetworkStackStub -->
<uses-permission android:name="android.permission.MAINLINE_NETWORK_STACK" />
- <application android:extractNativeLibs="false">
+ <application
+ android:extractNativeLibs="false"
+ android:persistent="true">
<service android:name="com.android.server.NetworkStackService">
<intent-filter>
<action android:name="android.net.INetworkStackConnector"/>
diff --git a/packages/NetworkStack/src/com/android/server/NetworkStackService.java b/packages/NetworkStack/src/com/android/server/NetworkStackService.java
index a6d7484..c394d4c 100644
--- a/packages/NetworkStack/src/com/android/server/NetworkStackService.java
+++ b/packages/NetworkStack/src/com/android/server/NetworkStackService.java
@@ -62,6 +62,7 @@
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* Android service used to start the network stack when bound to via an intent.
@@ -117,6 +118,15 @@
@GuardedBy("mValidationLogs")
private final ArrayDeque<SharedLog> mValidationLogs = new ArrayDeque<>(MAX_VALIDATION_LOGS);
+ private static final int VERSION_UNKNOWN = 0;
+ private static final String DUMPSYS_ARG_VERSION = "version";
+
+ /** Version of the AIDL interfaces observed on the system */
+ private final AtomicInteger mSystemAidlVersion = new AtomicInteger(VERSION_UNKNOWN);
+
+ /** Whether different versions have been observed on interfaces provided by the system */
+ private volatile boolean mConflictingSystemAidlVersions = false;
+
private SharedLog addValidationLogs(Network network, String name) {
final SharedLog log = new SharedLog(NUM_VALIDATION_LOG_LINES, network + " - " + name);
synchronized (mValidationLogs) {
@@ -143,6 +153,13 @@
}
}
+ private void updateSystemAidlVersion(final int version) {
+ final int previousVersion = mSystemAidlVersion.getAndSet(version);
+ if (previousVersion != VERSION_UNKNOWN && previousVersion != version) {
+ mConflictingSystemAidlVersions = true;
+ }
+ }
+
@NonNull
private final SharedLog mLog = new SharedLog(TAG);
@@ -150,6 +167,7 @@
public void makeDhcpServer(@NonNull String ifName, @NonNull DhcpServingParamsParcel params,
@NonNull IDhcpServerCallbacks cb) throws RemoteException {
checkNetworkStackCallingPermission();
+ updateSystemAidlVersion(cb.getInterfaceVersion());
final DhcpServer server;
try {
server = new DhcpServer(
@@ -171,6 +189,7 @@
@Override
public void makeNetworkMonitor(Network network, String name, INetworkMonitorCallbacks cb)
throws RemoteException {
+ updateSystemAidlVersion(cb.getInterfaceVersion());
final SharedLog log = addValidationLogs(network, name);
final NetworkMonitor nm = new NetworkMonitor(mContext, cb, network, log);
cb.onNetworkMonitorCreated(new NetworkMonitorImpl(nm));
@@ -178,6 +197,7 @@
@Override
public void makeIpClient(String ifName, IIpClientCallbacks cb) throws RemoteException {
+ updateSystemAidlVersion(cb.getInterfaceVersion());
final IpClient ipClient = new IpClient(mContext, ifName, cb, mObserverRegistry, this);
synchronized (mIpClients) {
@@ -202,6 +222,7 @@
@Override
public void fetchIpMemoryStore(@NonNull final IIpMemoryStoreCallbacks cb)
throws RemoteException {
+ updateSystemAidlVersion(cb.getInterfaceVersion());
cb.onIpMemoryStoreFetched(mIpMemoryStoreService);
}
@@ -209,6 +230,11 @@
protected void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter fout,
@Nullable String[] args) {
checkDumpPermission();
+ if (args != null && args.length >= 1 && DUMPSYS_ARG_VERSION.equals(args[0])) {
+ dumpVersion(fout);
+ return;
+ }
+
final IndentingPrintWriter pw = new IndentingPrintWriter(fout, " ");
pw.println("NetworkStack logs:");
mLog.dump(fd, pw, args);
@@ -252,6 +278,15 @@
}
}
+ /**
+ * Dump version information of the module and detected system version.
+ */
+ private void dumpVersion(@NonNull PrintWriter fout) {
+ fout.println("NetworkStackConnector: " + this.VERSION);
+ fout.println("SystemServer: " + mSystemAidlVersion);
+ fout.println("SystemServerConflicts: " + mConflictingSystemAidlVersions);
+ }
+
@Override
public int getInterfaceVersion() {
return this.VERSION;
diff --git a/packages/NetworkStack/tests/Android.bp b/packages/NetworkStack/tests/unit/Android.bp
similarity index 100%
rename from packages/NetworkStack/tests/Android.bp
rename to packages/NetworkStack/tests/unit/Android.bp
diff --git a/packages/NetworkStack/tests/AndroidManifest.xml b/packages/NetworkStack/tests/unit/AndroidManifest.xml
similarity index 100%
rename from packages/NetworkStack/tests/AndroidManifest.xml
rename to packages/NetworkStack/tests/unit/AndroidManifest.xml
diff --git a/packages/NetworkStack/tests/AndroidTest.xml b/packages/NetworkStack/tests/unit/AndroidTest.xml
similarity index 100%
rename from packages/NetworkStack/tests/AndroidTest.xml
rename to packages/NetworkStack/tests/unit/AndroidTest.xml
diff --git a/packages/NetworkStack/tests/jni/apf_jni.cpp b/packages/NetworkStack/tests/unit/jni/apf_jni.cpp
similarity index 100%
rename from packages/NetworkStack/tests/jni/apf_jni.cpp
rename to packages/NetworkStack/tests/unit/jni/apf_jni.cpp
diff --git a/packages/NetworkStack/tests/res/raw/apf.pcap b/packages/NetworkStack/tests/unit/res/raw/apf.pcap
similarity index 100%
rename from packages/NetworkStack/tests/res/raw/apf.pcap
rename to packages/NetworkStack/tests/unit/res/raw/apf.pcap
Binary files differ
diff --git a/packages/NetworkStack/tests/res/raw/apfPcap.pcap b/packages/NetworkStack/tests/unit/res/raw/apfPcap.pcap
similarity index 100%
rename from packages/NetworkStack/tests/res/raw/apfPcap.pcap
rename to packages/NetworkStack/tests/unit/res/raw/apfPcap.pcap
Binary files differ
diff --git a/packages/NetworkStack/tests/src/android/net/apf/ApfTest.java b/packages/NetworkStack/tests/unit/src/android/net/apf/ApfTest.java
similarity index 100%
rename from packages/NetworkStack/tests/src/android/net/apf/ApfTest.java
rename to packages/NetworkStack/tests/unit/src/android/net/apf/ApfTest.java
diff --git a/packages/NetworkStack/tests/src/android/net/apf/Bpf2Apf.java b/packages/NetworkStack/tests/unit/src/android/net/apf/Bpf2Apf.java
similarity index 100%
rename from packages/NetworkStack/tests/src/android/net/apf/Bpf2Apf.java
rename to packages/NetworkStack/tests/unit/src/android/net/apf/Bpf2Apf.java
diff --git a/packages/NetworkStack/tests/src/android/net/captiveportal/CaptivePortalProbeSpecTest.java b/packages/NetworkStack/tests/unit/src/android/net/captiveportal/CaptivePortalProbeSpecTest.java
similarity index 100%
rename from packages/NetworkStack/tests/src/android/net/captiveportal/CaptivePortalProbeSpecTest.java
rename to packages/NetworkStack/tests/unit/src/android/net/captiveportal/CaptivePortalProbeSpecTest.java
diff --git a/packages/NetworkStack/tests/src/android/net/dhcp/DhcpLeaseRepositoryTest.java b/packages/NetworkStack/tests/unit/src/android/net/dhcp/DhcpLeaseRepositoryTest.java
similarity index 100%
rename from packages/NetworkStack/tests/src/android/net/dhcp/DhcpLeaseRepositoryTest.java
rename to packages/NetworkStack/tests/unit/src/android/net/dhcp/DhcpLeaseRepositoryTest.java
diff --git a/packages/NetworkStack/tests/src/android/net/dhcp/DhcpPacketTest.java b/packages/NetworkStack/tests/unit/src/android/net/dhcp/DhcpPacketTest.java
similarity index 100%
rename from packages/NetworkStack/tests/src/android/net/dhcp/DhcpPacketTest.java
rename to packages/NetworkStack/tests/unit/src/android/net/dhcp/DhcpPacketTest.java
diff --git a/packages/NetworkStack/tests/src/android/net/dhcp/DhcpServerTest.java b/packages/NetworkStack/tests/unit/src/android/net/dhcp/DhcpServerTest.java
similarity index 100%
rename from packages/NetworkStack/tests/src/android/net/dhcp/DhcpServerTest.java
rename to packages/NetworkStack/tests/unit/src/android/net/dhcp/DhcpServerTest.java
diff --git a/packages/NetworkStack/tests/src/android/net/dhcp/DhcpServingParamsTest.java b/packages/NetworkStack/tests/unit/src/android/net/dhcp/DhcpServingParamsTest.java
similarity index 100%
rename from packages/NetworkStack/tests/src/android/net/dhcp/DhcpServingParamsTest.java
rename to packages/NetworkStack/tests/unit/src/android/net/dhcp/DhcpServingParamsTest.java
diff --git a/packages/NetworkStack/tests/src/android/net/ip/IpClientTest.java b/packages/NetworkStack/tests/unit/src/android/net/ip/IpClientTest.java
similarity index 100%
rename from packages/NetworkStack/tests/src/android/net/ip/IpClientTest.java
rename to packages/NetworkStack/tests/unit/src/android/net/ip/IpClientTest.java
diff --git a/packages/NetworkStack/tests/src/android/net/ip/IpReachabilityMonitorTest.java b/packages/NetworkStack/tests/unit/src/android/net/ip/IpReachabilityMonitorTest.java
similarity index 100%
rename from packages/NetworkStack/tests/src/android/net/ip/IpReachabilityMonitorTest.java
rename to packages/NetworkStack/tests/unit/src/android/net/ip/IpReachabilityMonitorTest.java
diff --git a/packages/NetworkStack/tests/src/android/net/util/ConnectivityPacketSummaryTest.java b/packages/NetworkStack/tests/unit/src/android/net/util/ConnectivityPacketSummaryTest.java
similarity index 100%
rename from packages/NetworkStack/tests/src/android/net/util/ConnectivityPacketSummaryTest.java
rename to packages/NetworkStack/tests/unit/src/android/net/util/ConnectivityPacketSummaryTest.java
diff --git a/packages/NetworkStack/tests/src/android/net/util/PacketReaderTest.java b/packages/NetworkStack/tests/unit/src/android/net/util/PacketReaderTest.java
similarity index 100%
rename from packages/NetworkStack/tests/src/android/net/util/PacketReaderTest.java
rename to packages/NetworkStack/tests/unit/src/android/net/util/PacketReaderTest.java
diff --git a/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java b/packages/NetworkStack/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
similarity index 100%
rename from packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java
rename to packages/NetworkStack/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
diff --git a/packages/NetworkStack/tests/src/com/android/server/connectivity/ipmemorystore/IpMemoryStoreServiceTest.java b/packages/NetworkStack/tests/unit/src/com/android/server/connectivity/ipmemorystore/IpMemoryStoreServiceTest.java
similarity index 100%
rename from packages/NetworkStack/tests/src/com/android/server/connectivity/ipmemorystore/IpMemoryStoreServiceTest.java
rename to packages/NetworkStack/tests/unit/src/com/android/server/connectivity/ipmemorystore/IpMemoryStoreServiceTest.java
diff --git a/packages/NetworkStack/tests/src/com/android/server/connectivity/ipmemorystore/RelevanceUtilsTests.java b/packages/NetworkStack/tests/unit/src/com/android/server/connectivity/ipmemorystore/RelevanceUtilsTests.java
similarity index 100%
rename from packages/NetworkStack/tests/src/com/android/server/connectivity/ipmemorystore/RelevanceUtilsTests.java
rename to packages/NetworkStack/tests/unit/src/com/android/server/connectivity/ipmemorystore/RelevanceUtilsTests.java
diff --git a/packages/NetworkStack/tests/src/com/android/server/util/SharedLogTest.java b/packages/NetworkStack/tests/unit/src/com/android/server/util/SharedLogTest.java
similarity index 100%
rename from packages/NetworkStack/tests/src/com/android/server/util/SharedLogTest.java
rename to packages/NetworkStack/tests/unit/src/com/android/server/util/SharedLogTest.java
diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java
index 3b64c8a..0ee08e1 100644
--- a/telephony/java/android/telephony/SmsManager.java
+++ b/telephony/java/android/telephony/SmsManager.java
@@ -567,20 +567,17 @@
}
/**
- * Divide a message text into several fragments, none bigger than
- * the maximum SMS message size.
+ * Divide a message text into several fragments, none bigger than the maximum SMS message size.
*
- * @param text the original message. Must not be null.
- * @return an <code>ArrayList</code> of strings that, in order,
- * comprise the original message
- *
- * @throws IllegalArgumentException if text is null
+ * @param text the original message. Must not be null.
+ * @return an <code>ArrayList</code> of strings that, in order, comprise the original message.
+ * @throws IllegalArgumentException if text is null.
*/
public ArrayList<String> divideMessage(String text) {
if (null == text) {
throw new IllegalArgumentException("text is null");
}
- return SmsMessage.fragmentText(text);
+ return SmsMessage.fragmentText(text, getSubscriptionId());
}
/**
diff --git a/telephony/java/android/telephony/SmsMessage.java b/telephony/java/android/telephony/SmsMessage.java
index 2aa4768..7d4bcb7 100644
--- a/telephony/java/android/telephony/SmsMessage.java
+++ b/telephony/java/android/telephony/SmsMessage.java
@@ -337,27 +337,45 @@
*/
/**
- * Calculates the number of SMS's required to encode the message body and
- * the number of characters remaining until the next message.
+ * Calculates the number of SMS's required to encode the message body and the number of
+ * characters remaining until the next message.
*
* @param msgBody the message to encode
- * @param use7bitOnly if true, characters that are not part of the
- * radio-specific 7-bit encoding are counted as single
- * space chars. If false, and if the messageBody contains
- * non-7-bit encodable characters, length is calculated
- * using a 16-bit encoding.
- * @return an int[4] with int[0] being the number of SMS's
- * required, int[1] the number of code units used, and
- * int[2] is the number of code units remaining until the
- * next message. int[3] is an indicator of the encoding
- * code unit size (see the ENCODING_* definitions in SmsConstants)
+ * @param use7bitOnly if true, characters that are not part of the radio-specific 7-bit encoding
+ * are counted as single space chars. If false, and if the messageBody contains non-7-bit
+ * encodable characters, length is calculated using a 16-bit encoding.
+ * @return an int[4] with int[0] being the number of SMS's required, int[1] the number of code
+ * units used, and int[2] is the number of code units remaining until the next message.
+ * int[3] is an indicator of the encoding code unit size (see the ENCODING_* definitions in
+ * SmsConstants).
*/
public static int[] calculateLength(CharSequence msgBody, boolean use7bitOnly) {
+ return calculateLength(msgBody, use7bitOnly, SmsManager.getDefaultSmsSubscriptionId());
+ }
+
+ /**
+ * Calculates the number of SMS's required to encode the message body and the number of
+ * characters remaining until the next message.
+ *
+ * @param msgBody the message to encode
+ * @param use7bitOnly if true, characters that are not part of the radio-specific 7-bit encoding
+ * are counted as single space chars. If false, and if the messageBody contains non-7-bit
+ * encodable characters, length is calculated using a 16-bit encoding.
+ * @param subId Subscription to take SMS format.
+ * @return an int[4] with int[0] being the number of SMS's required, int[1] the number of code
+ * units used, and int[2] is the number of code units remaining until the next message.
+ * int[3] is an indicator of the encoding code unit size (see the ENCODING_* definitions in
+ * SmsConstants).
+ * @hide
+ */
+ public static int[] calculateLength(CharSequence msgBody, boolean use7bitOnly, int subId) {
// this function is for MO SMS
- TextEncodingDetails ted = (useCdmaFormatForMoSms()) ?
- com.android.internal.telephony.cdma.SmsMessage.calculateLength(msgBody, use7bitOnly,
- true) :
- com.android.internal.telephony.gsm.SmsMessage.calculateLength(msgBody, use7bitOnly);
+ TextEncodingDetails ted =
+ useCdmaFormatForMoSms(subId)
+ ? com.android.internal.telephony.cdma.SmsMessage.calculateLength(
+ msgBody, use7bitOnly, true)
+ : com.android.internal.telephony.gsm.SmsMessage.calculateLength(
+ msgBody, use7bitOnly);
int ret[] = new int[4];
ret[0] = ted.msgCount;
ret[1] = ted.codeUnitCount;
@@ -367,21 +385,37 @@
}
/**
- * Divide a message text into several fragments, none bigger than
- * the maximum SMS message text size.
+ * Divide a message text into several fragments, none bigger than the maximum SMS message text
+ * size.
*
* @param text text, must not be null.
- * @return an <code>ArrayList</code> of strings that, in order,
- * comprise the original msg text
- *
+ * @return an <code>ArrayList</code> of strings that, in order, comprise the original msg text.
* @hide
*/
@UnsupportedAppUsage
public static ArrayList<String> fragmentText(String text) {
+ return fragmentText(text, SmsManager.getDefaultSmsSubscriptionId());
+ }
+
+ /**
+ * Divide a message text into several fragments, none bigger than the maximum SMS message text
+ * size.
+ *
+ * @param text text, must not be null.
+ * @param subId Subscription to take SMS format.
+ * @return an <code>ArrayList</code> of strings that, in order, comprise the original msg text.
+ * @hide
+ */
+ public static ArrayList<String> fragmentText(String text, int subId) {
// This function is for MO SMS
- TextEncodingDetails ted = (useCdmaFormatForMoSms()) ?
- com.android.internal.telephony.cdma.SmsMessage.calculateLength(text, false, true) :
- com.android.internal.telephony.gsm.SmsMessage.calculateLength(text, false);
+ final boolean isCdma = useCdmaFormatForMoSms(subId);
+
+ TextEncodingDetails ted =
+ isCdma
+ ? com.android.internal.telephony.cdma.SmsMessage.calculateLength(
+ text, false, true)
+ : com.android.internal.telephony.gsm.SmsMessage.calculateLength(
+ text, false);
// TODO(cleanup): The code here could be rolled into the logic
// below cleanly if these MAX_* constants were defined more
@@ -427,18 +461,19 @@
String newMsgBody = null;
Resources r = Resources.getSystem();
if (r.getBoolean(com.android.internal.R.bool.config_sms_force_7bit_encoding)) {
- newMsgBody = Sms7BitEncodingTranslator.translate(text);
+ newMsgBody = Sms7BitEncodingTranslator.translate(text, isCdma);
}
if (TextUtils.isEmpty(newMsgBody)) {
newMsgBody = text;
}
+
int pos = 0; // Index in code units.
int textLen = newMsgBody.length();
ArrayList<String> result = new ArrayList<String>(ted.msgCount);
while (pos < textLen) {
int nextPos = 0; // Counts code units.
if (ted.codeUnitSize == SmsConstants.ENCODING_7BIT) {
- if (useCdmaFormatForMoSms() && ted.msgCount == 1) {
+ if (isCdma && ted.msgCount == 1) {
// For a singleton CDMA message, the encoding must be ASCII...
nextPos = pos + Math.min(limit, textLen - pos);
} else {
@@ -461,25 +496,39 @@
}
/**
- * Calculates the number of SMS's required to encode the message body and
- * the number of characters remaining until the next message, given the
- * current encoding.
+ * Calculates the number of SMS's required to encode the message body and the number of
+ * characters remaining until the next message, given the current encoding.
*
* @param messageBody the message to encode
- * @param use7bitOnly if true, characters that are not part of the radio
- * specific (GSM / CDMA) alphabet encoding are converted to as a
- * single space characters. If false, a messageBody containing
- * non-GSM or non-CDMA alphabet characters are encoded using
- * 16-bit encoding.
- * @return an int[4] with int[0] being the number of SMS's required, int[1]
- * the number of code units used, and int[2] is the number of code
- * units remaining until the next message. int[3] is the encoding
- * type that should be used for the message.
+ * @param use7bitOnly if true, characters that are not part of the radio specific (GSM / CDMA)
+ * alphabet encoding are converted to as a single space characters. If false, a messageBody
+ * containing non-GSM or non-CDMA alphabet characters are encoded using 16-bit encoding.
+ * @return an int[4] with int[0] being the number of SMS's required, int[1] the number of code
+ * units used, and int[2] is the number of code units remaining until the next message.
+ * int[3] is the encoding type that should be used for the message.
*/
public static int[] calculateLength(String messageBody, boolean use7bitOnly) {
return calculateLength((CharSequence)messageBody, use7bitOnly);
}
+ /**
+ * Calculates the number of SMS's required to encode the message body and the number of
+ * characters remaining until the next message, given the current encoding.
+ *
+ * @param messageBody the message to encode
+ * @param use7bitOnly if true, characters that are not part of the radio specific (GSM / CDMA)
+ * alphabet encoding are converted to as a single space characters. If false, a messageBody
+ * containing non-GSM or non-CDMA alphabet characters are encoded using 16-bit encoding.
+ * @param subId Subscription to take SMS format.
+ * @return an int[4] with int[0] being the number of SMS's required, int[1] the number of code
+ * units used, and int[2] is the number of code units remaining until the next message.
+ * int[3] is the encoding type that should be used for the message.
+ * @hide
+ */
+ public static int[] calculateLength(String messageBody, boolean use7bitOnly, int subId) {
+ return calculateLength((CharSequence) messageBody, use7bitOnly, subId);
+ }
+
/*
* TODO(cleanup): It looks like there is now no useful reason why
* apps should generate pdus themselves using these routines,
@@ -510,8 +559,12 @@
*/
public static SubmitPdu getSubmitPdu(String scAddress,
String destinationAddress, String message, boolean statusReportRequested) {
- return getSubmitPdu(scAddress, destinationAddress, message, statusReportRequested,
- SubscriptionManager.getDefaultSmsSubscriptionId());
+ return getSubmitPdu(
+ scAddress,
+ destinationAddress,
+ message,
+ statusReportRequested,
+ SmsManager.getDefaultSmsSubscriptionId());
}
/**
@@ -834,7 +887,7 @@
@UnsupportedAppUsage
private static boolean useCdmaFormatForMoSms() {
// IMS is registered with SMS support, check the SMS format supported
- return useCdmaFormatForMoSms(SubscriptionManager.getDefaultSmsSubscriptionId());
+ return useCdmaFormatForMoSms(SmsManager.getDefaultSmsSubscriptionId());
}
/**
@@ -863,7 +916,7 @@
* @return true if current phone type is cdma, false otherwise.
*/
private static boolean isCdmaVoice() {
- return isCdmaVoice(SubscriptionManager.getDefaultSmsSubscriptionId());
+ return isCdmaVoice(SmsManager.getDefaultSmsSubscriptionId());
}
/**
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index d611da9..5731646 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -2412,7 +2412,21 @@
* @return the NETWORK_TYPE_xxxx for current data connection.
*/
public @NetworkType int getNetworkType() {
- return getDataNetworkType();
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ return telephony.getNetworkType();
+ } else {
+ // This can happen when the ITelephony interface is not up yet.
+ return NETWORK_TYPE_UNKNOWN;
+ }
+ } catch(RemoteException ex) {
+ // This shouldn't happen in the normal case
+ return NETWORK_TYPE_UNKNOWN;
+ } catch (NullPointerException ex) {
+ // This could happen before phone restarts due to crashing
+ return NETWORK_TYPE_UNKNOWN;
+ }
}
/**
@@ -2443,9 +2457,23 @@
* @hide
*/
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
- @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
+ @UnsupportedAppUsage
public int getNetworkType(int subId) {
- return getDataNetworkType(subId);
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ return telephony.getNetworkTypeForSubscriber(subId, getOpPackageName());
+ } else {
+ // This can happen when the ITelephony interface is not up yet.
+ return NETWORK_TYPE_UNKNOWN;
+ }
+ } catch (RemoteException ex) {
+ // This shouldn't happen in the normal case
+ return NETWORK_TYPE_UNKNOWN;
+ } catch (NullPointerException ex) {
+ // This could happen before phone restarts due to crashing
+ return NETWORK_TYPE_UNKNOWN;
+ }
}
/**
diff --git a/telephony/java/com/android/internal/telephony/GsmAlphabet.java b/telephony/java/com/android/internal/telephony/GsmAlphabet.java
index 5c076f5..a75096f 100644
--- a/telephony/java/com/android/internal/telephony/GsmAlphabet.java
+++ b/telephony/java/com/android/internal/telephony/GsmAlphabet.java
@@ -868,7 +868,6 @@
ted.msgCount = 1;
ted.codeUnitsRemaining = SmsConstants.MAX_USER_DATA_SEPTETS - septets;
}
- ted.codeUnitSize = SmsConstants.ENCODING_7BIT;
return ted;
}
diff --git a/telephony/java/com/android/internal/telephony/Sms7BitEncodingTranslator.java b/telephony/java/com/android/internal/telephony/Sms7BitEncodingTranslator.java
index 439eaea..49c737f 100644
--- a/telephony/java/com/android/internal/telephony/Sms7BitEncodingTranslator.java
+++ b/telephony/java/com/android/internal/telephony/Sms7BitEncodingTranslator.java
@@ -47,17 +47,14 @@
private static final String XML_TO_TAG = "to";
/**
- * Translates each message character that is not supported by GSM 7bit
- * alphabet into a supported one
+ * Translates each message character that is not supported by GSM 7bit alphabet into a supported
+ * one.
*
- * @param message
- * message to be translated
- * @param throwsException
- * if true and some error occurs during translation, an exception
- * is thrown; otherwise a null String is returned
- * @return translated message or null if some error occur
+ * @param message message to be translated.
+ * @param isCdmaFormat true if cdma format should be used.
+ * @return translated message or null if some error occur.
*/
- public static String translate(CharSequence message) {
+ public static String translate(CharSequence message, boolean isCdmaFormat) {
if (message == null) {
Rlog.w(TAG, "Null message can not be translated");
return null;
@@ -80,7 +77,6 @@
(mTranslationTableGSM != null && mTranslationTableGSM.size() > 0) ||
(mTranslationTableCDMA != null && mTranslationTableCDMA.size() > 0)) {
char[] output = new char[size];
- boolean isCdmaFormat = useCdmaFormatForMoSms();
for (int i = 0; i < size; i++) {
output[i] = translateIfNeeded(message.charAt(i), isCdmaFormat);
}
@@ -159,16 +155,6 @@
}
}
- private static boolean useCdmaFormatForMoSms() {
- if (!SmsManager.getDefault().isImsSmsSupported()) {
- // use Voice technology to determine SMS format.
- return TelephonyManager.getDefault().getCurrentPhoneType()
- == PhoneConstants.PHONE_TYPE_CDMA;
- }
- // IMS is registered with SMS support, check the SMS format supported
- return (SmsConstants.FORMAT_3GPP2.equals(SmsManager.getDefault().getImsSmsFormat()));
- }
-
/**
* Load the whole translation table file from the framework resource
* encoded in XML.
diff --git a/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java b/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java
index a31fa0b..56403ff 100644
--- a/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java
+++ b/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java
@@ -418,7 +418,7 @@
CharSequence newMsgBody = null;
Resources r = Resources.getSystem();
if (r.getBoolean(com.android.internal.R.bool.config_sms_force_7bit_encoding)) {
- newMsgBody = Sms7BitEncodingTranslator.translate(messageBody);
+ newMsgBody = Sms7BitEncodingTranslator.translate(messageBody, true);
}
if (TextUtils.isEmpty(newMsgBody)) {
newMsgBody = messageBody;
diff --git a/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java b/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java
index 19465a4..1a6c7b5 100644
--- a/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java
+++ b/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java
@@ -914,7 +914,7 @@
CharSequence newMsgBody = null;
Resources r = Resources.getSystem();
if (r.getBoolean(com.android.internal.R.bool.config_sms_force_7bit_encoding)) {
- newMsgBody = Sms7BitEncodingTranslator.translate(msgBody);
+ newMsgBody = Sms7BitEncodingTranslator.translate(msgBody, false);
}
if (TextUtils.isEmpty(newMsgBody)) {
newMsgBody = msgBody;