Merge "Support dexopting shared libraries."
diff --git a/api/current.txt b/api/current.txt
index e789d5b..dd26589 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -4203,10 +4203,9 @@
public class AppComponentFactory {
ctor public AppComponentFactory();
- method public android.content.pm.ApplicationInfo getApplicationInfo();
method @NonNull public android.app.Activity instantiateActivity(@NonNull ClassLoader, @NonNull String, @Nullable android.content.Intent) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException;
method @NonNull public android.app.Application instantiateApplication(@NonNull ClassLoader, @NonNull String) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException;
- method @NonNull public ClassLoader instantiateClassLoader(@NonNull ClassLoader);
+ method @NonNull public ClassLoader instantiateClassLoader(@NonNull ClassLoader, @NonNull android.content.pm.ApplicationInfo);
method @NonNull public android.content.ContentProvider instantiateProvider(@NonNull ClassLoader, @NonNull String) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException;
method @NonNull public android.content.BroadcastReceiver instantiateReceiver(@NonNull ClassLoader, @NonNull String, @Nullable android.content.Intent) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException;
method @NonNull public android.app.Service instantiateService(@NonNull ClassLoader, @NonNull String, @Nullable android.content.Intent) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException;
@@ -37321,7 +37320,7 @@
}
public static final class Telephony.CarrierId implements android.provider.BaseColumns {
- method public static android.net.Uri getPreciseCarrierIdUriForSubscriptionId(int);
+ method @NonNull public static android.net.Uri getPreciseCarrierIdUriForSubscriptionId(int);
method public static android.net.Uri getUriForSubscriptionId(int);
field public static final String CARRIER_ID = "carrier_id";
field public static final String CARRIER_NAME = "carrier_name";
@@ -42383,6 +42382,7 @@
field public static final int CONNECTION_UNKNOWN = 2147483647; // 0x7fffffff
field public static final android.os.Parcelable.Creator<android.telephony.CellInfo> CREATOR;
field public static final int UNAVAILABLE = 2147483647; // 0x7fffffff
+ field public static final long UNAVAILABLE_LONG = 9223372036854775807L; // 0x7fffffffffffffffL
}
public final class CellInfoCdma extends android.telephony.CellInfo implements android.os.Parcelable {
diff --git a/api/system-current.txt b/api/system-current.txt
index 67ff89f..d56cdec 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -6107,7 +6107,7 @@
method @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public void onCallDisconnectCauseChanged(int, int);
method @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public void onImsCallDisconnectCauseChanged(@NonNull android.telephony.ims.ImsReasonInfo);
method @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public void onPreciseCallStateChanged(@NonNull android.telephony.PreciseCallState);
- method @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public void onPreciseDataConnectionStateChanged(android.telephony.PreciseDataConnectionState);
+ method @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public void onPreciseDataConnectionStateChanged(@NonNull android.telephony.PreciseDataConnectionState);
method public void onRadioPowerStateChanged(int);
method public void onSrvccStateChanged(int);
method public void onVoiceActivationStateChanged(int);
@@ -6142,7 +6142,7 @@
public final class PreciseDataConnectionState implements android.os.Parcelable {
method public int describeContents();
- method public String getDataConnectionApn();
+ method @Nullable public String getDataConnectionApn();
method public int getDataConnectionApnTypeBitMask();
method public int getDataConnectionFailCause();
method public int getDataConnectionState();
@@ -6296,17 +6296,17 @@
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDefaultDataSubId(int);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDefaultSmsSubId(int);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setSubscriptionEnabled(int, boolean);
- field public static final android.net.Uri ADVANCED_CALLING_ENABLED_CONTENT_URI;
+ field @NonNull public static final android.net.Uri ADVANCED_CALLING_ENABLED_CONTENT_URI;
field public static final int PROFILE_CLASS_DEFAULT = -1; // 0xffffffff
field public static final int PROFILE_CLASS_OPERATIONAL = 2; // 0x2
field public static final int PROFILE_CLASS_PROVISIONING = 1; // 0x1
field public static final int PROFILE_CLASS_TESTING = 0; // 0x0
field public static final int PROFILE_CLASS_UNSET = -1; // 0xffffffff
- field public static final android.net.Uri VT_ENABLED_CONTENT_URI;
- field public static final android.net.Uri WFC_ENABLED_CONTENT_URI;
- field public static final android.net.Uri WFC_MODE_CONTENT_URI;
- field public static final android.net.Uri WFC_ROAMING_ENABLED_CONTENT_URI;
- field public static final android.net.Uri WFC_ROAMING_MODE_CONTENT_URI;
+ field @NonNull public static final android.net.Uri VT_ENABLED_CONTENT_URI;
+ field @NonNull public static final android.net.Uri WFC_ENABLED_CONTENT_URI;
+ field @NonNull public static final android.net.Uri WFC_MODE_CONTENT_URI;
+ field @NonNull public static final android.net.Uri WFC_ROAMING_ENABLED_CONTENT_URI;
+ field @NonNull public static final android.net.Uri WFC_ROAMING_MODE_CONTENT_URI;
}
public static class SubscriptionPlan.Builder {
diff --git a/config/hiddenapi-greylist.txt b/config/hiddenapi-greylist.txt
index 4a43616..e9bd735 100644
--- a/config/hiddenapi-greylist.txt
+++ b/config/hiddenapi-greylist.txt
@@ -1556,9 +1556,6 @@
Landroid/telephony/SmsCbMessage;->isCmasMessage()Z
Landroid/telephony/SmsCbMessage;->isEmergencyMessage()Z
Landroid/telephony/TelephonyManager$MultiSimVariants;->values()[Landroid/telephony/TelephonyManager$MultiSimVariants;
-Landroid/test/AndroidTestCase;->getTestContext()Landroid/content/Context;
-Landroid/test/AndroidTestCase;->setTestContext(Landroid/content/Context;)V
-Landroid/test/InstrumentationTestCase;->runMethod(Ljava/lang/reflect/Method;I)V
Landroid/util/Singleton;-><init>()V
Landroid/util/XmlPullAttributes;-><init>(Lorg/xmlpull/v1/XmlPullParser;)V
Landroid/util/XmlPullAttributes;->mParser:Lorg/xmlpull/v1/XmlPullParser;
@@ -4596,9 +4593,6 @@
Lgov/nist/javax/sip/address/SipUri;->setUserParam(Ljava/lang/String;)V
Lgov/nist/javax/sip/parser/URLParser;-><init>(Ljava/lang/String;)V
Lgov/nist/javax/sip/parser/URLParser;->sipURL(Z)Lgov/nist/javax/sip/address/SipUri;
-Ljunit/framework/TestCase;->fName:Ljava/lang/String;
-Ljunit/framework/TestSuite;->isPublicTestMethod(Ljava/lang/reflect/Method;)Z
-Ljunit/framework/TestSuite;->isTestMethod(Ljava/lang/reflect/Method;)Z
Lorg/apache/xalan/extensions/ExpressionContext;->getContextNode()Lorg/w3c/dom/Node;
Lorg/apache/xalan/extensions/ExpressionContext;->getErrorListener()Ljavax/xml/transform/ErrorListener;
Lorg/apache/xalan/extensions/ExpressionContext;->getVariableOrParam(Lorg/apache/xml/utils/QName;)Lorg/apache/xpath/objects/XObject;
diff --git a/core/java/android/app/AppComponentFactory.java b/core/java/android/app/AppComponentFactory.java
index ae63291..2cec7f0 100644
--- a/core/java/android/app/AppComponentFactory.java
+++ b/core/java/android/app/AppComponentFactory.java
@@ -27,6 +27,7 @@
*
* @see #instantiateApplication
* @see #instantiateActivity
+ * @see #instantiateClassLoader
* @see #instantiateService
* @see #instantiateReceiver
* @see #instantiateProvider
@@ -39,8 +40,10 @@
* a custom class loader hierarchy.
*
* @param cl The default classloader instantiated by platform.
+ * @param aInfo Information about the application being loaded.
*/
- public @NonNull ClassLoader instantiateClassLoader(@NonNull ClassLoader cl) {
+ public @NonNull ClassLoader instantiateClassLoader(@NonNull ClassLoader cl,
+ @NonNull ApplicationInfo aInfo) {
return cl;
}
@@ -133,19 +136,6 @@
return (ContentProvider) cl.loadClass(className).newInstance();
}
- private ApplicationInfo mApplicationInfo = null;
-
- void setApplicationInfo(ApplicationInfo info) {
- mApplicationInfo = info;
- }
-
- /**
- * Returns the ApplicationInfo associated with this package.
- */
- public ApplicationInfo getApplicationInfo() {
- return mApplicationInfo;
- }
-
/**
* @hide
*/
diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java
index ac33c16..3a76de4 100644
--- a/core/java/android/app/LoadedApk.java
+++ b/core/java/android/app/LoadedApk.java
@@ -232,7 +232,8 @@
mResources = Resources.getSystem();
mDefaultClassLoader = ClassLoader.getSystemClassLoader();
mAppComponentFactory = createAppFactory(mApplicationInfo, mDefaultClassLoader);
- mClassLoader = mAppComponentFactory.instantiateClassLoader(mDefaultClassLoader);
+ mClassLoader = mAppComponentFactory.instantiateClassLoader(mDefaultClassLoader,
+ new ApplicationInfo(mApplicationInfo));
}
/**
@@ -243,19 +244,15 @@
mApplicationInfo = info;
mDefaultClassLoader = classLoader;
mAppComponentFactory = createAppFactory(info, mDefaultClassLoader);
- mClassLoader = mAppComponentFactory.instantiateClassLoader(mDefaultClassLoader);
+ mClassLoader = mAppComponentFactory.instantiateClassLoader(mDefaultClassLoader,
+ new ApplicationInfo(mApplicationInfo));
}
private AppComponentFactory createAppFactory(ApplicationInfo appInfo, ClassLoader cl) {
if (appInfo.appComponentFactory != null && cl != null) {
try {
- AppComponentFactory factory = (AppComponentFactory) cl.loadClass(
- appInfo.appComponentFactory).newInstance();
- // Pass a copy of ApplicationInfo to the factory. Copying protects the framework
- // from apps which would override the factory and change ApplicationInfo contents.
- // ApplicationInfo is used to set up the default class loader.
- factory.setApplicationInfo(new ApplicationInfo(appInfo));
- return factory;
+ return (AppComponentFactory)
+ cl.loadClass(appInfo.appComponentFactory).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
Slog.e(TAG, "Unable to instantiate appComponentFactory", e);
}
@@ -712,8 +709,8 @@
mDefaultClassLoader = ClassLoader.getSystemClassLoader();
}
mAppComponentFactory = createAppFactory(mApplicationInfo, mDefaultClassLoader);
- mClassLoader = mAppComponentFactory.instantiateClassLoader(mDefaultClassLoader);
-
+ mClassLoader = mAppComponentFactory.instantiateClassLoader(mDefaultClassLoader,
+ new ApplicationInfo(mApplicationInfo));
return;
}
@@ -801,7 +798,8 @@
}
if (mClassLoader == null) {
- mClassLoader = mAppComponentFactory.instantiateClassLoader(mDefaultClassLoader);
+ mClassLoader = mAppComponentFactory.instantiateClassLoader(mDefaultClassLoader,
+ new ApplicationInfo(mApplicationInfo));
}
return;
@@ -915,8 +913,10 @@
// Call AppComponentFactory to select/create the main class loader of this app.
// Since this may call code in the app, mDefaultClassLoader must be fully set up
// before invoking the factory.
+ // Invoke with a copy of ApplicationInfo to protect against the app changing it.
if (mClassLoader == null) {
- mClassLoader = mAppComponentFactory.instantiateClassLoader(mDefaultClassLoader);
+ mClassLoader = mAppComponentFactory.instantiateClassLoader(mDefaultClassLoader,
+ new ApplicationInfo(mApplicationInfo));
}
}
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 92b30a4..24a907b 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -3668,7 +3668,8 @@
/**
* Registers to receive notifications about all networks which satisfy the given
* {@link NetworkRequest}. The callbacks will continue to be called until
- * either the application exits or link #unregisterNetworkCallback(NetworkCallback)} is called.
+ * either the application exits or {@link #unregisterNetworkCallback(NetworkCallback)} is
+ * called.
*
* @param request {@link NetworkRequest} describing this request.
* @param networkCallback The {@link NetworkCallback} that the system will call as suitable
@@ -3684,7 +3685,8 @@
/**
* Registers to receive notifications about all networks which satisfy the given
* {@link NetworkRequest}. The callbacks will continue to be called until
- * either the application exits or link #unregisterNetworkCallback(NetworkCallback)} is called.
+ * either the application exits or {@link #unregisterNetworkCallback(NetworkCallback)} is
+ * called.
*
* @param request {@link NetworkRequest} describing this request.
* @param networkCallback The {@link NetworkCallback} that the system will call as suitable
diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl
index 83bb3a0..84036ca 100644
--- a/core/java/android/net/IConnectivityManager.aidl
+++ b/core/java/android/net/IConnectivityManager.aidl
@@ -122,8 +122,6 @@
LegacyVpnInfo getLegacyVpnInfo(int userId);
- VpnInfo[] getAllVpnInfo();
-
boolean updateLockdownVpn();
boolean isAlwaysOnVpnPackageSupported(int userId, String packageName);
boolean setAlwaysOnVpnPackage(int userId, String packageName, boolean lockdown,
diff --git a/core/java/android/net/INetworkStatsService.aidl b/core/java/android/net/INetworkStatsService.aidl
index 8e6f272..148b25d 100644
--- a/core/java/android/net/INetworkStatsService.aidl
+++ b/core/java/android/net/INetworkStatsService.aidl
@@ -19,11 +19,13 @@
import android.net.DataUsageRequest;
import android.net.INetworkStatsSession;
import android.net.Network;
+import android.net.NetworkState;
import android.net.NetworkStats;
import android.net.NetworkStatsHistory;
import android.net.NetworkTemplate;
import android.os.IBinder;
import android.os.Messenger;
+import com.android.internal.net.VpnInfo;
/** {@hide} */
interface INetworkStatsService {
@@ -58,7 +60,11 @@
void incrementOperationCount(int uid, int tag, int operationCount);
/** Force update of ifaces. */
- void forceUpdateIfaces(in Network[] defaultNetworks);
+ void forceUpdateIfaces(
+ in Network[] defaultNetworks,
+ in VpnInfo[] vpnArray,
+ in NetworkState[] networkStates,
+ in String activeIface);
/** Force update of statistics. */
void forceUpdate();
diff --git a/core/jni/runtime_native_boot-flags-test.sh b/core/jni/runtime_native_boot-flags-test.sh
index 01f37f0..a5d7a5a 100755
--- a/core/jni/runtime_native_boot-flags-test.sh
+++ b/core/jni/runtime_native_boot-flags-test.sh
@@ -172,14 +172,42 @@
done
}
-# test_android_runtime_flag FLAG VALUE GC_RUNTIME_OPTION
-# ------------------------------------------------------
-# Test device configuration FLAG with VALUE. Check that GC_RUNTIME_OPTION is
-# passed as GC Runtime option by the zygote.
+# check_android_runtime_message CONTEXT MESSAGE
+# ---------------------------------------------
+# Return whether AndroidRuntime generated MESSAGE in logcat. Use CONTEXT in
+# logging.
+function check_android_runtime_message {
+ local context=$1
+ local message=$2
+
+ say "[$context] Check that AndroidRuntime generated expected message in logcat..."
+ adb logcat -d -s AndroidRuntime | grep -F -q "$message" \
+ || fail "Found no message \"$message\" generated by AndroidRuntime"
+}
+
+# check_no_android_runtime_message CONTEXT MESSAGE
+# ------------------------------------------------
+# Return whether AndroidRuntime did not generate MESSAGE in logcat. Use CONTEXT
+# in logging.
+function check_no_android_runtime_message {
+ local context=$1
+ local message=$2
+
+ say "[$context] Check that AndroidRuntime did not generate unexpected message in logcat..."
+ adb logcat -d -s AndroidRuntime | grep -F -q -v "$message" \
+ || fail "Found message \"$message\" generated by AndroidRuntime"
+}
+
+# test_android_runtime_flag FLAG VALUE CHECK_EFFECT CHECK_NO_EFFECT
+# -----------------------------------------------------------------
+# Test device configuration FLAG with VALUE. CHECK_EFFECT and CHECK_NO_EFFECT
+# are functions that are passed a context as sole argument and that respectively
+# check the effect or the absence of effect of the flag.
function test_android_runtime_flag {
local flag=$1
local value=$2
- local gc_runtime_option=$3
+ local check_effect=$3
+ local check_no_effect=$4
# Persistent system property (set after a reboot) associated with the device
# configuration flag.
@@ -193,26 +221,26 @@
sleep 3
# Check that both the device configuration flag and the associated system
- # property are set, but that the zygote hasn't had the flag passed to it as a
- # GC runtime option (as we haven't rebooted yet).
+ # property are set, but that flag has not produced an effect on the system (as
+ # we haven't rebooted yet).
local context="Flag set, before reboot"
check_device_config_flag "$context" "$flag" "$value"
check_system_property "$context" "$prop" "$value"
- check_no_zygote_gc_runtime_option "$context" "$gc_runtime_option"
+ $check_no_effect "$context"
# Reboot device for the flag value to take effect.
reboot_and_wait_for_device
context="Flag set, after 1st reboot"
check_device_config_flag "$context" "$flag" "$value"
check_system_property "$context" "$prop" "$value"
- check_zygote_gc_runtime_option "$context" "$gc_runtime_option"
+ $check_effect "$context"
# Reboot device a second time and check that the state has persisted.
reboot_and_wait_for_device
context="Flag set, after 2nd reboot"
check_device_config_flag "$context" "$flag" "$value"
check_system_property "$context" "$prop" "$value"
- check_zygote_gc_runtime_option "$context" "$gc_runtime_option"
+ $check_effect "$context"
say "Unsetting device configuration flag..."
adb shell device_config delete "$namespace" "$flag" >/dev/null
@@ -224,9 +252,13 @@
context="Flag unset, after 3rd reboot"
check_no_device_config_flag "$context" "$flag"
check_no_system_property "$context" "$prop"
- check_no_zygote_gc_runtime_option "$context" "$gc_runtime_option"
+ $check_no_effect "$context"
}
+
+# Pre-test actions.
+# =================
+
# Enumerate Zygote processes.
case $(adb shell getprop ro.zygote) in
(zygote32) zygotes="zygote";;
@@ -235,8 +267,53 @@
esac
# Test "enable_generational_cc" flag values.
-test_android_runtime_flag enable_generational_cc false nogenerational_cc
-test_android_runtime_flag enable_generational_cc true generational_cc
+# ==========================================
+
+function check_nogenerational_cc {
+ check_zygote_gc_runtime_option "$1" nogenerational_cc
+}
+function check_no_nogenerational_cc {
+ check_no_zygote_gc_runtime_option "$1" nogenerational_cc
+}
+
+function check_generational_cc {
+ check_zygote_gc_runtime_option "$1" generational_cc
+}
+function check_no_generational_cc {
+ check_no_zygote_gc_runtime_option "$1" generational_cc
+}
+
+test_android_runtime_flag \
+ enable_generational_cc false check_nogenerational_cc check_no_nogenerational_cc
+test_android_runtime_flag \
+ enable_generational_cc true check_generational_cc check_no_generational_cc
+
+# Test "enable_apex_image" flag values.
+# =====================================
+
+default_boot_image_message="Using default boot image"
+function check_default_boot_image {
+ check_android_runtime_message "$1" "$default_boot_image_message"
+}
+function check_no_default_boot_image {
+ check_no_android_runtime_message "$1" "$default_boot_image_message"
+}
+
+apex_boot_image_message="Using Apex boot image: '-Ximage:/system/framework/apex.art'"
+function check_apex_boot_image {
+ check_android_runtime_message "$1" "$apex_boot_image_message"
+}
+function check_no_apex_boot_image {
+ check_no_android_runtime_message "$1" "$apex_boot_image_message"
+}
+
+test_android_runtime_flag \
+ enable_apex_image false check_default_boot_image check_no_default_boot_image
+test_android_runtime_flag \
+ enable_apex_image true check_apex_boot_image check_no_apex_boot_image
+
+# Post-test actions.
+# ==================
if [[ "$exit_status" -eq 0 ]]; then
banner "All tests passed."
diff --git a/core/res/res/values/colors_device_defaults.xml b/core/res/res/values/colors_device_defaults.xml
index 0fe80a1..256c531 100644
--- a/core/res/res/values/colors_device_defaults.xml
+++ b/core/res/res/values/colors_device_defaults.xml
@@ -26,6 +26,8 @@
<color name="primary_dark_device_default_settings">@color/primary_dark_material_settings</color>
<color name="primary_dark_device_default_settings_light">@color/primary_dark_material_settings_light</color>
+ <color name="navigation_bar_divider_device_default_settings">#1f000000</color>
+
<color name="secondary_device_default_settings">@color/secondary_material_settings</color>
<color name="secondary_device_default_settings_light">@color/secondary_material_settings_light</color>
<color name="tertiary_device_default_settings">@color/tertiary_material_settings</color>
diff --git a/core/res/res/values/themes_device_defaults.xml b/core/res/res/values/themes_device_defaults.xml
index 14e5082..83edeac 100644
--- a/core/res/res/values/themes_device_defaults.xml
+++ b/core/res/res/values/themes_device_defaults.xml
@@ -1447,7 +1447,7 @@
<item name="colorEdgeEffect">@android:color/black</item>
<!-- Add white nav bar with divider that matches material -->
- <item name="navigationBarDividerColor">#1f000000</item>
+ <item name="navigationBarDividerColor">@color/navigation_bar_divider_device_default_settings</item>
<item name="navigationBarColor">@android:color/white</item>
<item name="windowLightNavigationBar">true</item>
diff --git a/media/java/android/media/MediaHTTPConnection.java b/media/java/android/media/MediaHTTPConnection.java
index 5f324f7..d724762 100644
--- a/media/java/android/media/MediaHTTPConnection.java
+++ b/media/java/android/media/MediaHTTPConnection.java
@@ -37,7 +37,6 @@
import java.net.UnknownServiceException;
import java.util.HashMap;
import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
/** @hide */
public class MediaHTTPConnection extends IMediaHTTPConnection.Stub {
@@ -67,7 +66,6 @@
// from com.squareup.okhttp.internal.http
private final static int HTTP_TEMP_REDIRECT = 307;
private final static int MAX_REDIRECTS = 20;
- private AtomicBoolean mIsConnected = new AtomicBoolean(false);
@UnsupportedAppUsage
public MediaHTTPConnection() {
@@ -91,7 +89,6 @@
mAllowCrossDomainRedirect = true;
mURL = new URL(uri);
mHeaders = convertHeaderStringToMap(headers);
- mIsConnected.set(true);
} catch (MalformedURLException e) {
return null;
}
@@ -142,14 +139,7 @@
@Override
@UnsupportedAppUsage
public void disconnect() {
- if (mIsConnected.getAndSet(false)) {
- (new Thread() {
- @Override
- public void run() {
- teardownConnection();
- }
- }).start();
- }
+ teardownConnection();
mHeaders = null;
mURL = null;
}
@@ -334,14 +324,7 @@
@Override
@UnsupportedAppUsage
public int readAt(long offset, int size) {
- if (!mIsConnected.get()) {
- return -1;
- }
- int result = native_readAt(offset, size);
- if (!mIsConnected.get()) {
- return -1;
- }
- return result;
+ return native_readAt(offset, size);
}
private int readAt(long offset, byte[] data, int size) {
diff --git a/packages/CaptivePortalLogin/AndroidManifest.xml b/packages/CaptivePortalLogin/AndroidManifest.xml
index 0894ee5..a5f3b88fe 100644
--- a/packages/CaptivePortalLogin/AndroidManifest.xml
+++ b/packages/CaptivePortalLogin/AndroidManifest.xml
@@ -17,8 +17,11 @@
*/
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.captiveportallogin" >
+ package="com.android.captiveportallogin"
+ android:versionCode="10"
+ android:versionName="Q-initial">
+ <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
diff --git a/packages/NetworkStack/AndroidManifest.xml b/packages/NetworkStack/AndroidManifest.xml
index 52c209e..740c573 100644
--- a/packages/NetworkStack/AndroidManifest.xml
+++ b/packages/NetworkStack/AndroidManifest.xml
@@ -18,7 +18,10 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.networkstack"
- android:sharedUserId="android.uid.networkstack">
+ android:sharedUserId="android.uid.networkstack"
+ android:versionCode="10"
+ android:versionName="Q-initial">
+ <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
diff --git a/packages/NetworkStackPermissionStub/AndroidManifest.xml b/packages/NetworkStackPermissionStub/AndroidManifest.xml
index a8742d7..62bf3de 100644
--- a/packages/NetworkStackPermissionStub/AndroidManifest.xml
+++ b/packages/NetworkStackPermissionStub/AndroidManifest.xml
@@ -18,7 +18,10 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.networkstack.permissionstub"
- android:sharedUserId="android.uid.networkstack">
+ android:sharedUserId="android.uid.networkstack"
+ android:versionCode="10"
+ android:versionName="Q-initial">
+ <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="28" />
<!--
This package only exists to define the below permissions, and enforce that they are only
granted to apps sharing the same signature.
@@ -34,4 +37,4 @@
android:protectionLevel="signature"/>
<application android:name="com.android.server.NetworkStackPermissionStub"/>
-</manifest>
\ No newline at end of file
+</manifest>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java
index 24a5896..72da591 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java
@@ -43,6 +43,7 @@
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import static com.android.systemui.statusbar.phone.StatusBarIconController.TAG_PRIMARY;
@@ -121,7 +122,7 @@
// Remove all the icons.
for (int i = currentSlots.size() - 1; i >= 0; i--) {
Slot s = currentSlots.get(i);
- slotsToReAdd.put(s, s.getHolderListInViewOrder());
+ slotsToReAdd.put(s, s.getHolderList());
removeAllIconsForSlot(s.getName());
}
@@ -200,6 +201,10 @@
Slot mobileSlot = getSlot(slot);
int slotIndex = getSlotIndex(slot);
+ // Reverse the sort order to show icons with left to right([Slot1][Slot2]..).
+ // StatusBarIconList has UI design that first items go to the right of second items.
+ Collections.reverse(iconStates);
+
for (MobileIconState state : iconStates) {
StatusBarIconHolder holder = mobileSlot.getHolderForTag(state.subId);
if (holder == null) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconList.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconList.java
index b7e1cfb..fc41225 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconList.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconList.java
@@ -249,6 +249,25 @@
return holders;
}
+ /**
+ * Build a list of the {@link StatusBarIconHolder}s in the same order.
+ * This provides a safe list that can be iterated and inserted into its group.
+ *
+ * @return all holders contained here
+ */
+ public List<StatusBarIconHolder> getHolderList() {
+ ArrayList<StatusBarIconHolder> holders = new ArrayList<>();
+ if (mHolder != null) {
+ holders.add(mHolder);
+ }
+
+ if (mSubSlots != null) {
+ holders.addAll(mSubSlots);
+ }
+
+ return holders;
+ }
+
@Override
public String toString() {
return String.format("(%s) %s", mName, subSlotsString());
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 446d186..90281b7 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -4096,12 +4096,14 @@
}
/**
- * Return the information of all ongoing VPNs. This method is used by NetworkStatsService
- * and not available in ConnectivityManager.
+ * Return the information of all ongoing VPNs.
+ *
+ * <p>This method is used to update NetworkStatsService.
+ *
+ * <p>Must be called on the handler thread.
*/
- @Override
- public VpnInfo[] getAllVpnInfo() {
- enforceConnectivityInternalPermission();
+ private VpnInfo[] getAllVpnInfo() {
+ ensureRunningOnConnectivityServiceThread();
synchronized (mVpns) {
if (mLockdownEnabled) {
return new VpnInfo[0];
@@ -6397,6 +6399,7 @@
* Must be called on the handler thread.
*/
private Network[] getDefaultNetworks() {
+ ensureRunningOnConnectivityServiceThread();
ArrayList<Network> defaultNetworks = new ArrayList<>();
NetworkAgentInfo defaultNetwork = getDefaultNetwork();
for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
@@ -6412,8 +6415,15 @@
* properties tracked by NetworkStatsService on an active iface has changed.
*/
private void notifyIfacesChangedForNetworkStats() {
+ ensureRunningOnConnectivityServiceThread();
+ String activeIface = null;
+ LinkProperties activeLinkProperties = getActiveLinkProperties();
+ if (activeLinkProperties != null) {
+ activeIface = activeLinkProperties.getInterfaceName();
+ }
try {
- mStatsService.forceUpdateIfaces(getDefaultNetworks());
+ mStatsService.forceUpdateIfaces(
+ getDefaultNetworks(), getAllVpnInfo(), getAllNetworkState(), activeIface);
} catch (Exception ignored) {
}
}
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index b4d45d4..d8a54f7 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -1454,7 +1454,7 @@
synchronized (mRecords) {
mPreciseDataConnectionState = new PreciseDataConnectionState(
TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN,
- ApnSetting.getApnTypesBitmaskFromString(apnType), "", null,
+ ApnSetting.getApnTypesBitmaskFromString(apnType), null, null,
DataFailCause.NONE);
for (Record r : mRecords) {
if (r.matchPhoneStateListenerEvent(
@@ -1470,7 +1470,7 @@
}
broadcastDataConnectionFailed(apnType, subId);
broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
- TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, "", null,
+ TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, null, null,
DataFailCause.NONE);
}
diff --git a/services/core/java/com/android/server/net/NetworkStatsService.java b/services/core/java/com/android/server/net/NetworkStatsService.java
index 2e7cbc6..8fa435c 100644
--- a/services/core/java/com/android/server/net/NetworkStatsService.java
+++ b/services/core/java/com/android/server/net/NetworkStatsService.java
@@ -82,7 +82,6 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.net.DataUsageRequest;
-import android.net.IConnectivityManager;
import android.net.INetworkManagementEventObserver;
import android.net.INetworkStatsService;
import android.net.INetworkStatsSession;
@@ -195,8 +194,6 @@
private final boolean mUseBpfTrafficStats;
- private IConnectivityManager mConnManager;
-
@VisibleForTesting
public static final String ACTION_NETWORK_STATS_POLL =
"com.android.server.action.NETWORK_STATS_POLL";
@@ -258,6 +255,7 @@
private final ArrayMap<String, NetworkIdentitySet> mActiveUidIfaces = new ArrayMap<>();
/** Current default active iface. */
+ @GuardedBy("mStatsLock")
private String mActiveIface;
/** Set of any ifaces associated with mobile networks since boot. */
@@ -268,6 +266,10 @@
@GuardedBy("mStatsLock")
private Network[] mDefaultNetworks = new Network[0];
+ /** Set containing info about active VPNs and their underlying networks. */
+ @GuardedBy("mStatsLock")
+ private VpnInfo[] mVpnInfos = new VpnInfo[0];
+
private final DropBoxNonMonotonicObserver mNonMonotonicObserver =
new DropBoxNonMonotonicObserver();
@@ -375,10 +377,6 @@
mHandlerCallback = callback;
}
- public void bindConnectivityManager(IConnectivityManager connManager) {
- mConnManager = checkNotNull(connManager, "missing IConnectivityManager");
- }
-
public void systemReady() {
mSystemReady = true;
@@ -857,13 +855,17 @@
}
@Override
- public void forceUpdateIfaces(Network[] defaultNetworks) {
+ public void forceUpdateIfaces(
+ Network[] defaultNetworks,
+ VpnInfo[] vpnArray,
+ NetworkState[] networkStates,
+ String activeIface) {
mContext.enforceCallingOrSelfPermission(READ_NETWORK_USAGE_HISTORY, TAG);
assertBandwidthControlEnabled();
final long token = Binder.clearCallingIdentity();
try {
- updateIfaces(defaultNetworks);
+ updateIfaces(defaultNetworks, vpnArray, networkStates, activeIface);
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -1127,11 +1129,17 @@
}
};
- private void updateIfaces(Network[] defaultNetworks) {
+ private void updateIfaces(
+ Network[] defaultNetworks,
+ VpnInfo[] vpnArray,
+ NetworkState[] networkStates,
+ String activeIface) {
synchronized (mStatsLock) {
mWakeLock.acquire();
try {
- updateIfacesLocked(defaultNetworks);
+ mVpnInfos = vpnArray;
+ mActiveIface = activeIface;
+ updateIfacesLocked(defaultNetworks, networkStates);
} finally {
mWakeLock.release();
}
@@ -1145,7 +1153,7 @@
* {@link NetworkIdentitySet}.
*/
@GuardedBy("mStatsLock")
- private void updateIfacesLocked(Network[] defaultNetworks) {
+ private void updateIfacesLocked(Network[] defaultNetworks, NetworkState[] states) {
if (!mSystemReady) return;
if (LOGV) Slog.v(TAG, "updateIfacesLocked()");
@@ -1157,18 +1165,6 @@
// will be persisted during next alarm poll event.
performPollLocked(FLAG_PERSIST_NETWORK);
- final NetworkState[] states;
- final LinkProperties activeLink;
- try {
- states = mConnManager.getAllNetworkState();
- activeLink = mConnManager.getActiveLinkProperties();
- } catch (RemoteException e) {
- // ignored; service lives in system_server
- return;
- }
-
- mActiveIface = activeLink != null ? activeLink.getInterfaceName() : null;
-
// Rebuild active interfaces based on connected networks
mActiveIfaces.clear();
mActiveUidIfaces.clear();
@@ -1280,7 +1276,7 @@
Trace.traceEnd(TRACE_TAG_NETWORK);
// For per-UID stats, pass the VPN info so VPN traffic is reattributed to responsible apps.
- VpnInfo[] vpnArray = mConnManager.getAllVpnInfo();
+ VpnInfo[] vpnArray = mVpnInfos;
Trace.traceBegin(TRACE_TAG_NETWORK, "recordUid");
mUidRecorder.recordSnapshotLocked(uidSnapshot, mActiveUidIfaces, vpnArray, currentTime);
Trace.traceEnd(TRACE_TAG_NETWORK);
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 2733da9..6cbb35b 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -1235,7 +1235,6 @@
ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity,
/* allowIsolated= */ false,
DUMP_FLAG_PRIORITY_HIGH | DUMP_FLAG_PRIORITY_NORMAL);
- networkStats.bindConnectivityManager(connectivity);
networkPolicy.bindConnectivityManager(connectivity);
} catch (Throwable e) {
reportWtf("starting Connectivity Service", e);
diff --git a/telecomm/java/android/telecom/ConnectionRequest.java b/telecomm/java/android/telecom/ConnectionRequest.java
index b6e6b0e..d69d2cd 100644
--- a/telecomm/java/android/telecom/ConnectionRequest.java
+++ b/telecomm/java/android/telecom/ConnectionRequest.java
@@ -337,7 +337,31 @@
mAddress == null
? Uri.EMPTY
: Connection.toLogSafePhoneNumber(mAddress.toString()),
- mExtras == null ? "" : mExtras);
+ bundleToString(mExtras));
+ }
+
+ private static String bundleToString(Bundle extras){
+ if (extras == null) {
+ return "";
+ }
+ StringBuilder sb = new StringBuilder();
+ sb.append("Bundle[");
+ for (String key : extras.keySet()) {
+ sb.append(key);
+ sb.append("=");
+ switch (key) {
+ case TelecomManager.EXTRA_INCOMING_CALL_ADDRESS:
+ case TelecomManager.EXTRA_UNKNOWN_CALL_HANDLE:
+ sb.append(Log.pii(extras.get(key)));
+ break;
+ default:
+ sb.append(extras.get(key));
+ break;
+ }
+ sb.append(", ");
+ }
+ sb.append("]");
+ return sb.toString();
}
public static final Creator<ConnectionRequest> CREATOR = new Creator<ConnectionRequest> () {
diff --git a/telephony/java/android/provider/Telephony.java b/telephony/java/android/provider/Telephony.java
index 21cc1a2..1dadaee 100644
--- a/telephony/java/android/provider/Telephony.java
+++ b/telephony/java/android/provider/Telephony.java
@@ -17,6 +17,7 @@
package android.provider;
import android.annotation.IntDef;
+import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
@@ -4277,6 +4278,7 @@
* @param subscriptionId the subscriptionId to receive updates on
* @return the Uri used to observe precise carrier identity changes
*/
+ @NonNull
public static Uri getPreciseCarrierIdUriForSubscriptionId(int subscriptionId) {
return Uri.withAppendedPath(Uri.withAppendedPath(CONTENT_URI, "precise"),
String.valueOf(subscriptionId));
diff --git a/telephony/java/android/telephony/CellIdentityNr.java b/telephony/java/android/telephony/CellIdentityNr.java
index 856f081..19bc0ce 100644
--- a/telephony/java/android/telephony/CellIdentityNr.java
+++ b/telephony/java/android/telephony/CellIdentityNr.java
@@ -81,7 +81,8 @@
/**
* Get the NR Cell Identity.
*
- * @return The NR Cell Identity in range [0, 68719476735] or Long.MAX_VALUE if unknown.
+ * @return The 36-bit NR Cell Identity in range [0, 68719476735] or
+ * {@link CellInfo#UNAVAILABLE_LONG} if unknown.
*/
public long getNci() {
return mNci;
diff --git a/telephony/java/android/telephony/CellInfo.java b/telephony/java/android/telephony/CellInfo.java
index 8ce5c54..c7853f1 100644
--- a/telephony/java/android/telephony/CellInfo.java
+++ b/telephony/java/android/telephony/CellInfo.java
@@ -40,6 +40,11 @@
public static final int UNAVAILABLE = Integer.MAX_VALUE;
/**
+ * This value indicates that the long field is unreported.
+ */
+ public static final long UNAVAILABLE_LONG = Long.MAX_VALUE;
+
+ /**
* Cell identity type
* @hide
*/
diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java
index da92730..24319a2 100644
--- a/telephony/java/android/telephony/PhoneStateListener.java
+++ b/telephony/java/android/telephony/PhoneStateListener.java
@@ -606,7 +606,7 @@
@RequiresPermission((android.Manifest.permission.READ_PRECISE_PHONE_STATE))
@SystemApi
public void onPreciseDataConnectionStateChanged(
- PreciseDataConnectionState dataConnectionState) {
+ @NonNull PreciseDataConnectionState dataConnectionState) {
// default implementation empty
}
diff --git a/telephony/java/android/telephony/PreciseDataConnectionState.java b/telephony/java/android/telephony/PreciseDataConnectionState.java
index 57a1826..d593678 100644
--- a/telephony/java/android/telephony/PreciseDataConnectionState.java
+++ b/telephony/java/android/telephony/PreciseDataConnectionState.java
@@ -16,6 +16,8 @@
package android.telephony;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.UnsupportedAppUsage;
import android.net.LinkProperties;
@@ -25,6 +27,7 @@
import java.util.Objects;
+
/**
* Contains precise data connection state.
*
@@ -119,6 +122,7 @@
/**
* Returns APN {@link ApnSetting} of this data connection.
*/
+ @Nullable
public String getDataConnectionApn() {
return mAPN;
}
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index 52cab55..635e4fe 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -149,6 +149,7 @@
* {@link Uri#withAppendedPath(Uri, String)}.
* @hide
*/
+ @NonNull
@SystemApi
public static final Uri WFC_ENABLED_CONTENT_URI = Uri.withAppendedPath(CONTENT_URI, "wfc");
@@ -167,6 +168,7 @@
* {@link Uri#withAppendedPath(Uri, String)}.
* @hide
*/
+ @NonNull
@SystemApi
public static final Uri ADVANCED_CALLING_ENABLED_CONTENT_URI = Uri.withAppendedPath(
CONTENT_URI, "advanced_calling");
@@ -184,6 +186,7 @@
* {@link Uri#withAppendedPath(Uri, String)}.
* @hide
*/
+ @NonNull
@SystemApi
public static final Uri WFC_MODE_CONTENT_URI = Uri.withAppendedPath(CONTENT_URI, "wfc_mode");
@@ -200,6 +203,7 @@
* {@link Uri#withAppendedPath(Uri, String)}.
* @hide
*/
+ @NonNull
@SystemApi
public static final Uri WFC_ROAMING_MODE_CONTENT_URI = Uri.withAppendedPath(
CONTENT_URI, "wfc_roaming_mode");
@@ -218,6 +222,7 @@
* {@link Uri#withAppendedPath(Uri, String)}.
* @hide
*/
+ @NonNull
@SystemApi
public static final Uri VT_ENABLED_CONTENT_URI = Uri.withAppendedPath(
CONTENT_URI, "vt_enabled");
@@ -235,6 +240,7 @@
* {@link Uri#withAppendedPath(Uri, String)}.
* @hide
*/
+ @NonNull
@SystemApi
public static final Uri WFC_ROAMING_ENABLED_CONTENT_URI = Uri.withAppendedPath(
CONTENT_URI, "wfc_roaming_enabled");
diff --git a/telephony/java/android/telephony/ims/ImsConferenceState.java b/telephony/java/android/telephony/ims/ImsConferenceState.java
index 66d2f8d..8af8cff 100644
--- a/telephony/java/android/telephony/ims/ImsConferenceState.java
+++ b/telephony/java/android/telephony/ims/ImsConferenceState.java
@@ -16,17 +16,18 @@
package android.telephony.ims;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.Set;
-
import android.annotation.SystemApi;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.telecom.Call;
import android.telecom.Connection;
+import android.telecom.Log;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Set;
/**
* Provides the conference information (defined in RFC 4575) for IMS conference call.
@@ -189,7 +190,7 @@
sb.append("<");
while (iterator.hasNext()) {
Entry<String, Bundle> entry = iterator.next();
- sb.append(entry.getKey());
+ sb.append(Log.pii(entry.getKey()));
sb.append(": ");
Bundle participantData = entry.getValue();
@@ -197,7 +198,7 @@
sb.append(key);
sb.append("=");
if (ENDPOINT.equals(key) || USER.equals(key)) {
- sb.append(android.telecom.Log.pii(participantData.get(key)));
+ sb.append(Log.pii(participantData.get(key)));
} else {
sb.append(participantData.get(key));
}
diff --git a/test-base/hiddenapi/Android.bp b/test-base/hiddenapi/Android.bp
new file mode 100644
index 0000000..c4e0fab
--- /dev/null
+++ b/test-base/hiddenapi/Android.bp
@@ -0,0 +1,29 @@
+//
+// Copyright (C) 2019 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.
+//
+
+// Provided solely to contribute information about which hidden parts of the android.test.base
+// library are used by apps. The source files are stubs of the actual files in ../src which use the
+// UnsupportedAppUsage annotation to tag those methods that are accessible via the hiddenapi.
+// Relies on the convention that modules with name <x>-hiddenapi provide hiddenapi information for
+// module <x> that is on the bootclasspath.
+java_library {
+ name: "android.test.base-hiddenapi",
+ compile_dex: true,
+
+ srcs: ["src/**/*.java"],
+
+ libs: ["android.test.base"],
+}
diff --git a/test-base/hiddenapi/src/android/test/AndroidTestCase.java b/test-base/hiddenapi/src/android/test/AndroidTestCase.java
new file mode 100644
index 0000000..2b9beb1
--- /dev/null
+++ b/test-base/hiddenapi/src/android/test/AndroidTestCase.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+package android.test;
+
+import android.annotation.UnsupportedAppUsage;
+import android.content.Context;
+
+import junit.framework.TestCase;
+
+/**
+ * @deprecated Stub only
+ */
+@SuppressWarnings({ "unchecked", "deprecation", "all" })
+@Deprecated
+public class AndroidTestCase extends TestCase {
+
+ /**
+ * Stub only
+ */
+ @UnsupportedAppUsage
+ public void setTestContext(Context context) {
+ throw new RuntimeException("Stub!");
+ }
+
+ /**
+ * Stub only
+ */
+ @UnsupportedAppUsage
+ public Context getTestContext() {
+ throw new RuntimeException("Stub!");
+ }
+}
diff --git a/test-base/hiddenapi/src/android/test/InstrumentationTestCase.java b/test-base/hiddenapi/src/android/test/InstrumentationTestCase.java
new file mode 100644
index 0000000..139cd18
--- /dev/null
+++ b/test-base/hiddenapi/src/android/test/InstrumentationTestCase.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+package android.test;
+
+import android.annotation.UnsupportedAppUsage;
+
+import junit.framework.TestCase;
+
+import java.lang.reflect.Method;
+
+/**
+ * @deprecated Stub only
+ */
+@SuppressWarnings({ "unchecked", "deprecation", "all" })
+@Deprecated
+public class InstrumentationTestCase extends TestCase {
+
+ /**
+ * Stub only
+ */
+ @UnsupportedAppUsage
+ private void runMethod(Method runMethod, int tolerance) throws Throwable {
+ throw new RuntimeException("Stub!");
+ }
+}
diff --git a/test-base/hiddenapi/src/junit/framework/TestCase.java b/test-base/hiddenapi/src/junit/framework/TestCase.java
new file mode 100644
index 0000000..5a54861
--- /dev/null
+++ b/test-base/hiddenapi/src/junit/framework/TestCase.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+package junit.framework;
+
+import android.annotation.UnsupportedAppUsage;
+
+/**
+ * Stub only
+ */
+@SuppressWarnings({ "unchecked", "deprecation", "all" })
+public abstract class TestCase extends Assert implements Test {
+
+ /**
+ * the name of the test case
+ */
+ @UnsupportedAppUsage
+ private String fName;
+
+ /**
+ * Stub only
+ */
+ public int countTestCases() {
+ throw new RuntimeException("Stub!");
+ }
+
+ /**
+ * Stub only
+ */
+ public void run(TestResult result) {
+ throw new RuntimeException("Stub!");
+ }
+}
diff --git a/test-base/hiddenapi/src/junit/framework/TestSuite.java b/test-base/hiddenapi/src/junit/framework/TestSuite.java
new file mode 100644
index 0000000..368c661
--- /dev/null
+++ b/test-base/hiddenapi/src/junit/framework/TestSuite.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+package junit.framework;
+
+import android.annotation.UnsupportedAppUsage;
+
+import java.lang.reflect.Method;
+
+/**
+ * Stub only
+ */
+@SuppressWarnings({ "unchecked", "deprecation", "all" })
+public class TestSuite implements Test {
+
+ /**
+ * Stub only
+ */
+ @UnsupportedAppUsage
+ private boolean isPublicTestMethod(Method m) {
+ throw new RuntimeException("Stub!");
+ }
+
+ /**
+ * Stub only
+ */
+ @UnsupportedAppUsage
+ private boolean isTestMethod(Method m) {
+ throw new RuntimeException("Stub!");
+ }
+
+ /**
+ * Stub only
+ */
+ public int countTestCases() {
+ throw new RuntimeException("Stub!");
+ }
+
+ /**
+ * Stub only
+ */
+ public void run(TestResult result) {
+ throw new RuntimeException("Stub!");
+ }
+}
diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java
index c126026..b460c90 100644
--- a/tests/net/java/com/android/server/ConnectivityServiceTest.java
+++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java
@@ -125,6 +125,7 @@
import android.net.NetworkRequest;
import android.net.NetworkSpecifier;
import android.net.NetworkStackClient;
+import android.net.NetworkState;
import android.net.NetworkUtils;
import android.net.ProxyInfo;
import android.net.RouteInfo;
@@ -156,6 +157,7 @@
import android.util.Log;
import com.android.internal.net.VpnConfig;
+import com.android.internal.net.VpnInfo;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.WakeupMessage;
import com.android.internal.util.test.BroadcastInterceptingContext;
@@ -4273,48 +4275,91 @@
mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR);
mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI);
- Network[] onlyCell = new Network[]{mCellNetworkAgent.getNetwork()};
- Network[] onlyWifi = new Network[]{mWiFiNetworkAgent.getNetwork()};
+ Network[] onlyCell = new Network[] {mCellNetworkAgent.getNetwork()};
+ Network[] onlyWifi = new Network[] {mWiFiNetworkAgent.getNetwork()};
+
+ LinkProperties cellLp = new LinkProperties();
+ cellLp.setInterfaceName(MOBILE_IFNAME);
+ LinkProperties wifiLp = new LinkProperties();
+ wifiLp.setInterfaceName(WIFI_IFNAME);
// Simple connection should have updated ifaces
mCellNetworkAgent.connect(false);
+ mCellNetworkAgent.sendLinkProperties(cellLp);
waitForIdle();
- verify(mStatsService, atLeastOnce()).forceUpdateIfaces(onlyCell);
+ verify(mStatsService, atLeastOnce())
+ .forceUpdateIfaces(
+ eq(onlyCell),
+ eq(new VpnInfo[0]),
+ any(NetworkState[].class),
+ eq(MOBILE_IFNAME));
reset(mStatsService);
// Default network switch should update ifaces.
mWiFiNetworkAgent.connect(false);
+ mWiFiNetworkAgent.sendLinkProperties(wifiLp);
waitForIdle();
- verify(mStatsService, atLeastOnce()).forceUpdateIfaces(onlyWifi);
+ assertEquals(wifiLp, mService.getActiveLinkProperties());
+ verify(mStatsService, atLeastOnce())
+ .forceUpdateIfaces(
+ eq(onlyWifi),
+ eq(new VpnInfo[0]),
+ any(NetworkState[].class),
+ eq(WIFI_IFNAME));
reset(mStatsService);
// Disconnect should update ifaces.
mWiFiNetworkAgent.disconnect();
waitForIdle();
- verify(mStatsService, atLeastOnce()).forceUpdateIfaces(onlyCell);
+ verify(mStatsService, atLeastOnce())
+ .forceUpdateIfaces(
+ eq(onlyCell),
+ eq(new VpnInfo[0]),
+ any(NetworkState[].class),
+ eq(MOBILE_IFNAME));
reset(mStatsService);
// Metered change should update ifaces
mCellNetworkAgent.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED);
waitForIdle();
- verify(mStatsService, atLeastOnce()).forceUpdateIfaces(onlyCell);
+ verify(mStatsService, atLeastOnce())
+ .forceUpdateIfaces(
+ eq(onlyCell),
+ eq(new VpnInfo[0]),
+ any(NetworkState[].class),
+ eq(MOBILE_IFNAME));
reset(mStatsService);
mCellNetworkAgent.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED);
waitForIdle();
- verify(mStatsService, atLeastOnce()).forceUpdateIfaces(onlyCell);
+ verify(mStatsService, atLeastOnce())
+ .forceUpdateIfaces(
+ eq(onlyCell),
+ eq(new VpnInfo[0]),
+ any(NetworkState[].class),
+ eq(MOBILE_IFNAME));
reset(mStatsService);
// Captive portal change shouldn't update ifaces
mCellNetworkAgent.addCapability(NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL);
waitForIdle();
- verify(mStatsService, never()).forceUpdateIfaces(onlyCell);
+ verify(mStatsService, never())
+ .forceUpdateIfaces(
+ eq(onlyCell),
+ eq(new VpnInfo[0]),
+ any(NetworkState[].class),
+ eq(MOBILE_IFNAME));
reset(mStatsService);
// Roaming change should update ifaces
mCellNetworkAgent.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING);
waitForIdle();
- verify(mStatsService, atLeastOnce()).forceUpdateIfaces(onlyCell);
+ verify(mStatsService, atLeastOnce())
+ .forceUpdateIfaces(
+ eq(onlyCell),
+ eq(new VpnInfo[0]),
+ any(NetworkState[].class),
+ eq(MOBILE_IFNAME));
reset(mStatsService);
}
diff --git a/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java b/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java
index f89f303..d91d3eb 100644
--- a/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java
+++ b/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java
@@ -70,7 +70,6 @@
import android.content.Context;
import android.content.Intent;
import android.net.DataUsageRequest;
-import android.net.IConnectivityManager;
import android.net.INetworkManagementEventObserver;
import android.net.INetworkStatsSession;
import android.net.LinkProperties;
@@ -163,7 +162,6 @@
private @Mock INetworkManagementService mNetManager;
private @Mock NetworkStatsSettings mSettings;
- private @Mock IConnectivityManager mConnManager;
private @Mock IBinder mBinder;
private @Mock AlarmManager mAlarmManager;
private HandlerThread mHandlerThread;
@@ -205,7 +203,6 @@
Handler.Callback callback = new NetworkStatsService.HandlerCallback(mService);
mHandler = new Handler(mHandlerThread.getLooper(), callback);
mService.setHandler(mHandler, callback);
- mService.bindConnectivityManager(mConnManager);
mElapsedRealtime = 0L;
@@ -234,7 +231,6 @@
mNetManager = null;
mSettings = null;
- mConnManager = null;
mSession.close();
mService = null;
@@ -245,12 +241,12 @@
// pretend that wifi network comes online; service should ask about full
// network state, and poll any existing interfaces before updating.
expectDefaultSettings();
- expectNetworkState(buildWifiState());
+ NetworkState[] states = new NetworkState[] {buildWifiState()};
expectNetworkStatsSummary(buildEmptyStats());
expectNetworkStatsUidDetail(buildEmptyStats());
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_WIFI);
+ mService.forceUpdateIfaces(NETWORKS_WIFI, new VpnInfo[0], states, getActiveIface(states));
// verify service has empty history for wifi
assertNetworkTotal(sTemplateWifi, 0L, 0L, 0L, 0L, 0);
@@ -289,12 +285,12 @@
// pretend that wifi network comes online; service should ask about full
// network state, and poll any existing interfaces before updating.
expectDefaultSettings();
- expectNetworkState(buildWifiState());
+ NetworkState[] states = new NetworkState[] {buildWifiState()};
expectNetworkStatsSummary(buildEmptyStats());
expectNetworkStatsUidDetail(buildEmptyStats());
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_WIFI);
+ mService.forceUpdateIfaces(NETWORKS_WIFI, new VpnInfo[0], states, getActiveIface(states));
// verify service has empty history for wifi
assertNetworkTotal(sTemplateWifi, 0L, 0L, 0L, 0L, 0);
@@ -363,12 +359,12 @@
// pretend that wifi network comes online; service should ask about full
// network state, and poll any existing interfaces before updating.
expectSettings(0L, HOUR_IN_MILLIS, WEEK_IN_MILLIS);
- expectNetworkState(buildWifiState());
+ NetworkState[] states = new NetworkState[] {buildWifiState()};
expectNetworkStatsSummary(buildEmptyStats());
expectNetworkStatsUidDetail(buildEmptyStats());
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_WIFI);
+ mService.forceUpdateIfaces(NETWORKS_WIFI, new VpnInfo[0], states, getActiveIface(states));
// modify some number on wifi, and trigger poll event
@@ -405,12 +401,12 @@
public void testUidStatsAcrossNetworks() throws Exception {
// pretend first mobile network comes online
expectDefaultSettings();
- expectNetworkState(buildMobile3gState(IMSI_1));
+ NetworkState[] states = new NetworkState[] {buildMobile3gState(IMSI_1)};
expectNetworkStatsSummary(buildEmptyStats());
expectNetworkStatsUidDetail(buildEmptyStats());
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_MOBILE);
+ mService.forceUpdateIfaces(NETWORKS_MOBILE, new VpnInfo[0], states, getActiveIface(states));
// create some traffic on first network
@@ -437,7 +433,7 @@
// disappearing, to verify we don't count backwards.
incrementCurrentTime(HOUR_IN_MILLIS);
expectDefaultSettings();
- expectNetworkState(buildMobile3gState(IMSI_2));
+ states = new NetworkState[] {buildMobile3gState(IMSI_2)};
expectNetworkStatsSummary(new NetworkStats(getElapsedRealtime(), 1)
.addIfaceValues(TEST_IFACE, 2048L, 16L, 512L, 4L));
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 3)
@@ -446,7 +442,7 @@
.addValues(TEST_IFACE, UID_BLUE, SET_DEFAULT, TAG_NONE, 512L, 4L, 0L, 0L, 0L));
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_MOBILE);
+ mService.forceUpdateIfaces(NETWORKS_MOBILE, new VpnInfo[0], states, getActiveIface(states));
forcePollAndWaitForIdle();
@@ -481,12 +477,12 @@
public void testUidRemovedIsMoved() throws Exception {
// pretend that network comes online
expectDefaultSettings();
- expectNetworkState(buildWifiState());
+ NetworkState[] states = new NetworkState[] {buildWifiState()};
expectNetworkStatsSummary(buildEmptyStats());
expectNetworkStatsUidDetail(buildEmptyStats());
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_WIFI);
+ mService.forceUpdateIfaces(NETWORKS_WIFI, new VpnInfo[0], states, getActiveIface(states));
// create some traffic
@@ -540,12 +536,12 @@
public void testUid3g4gCombinedByTemplate() throws Exception {
// pretend that network comes online
expectDefaultSettings();
- expectNetworkState(buildMobile3gState(IMSI_1));
+ NetworkState[] states = new NetworkState[] {buildMobile3gState(IMSI_1)};
expectNetworkStatsSummary(buildEmptyStats());
expectNetworkStatsUidDetail(buildEmptyStats());
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_MOBILE);
+ mService.forceUpdateIfaces(NETWORKS_MOBILE, new VpnInfo[0], states, getActiveIface(states));
// create some traffic
@@ -566,14 +562,14 @@
// now switch over to 4g network
incrementCurrentTime(HOUR_IN_MILLIS);
expectDefaultSettings();
- expectNetworkState(buildMobile4gState(TEST_IFACE2));
+ states = new NetworkState[] {buildMobile4gState(TEST_IFACE2)};
expectNetworkStatsSummary(buildEmptyStats());
expectNetworkStatsUidDetail(new NetworkStats(getElapsedRealtime(), 1)
.addValues(TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE, 1024L, 8L, 1024L, 8L, 0L)
.addValues(TEST_IFACE, UID_RED, SET_DEFAULT, 0xF00D, 512L, 4L, 512L, 4L, 0L));
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_MOBILE);
+ mService.forceUpdateIfaces(NETWORKS_MOBILE, new VpnInfo[0], states, getActiveIface(states));
forcePollAndWaitForIdle();
@@ -598,12 +594,12 @@
public void testSummaryForAllUid() throws Exception {
// pretend that network comes online
expectDefaultSettings();
- expectNetworkState(buildWifiState());
+ NetworkState[] states = new NetworkState[] {buildWifiState()};
expectNetworkStatsSummary(buildEmptyStats());
expectNetworkStatsUidDetail(buildEmptyStats());
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_WIFI);
+ mService.forceUpdateIfaces(NETWORKS_WIFI, new VpnInfo[0], states, getActiveIface(states));
// create some traffic for two apps
@@ -657,12 +653,12 @@
public void testDetailedUidStats() throws Exception {
// pretend that network comes online
expectDefaultSettings();
- expectNetworkState(buildWifiState());
+ NetworkState[] states = new NetworkState[] {buildWifiState()};
expectNetworkStatsSummary(buildEmptyStats());
expectNetworkStatsUidDetail(buildEmptyStats());
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_WIFI);
+ mService.forceUpdateIfaces(NETWORKS_WIFI, new VpnInfo[0], states, getActiveIface(states));
NetworkStats.Entry entry1 = new NetworkStats.Entry(
TEST_IFACE, UID_RED, SET_DEFAULT, TAG_NONE, 50L, 5L, 50L, 5L, 0L);
@@ -700,13 +696,13 @@
stackedProp.setInterfaceName(stackedIface);
final NetworkState wifiState = buildWifiState();
wifiState.linkProperties.addStackedLink(stackedProp);
- expectNetworkState(wifiState);
+ NetworkState[] states = new NetworkState[] {wifiState};
expectNetworkStatsSummary(buildEmptyStats());
expectNetworkStatsUidDetail(buildEmptyStats());
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_WIFI);
+ mService.forceUpdateIfaces(NETWORKS_WIFI, new VpnInfo[0], states, getActiveIface(states));
NetworkStats.Entry uidStats = new NetworkStats.Entry(
TEST_IFACE, UID_BLUE, SET_DEFAULT, 0xF00D, 1024L, 8L, 512L, 4L, 0L);
@@ -745,12 +741,12 @@
public void testForegroundBackground() throws Exception {
// pretend that network comes online
expectDefaultSettings();
- expectNetworkState(buildWifiState());
+ NetworkState[] states = new NetworkState[] {buildWifiState()};
expectNetworkStatsSummary(buildEmptyStats());
expectNetworkStatsUidDetail(buildEmptyStats());
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_WIFI);
+ mService.forceUpdateIfaces(NETWORKS_WIFI, new VpnInfo[0], states, getActiveIface(states));
// create some initial traffic
@@ -803,12 +799,12 @@
public void testMetered() throws Exception {
// pretend that network comes online
expectDefaultSettings();
- expectNetworkState(buildWifiState(true /* isMetered */));
+ NetworkState[] states = new NetworkState[] {buildWifiState(true /* isMetered */)};
expectNetworkStatsSummary(buildEmptyStats());
expectNetworkStatsUidDetail(buildEmptyStats());
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_WIFI);
+ mService.forceUpdateIfaces(NETWORKS_WIFI, new VpnInfo[0], states, getActiveIface(states));
// create some initial traffic
@@ -843,12 +839,13 @@
public void testRoaming() throws Exception {
// pretend that network comes online
expectDefaultSettings();
- expectNetworkState(buildMobile3gState(IMSI_1, true /* isRoaming */));
+ NetworkState[] states =
+ new NetworkState[] {buildMobile3gState(IMSI_1, true /* isRoaming */)};
expectNetworkStatsSummary(buildEmptyStats());
expectNetworkStatsUidDetail(buildEmptyStats());
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_MOBILE);
+ mService.forceUpdateIfaces(NETWORKS_MOBILE, new VpnInfo[0], states, getActiveIface(states));
// Create some traffic
@@ -882,12 +879,12 @@
public void testTethering() throws Exception {
// pretend first mobile network comes online
expectDefaultSettings();
- expectNetworkState(buildMobile3gState(IMSI_1));
+ NetworkState[] states = new NetworkState[] {buildMobile3gState(IMSI_1)};
expectNetworkStatsSummary(buildEmptyStats());
expectNetworkStatsUidDetail(buildEmptyStats());
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_MOBILE);
+ mService.forceUpdateIfaces(NETWORKS_MOBILE, new VpnInfo[0], states, getActiveIface(states));
// create some tethering traffic
@@ -925,12 +922,12 @@
// pretend that wifi network comes online; service should ask about full
// network state, and poll any existing interfaces before updating.
expectDefaultSettings();
- expectNetworkState(buildWifiState());
+ NetworkState[] states = new NetworkState[] {buildWifiState()};
expectNetworkStatsSummary(buildEmptyStats());
expectNetworkStatsUidDetail(buildEmptyStats());
expectBandwidthControlCheck();
- mService.forceUpdateIfaces(NETWORKS_WIFI);
+ mService.forceUpdateIfaces(NETWORKS_WIFI, new VpnInfo[0], states, getActiveIface(states));
// verify service has empty history for wifi
assertNetworkTotal(sTemplateWifi, 0L, 0L, 0L, 0L, 0);
@@ -1077,11 +1074,11 @@
expectBandwidthControlCheck();
}
- private void expectNetworkState(NetworkState... state) throws Exception {
- when(mConnManager.getAllNetworkState()).thenReturn(state);
-
- final LinkProperties linkProp = state.length > 0 ? state[0].linkProperties : null;
- when(mConnManager.getActiveLinkProperties()).thenReturn(linkProp);
+ private String getActiveIface(NetworkState... states) throws Exception {
+ if (states == null || states.length == 0 || states[0].linkProperties == null) {
+ return null;
+ }
+ return states[0].linkProperties.getInterfaceName();
}
private void expectNetworkStatsSummary(NetworkStats summary) throws Exception {
@@ -1090,8 +1087,6 @@
private void expectNetworkStatsSummary(NetworkStats summary, NetworkStats tetherStats)
throws Exception {
- when(mConnManager.getAllVpnInfo()).thenReturn(new VpnInfo[0]);
-
expectNetworkStatsTethering(STATS_PER_IFACE, tetherStats);
expectNetworkStatsSummaryDev(summary.clone());
expectNetworkStatsSummaryXt(summary.clone());
diff --git a/tools/apilint/apilint.py b/tools/apilint/apilint.py
index ef405e4..295e3de 100644
--- a/tools/apilint/apilint.py
+++ b/tools/apilint/apilint.py
@@ -79,6 +79,7 @@
self.value = raw[3].strip(';"')
else:
self.value = None
+ self.annotations = []
self.ident = "-".join((self.typ, self.name, self.value or ""))
@@ -88,6 +89,18 @@
def __repr__(self):
return self.raw
+
+class Argument(object):
+
+ __slots__ = ["type", "annotations", "name", "default"]
+
+ def __init__(self, type):
+ self.type = type
+ self.annotations = []
+ self.name = None
+ self.default = None
+
+
class Method():
def __init__(self, clazz, line, raw, blame, sig_format = 1):
self.clazz = clazz
@@ -118,21 +131,24 @@
self.name = raw[1]
# parse args
- self.args = []
+ self.detailed_args = []
for arg in re.split(",\s*", raw_args):
arg = re.split("\s", arg)
# ignore annotations for now
arg = [ a for a in arg if not a.startswith("@") ]
if len(arg[0]) > 0:
- self.args.append(arg[0])
+ self.detailed_args.append(Argument(arg[0]))
# parse throws
self.throws = []
for throw in re.split(",\s*", raw_throws):
self.throws.append(throw)
+
+ self.annotations = []
else:
raise ValueError("Unknown signature format: " + sig_format)
+ self.args = map(lambda a: a.type, self.detailed_args)
self.ident = "-".join((self.typ, self.name, "-".join(self.args)))
def sig_matches(self, typ, name, args):
@@ -312,10 +328,10 @@
method.split = []
kind = self.parse_one_of("ctor", "method")
method.split.append(kind)
- annotations = self.parse_annotations()
+ method.annotations = self.parse_annotations()
method.split.extend(self.parse_modifiers())
self.parse_matching_paren("<", ">")
- if "@Deprecated" in annotations:
+ if "@Deprecated" in method.annotations:
method.split.append("deprecated")
if kind == "ctor":
method.typ = "ctor"
@@ -325,7 +341,7 @@
method.name = self.parse_name()
method.split.append(method.name)
self.parse_token("(")
- method.args = self.parse_args()
+ method.detailed_args = self.parse_args()
self.parse_token(")")
method.throws = self.parse_throws()
if "@interface" in method.clazz.split:
@@ -360,8 +376,8 @@
def parse_into_field(self, field):
kind = self.parse_one_of(*V2LineParser.FIELD_KINDS)
field.split = [kind]
- annotations = self.parse_annotations()
- if "@Deprecated" in annotations:
+ field.annotations = self.parse_annotations()
+ if "@Deprecated" in field.annotations:
field.split.append("deprecated")
field.split.extend(self.parse_modifiers())
field.typ = self.parse_type()
@@ -488,15 +504,16 @@
def parse_arg(self):
self.parse_if("vararg") # kotlin vararg
- self.parse_annotations()
- type = self.parse_arg_type()
+ annotations = self.parse_annotations()
+ arg = Argument(self.parse_arg_type())
+ arg.annotations = annotations
l = self.lookahead()
if l != "," and l != ")":
if self.lookahead() != '=':
- self.parse_token() # kotlin argument name
+ arg.name = self.parse_token() # kotlin argument name
if self.parse_if('='): # kotlin default value
- self.parse_expression()
- return type
+ arg.default = self.parse_expression()
+ return arg
def parse_expression(self):
while not self.lookahead() in [')', ',', ';']:
@@ -593,7 +610,7 @@
blame = None
sig_format = 1
- re_blame = re.compile("^([a-z0-9]{7,}) \(<([^>]+)>.+?\) (.+?)$")
+ re_blame = re.compile(r"^(\^?[a-z0-9]{7,}) \(<([^>]+)>.+?\) (.+?)$")
field_prefixes = map(lambda kind: " %s" % (kind,), V2LineParser.FIELD_KINDS)
def startsWithFieldPrefix(raw):
@@ -608,11 +625,13 @@
match = re_blame.match(raw)
if match is not None:
blame = match.groups()[0:2]
+ if blame[0].startswith("^"): # Outside of blame range
+ blame = None
raw = match.groups()[2]
else:
blame = None
- if line == 1 and raw.startswith("// Signature format: "):
+ if line == 1 and V2Tokenizer.SIGNATURE_PREFIX in raw:
sig_format_string = raw[len(V2Tokenizer.SIGNATURE_PREFIX):]
if sig_format_string in ["2.0", "3.0"]:
sig_format = 2
@@ -1871,6 +1890,35 @@
if arg in discouraged:
warn(clazz, m, "FW12", "Should avoid odd sized primitives; use int instead")
+PRIMITIVES = {"void", "int", "float", "boolean", "short", "char", "byte", "long", "double"}
+
+def verify_nullability(clazz):
+ """Catches missing nullability annotations"""
+
+ for f in clazz.fields:
+ if f.value is not None and 'static' in f.split and 'final' in f.split:
+ continue # Nullability of constants can be inferred.
+ if f.typ not in PRIMITIVES and not has_nullability(f.annotations):
+ error(clazz, f, "M12", "Field must be marked either @NonNull or @Nullable")
+
+ for c in clazz.ctors:
+ verify_nullability_args(clazz, c)
+
+ for m in clazz.methods:
+ if m.name == "writeToParcel" or m.name == "onReceive":
+ continue # Parcelable.writeToParcel() and BroadcastReceiver.onReceive() are not yet annotated
+
+ if m.typ not in PRIMITIVES and not has_nullability(m.annotations):
+ error(clazz, m, "M12", "Return value must be marked either @NonNull or @Nullable")
+ verify_nullability_args(clazz, m)
+
+def verify_nullability_args(clazz, m):
+ for i, arg in enumerate(m.detailed_args):
+ if arg.type not in PRIMITIVES and not has_nullability(arg.annotations):
+ error(clazz, m, "M12", "Argument %d must be marked either @NonNull or @Nullable" % (i+1,))
+
+def has_nullability(annotations):
+ return "@NonNull" in annotations or "@Nullable" in annotations
def verify_singleton(clazz):
"""Catch singleton objects with constructors."""
@@ -1959,6 +2007,7 @@
verify_pfd(clazz)
verify_numbers(clazz)
verify_singleton(clazz)
+ verify_nullability(clazz)
def examine_stream(stream, base_stream=None, in_classes_with_base=[], out_classes_with_base=None):
diff --git a/tools/apilint/apilint_test.py b/tools/apilint/apilint_test.py
index c10ef15..f34492d 100644
--- a/tools/apilint/apilint_test.py
+++ b/tools/apilint/apilint_test.py
@@ -88,20 +88,22 @@
faulty_current_txt = """
+// Signature format: 2.0
package android.app {
public final class Activity {
}
public final class WallpaperColors implements android.os.Parcelable {
- ctor public WallpaperColors(android.os.Parcel);
+ ctor public WallpaperColors(@NonNull android.os.Parcel);
method public int describeContents();
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.app.WallpaperColors> CREATOR;
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.app.WallpaperColors> CREATOR;
}
}
-""".split('\n')
+""".strip().split('\n')
ok_current_txt = """
+// Signature format: 2.0
package android.app {
public final class Activity {
}
@@ -109,19 +111,20 @@
public final class WallpaperColors implements android.os.Parcelable {
ctor public WallpaperColors();
method public int describeContents();
- method public void writeToParcel(android.os.Parcel, int);
- field public static final android.os.Parcelable.Creator<android.app.WallpaperColors> CREATOR;
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.app.WallpaperColors> CREATOR;
}
}
-""".split('\n')
+""".strip().split('\n')
system_current_txt = """
+// Signature format: 2.0
package android.app {
public final class WallpaperColors implements android.os.Parcelable {
method public int getSomething();
}
}
-""".split('\n')
+""".strip().split('\n')
diff --git a/tools/hiddenapi/exclude.sh b/tools/hiddenapi/exclude.sh
index 4ffcf68..18c4054 100755
--- a/tools/hiddenapi/exclude.sh
+++ b/tools/hiddenapi/exclude.sh
@@ -9,6 +9,7 @@
LIBCORE_PACKAGES="\
android.icu \
android.system \
+ android.test \
com.android.bouncycastle \
com.android.conscrypt \
com.android.i18n.phonenumbers \
@@ -17,6 +18,7 @@
dalvik \
java \
javax \
+ junit \
libcore \
org.apache.harmony \
org.json \