Merge "Add InetAddresses class to API"
diff --git a/api/current.txt b/api/current.txt
index ec42fd7..57fe55a 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -37335,10 +37335,13 @@
}
public static final class Telephony.CarrierId implements android.provider.BaseColumns {
+ method public static android.net.Uri getPreciseCarrierIdUriForSubscriptionId(int);
method public static android.net.Uri getUriForSubscriptionId(int);
field public static final java.lang.String CARRIER_ID = "carrier_id";
field public static final java.lang.String CARRIER_NAME = "carrier_name";
field public static final android.net.Uri CONTENT_URI;
+ field public static final java.lang.String PRECISE_CARRIER_ID = "precise_carrier_id";
+ field public static final java.lang.String PRECISE_CARRIER_ID_NAME = "precise_carrier_id_name";
}
public static final class Telephony.Carriers implements android.provider.BaseColumns {
@@ -39463,13 +39466,16 @@
public class CarrierIdentifier implements android.os.Parcelable {
ctor public CarrierIdentifier(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String);
+ ctor public CarrierIdentifier(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int, int);
ctor public CarrierIdentifier(byte[], java.lang.String, java.lang.String);
method public int describeContents();
+ method public int getCarrierId();
method public java.lang.String getGid1();
method public java.lang.String getGid2();
method public java.lang.String getImsi();
method public java.lang.String getMcc();
method public java.lang.String getMnc();
+ method public int getPreciseCarrierId();
method public java.lang.String getSpn();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.service.carrier.CarrierIdentifier> CREATOR;
@@ -41941,9 +41947,12 @@
public static final class VideoProfile.CameraCapabilities implements android.os.Parcelable {
ctor public VideoProfile.CameraCapabilities(int, int);
+ ctor public VideoProfile.CameraCapabilities(int, int, boolean, float);
method public int describeContents();
method public int getHeight();
+ method public float getMaxZoom();
method public int getWidth();
+ method public boolean isZoomSupported();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.telecom.VideoProfile.CameraCapabilities> CREATOR;
}
@@ -42962,6 +42971,7 @@
method public java.util.List<android.telephony.CellInfo> getAllCellInfo();
method public int getCallState();
method public android.os.PersistableBundle getCarrierConfig();
+ method public int getCarrierIdFromSimMccMnc();
method public deprecated android.telephony.CellLocation getCellLocation();
method public java.util.Map<java.lang.Integer, java.util.List<android.telephony.emergency.EmergencyNumber>> getCurrentEmergencyNumberList();
method public java.util.Map<java.lang.Integer, java.util.List<android.telephony.emergency.EmergencyNumber>> getCurrentEmergencyNumberList(int);
@@ -42999,6 +43009,8 @@
method public java.lang.String getSimCountryIso();
method public java.lang.String getSimOperator();
method public java.lang.String getSimOperatorName();
+ method public int getSimPreciseCarrierId();
+ method public java.lang.CharSequence getSimPreciseCarrierIdName();
method public java.lang.String getSimSerialNumber();
method public int getSimState();
method public int getSimState(int);
@@ -43054,6 +43066,7 @@
field public static final java.lang.String ACTION_SECRET_CODE = "android.telephony.action.SECRET_CODE";
field public static final java.lang.String ACTION_SHOW_VOICEMAIL_NOTIFICATION = "android.telephony.action.SHOW_VOICEMAIL_NOTIFICATION";
field public static final java.lang.String ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED = "android.telephony.action.SUBSCRIPTION_CARRIER_IDENTITY_CHANGED";
+ field public static final java.lang.String ACTION_SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED = "android.telephony.action.SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED";
field public static final int APPTYPE_CSIM = 4; // 0x4
field public static final int APPTYPE_ISIM = 5; // 0x5
field public static final int APPTYPE_RUIM = 3; // 0x3
@@ -43086,6 +43099,8 @@
field public static final java.lang.String EXTRA_LAUNCH_VOICEMAIL_SETTINGS_INTENT = "android.telephony.extra.LAUNCH_VOICEMAIL_SETTINGS_INTENT";
field public static final java.lang.String EXTRA_NOTIFICATION_COUNT = "android.telephony.extra.NOTIFICATION_COUNT";
field public static final java.lang.String EXTRA_PHONE_ACCOUNT_HANDLE = "android.telephony.extra.PHONE_ACCOUNT_HANDLE";
+ field public static final java.lang.String EXTRA_PRECISE_CARRIER_ID = "android.telephony.extra.PRECISE_CARRIER_ID";
+ field public static final java.lang.String EXTRA_PRECISE_CARRIER_NAME = "android.telephony.extra.PRECISE_CARRIER_NAME";
field public static final java.lang.String EXTRA_STATE = "state";
field public static final java.lang.String EXTRA_STATE_IDLE;
field public static final java.lang.String EXTRA_STATE_OFFHOOK;
diff --git a/cmds/statsd/src/config/ConfigManager.cpp b/cmds/statsd/src/config/ConfigManager.cpp
index 16b7e79..5fea90b 100644
--- a/cmds/statsd/src/config/ConfigManager.cpp
+++ b/cmds/statsd/src/config/ConfigManager.cpp
@@ -106,14 +106,14 @@
// Add to set.
mConfigs[key.GetUid()].insert(key);
- for (sp<ConfigListener> listener : mListeners) {
+ for (const sp<ConfigListener>& listener : mListeners) {
broadcastList.push_back(listener);
}
}
const int64_t timestampNs = getElapsedRealtimeNs();
// Tell everyone
- for (sp<ConfigListener> listener : broadcastList) {
+ for (const sp<ConfigListener>& listener : broadcastList) {
listener->OnConfigUpdated(timestampNs, key, config);
}
}
@@ -137,7 +137,7 @@
if (uidIt != mConfigs.end() && uidIt->second.find(key) != uidIt->second.end()) {
// Remove from map
uidIt->second.erase(key);
- for (sp<ConfigListener> listener : mListeners) {
+ for (const sp<ConfigListener>& listener : mListeners) {
broadcastList.push_back(listener);
}
}
@@ -153,7 +153,7 @@
remove_saved_configs(key);
}
- for (sp<ConfigListener> listener:broadcastList) {
+ for (const sp<ConfigListener>& listener:broadcastList) {
listener->OnConfigRemoved(key);
}
}
@@ -183,7 +183,7 @@
mConfigs.erase(uidIt);
- for (sp<ConfigListener> listener : mListeners) {
+ for (const sp<ConfigListener>& listener : mListeners) {
broadcastList.push_back(listener);
}
}
@@ -191,7 +191,7 @@
// Remove separately so if they do anything in the callback they can't mess up our iteration.
for (auto& key : removed) {
// Tell everyone
- for (sp<ConfigListener> listener:broadcastList) {
+ for (const sp<ConfigListener>& listener:broadcastList) {
listener->OnConfigRemoved(key);
}
}
@@ -213,7 +213,7 @@
}
mConfigReceivers.clear();
- for (sp<ConfigListener> listener : mListeners) {
+ for (const sp<ConfigListener>& listener : mListeners) {
broadcastList.push_back(listener);
}
}
@@ -221,7 +221,7 @@
// Remove separately so if they do anything in the callback they can't mess up our iteration.
for (auto& key : removed) {
// Tell everyone
- for (sp<ConfigListener> listener:broadcastList) {
+ for (const sp<ConfigListener>& listener:broadcastList) {
listener->OnConfigRemoved(key);
}
}
diff --git a/cmds/statsd/src/external/SubsystemSleepStatePuller.cpp b/cmds/statsd/src/external/SubsystemSleepStatePuller.cpp
index 4501b64..2713d327 100644
--- a/cmds/statsd/src/external/SubsystemSleepStatePuller.cpp
+++ b/cmds/statsd/src/external/SubsystemSleepStatePuller.cpp
@@ -111,7 +111,7 @@
(long long)state.residencyInMsecSinceBoot,
(long long)state.totalTransitions,
state.supportedOnlyInSuspend ? 1 : 0);
- for (auto voter : state.voters) {
+ for (const auto& voter : state.voters) {
auto voterPtr = make_shared<LogEvent>(
android::util::SUBSYSTEM_SLEEP_STATE,
wallClockTimestampNs, elapsedTimestampNs);
diff --git a/cmds/statsd/src/metrics/MetricsManager.cpp b/cmds/statsd/src/metrics/MetricsManager.cpp
index 4fac0e1..a6c7f3a 100644
--- a/cmds/statsd/src/metrics/MetricsManager.cpp
+++ b/cmds/statsd/src/metrics/MetricsManager.cpp
@@ -395,7 +395,7 @@
// Returns the total byte size of all metrics managed by a single config source.
size_t MetricsManager::byteSize() {
size_t totalSize = 0;
- for (auto metricProducer : mAllMetricProducers) {
+ for (const auto& metricProducer : mAllMetricProducers) {
totalSize += metricProducer->byteSize();
}
return totalSize;
diff --git a/cmds/statsd/src/metrics/metrics_manager_util.cpp b/cmds/statsd/src/metrics/metrics_manager_util.cpp
index 811a00e..a1c80b8 100644
--- a/cmds/statsd/src/metrics/metrics_manager_util.cpp
+++ b/cmds/statsd/src/metrics/metrics_manager_util.cpp
@@ -537,7 +537,7 @@
}
noReportMetricIds.insert(no_report_metric);
}
- for (auto it : allMetricProducers) {
+ for (const auto& it : allMetricProducers) {
uidMap.addListener(it);
}
return true;
diff --git a/cmds/statsd/src/packages/UidMap.cpp b/cmds/statsd/src/packages/UidMap.cpp
index 73ac968..88957df 100644
--- a/cmds/statsd/src/packages/UidMap.cpp
+++ b/cmds/statsd/src/packages/UidMap.cpp
@@ -141,7 +141,7 @@
// listener removes itself before we call it. It's then the listener's job to handle it (expect
// the callback to be called after listener is removed, and the listener should properly
// ignore it).
- for (auto weakPtr : broadcastList) {
+ for (const auto& weakPtr : broadcastList) {
auto strongPtr = weakPtr.promote();
if (strongPtr != NULL) {
strongPtr->onUidMapReceived(timestamp);
@@ -181,7 +181,7 @@
StatsdStats::getInstance().setUidMapChanges(mChanges.size());
}
- for (auto weakPtr : broadcastList) {
+ for (const auto& weakPtr : broadcastList) {
auto strongPtr = weakPtr.promote();
if (strongPtr != NULL) {
strongPtr->notifyAppUpgrade(timestamp, appName, uid, versionCode);
@@ -248,7 +248,7 @@
getListenerListCopyLocked(&broadcastList);
}
- for (auto weakPtr : broadcastList) {
+ for (const auto& weakPtr : broadcastList) {
auto strongPtr = weakPtr.promote();
if (strongPtr != NULL) {
strongPtr->notifyAppRemoved(timestamp, app, uid);
diff --git a/cmds/statsd/tests/anomaly/AnomalyTracker_test.cpp b/cmds/statsd/tests/anomaly/AnomalyTracker_test.cpp
index 218d52a..e125887 100644
--- a/cmds/statsd/tests/anomaly/AnomalyTracker_test.cpp
+++ b/cmds/statsd/tests/anomaly/AnomalyTracker_test.cpp
@@ -71,12 +71,12 @@
const std::shared_ptr<DimToValMap>& currentBucket,
const std::set<const MetricDimensionKey>& trueList,
const std::set<const MetricDimensionKey>& falseList) {
- for (MetricDimensionKey key : trueList) {
+ for (const MetricDimensionKey& key : trueList) {
if (!tracker.detectAnomaly(bucketNum, key, getBucketValue(currentBucket, key))) {
return false;
}
}
- for (MetricDimensionKey key : falseList) {
+ for (const MetricDimensionKey& key : falseList) {
if (tracker.detectAnomaly(bucketNum, key, getBucketValue(currentBucket, key))) {
return false;
}
diff --git a/config/dirty-image-objects b/config/dirty-image-objects
index 9b4d199..9e2230b 100644
--- a/config/dirty-image-objects
+++ b/config/dirty-image-objects
@@ -44,7 +44,6 @@
sun.misc.FormattedFloatingDecimal
java.util.stream.IntStream
android.icu.util.TimeZone
-libcore.io.DropBox
org.apache.harmony.luni.internal.util.TimezoneGetter
dalvik.system.SocketTagger
dalvik.system.CloseGuard
@@ -137,7 +136,6 @@
android.icu.util.ULocale
dalvik.system.BaseDexClassLoader
android.icu.text.BreakIterator
-libcore.io.EventLogger
libcore.net.NetworkSecurityPolicy
android.icu.text.UnicodeSet
com.android.org.conscrypt.TrustedCertificateStore$PreloadHolder
diff --git a/config/preloaded-classes b/config/preloaded-classes
index 495615b..fafcc6b 100644
--- a/config/preloaded-classes
+++ b/config/preloaded-classes
@@ -6124,12 +6124,6 @@
libcore.io.ClassPathURLStreamHandler
libcore.io.ClassPathURLStreamHandler$ClassPathURLConnection
libcore.io.ClassPathURLStreamHandler$ClassPathURLConnection$1
-libcore.io.DropBox
-libcore.io.DropBox$DefaultReporter
-libcore.io.DropBox$Reporter
-libcore.io.EventLogger
-libcore.io.EventLogger$DefaultReporter
-libcore.io.EventLogger$Reporter
libcore.io.ForwardingOs
libcore.io.IoBridge
libcore.io.IoTracker
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 47fddfe..15af8a9 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -81,7 +81,6 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Debug;
-import android.os.DropBoxManager;
import android.os.Environment;
import android.os.GraphicsEnvironment;
import android.os.Handler;
@@ -157,8 +156,6 @@
import dalvik.system.VMDebug;
import dalvik.system.VMRuntime;
-import libcore.io.DropBox;
-import libcore.io.EventLogger;
import libcore.io.IoUtils;
import libcore.net.event.NetworkEventDispatcher;
@@ -6680,9 +6677,6 @@
}
}
- // add dropbox logging to libcore
- DropBox.setReporter(new DropBoxReporter());
-
ViewRootImpl.ConfigChangedCallback configChangedCallback
= (Configuration globalConfig) -> {
synchronized (mResourcesManager) {
@@ -6736,38 +6730,6 @@
}
}
- private static class EventLoggingReporter implements EventLogger.Reporter {
- @Override
- public void report (int code, Object... list) {
- EventLog.writeEvent(code, list);
- }
- }
-
- private class DropBoxReporter implements DropBox.Reporter {
-
- private DropBoxManager dropBox;
-
- public DropBoxReporter() {}
-
- @Override
- public void addData(String tag, byte[] data, int flags) {
- ensureInitialized();
- dropBox.addData(tag, data, flags);
- }
-
- @Override
- public void addText(String tag, String data) {
- ensureInitialized();
- dropBox.addText(tag, data);
- }
-
- private synchronized void ensureInitialized() {
- if (dropBox == null) {
- dropBox = (DropBoxManager) getSystemContext().getSystemService(Context.DROPBOX_SERVICE);
- }
- }
- }
-
public static void main(String[] args) {
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "ActivityThreadMain");
@@ -6778,9 +6740,6 @@
Environment.initForCurrentUser();
- // Set the reporter for event logging in libcore
- EventLogger.setReporter(new EventLoggingReporter());
-
// Make sure TrustedCertificateStore looks in the right place for CA certificates
final File configDir = Environment.getUserConfigDirectory(UserHandle.myUserId());
TrustedCertificateStore.setDefaultUserDirectory(configDir);
diff --git a/core/java/android/net/INetdEventCallback.aidl b/core/java/android/net/INetdEventCallback.aidl
index 4b1a08d..0877a1a4 100644
--- a/core/java/android/net/INetdEventCallback.aidl
+++ b/core/java/android/net/INetdEventCallback.aidl
@@ -45,6 +45,20 @@
in String[] ipAddresses, int ipAddressesCount, long timestamp, int uid);
/**
+ * Represents adding or removing a NAT64 prefix.
+ * This method must not block or perform long-running operations.
+ *
+ * @param netId the ID of the network the prefix was performed on.
+ * @param added true if the NAT64 prefix was added, or false if the NAT64 prefix was removed.
+ * There is only one prefix at a time for each netId. If a prefix is added, it replaces
+ * the previous-added prefix.
+ * @param prefixString the detected NAT64 prefix as a string literal.
+ * @param prefixLength the prefix length associated with this NAT64 prefix.
+ */
+ void onNat64PrefixEvent(int netId, boolean added, @utf8InCpp String prefixString,
+ int prefixLength);
+
+ /**
* Represents a private DNS validation success or failure.
* This method must not block or perform long-running operations.
*
diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl
index be8cf0e..fdd7488 100644
--- a/core/java/android/os/INetworkManagementService.aidl
+++ b/core/java/android/os/INetworkManagementService.aidl
@@ -390,7 +390,7 @@
/**
* Setup a new VPN.
*/
- void createVirtualNetwork(int netId, boolean hasDNS, boolean secure);
+ void createVirtualNetwork(int netId, boolean secure);
/**
* Remove a network.
diff --git a/core/java/android/service/carrier/CarrierIdentifier.java b/core/java/android/service/carrier/CarrierIdentifier.java
index e930f40..568ca0f 100644
--- a/core/java/android/service/carrier/CarrierIdentifier.java
+++ b/core/java/android/service/carrier/CarrierIdentifier.java
@@ -71,10 +71,8 @@
* @param gid2 group id level 2
* @param carrierid carrier unique identifier {@link TelephonyManager#getSimCarrierId()}, used
* to uniquely identify the carrier and look up the carrier configurations.
- * @param preciseCarrierId precise carrier identifier {@link TelephonyManager#getSimPreciseCarrierId()}
- * @hide
- *
- * TODO: expose this to public API
+ * @param preciseCarrierId precise carrier identifier
+ * {@link TelephonyManager#getSimPreciseCarrierId()}
*/
public CarrierIdentifier(String mcc, String mnc, @Nullable String spn,
@Nullable String imsi, @Nullable String gid1, @Nullable String gid2,
@@ -155,16 +153,16 @@
}
/**
- * Get the carrier id {@link TelephonyManager#getSimCarrierId() }
- * @hide
+ * Returns the carrier id.
+ * @see TelephonyManager#getSimCarrierId()
*/
public int getCarrierId() {
return mCarrierId;
}
/**
- * Get the precise carrier id {@link TelephonyManager#getSimPreciseCarrierId()}
- * @hide
+ * Returns the precise carrier id.
+ * @see TelephonyManager#getSimPreciseCarrierId()
*/
public int getPreciseCarrierId() {
return mPreciseCarrierId;
diff --git a/core/java/com/android/server/net/BaseNetdEventCallback.java b/core/java/com/android/server/net/BaseNetdEventCallback.java
index 97247aa..a65214a 100644
--- a/core/java/com/android/server/net/BaseNetdEventCallback.java
+++ b/core/java/com/android/server/net/BaseNetdEventCallback.java
@@ -32,6 +32,12 @@
}
@Override
+ public void onNat64PrefixEvent(int netId, boolean added, String prefixString,
+ int prefixLength) {
+ // default no-op
+ }
+
+ @Override
public void onPrivateDnsValidationEvent(int netId, String ipAddress,
String hostname, boolean validated) {
// default no-op
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
index 01105ba..2e6b1b9 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -414,7 +414,7 @@
}
endmntent(fp);
- for (auto path : toUnmount) {
+ for (const auto& path : toUnmount) {
if (umount2(path.c_str(), MNT_DETACH)) {
ALOGW("Failed to unmount %s: %s", path.c_str(), strerror(errno));
}
diff --git a/libs/hwui/tests/common/scenes/ShapeAnimation.cpp b/libs/hwui/tests/common/scenes/ShapeAnimation.cpp
index 0d87776..d189a93 100644
--- a/libs/hwui/tests/common/scenes/ShapeAnimation.cpp
+++ b/libs/hwui/tests/common/scenes/ShapeAnimation.cpp
@@ -76,7 +76,7 @@
paint.setStrokeWidth(strokeWidth);
// fill column with each op
int middleCount = canvas.save(SaveFlags::MatrixClip);
- for (auto op : ops) {
+ for (const auto& op : ops) {
int innerCount = canvas.save(SaveFlags::MatrixClip);
canvas.clipRect(0, 0, cellSize, cellSize, SkClipOp::kIntersect);
canvas.drawColor(Color::White, SkBlendMode::kSrcOver);
diff --git a/libs/hwui/tests/unit/VectorDrawableTests.cpp b/libs/hwui/tests/unit/VectorDrawableTests.cpp
index 02f740c..4f299e3 100644
--- a/libs/hwui/tests/unit/VectorDrawableTests.cpp
+++ b/libs/hwui/tests/unit/VectorDrawableTests.cpp
@@ -251,7 +251,7 @@
}
TEST(PathParser, parseStringForData) {
- for (TestData testData : sTestDataSet) {
+ for (const TestData& testData : sTestDataSet) {
PathParser::ParseResult result;
// Test generated path data against the given data.
PathData pathData;
@@ -271,7 +271,7 @@
}
TEST(VectorDrawableUtils, createSkPathFromPathData) {
- for (TestData testData : sTestDataSet) {
+ for (const TestData& testData : sTestDataSet) {
SkPath expectedPath;
testData.skPathLamda(&expectedPath);
SkPath actualPath;
@@ -281,7 +281,7 @@
}
TEST(PathParser, parseAsciiStringForSkPath) {
- for (TestData testData : sTestDataSet) {
+ for (const TestData& testData : sTestDataSet) {
PathParser::ParseResult result;
size_t length = strlen(testData.pathString);
// Check the return value as well as the SkPath generated.
@@ -304,8 +304,8 @@
}
TEST(VectorDrawableUtils, morphPathData) {
- for (TestData fromData : sTestDataSet) {
- for (TestData toData : sTestDataSet) {
+ for (const TestData& fromData : sTestDataSet) {
+ for (const TestData& toData : sTestDataSet) {
bool canMorph = VectorDrawableUtils::canMorph(fromData.pathData, toData.pathData);
if (fromData.pathData == toData.pathData) {
EXPECT_TRUE(canMorph);
@@ -319,8 +319,8 @@
TEST(VectorDrawableUtils, interpolatePathData) {
// Interpolate path data with itself and every other path data
- for (TestData fromData : sTestDataSet) {
- for (TestData toData : sTestDataSet) {
+ for (const TestData& fromData : sTestDataSet) {
+ for (const TestData& toData : sTestDataSet) {
PathData outData;
bool success = VectorDrawableUtils::interpolatePathData(&outData, fromData.pathData,
toData.pathData, 0.5);
@@ -331,7 +331,7 @@
float fractions[] = {0, 0.00001, 0.28, 0.5, 0.7777, 0.9999999, 1};
// Now try to interpolate with a slightly modified version of self and expect success
- for (TestData fromData : sTestDataSet) {
+ for (const TestData& fromData : sTestDataSet) {
PathData toPathData = fromData.pathData;
for (size_t i = 0; i < toPathData.points.size(); i++) {
toPathData.points[i]++;
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 89194e4..66ceae4 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -5714,7 +5714,6 @@
// This should never fail. Specifying an already in use NetID will cause failure.
if (networkAgent.isVPN()) {
mNMS.createVirtualNetwork(networkAgent.network.netId,
- !networkAgent.linkProperties.getDnsServers().isEmpty(),
(networkAgent.networkMisc == null ||
!networkAgent.networkMisc.allowBypass));
} else {
diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java
index 0f00c11..00b1320 100644
--- a/services/core/java/com/android/server/NetworkManagementService.java
+++ b/services/core/java/com/android/server/NetworkManagementService.java
@@ -2308,11 +2308,11 @@
}
@Override
- public void createVirtualNetwork(int netId, boolean hasDNS, boolean secure) {
+ public void createVirtualNetwork(int netId, boolean secure) {
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
try {
- mNetdService.networkCreateVpn(netId, hasDNS, secure);
+ mNetdService.networkCreateVpn(netId, secure);
} catch (RemoteException | ServiceSpecificException e) {
throw new IllegalStateException(e);
}
diff --git a/services/core/java/com/android/server/connectivity/NetdEventListenerService.java b/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
index 422f556..e40949b 100644
--- a/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
+++ b/services/core/java/com/android/server/connectivity/NetdEventListenerService.java
@@ -217,6 +217,19 @@
@Override
// Called concurrently by multiple binder threads.
// This method must not block or perform long-running operations.
+ public synchronized void onNat64PrefixEvent(int netId,
+ boolean added, String prefixString, int prefixLength)
+ throws RemoteException {
+ for (INetdEventCallback callback : mNetdEventCallbackList) {
+ if (callback != null) {
+ callback.onNat64PrefixEvent(netId, added, prefixString, prefixLength);
+ }
+ }
+ }
+
+ @Override
+ // Called concurrently by multiple binder threads.
+ // This method must not block or perform long-running operations.
public synchronized void onPrivateDnsValidationEvent(int netId,
String ipAddress, String hostname, boolean validated)
throws RemoteException {
diff --git a/services/net/java/android/net/dhcp/DhcpServer.java b/services/net/java/android/net/dhcp/DhcpServer.java
index cee6fa9..35d29e7 100644
--- a/services/net/java/android/net/dhcp/DhcpServer.java
+++ b/services/net/java/android/net/dhcp/DhcpServer.java
@@ -39,7 +39,6 @@
import android.net.MacAddress;
import android.net.NetworkUtils;
import android.net.TrafficStats;
-import android.net.util.InterfaceParams;
import android.net.util.SharedLog;
import android.os.Handler;
import android.os.Looper;
@@ -85,7 +84,7 @@
@NonNull
private final ServerHandler mHandler;
@NonNull
- private final InterfaceParams mIface;
+ private final String mIfName;
@NonNull
private final DhcpLeaseRepository mLeaseRepo;
@NonNull
@@ -161,20 +160,20 @@
}
}
- public DhcpServer(@NonNull Looper looper, @NonNull InterfaceParams iface,
+ public DhcpServer(@NonNull Looper looper, @NonNull String ifName,
@NonNull DhcpServingParams params, @NonNull SharedLog log) {
- this(looper, iface, params, log, null);
+ this(looper, ifName, params, log, null);
}
@VisibleForTesting
- DhcpServer(@NonNull Looper looper, @NonNull InterfaceParams iface,
+ DhcpServer(@NonNull Looper looper, @NonNull String ifName,
@NonNull DhcpServingParams params, @NonNull SharedLog log,
@Nullable Dependencies deps) {
if (deps == null) {
deps = new DependenciesImpl();
}
mHandler = new ServerHandler(looper);
- mIface = iface;
+ mIfName = ifName;
mServingParams = params;
mLog = log;
mDeps = deps;
@@ -444,7 +443,7 @@
private boolean addArpEntry(@NonNull MacAddress macAddr, @NonNull Inet4Address inetAddr) {
try {
- mDeps.addArpEntry(inetAddr, macAddr, mIface.name, mSocket);
+ mDeps.addArpEntry(inetAddr, macAddr, mIfName, mSocket);
return true;
} catch (IOException e) {
mLog.e("Error adding client to ARP table", e);
@@ -526,7 +525,7 @@
// SO_BINDTODEVICE actually takes a string. This works because the first member
// of struct ifreq is a NULL-terminated interface name.
// TODO: add a setsockoptString()
- Os.setsockoptIfreq(mSocket, SOL_SOCKET, SO_BINDTODEVICE, mIface.name);
+ Os.setsockoptIfreq(mSocket, SOL_SOCKET, SO_BINDTODEVICE, mIfName);
Os.setsockoptInt(mSocket, SOL_SOCKET, SO_BROADCAST, 1);
Os.bind(mSocket, Inet4Address.ANY, DHCP_SERVER);
NetworkUtils.protectFromVpn(mSocket);
diff --git a/services/net/java/android/net/ip/IpServer.java b/services/net/java/android/net/ip/IpServer.java
index 823c0a1..493350d 100644
--- a/services/net/java/android/net/ip/IpServer.java
+++ b/services/net/java/android/net/ip/IpServer.java
@@ -138,9 +138,9 @@
return NetdService.getInstance();
}
- public DhcpServer makeDhcpServer(Looper looper, InterfaceParams iface,
+ public DhcpServer makeDhcpServer(Looper looper, String ifName,
DhcpServingParams params, SharedLog log) {
- return new DhcpServer(looper, iface, params, log);
+ return new DhcpServer(looper, ifName, params, log);
}
}
@@ -256,12 +256,6 @@
if (mUsingLegacyDhcp) {
return true;
}
-
- final InterfaceParams ifaceParams = mDeps.getInterfaceParams(mIfaceName);
- if (ifaceParams == null) {
- Log.e(TAG, "Failed to find interface params for DHCPv4");
- return false;
- }
final DhcpServingParams params;
try {
params = new DhcpServingParams.Builder()
@@ -277,7 +271,7 @@
return false;
}
- mDhcpServer = mDeps.makeDhcpServer(getHandler().getLooper(), ifaceParams, params,
+ mDhcpServer = mDeps.makeDhcpServer(getHandler().getLooper(), mIfaceName, params,
mLog.forSubComponent("DHCP"));
mDhcpServer.start();
return true;
diff --git a/startop/view_compiler/Android.bp b/startop/view_compiler/Android.bp
index de40e0d..91cec554 100644
--- a/startop/view_compiler/Android.bp
+++ b/startop/view_compiler/Android.bp
@@ -24,6 +24,9 @@
"libdexfile",
"slicer",
],
+ static_libs: [
+ "libtinyxml2",
+ ],
}
cc_library_host_static {
@@ -32,7 +35,9 @@
srcs: [
"dex_builder.cc",
"java_lang_builder.cc",
+ "tinyxml_layout_parser.cc",
"util.cc",
+ "layout_validation.cc",
],
}
@@ -43,7 +48,6 @@
"main.cc",
],
static_libs: [
- "libtinyxml2",
"libgflags",
"libviewcompiler",
],
@@ -54,6 +58,7 @@
defaults: ["viewcompiler_defaults"],
srcs: [
"dex_builder_test.cc",
+ "layout_validation_test.cc",
"util_test.cc",
],
static_libs: [
diff --git a/startop/view_compiler/dex_builder.cc b/startop/view_compiler/dex_builder.cc
index 906d64c..94879d0 100644
--- a/startop/view_compiler/dex_builder.cc
+++ b/startop/view_compiler/dex_builder.cc
@@ -61,18 +61,46 @@
case Instruction::Op::kInvokeDirect:
out << "kInvokeDirect";
return out;
+ case Instruction::Op::kInvokeStatic:
+ out << "kInvokeStatic";
+ return out;
+ case Instruction::Op::kInvokeInterface:
+ out << "kInvokeInterface";
+ return out;
case Instruction::Op::kBindLabel:
out << "kBindLabel";
return out;
case Instruction::Op::kBranchEqz:
out << "kBranchEqz";
return out;
+ case Instruction::Op::kBranchNEqz:
+ out << "kBranchNEqz";
+ return out;
case Instruction::Op::kNew:
out << "kNew";
return out;
}
}
+std::ostream& operator<<(std::ostream& out, const Value& value) {
+ if (value.is_register()) {
+ out << "Register(" << value.value() << ")";
+ } else if (value.is_parameter()) {
+ out << "Parameter(" << value.value() << ")";
+ } else if (value.is_immediate()) {
+ out << "Immediate(" << value.value() << ")";
+ } else if (value.is_string()) {
+ out << "String(" << value.value() << ")";
+ } else if (value.is_label()) {
+ out << "Label(" << value.value() << ")";
+ } else if (value.is_type()) {
+ out << "Type(" << value.value() << ")";
+ } else {
+ out << "UnknownValue";
+ }
+ return out;
+}
+
void* TrackingAllocator::Allocate(size_t size) {
std::unique_ptr<uint8_t[]> buffer = std::make_unique<uint8_t[]>(size);
void* raw_buffer = buffer.get();
@@ -289,10 +317,16 @@
return EncodeInvoke(instruction, art::Instruction::INVOKE_VIRTUAL);
case Instruction::Op::kInvokeDirect:
return EncodeInvoke(instruction, art::Instruction::INVOKE_DIRECT);
+ case Instruction::Op::kInvokeStatic:
+ return EncodeInvoke(instruction, art::Instruction::INVOKE_STATIC);
+ case Instruction::Op::kInvokeInterface:
+ return EncodeInvoke(instruction, art::Instruction::INVOKE_INTERFACE);
case Instruction::Op::kBindLabel:
return BindLabel(instruction.args()[0]);
case Instruction::Op::kBranchEqz:
return EncodeBranch(art::Instruction::IF_EQZ, instruction);
+ case Instruction::Op::kBranchNEqz:
+ return EncodeBranch(art::Instruction::IF_NEZ, instruction);
case Instruction::Op::kNew:
return EncodeNew(instruction);
}
@@ -353,7 +387,9 @@
// If there is a return value, add a move-result instruction
if (instruction.dest().has_value()) {
- Encode11x(art::Instruction::MOVE_RESULT, RegisterValue(*instruction.dest()));
+ Encode11x(instruction.result_is_object() ? art::Instruction::MOVE_RESULT_OBJECT
+ : art::Instruction::MOVE_RESULT,
+ RegisterValue(*instruction.dest()));
}
max_args_ = std::max(max_args_, instruction.args().size());
@@ -447,7 +483,7 @@
auto& ir_node = dex_file_->methods_map[new_index];
SLICER_CHECK(ir_node == nullptr);
ir_node = decl;
- decl->orig_index = new_index;
+ decl->orig_index = decl->index = new_index;
entry = {id, decl};
}
diff --git a/startop/view_compiler/dex_builder.h b/startop/view_compiler/dex_builder.h
index adf82bf..45596ac 100644
--- a/startop/view_compiler/dex_builder.h
+++ b/startop/view_compiler/dex_builder.h
@@ -147,8 +147,11 @@
kMove,
kInvokeVirtual,
kInvokeDirect,
+ kInvokeStatic,
+ kInvokeInterface,
kBindLabel,
kBranchEqz,
+ kBranchNEqz,
kNew
};
@@ -163,19 +166,53 @@
// For most instructions, which take some number of arguments and have an optional return value.
template <typename... T>
static inline Instruction OpWithArgs(Op opcode, std::optional<const Value> dest, T... args) {
- return Instruction{opcode, /*method_id*/ 0, dest, args...};
+ return Instruction{opcode, /*method_id=*/0, /*result_is_object=*/false, dest, args...};
}
// For method calls.
template <typename... T>
static inline Instruction InvokeVirtual(size_t method_id, std::optional<const Value> dest,
Value this_arg, T... args) {
- return Instruction{Op::kInvokeVirtual, method_id, dest, this_arg, args...};
+ return Instruction{
+ Op::kInvokeVirtual, method_id, /*result_is_object=*/false, dest, this_arg, args...};
+ }
+ // Returns an object
+ template <typename... T>
+ static inline Instruction InvokeVirtualObject(size_t method_id, std::optional<const Value> dest,
+ Value this_arg, T... args) {
+ return Instruction{
+ Op::kInvokeVirtual, method_id, /*result_is_object=*/true, dest, this_arg, args...};
}
// For direct calls (basically, constructors).
template <typename... T>
static inline Instruction InvokeDirect(size_t method_id, std::optional<const Value> dest,
Value this_arg, T... args) {
- return Instruction{Op::kInvokeDirect, method_id, dest, this_arg, args...};
+ return Instruction{
+ Op::kInvokeDirect, method_id, /*result_is_object=*/false, dest, this_arg, args...};
+ }
+ // Returns an object
+ template <typename... T>
+ static inline Instruction InvokeDirectObject(size_t method_id, std::optional<const Value> dest,
+ Value this_arg, T... args) {
+ return Instruction{
+ Op::kInvokeDirect, method_id, /*result_is_object=*/true, dest, this_arg, args...};
+ }
+ // For static calls.
+ template <typename... T>
+ static inline Instruction InvokeStatic(size_t method_id, std::optional<const Value> dest,
+ T... args) {
+ return Instruction{Op::kInvokeStatic, method_id, /*result_is_object=*/false, dest, args...};
+ }
+ // Returns an object
+ template <typename... T>
+ static inline Instruction InvokeStaticObject(size_t method_id, std::optional<const Value> dest,
+ T... args) {
+ return Instruction{Op::kInvokeStatic, method_id, /*result_is_object=*/true, dest, args...};
+ }
+ // For static calls.
+ template <typename... T>
+ static inline Instruction InvokeInterface(size_t method_id, std::optional<const Value> dest,
+ T... args) {
+ return Instruction{Op::kInvokeInterface, method_id, /*result_is_object=*/false, dest, args...};
}
///////////////
@@ -184,21 +221,27 @@
Op opcode() const { return opcode_; }
size_t method_id() const { return method_id_; }
+ bool result_is_object() const { return result_is_object_; }
const std::optional<const Value>& dest() const { return dest_; }
const std::vector<const Value>& args() const { return args_; }
private:
inline Instruction(Op opcode, size_t method_id, std::optional<const Value> dest)
- : opcode_{opcode}, method_id_{method_id}, dest_{dest}, args_{} {}
+ : opcode_{opcode}, method_id_{method_id}, result_is_object_{false}, dest_{dest}, args_{} {}
template <typename... T>
- inline constexpr Instruction(Op opcode, size_t method_id, std::optional<const Value> dest,
- T... args)
- : opcode_{opcode}, method_id_{method_id}, dest_{dest}, args_{args...} {}
+ inline constexpr Instruction(Op opcode, size_t method_id, bool result_is_object,
+ std::optional<const Value> dest, T... args)
+ : opcode_{opcode},
+ method_id_{method_id},
+ result_is_object_{result_is_object},
+ dest_{dest},
+ args_{args...} {}
const Op opcode_;
// The index of the method to invoke, for kInvokeVirtual and similar opcodes.
const size_t method_id_{0};
+ const bool result_is_object_;
const std::optional<const Value> dest_;
const std::vector<const Value> args_;
};
@@ -244,6 +287,8 @@
// TODO: add builders for more instructions
+ DexBuilder* dex_file() const { return dex_; }
+
private:
void EncodeInstructions();
void EncodeInstruction(const Instruction& instruction);
diff --git a/startop/view_compiler/dex_builder_test/src/android/startop/test/DexBuilderTest.java b/startop/view_compiler/dex_builder_test/src/android/startop/test/DexBuilderTest.java
index e20f3a9..1508ad9e 100644
--- a/startop/view_compiler/dex_builder_test/src/android/startop/test/DexBuilderTest.java
+++ b/startop/view_compiler/dex_builder_test/src/android/startop/test/DexBuilderTest.java
@@ -84,6 +84,15 @@
}
@Test
+ public void returnIfNotZero() throws Exception {
+ ClassLoader loader = loadDexFile("simple.dex");
+ Class clazz = loader.loadClass("android.startop.test.testcases.SimpleTests");
+ Method method = clazz.getMethod("returnIfNotZero", int.class);
+ Assert.assertEquals(3, method.invoke(null, 0));
+ Assert.assertEquals(5, method.invoke(null, 17));
+ }
+
+ @Test
public void backwardsBranch() throws Exception {
ClassLoader loader = loadDexFile("simple.dex");
Class clazz = loader.loadClass("android.startop.test.testcases.SimpleTests");
@@ -124,4 +133,22 @@
Assert.assertEquals("b", method.invoke(null, 0));
Assert.assertEquals("a", method.invoke(null, 1));
}
+
+ @Test
+ public void invokeStaticReturnObject() throws Exception {
+ ClassLoader loader = loadDexFile("simple.dex");
+ Class clazz = loader.loadClass("android.startop.test.testcases.SimpleTests");
+ Method method = clazz.getMethod("invokeStaticReturnObject", int.class, int.class);
+ Assert.assertEquals("10", method.invoke(null, 10, 10));
+ Assert.assertEquals("a", method.invoke(null, 10, 16));
+ Assert.assertEquals("5", method.invoke(null, 5, 16));
+ }
+
+ @Test
+ public void invokeVirtualReturnObject() throws Exception {
+ ClassLoader loader = loadDexFile("simple.dex");
+ Class clazz = loader.loadClass("android.startop.test.testcases.SimpleTests");
+ Method method = clazz.getMethod("invokeVirtualReturnObject", String.class, int.class);
+ Assert.assertEquals("bc", method.invoke(null, "abc", 1));
+ }
}
diff --git a/startop/view_compiler/dex_testcase_generator.cc b/startop/view_compiler/dex_testcase_generator.cc
index e2bf43bc..2781aa5 100644
--- a/startop/view_compiler/dex_testcase_generator.cc
+++ b/startop/view_compiler/dex_testcase_generator.cc
@@ -108,6 +108,27 @@
}
returnIfZero.Encode();
+ // int returnIfNotZero(int x) { if (x != 0) { return 5; } else { return 3; } }
+ MethodBuilder returnIfNotZero{cbuilder.CreateMethod(
+ "returnIfNotZero", Prototype{TypeDescriptor::Int(), TypeDescriptor::Int()})};
+ {
+ Value resultIfNotZero{returnIfNotZero.MakeRegister()};
+ Value else_target{returnIfNotZero.MakeLabel()};
+ returnIfNotZero.AddInstruction(Instruction::OpWithArgs(
+ Instruction::Op::kBranchNEqz, /*dest=*/{}, Value::Parameter(0), else_target));
+ // else branch
+ returnIfNotZero.BuildConst4(resultIfNotZero, 3);
+ returnIfNotZero.AddInstruction(
+ Instruction::OpWithArgs(Instruction::Op::kReturn, /*dest=*/{}, resultIfNotZero));
+ // then branch
+ returnIfNotZero.AddInstruction(
+ Instruction::OpWithArgs(Instruction::Op::kBindLabel, /*dest=*/{}, else_target));
+ returnIfNotZero.BuildConst4(resultIfNotZero, 5);
+ returnIfNotZero.AddInstruction(
+ Instruction::OpWithArgs(Instruction::Op::kReturn, /*dest=*/{}, resultIfNotZero));
+ }
+ returnIfNotZero.Encode();
+
// Make sure backwards branches work too.
//
// Pseudo code for test:
@@ -216,6 +237,38 @@
method.Encode();
}(returnStringIfZeroBA);
+ // Make sure we can invoke static methods that return an object
+ // String invokeStaticReturnObject(int n, int radix) { return java.lang.Integer.toString(n,
+ // radix); }
+ MethodBuilder invokeStaticReturnObject{
+ cbuilder.CreateMethod("invokeStaticReturnObject",
+ Prototype{string_type, TypeDescriptor::Int(), TypeDescriptor::Int()})};
+ [&](MethodBuilder& method) {
+ Value result{method.MakeRegister()};
+ MethodDeclData to_string{dex_file.GetOrDeclareMethod(
+ TypeDescriptor::FromClassname("java.lang.Integer"),
+ "toString",
+ Prototype{string_type, TypeDescriptor::Int(), TypeDescriptor::Int()})};
+ method.AddInstruction(Instruction::InvokeStaticObject(
+ to_string.id, result, Value::Parameter(0), Value::Parameter(1)));
+ method.BuildReturn(result, /*is_object=*/true);
+ method.Encode();
+ }(invokeStaticReturnObject);
+
+ // Make sure we can invoke virtual methods that return an object
+ // String invokeVirtualReturnObject(String s, int n) { return s.substring(n); }
+ MethodBuilder invokeVirtualReturnObject{cbuilder.CreateMethod(
+ "invokeVirtualReturnObject", Prototype{string_type, string_type, TypeDescriptor::Int()})};
+ [&](MethodBuilder& method) {
+ Value result{method.MakeRegister()};
+ MethodDeclData substring{dex_file.GetOrDeclareMethod(
+ string_type, "substring", Prototype{string_type, TypeDescriptor::Int()})};
+ method.AddInstruction(Instruction::InvokeVirtualObject(
+ substring.id, result, Value::Parameter(0), Value::Parameter(1)));
+ method.BuildReturn(result, /*is_object=*/true);
+ method.Encode();
+ }(invokeVirtualReturnObject);
+
slicer::MemView image{dex_file.CreateImage()};
std::ofstream out_file(outdir + "/simple.dex");
out_file.write(image.ptr<const char>(), image.size());
diff --git a/startop/view_compiler/layout_validation.cc b/startop/view_compiler/layout_validation.cc
new file mode 100644
index 0000000..8c77377
--- /dev/null
+++ b/startop/view_compiler/layout_validation.cc
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#include "layout_validation.h"
+
+#include "android-base/stringprintf.h"
+
+namespace startop {
+
+void LayoutValidationVisitor::VisitStartTag(const std::u16string& name) {
+ if (0 == name.compare(u"merge")) {
+ message_ = "Merge tags are not supported";
+ can_compile_ = false;
+ }
+ if (0 == name.compare(u"include")) {
+ message_ = "Include tags are not supported";
+ can_compile_ = false;
+ }
+ if (0 == name.compare(u"view")) {
+ message_ = "View tags are not supported";
+ can_compile_ = false;
+ }
+ if (0 == name.compare(u"fragment")) {
+ message_ = "Fragment tags are not supported";
+ can_compile_ = false;
+ }
+}
+
+} // namespace startop
\ No newline at end of file
diff --git a/startop/view_compiler/layout_validation.h b/startop/view_compiler/layout_validation.h
new file mode 100644
index 0000000..bed34bb
--- /dev/null
+++ b/startop/view_compiler/layout_validation.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#ifndef LAYOUT_VALIDATION_H_
+#define LAYOUT_VALIDATION_H_
+
+#include "dex_builder.h"
+
+#include <string>
+
+namespace startop {
+
+// This visitor determines whether a layout can be compiled. Since we do not currently support all
+// features, such as includes and merges, we need to pre-validate the layout before we start
+// compiling.
+class LayoutValidationVisitor {
+ public:
+ void VisitStartDocument() const {}
+ void VisitEndDocument() const {}
+ void VisitStartTag(const std::u16string& name);
+ void VisitEndTag() const {}
+
+ const std::string& message() const { return message_; }
+ bool can_compile() const { return can_compile_; }
+
+ private:
+ std::string message_{"Okay"};
+ bool can_compile_{true};
+};
+
+} // namespace startop
+
+#endif // LAYOUT_VALIDATION_H_
diff --git a/startop/view_compiler/layout_validation_test.cc b/startop/view_compiler/layout_validation_test.cc
new file mode 100644
index 0000000..b74cdae
--- /dev/null
+++ b/startop/view_compiler/layout_validation_test.cc
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+#include "tinyxml_layout_parser.h"
+
+#include "gtest/gtest.h"
+
+using startop::CanCompileLayout;
+using std::string;
+
+namespace {
+void ValidateXmlText(const string& xml, bool expected) {
+ tinyxml2::XMLDocument doc;
+ doc.Parse(xml.c_str());
+ EXPECT_EQ(CanCompileLayout(doc), expected);
+}
+} // namespace
+
+TEST(LayoutValidationTest, SingleButtonLayout) {
+ const string xml = R"(<?xml version="1.0" encoding="utf-8"?>
+<Button xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:text="Hello, World!">
+
+</Button>)";
+ ValidateXmlText(xml, /*expected=*/true);
+}
+
+TEST(LayoutValidationTest, SmallConstraintLayout) {
+ const string xml = R"(<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <Button
+ android:id="@+id/button6"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="16dp"
+ android:layout_marginBottom="16dp"
+ android:text="Button"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent" />
+
+ <Button
+ android:id="@+id/button7"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="8dp"
+ android:layout_marginBottom="16dp"
+ android:text="Button2"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/button6" />
+
+ <Button
+ android:id="@+id/button8"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="8dp"
+ android:layout_marginBottom="16dp"
+ android:text="Button1"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/button7" />
+</android.support.constraint.ConstraintLayout>)";
+ ValidateXmlText(xml, /*expected=*/true);
+}
+
+TEST(LayoutValidationTest, MergeNode) {
+ const string xml = R"(<?xml version="1.0" encoding="utf-8"?>
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <TextView
+ android:id="@+id/textView3"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="TextView" />
+
+ <Button
+ android:id="@+id/button9"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Button" />
+</merge>)";
+ ValidateXmlText(xml, /*expected=*/false);
+}
+
+TEST(LayoutValidationTest, IncludeLayout) {
+ const string xml = R"(<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <include
+ layout="@layout/single_button_layout"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+</android.support.constraint.ConstraintLayout>)";
+ ValidateXmlText(xml, /*expected=*/false);
+}
+
+TEST(LayoutValidationTest, ViewNode) {
+ const string xml = R"(<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <view
+ class="android.support.design.button.MaterialButton"
+ id="@+id/view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+</android.support.constraint.ConstraintLayout>)";
+ ValidateXmlText(xml, /*expected=*/false);
+}
+
+TEST(LayoutValidationTest, FragmentNode) {
+ // This test case is from https://developer.android.com/guide/components/fragments
+ const string xml = R"(<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <fragment android:name="com.example.news.ArticleListFragment"
+ android:id="@+id/list"
+ android:layout_weight="1"
+ android:layout_width="0dp"
+ android:layout_height="match_parent" />
+ <fragment android:name="com.example.news.ArticleReaderFragment"
+ android:id="@+id/viewer"
+ android:layout_weight="2"
+ android:layout_width="0dp"
+ android:layout_height="match_parent" />
+</LinearLayout>)";
+ ValidateXmlText(xml, /*expected=*/false);
+}
diff --git a/startop/view_compiler/main.cc b/startop/view_compiler/main.cc
index 7d791c2..9351dc3 100644
--- a/startop/view_compiler/main.cc
+++ b/startop/view_compiler/main.cc
@@ -18,6 +18,7 @@
#include "dex_builder.h"
#include "java_lang_builder.h"
+#include "tinyxml_layout_parser.h"
#include "util.h"
#include "tinyxml2.h"
@@ -100,6 +101,12 @@
XMLDocument xml;
xml.LoadFile(filename);
+ string message{};
+ if (!startop::CanCompileLayout(xml, &message)) {
+ LOG(ERROR) << "Layout not supported: " << message;
+ return 1;
+ }
+
std::ofstream outfile;
if (FLAGS_out != kStdoutFilename) {
outfile.open(FLAGS_out);
diff --git a/startop/view_compiler/tinyxml_layout_parser.cc b/startop/view_compiler/tinyxml_layout_parser.cc
new file mode 100644
index 0000000..1b3a81f
--- /dev/null
+++ b/startop/view_compiler/tinyxml_layout_parser.cc
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+#include "tinyxml_layout_parser.h"
+
+#include "layout_validation.h"
+
+namespace startop {
+
+bool CanCompileLayout(const tinyxml2::XMLDocument& xml, std::string* message) {
+ LayoutValidationVisitor validator;
+ TinyXmlVisitorAdapter adapter{&validator};
+ xml.Accept(&adapter);
+
+ if (message != nullptr) {
+ *message = validator.message();
+ }
+
+ return validator.can_compile();
+}
+
+} // namespace startop
diff --git a/startop/view_compiler/tinyxml_layout_parser.h b/startop/view_compiler/tinyxml_layout_parser.h
new file mode 100644
index 0000000..8f714a2
--- /dev/null
+++ b/startop/view_compiler/tinyxml_layout_parser.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+#ifndef TINYXML_LAYOUT_PARSER_H_
+#define TINYXML_LAYOUT_PARSER_H_
+
+#include "tinyxml2.h"
+
+#include <codecvt>
+#include <locale>
+#include <string>
+
+namespace startop {
+
+template <typename Visitor>
+class TinyXmlVisitorAdapter : public tinyxml2::XMLVisitor {
+ public:
+ explicit TinyXmlVisitorAdapter(Visitor* visitor) : visitor_{visitor} {}
+
+ bool VisitEnter(const tinyxml2::XMLDocument& /*doc*/) override {
+ visitor_->VisitStartDocument();
+ return true;
+ }
+
+ bool VisitExit(const tinyxml2::XMLDocument& /*doc*/) override {
+ visitor_->VisitEndDocument();
+ return true;
+ }
+
+ bool VisitEnter(const tinyxml2::XMLElement& element,
+ const tinyxml2::XMLAttribute* /*firstAttribute*/) override {
+ visitor_->VisitStartTag(
+ std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(
+ element.Name()));
+ return true;
+ }
+
+ bool VisitExit(const tinyxml2::XMLElement& /*element*/) override {
+ visitor_->VisitEndTag();
+ return true;
+ }
+
+ private:
+ Visitor* visitor_;
+};
+
+// Returns whether a layout resource represented by a TinyXML document is supported by the layout
+// compiler.
+bool CanCompileLayout(const tinyxml2::XMLDocument& xml, std::string* message = nullptr);
+
+} // namespace startop
+
+#endif // TINYXML_LAYOUT_PARSER_H_
diff --git a/telecomm/java/android/telecom/VideoProfile.java b/telecomm/java/android/telecom/VideoProfile.java
index bbac8eb..7b23061 100644
--- a/telecomm/java/android/telecom/VideoProfile.java
+++ b/telecomm/java/android/telecom/VideoProfile.java
@@ -369,16 +369,13 @@
}
/**
- * Create a call camera capabilities instance that optionally
- * supports zoom.
+ * Create a call camera capabilities instance that optionally supports zoom.
*
* @param width The width of the camera video (in pixels).
* @param height The height of the camera video (in pixels).
* @param zoomSupported True when camera supports zoom.
* @param maxZoom Maximum zoom supported by camera.
- * @hide
*/
- @UnsupportedAppUsage
public CameraCapabilities(int width, int height, boolean zoomSupported, float maxZoom) {
mWidth = width;
mHeight = height;
@@ -455,16 +452,14 @@
}
/**
- * Whether the camera supports zoom.
- * @hide
+ * Returns {@code true} is zoom is supported, {@code false} otherwise.
*/
public boolean isZoomSupported() {
return mZoomSupported;
}
/**
- * The maximum zoom supported by the camera.
- * @hide
+ * Returns the maximum zoom supported by the camera.
*/
public float getMaxZoom() {
return mMaxZoom;
diff --git a/telephony/java/android/provider/Telephony.java b/telephony/java/android/provider/Telephony.java
index 0b5aa14..0245768dd 100644
--- a/telephony/java/android/provider/Telephony.java
+++ b/telephony/java/android/provider/Telephony.java
@@ -3577,8 +3577,9 @@
/**
* Generates a content {@link Uri} used to receive updates on precise carrier identity
- * change on the given subscriptionId
- * {@link TelephonyManager#ACTION_SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED}.
+ * change on the given subscriptionId returned by
+ * {@link TelephonyManager#getSimPreciseCarrierId()}.
+ * @see TelephonyManager#ACTION_SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED
* <p>
* Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the
* precise carrier identity {@link TelephonyManager#getSimPreciseCarrierId()}
@@ -3589,7 +3590,6 @@
*
* @param subscriptionId the subscriptionId to receive updates on
* @return the Uri used to observe precise carrier identity changes
- * @hide
*/
public static Uri getPreciseCarrierIdUriForSubscriptionId(int subscriptionId) {
return Uri.withAppendedPath(Uri.withAppendedPath(CONTENT_URI, "precise"),
@@ -3611,24 +3611,22 @@
public static final String CARRIER_ID = "carrier_id";
/**
- * A user facing carrier name for precise carrier id.
- * @see TelephonyManager#getSimPreciseCarrierIdName()
- * This is not a database column, only used to notify content observers for
- * {@link #getPreciseCarrierIdUriForSubscriptionId(int)}
- * @hide
- */
- public static final String PRECISE_CARRIER_ID_NAME = "precise_carrier_id_name";
-
- /**
* A fine-grained carrier id.
* @see TelephonyManager#getSimPreciseCarrierId()
* This is not a database column, only used to notify content observers for
* {@link #getPreciseCarrierIdUriForSubscriptionId(int)}
- * @hide
*/
public static final String PRECISE_CARRIER_ID = "precise_carrier_id";
/**
+ * A user facing carrier name for precise carrier id {@link #PRECISE_CARRIER_ID}.
+ * @see TelephonyManager#getSimPreciseCarrierIdName()
+ * This is not a database column, only used to notify content observers for
+ * {@link #getPreciseCarrierIdUriForSubscriptionId(int)}
+ */
+ public static final String PRECISE_CARRIER_ID_NAME = "precise_carrier_id_name";
+
+ /**
* A unique parent carrier id. The parent-child
* relationship can be used to further differentiate a single carrier by different networks,
* by prepaid v.s. postpaid or even by 4G v.s. 3G plan. It's an optional field.
@@ -3640,18 +3638,6 @@
public static final String PARENT_CARRIER_ID = "parent_carrier_id";
/**
- * A unique mno carrier id. mno carrier shares the same {@link All#MCCMNC} as carrier id
- * and can be solely identified by {@link All#MCCMNC} only. If there is no such mno
- * carrier, then mno carrier id equals to {@link #CARRIER_ID carrier id}.
- *
- * <p>mno carrier id can be used as fallback id. When the exact carrier id configurations
- * are not found, usually fall back to its mno carrier id.
- * <P>Type: INTEGER </P>
- * @hide
- */
- public static final String MNO_CARRIER_ID = "mno_carrier_id";
-
- /**
* Contains mappings between matching rules with carrier id for all carriers.
* @hide
*/
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index fed58c1..4b7d107 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -68,7 +68,13 @@
* This intent is broadcast by the system when carrier config changes. An int is specified in
* {@link #EXTRA_SLOT_INDEX} to indicate the slot index that this is for. An optional int extra
* {@link #EXTRA_SUBSCRIPTION_INDEX} is included to indicate the subscription index if a valid
- * one is available for the slot index.
+ * one is available for the slot index. An optional int extra
+ * {@link TelephonyManager#EXTRA_CARRIER_ID} is included to indicate the carrier id for the
+ * changed carrier configuration. An optional int extra
+ * {@link TelephonyManager#EXTRA_PRECISE_CARRIER_ID} is included to indicate the precise
+ * carrier id for the changed carrier configuration.
+ * @see TelephonyManager#getSimCarrierId()
+ * @see TelephonyManager#getSimPreciseCarrierId()
*/
public static final String
ACTION_CARRIER_CONFIG_CHANGED = "android.telephony.action.CARRIER_CONFIG_CHANGED";
diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java
index 13fbeaa..ca0c854a 100644
--- a/telephony/java/android/telephony/ServiceState.java
+++ b/telephony/java/android/telephony/ServiceState.java
@@ -118,6 +118,13 @@
*/
public static final int FREQUENCY_RANGE_MMWAVE = 4;
+ private static final List<Integer> FREQUENCY_RANGE_ORDER = Arrays.asList(
+ FREQUENCY_RANGE_UNKNOWN,
+ FREQUENCY_RANGE_LOW,
+ FREQUENCY_RANGE_MID,
+ FREQUENCY_RANGE_HIGH,
+ FREQUENCY_RANGE_MMWAVE);
+
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = "DUPLEX_MODE_",
@@ -1835,4 +1842,13 @@
mNetworkRegistrationStates.add(regState);
}
}
+
+ /**
+ * @hide
+ */
+ public static final int getBetterNRFrequencyRange(int range1, int range2) {
+ return FREQUENCY_RANGE_ORDER.indexOf(range1) > FREQUENCY_RANGE_ORDER.indexOf(range2)
+ ? range1
+ : range2;
+ }
}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 3649ecad..3a337d5 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -1223,81 +1223,79 @@
"android.telephony.action.SUBSCRIPTION_CARRIER_IDENTITY_CHANGED";
/**
- * Broadcast Action: The subscription precise carrier identity has changed.
- * Similar like {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED}, this intent will be sent
- * on the event of {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED}. However, its possible
- * that precise carrier identity changes while
- * {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} remains the same e.g, the same
- * subscription switches to different IMSI could potentially change its precise carrier id.
- *
- * The intent will have the following extra values:
- * <ul>
- * <li>{@link #EXTRA_PRECISE_CARRIER_ID} The up-to-date precise carrier id of the
- * current subscription.
- * </li>
- * <li>{@link #EXTRA_PRECISE_CARRIER_NAME} The up-to-date carrier name of the current
- * subscription.
- * </li>
- * <li>{@link #EXTRA_SUBSCRIPTION_ID} The subscription id associated with the changed carrier
- * identity.
- * </li>
- * </ul>
- * <p class="note">This is a protected intent that can only be sent by the system.
- * @hide
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String ACTION_SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED =
- "android.telephony.action.SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED";
-
- /**
* An int extra used with {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} which indicates
- * the updated carrier id {@link TelephonyManager#getSimCarrierId()} of
- * the current subscription.
+ * the updated carrier id returned by {@link TelephonyManager#getSimCarrierId()}.
* <p>Will be {@link TelephonyManager#UNKNOWN_CARRIER_ID} if the subscription is unavailable or
* the carrier cannot be identified.
*/
public static final String EXTRA_CARRIER_ID = "android.telephony.extra.CARRIER_ID";
/**
- * An int extra used with {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} which indicates
- * the updated mno carrier id of the current subscription.
- * <p>Will be {@link TelephonyManager#UNKNOWN_CARRIER_ID} if the subscription is unavailable or
- * the carrier cannot be identified.
- *
- *@hide
- */
- public static final String EXTRA_MNO_CARRIER_ID = "android.telephony.extra.MNO_CARRIER_ID";
-
- /**
* An string extra used with {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} which
* indicates the updated carrier name of the current subscription.
- * {@see TelephonyManager#getSimCarrierIdName()}
+ * @see TelephonyManager#getSimCarrierIdName()
* <p>Carrier name is a user-facing name of the carrier id {@link #EXTRA_CARRIER_ID},
* usually the brand name of the subsidiary (e.g. T-Mobile).
*/
public static final String EXTRA_CARRIER_NAME = "android.telephony.extra.CARRIER_NAME";
/**
+ * Broadcast Action: The subscription precise carrier identity has changed.
+ * The precise carrier id can be used to further differentiate a carrier by different
+ * networks, by prepaid v.s.postpaid or even by 4G v.s.3G plan. Each carrier has a unique
+ * carrier id returned by {@link #getSimCarrierId()} but could have multiple precise carrier id.
+ * e.g, {@link #getSimCarrierId()} will always return Tracfone (id 2022) for a Tracfone SIM,
+ * while {@link #getSimPreciseCarrierId()} can return Tracfone AT&T or Tracfone T-Mobile based
+ * on the current subscription IMSI. For carriers without any fine-grained ids, precise carrier
+ * id is same as carrier id.
+ *
+ * <p>Similar like {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED}, this intent will be
+ * sent on the event of {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} while its also
+ * possible to be sent without {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} when
+ * precise carrier id changes with the same carrier id.
+ * e.g, the same subscription switches to different IMSI could potentially change its
+ * precise carrier id while carrier id remains the same.
+ * @see #getSimPreciseCarrierId()
+ * @see #getSimCarrierId()
+ *
+ * The intent will have the following extra values:
+ * <ul>
+ * <li>{@link #EXTRA_PRECISE_CARRIER_ID} The up-to-date precise carrier id of the
+ * current subscription.
+ * </li>
+ * <li>{@link #EXTRA_PRECISE_CARRIER_NAME} The up-to-date name of the precise carrier id.
+ * </li>
+ * <li>{@link #EXTRA_SUBSCRIPTION_ID} The subscription id associated with the changed carrier
+ * identity.
+ * </li>
+ * </ul>
+ * <p class="note">This is a protected intent that can only be sent by the system.
+ */
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED =
+ "android.telephony.action.SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED";
+
+ /**
* An int extra used with {@link #ACTION_SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED} which
- * indicates the updated precise carrier id {@link TelephonyManager#getSimPreciseCarrierId()} of
- * the current subscription. Note, its possible precise carrier id changes while
- * {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} remains the same e.g, when
- * subscription switch to different IMSI.
+ * indicates the updated precise carrier id returned by
+ * {@link TelephonyManager#getSimPreciseCarrierId()}. Note, its possible precise carrier id
+ * changes while {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} remains the same
+ * e.g, when subscription switch to different IMSIs.
* <p>Will be {@link TelephonyManager#UNKNOWN_CARRIER_ID} if the subscription is unavailable or
* the carrier cannot be identified.
- * @hide
*/
public static final String EXTRA_PRECISE_CARRIER_ID =
"android.telephony.extra.PRECISE_CARRIER_ID";
/**
* An string extra used with {@link #ACTION_SUBSCRIPTION_PRECISE_CARRIER_IDENTITY_CHANGED} which
- * indicates the updated precise carrier name of the current subscription.
- * {@see TelephonyManager#getSimPreciseCarrierIdName()}
- * <p>it's a user-facing name of the precise carrier id {@link #EXTRA_PRECISE_CARRIER_ID},
- * @hide
+ * indicates the updated precise carrier name returned by
+ * {@link TelephonyManager#getSimPreciseCarrierIdName()}.
+ * <p>it's a user-facing name of the precise carrier id {@link #EXTRA_PRECISE_CARRIER_ID}, e.g,
+ * Tracfone-AT&T.
*/
- public static final String EXTRA_PRECISE_CARRIER_NAME = "android.telephony.extra.CARRIER_NAME";
+ public static final String EXTRA_PRECISE_CARRIER_NAME =
+ "android.telephony.extra.PRECISE_CARRIER_NAME";
/**
* An int extra used with {@link #ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED} to indicate the
@@ -8533,7 +8531,7 @@
/**
* Returns carrier id name of the current subscription.
- * <p>Carrier id name is a user-facing name of carrier id
+ * <p>Carrier id name is a user-facing name of carrier id returned by
* {@link #getSimCarrierId()}, usually the brand name of the subsidiary
* (e.g. T-Mobile). Each carrier could configure multiple {@link #getSimOperatorName() SPN} but
* should have a single carrier name. Carrier name is not a canonical identity,
@@ -8543,7 +8541,7 @@
* @return Carrier name of the current subscription. Return {@code null} if the subscription is
* unavailable or the carrier cannot be identified.
*/
- public CharSequence getSimCarrierIdName() {
+ public @Nullable CharSequence getSimCarrierIdName() {
try {
ITelephony service = getITelephony();
if (service != null) {
@@ -8560,10 +8558,10 @@
*
* <p>The precise carrier id can be used to further differentiate a carrier by different
* networks, by prepaid v.s.postpaid or even by 4G v.s.3G plan. Each carrier has a unique
- * carrier id {@link #getSimCarrierId()} but can have multiple precise carrier id. e.g,
- * {@link #getSimCarrierId()} will always return Tracfone (id 2022) for a Tracfone SIM, while
- * {@link #getSimPreciseCarrierId()} can return Tracfone AT&T or Tracfone T-Mobile based on the
- * current subscription IMSI.
+ * carrier id returned by {@link #getSimCarrierId()} but could have multiple precise carrier id.
+ * e.g, {@link #getSimCarrierId()} will always return Tracfone (id 2022) for a Tracfone SIM,
+ * while {@link #getSimPreciseCarrierId()} can return Tracfone AT&T or Tracfone T-Mobile based
+ * on the current subscription IMSI.
*
* <p>For carriers without any fine-grained carrier ids, return {@link #getSimCarrierId()}
* <p>Precise carrier ids are defined in the same way as carrier id
@@ -8573,8 +8571,6 @@
* @return Returns fine-grained carrier id of the current subscription.
* Return {@link #UNKNOWN_CARRIER_ID} if the subscription is unavailable or the carrier cannot
* be identified.
- *
- * @hide
*/
public int getSimPreciseCarrierId() {
try {
@@ -8590,16 +8586,14 @@
/**
* Similar like {@link #getSimCarrierIdName()}, returns user-facing name of the
- * precise carrier id {@link #getSimPreciseCarrierId()}
+ * precise carrier id returned by {@link #getSimPreciseCarrierId()}.
*
* <p>The returned name is unlocalized.
*
* @return user-facing name of the subscription precise carrier id. Return {@code null} if the
* subscription is unavailable or the carrier cannot be identified.
- *
- * @hide
*/
- public CharSequence getSimPreciseCarrierIdName() {
+ public @Nullable CharSequence getSimPreciseCarrierIdName() {
try {
ITelephony service = getITelephony();
if (service != null) {
@@ -8612,6 +8606,62 @@
}
/**
+ * Returns carrier id based on sim MCCMNC (returned by {@link #getSimOperator()}) only.
+ * This is used for fallback when configurations/logic for exact carrier id
+ * {@link #getSimCarrierId()} are not found.
+ *
+ * Android carrier id table <a href="https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/master/assets/carrier_list.textpb">here</a>
+ * can be updated out-of-band, its possible a MVNO (Mobile Virtual Network Operator) carrier
+ * was not fully recognized and assigned to its MNO (Mobile Network Operator) carrier id
+ * by default. After carrier id table update, a new carrier id was assigned. If apps don't
+ * take the update with the new id, it might be helpful to always fallback by using carrier
+ * id based on MCCMNC if there is no match.
+ *
+ * @return matching carrier id from sim MCCMNC. Return {@link #UNKNOWN_CARRIER_ID} if the
+ * subscription is unavailable or the carrier cannot be identified.
+ */
+ public int getCarrierIdFromSimMccMnc() {
+ try {
+ ITelephony service = getITelephony();
+ if (service != null) {
+ return service.getCarrierIdFromMccMnc(getSlotIndex(), getSimOperator(), true);
+ }
+ } catch (RemoteException ex) {
+ // This could happen if binder process crashes.
+ }
+ return UNKNOWN_CARRIER_ID;
+ }
+
+ /**
+ * Returns carrier id based on MCCMNC (returned by {@link #getSimOperator()}) only. This is
+ * used for fallback when configurations/logic for exact carrier id {@link #getSimCarrierId()}
+ * are not found.
+ *
+ * Android carrier id table <a href="https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/master/assets/carrier_list.textpb">here</a>
+ * can be updated out-of-band, its possible a MVNO (Mobile Virtual Network Operator) carrier
+ * was not fully recognized and assigned to its MNO (Mobile Network Operator) carrier id
+ * by default. After carrier id table update, a new carrier id was assigned. If apps don't
+ * take the update with the new id, it might be helpful to always fallback by using carrier
+ * id based on MCCMNC if there is no match.
+ *
+ * @return matching carrier id from passing MCCMNC. Return {@link #UNKNOWN_CARRIER_ID} if the
+ * subscription is unavailable or the carrier cannot be identified.
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ public int getCarrierIdFromMccMnc(String mccmnc) {
+ try {
+ ITelephony service = getITelephony();
+ if (service != null) {
+ return service.getCarrierIdFromMccMnc(getSlotIndex(), mccmnc, false);
+ }
+ } catch (RemoteException ex) {
+ // This could happen if binder process crashes.
+ }
+ return UNKNOWN_CARRIER_ID;
+ }
+
+ /**
* Return a list of certs in hex string from loaded carrier privileges access rules.
*
* @return a list of certificate in hex string. return {@code null} if there is no certs
@@ -8635,48 +8685,6 @@
}
/**
- * Returns MNO carrier id of the current subscription’s MCCMNC.
- * <p>MNO carrier id can be solely identified by subscription mccmnc. This is mainly used
- * for MNO fallback when exact carrier id {@link #getSimCarrierId()}
- * configurations are not found.
- *
- * @return MNO carrier id of the current subscription. Return the value same as carrier id
- * {@link #getSimCarrierId()}, if MNO carrier id cannot be identified.
- * @hide
- */
- public int getSimMNOCarrierId() {
- try {
- ITelephony service = getITelephony();
- if (service != null) {
- return service.getSubscriptionMNOCarrierId(getSubId());
- }
- } catch (RemoteException ex) {
- // This could happen if binder process crashes.
- }
- return UNKNOWN_CARRIER_ID;
- }
-
- /**
- * Returns carrier id based on MCCMNC only. This is for fallback when exact carrier id
- * {@link #getSimCarrierId()} configurations are not found
- *
- * @return matching carrier id from passing mccmnc.
- * @hide
- */
- @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
- public int getCarrierIdFromMccMnc(String mccmnc) {
- try {
- ITelephony service = getITelephony();
- if (service != null) {
- return service.getCarrierIdFromMccMnc(getSlotIndex(), mccmnc);
- }
- } catch (RemoteException ex) {
- // This could happen if binder process crashes.
- }
- return UNKNOWN_CARRIER_ID;
- }
-
- /**
* Return the application ID for the uicc application type like {@link #APPTYPE_CSIM}.
* All uicc applications are uniquely identified by application ID, represented by the hex
* string. e.g, A00000015141434C00. See ETSI 102.221 and 101.220
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 5a06f6a..5034bcc 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -1337,18 +1337,6 @@
String getSubscriptionCarrierName(int subId);
/**
- * Returns MNO carrier id of the current subscription’s MCCMNC.
- * <p>MNO carrier id can be solely identified by subscription mccmnc. This is mainly used
- * for MNO fallback when exact carrier id {@link #getSimCarrierId()}
- * configurations are not found.
- *
- * @return MNO carrier id of the current subscription. Return the value same as carrier id
- * {@link #getSimCarrierId()}, if MNO carrier id cannot be identified.
- * @hide
- */
- int getSubscriptionMNOCarrierId(int subId);
-
- /**
* Returns fine-grained carrier id of the current subscription.
*
* <p>The precise carrier id can be used to further differentiate a carrier by different
@@ -1383,10 +1371,13 @@
* Returns carrier id based on MCCMNC only. This will return a MNO carrier id used for fallback
* check when exact carrier id {@link #getSimCarrierId()} configurations are not found
*
+ * @param isSubscriptionMccMnc. If {@true} it means this is a query for subscription mccmnc
+ * {@false} otherwise.
+ *
* @return carrier id from passing mccmnc.
* @hide
*/
- int getCarrierIdFromMccMnc(int slotIndex, String mccmnc);
+ int getCarrierIdFromMccMnc(int slotIndex, String mccmnc, boolean isSubscriptionMccMnc);
/**
* Action set from carrier signalling broadcast receivers to enable/disable metered apns
diff --git a/tests/net/java/android/net/dhcp/DhcpServerTest.java b/tests/net/java/android/net/dhcp/DhcpServerTest.java
index df34c73..ab9bd84 100644
--- a/tests/net/java/android/net/dhcp/DhcpServerTest.java
+++ b/tests/net/java/android/net/dhcp/DhcpServerTest.java
@@ -25,7 +25,6 @@
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
@@ -48,7 +47,6 @@
import android.net.dhcp.DhcpLeaseRepository.OutOfAddressesException;
import android.net.dhcp.DhcpServer.Clock;
import android.net.dhcp.DhcpServer.Dependencies;
-import android.net.util.InterfaceParams;
import android.net.util.SharedLog;
import android.os.test.TestLooper;
import android.support.test.filters.SmallTest;
@@ -74,9 +72,6 @@
public class DhcpServerTest {
private static final String PROP_DEXMAKER_SHARE_CLASSLOADER = "dexmaker.share_classloader";
private static final String TEST_IFACE = "testiface";
- private static final MacAddress TEST_IFACE_MAC = MacAddress.fromString("11:22:33:44:55:66");
- private static final InterfaceParams TEST_IFACEPARAMS =
- new InterfaceParams(TEST_IFACE, 1, TEST_IFACE_MAC);
private static final Inet4Address TEST_SERVER_ADDR = parseAddr("192.168.0.2");
private static final LinkAddress TEST_SERVER_LINKADDR = new LinkAddress(TEST_SERVER_ADDR, 20);
@@ -149,7 +144,7 @@
.build();
mLooper = new TestLooper();
- mServer = new DhcpServer(mLooper.getLooper(), TEST_IFACEPARAMS, servingParams,
+ mServer = new DhcpServer(mLooper.getLooper(), TEST_IFACE, servingParams,
new SharedLog(DhcpServerTest.class.getSimpleName()), mDeps);
mServer.start();
diff --git a/tests/net/java/android/net/ip/IpServerTest.java b/tests/net/java/android/net/ip/IpServerTest.java
index cff0b54..2c675c6 100644
--- a/tests/net/java/android/net/ip/IpServerTest.java
+++ b/tests/net/java/android/net/ip/IpServerTest.java
@@ -404,7 +404,7 @@
private void assertDhcpStarted(IpPrefix expectedPrefix) {
verify(mDependencies, times(1)).makeDhcpServer(
- eq(mLooper.getLooper()), eq(TEST_IFACE_PARAMS), any(), eq(mSharedLog));
+ eq(mLooper.getLooper()), eq(IFACE_NAME), any(), eq(mSharedLog));
verify(mDhcpServer, times(1)).start();
final DhcpServingParams params = mDhcpParamsCaptor.getValue();
// Last address byte is random
diff --git a/tests/net/java/com/android/server/connectivity/TetheringTest.java b/tests/net/java/com/android/server/connectivity/TetheringTest.java
index bca9be7..e6b43d2 100644
--- a/tests/net/java/com/android/server/connectivity/TetheringTest.java
+++ b/tests/net/java/com/android/server/connectivity/TetheringTest.java
@@ -240,7 +240,7 @@
}
@Override
- public DhcpServer makeDhcpServer(Looper looper, InterfaceParams iface,
+ public DhcpServer makeDhcpServer(Looper looper, String ifName,
DhcpServingParams params, SharedLog log) {
return mDhcpServer;
}
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp
index 39ca80b..968376b 100644
--- a/tools/aapt2/ResourceParser.cpp
+++ b/tools/aapt2/ResourceParser.cpp
@@ -78,7 +78,7 @@
static uint32_t ParseFormatAttribute(const StringPiece& str) {
uint32_t mask = 0;
- for (StringPiece part : util::Tokenize(str, '|')) {
+ for (const StringPiece& part : util::Tokenize(str, '|')) {
StringPiece trimmed_part = util::TrimWhitespace(part);
uint32_t type = ParseFormatType(trimmed_part);
if (type == 0) {
diff --git a/tools/aapt2/ResourceUtils.cpp b/tools/aapt2/ResourceUtils.cpp
index 82d9e04..99420de 100644
--- a/tools/aapt2/ResourceUtils.cpp
+++ b/tools/aapt2/ResourceUtils.cpp
@@ -360,7 +360,7 @@
return util::make_unique<BinaryPrimitive>(flags);
}
- for (StringPiece part : util::Tokenize(str, '|')) {
+ for (const StringPiece& part : util::Tokenize(str, '|')) {
StringPiece trimmed_part = util::TrimWhitespace(part);
bool flag_set = false;
diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp
index 411ad74..0b43c5d 100644
--- a/tools/aapt2/cmd/Compile.cpp
+++ b/tools/aapt2/cmd/Compile.cpp
@@ -486,7 +486,7 @@
}
Printer r_txt_printer(&fout_text);
- for (const auto res : xmlres->file.exported_symbols) {
+ for (const auto& res : xmlres->file.exported_symbols) {
r_txt_printer.Print("default int id ");
r_txt_printer.Println(res.name.entry);
}
diff --git a/tools/aapt2/java/AnnotationProcessor.cpp b/tools/aapt2/java/AnnotationProcessor.cpp
index 8d91b00..a4610b2 100644
--- a/tools/aapt2/java/AnnotationProcessor.cpp
+++ b/tools/aapt2/java/AnnotationProcessor.cpp
@@ -113,7 +113,7 @@
void AnnotationProcessor::Print(Printer* printer) const {
if (has_comments_) {
std::string result = comment_.str();
- for (StringPiece line : util::Tokenize(result, '\n')) {
+ for (const StringPiece& line : util::Tokenize(result, '\n')) {
printer->Println(line);
}
printer->Println(" */");
diff --git a/tools/aapt2/util/Files.cpp b/tools/aapt2/util/Files.cpp
index 5a8ff09..a407c22 100644
--- a/tools/aapt2/util/Files.cpp
+++ b/tools/aapt2/util/Files.cpp
@@ -165,7 +165,7 @@
std::string PackageToPath(const StringPiece& package) {
std::string out_path;
- for (StringPiece part : util::Tokenize(package, '.')) {
+ for (const StringPiece& part : util::Tokenize(package, '.')) {
AppendPath(&out_path, part);
}
return out_path;