diff options
273 files changed, 2558 insertions, 1751 deletions
diff --git a/Android.bp b/Android.bp index ee593aac39ad..383f58f31cf0 100644 --- a/Android.bp +++ b/Android.bp @@ -550,6 +550,7 @@ java_defaults { "telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl", "telephony/java/com/android/internal/telephony/ISms.aidl", "telephony/java/com/android/internal/telephony/ISub.aidl", + "telephony/java/com/android/internal/telephony/IAns.aidl", "telephony/java/com/android/internal/telephony/ITelephony.aidl", "telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl", "telephony/java/com/android/internal/telephony/IWapPushManager.aidl", @@ -600,6 +601,7 @@ java_defaults { ":netd_aidl", ":vold_aidl", ":installd_aidl", + ":dumpstate_aidl", "lowpan/java/android/net/lowpan/ILowpanEnergyScanCallback.aidl", "lowpan/java/android/net/lowpan/ILowpanNetScanCallback.aidl", @@ -646,6 +648,7 @@ java_defaults { include_dirs: [ "system/update_engine/binder_bindings", "frameworks/native/aidl/binder", + "frameworks/native/cmds/dumpstate/binder", "frameworks/av/camera/aidl", "frameworks/av/media/libaudioclient/aidl", "frameworks/native/aidl/gui", @@ -668,9 +671,6 @@ java_defaults { no_framework_libs: true, libs: [ - "conscrypt", - "okhttp", - "bouncycastle", "ext", ], @@ -691,6 +691,7 @@ java_defaults { "android.hardware.radio-V1.0-java", "android.hardware.radio-V1.3-java", "android.hardware.usb.gadget-V1.0-java", + "netd_aidl_interface-java", ], // Loaded with System.loadLibrary by android.view.textclassifier @@ -1075,14 +1076,13 @@ framework_docs_args = "-android -manifest $(location core/res/AndroidManifest.xm "-federationapi SupportLib $(location current/support-api.txt) " framework_docs_only_args = " -android -manifest $(location core/res/AndroidManifest.xml) " + + "-werror -lerror -hide 111 -hide 113 -hide 125 -hide 126 -hide 127 -hide 128 " + "-overview $(location core/java/overview.html) " + // Federate Support Library references against local API file. "-federate SupportLib https://developer.android.com " + "-federationapi SupportLib $(location current/support-api.txt) " framework_docs_only_libs = [ - "conscrypt", - "bouncycastle", "voip-common", "android.test.mock", "android-support-annotations", @@ -1162,7 +1162,8 @@ stubs_defaults { doc_defaults { name: "framework-docs-default", - libs: framework_docs_only_libs, + libs: framework_docs_only_libs + + ["stub-annotations"], html_dirs: [ "docs/html", ], @@ -1559,7 +1560,6 @@ filegroup { "core/java/org/apache/http/params/CoreConnectionPNames.java", "core/java/org/apache/http/params/HttpConnectionParams.java", "core/java/org/apache/http/params/HttpParams.java", - "core/java/android/net/http/HttpResponseCache.java", "core/java/android/net/http/SslCertificate.java", "core/java/android/net/http/SslError.java", "core/java/com/android/internal/util/HexDump.java", diff --git a/Android.mk b/Android.mk index d33307425968..ba153ee76b0a 100644 --- a/Android.mk +++ b/Android.mk @@ -87,6 +87,7 @@ $(INTERNAL_PLATFORM_HIDDENAPI_WHITELIST): \ frameworks/base/tools/hiddenapi/generate_hiddenapi_lists.py \ frameworks/base/config/hiddenapi-light-greylist.txt \ frameworks/base/config/hiddenapi-vendor-list.txt \ + frameworks/base/config/hiddenapi-max-sdk-p-blacklist.txt \ frameworks/base/config/hiddenapi-force-blacklist.txt \ $(INTERNAL_PLATFORM_HIDDENAPI_PUBLIC_LIST) \ $(INTERNAL_PLATFORM_HIDDENAPI_PRIVATE_LIST) \ @@ -98,6 +99,7 @@ $(INTERNAL_PLATFORM_HIDDENAPI_WHITELIST): \ --input-greylists \ frameworks/base/config/hiddenapi-light-greylist.txt \ frameworks/base/config/hiddenapi-vendor-list.txt \ + frameworks/base/config/hiddenapi-max-sdk-p-blacklist.txt \ <(comm -12 <(sort $(INTERNAL_PLATFORM_REMOVED_DEX_API_FILE)) \ $(INTERNAL_PLATFORM_HIDDENAPI_PRIVATE_LIST)) \ $(PRIVATE_GREYLIST_INPUTS) \ diff --git a/CleanSpec.mk b/CleanSpec.mk index 2247e43758d7..6deda0caa9aa 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -247,6 +247,7 @@ $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/statsd $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/com.android.mediadrm.signer.jar) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/com.android.location.provider.jar) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/com.android.future.usb.accessory.jar) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/com.android.media.remotedisplay.jar) # ****************************************************************** # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST ABOVE THIS BANNER # ****************************************************************** diff --git a/api/current.txt b/api/current.txt index bafd4711cca3..aca5e5194290 100755 --- a/api/current.txt +++ b/api/current.txt @@ -42637,6 +42637,7 @@ package android.telephony { method public static int getDefaultSubscriptionId(); method public static int getDefaultVoiceSubscriptionId(); method public static int[] getSubscriptionIds(int); + method public java.util.List<android.telephony.SubscriptionInfo> getOpportunisticSubscriptions(int); method public java.util.List<android.telephony.SubscriptionPlan> getSubscriptionPlans(int); method public boolean isActiveSubscriptionId(int); method public boolean isNetworkRoaming(int); diff --git a/api/system-current.txt b/api/system-current.txt index 89ac7210de46..57f9efab3f5b 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -120,6 +120,7 @@ package android { field public static final java.lang.String MOUNT_FORMAT_FILESYSTEMS = "android.permission.MOUNT_FORMAT_FILESYSTEMS"; field public static final java.lang.String MOUNT_UNMOUNT_FILESYSTEMS = "android.permission.MOUNT_UNMOUNT_FILESYSTEMS"; field public static final java.lang.String MOVE_PACKAGE = "android.permission.MOVE_PACKAGE"; + field public static final java.lang.String NETWORK_SETUP_WIZARD = "android.permission.NETWORK_SETUP_WIZARD"; field public static final java.lang.String NOTIFICATION_DURING_SETUP = "android.permission.NOTIFICATION_DURING_SETUP"; field public static final java.lang.String NOTIFY_TV_INPUTS = "android.permission.NOTIFY_TV_INPUTS"; field public static final java.lang.String OBSERVE_APP_USAGE = "android.permission.OBSERVE_APP_USAGE"; @@ -3074,6 +3075,7 @@ package android.net { public class ConnectivityManager { method public java.lang.String getCaptivePortalServerUrl(); method public boolean isTetheringSupported(); + method public void setAirplaneMode(boolean); method public void startTethering(int, boolean, android.net.ConnectivityManager.OnStartTetheringCallback); method public void startTethering(int, boolean, android.net.ConnectivityManager.OnStartTetheringCallback, android.os.Handler); method public void stopTethering(int); @@ -5095,6 +5097,7 @@ package android.telephony { method public int getRejectCause(); method public int getTransportType(); method public boolean isEmergencyEnabled(); + method public boolean isRoaming(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.telephony.NetworkRegistrationState> CREATOR; field public static final int DOMAIN_CS = 1; // 0x1 @@ -5182,6 +5185,8 @@ package android.telephony { method public void setSubscriptionPlans(int, java.util.List<android.telephony.SubscriptionPlan>); field public static final java.lang.String ACTION_MANAGE_SUBSCRIPTION_PLANS = "android.telephony.action.MANAGE_SUBSCRIPTION_PLANS"; field public static final java.lang.String ACTION_REFRESH_SUBSCRIPTION_PLANS = "android.telephony.action.REFRESH_SUBSCRIPTION_PLANS"; + field public static final android.net.Uri ENHANCED_4G_ENABLED_CONTENT_URI; + field public static final android.net.Uri WFC_ENABLED_CONTENT_URI; } public final class SubscriptionPlan implements android.os.Parcelable { diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index c4824c084370..e12b665d1505 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -120,6 +120,8 @@ message Atom { AppCrashOccurred app_crash_occurred = 78; ANROccurred anr_occurred = 79; WTFOccurred wtf_occurred = 80; + PhoneServiceStateChanged phone_service_state_changed = 94; + PhoneStateChanged phone_state_changed = 95; LowMemReported low_mem_reported = 81; @@ -1137,6 +1139,33 @@ message PhoneSignalStrengthChanged { optional android.telephony.SignalStrengthEnum signal_strength = 1; } + +/** + * Logs when the phone state, sim state or signal strength changes + * + * Logged from: + * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java + */ +message PhoneServiceStateChanged { + optional android.telephony.ServiceStateEnum state = 1; + optional android.telephony.SimStateEnum sim_state = 2; + optional android.telephony.SignalStrengthEnum signal_strength = 3; +} + +/** + * Logs when the phone becomes on or off. + * + * Logged from: + * frameworks/base/core/java/com/android/internal/os/TelephonyRegistry.java + */ +message PhoneStateChanged { + enum State { + OFF = 0; + ON = 1; + } + optional State state = 1; +} + /** * Logs that a setting was updated. * Logged from: diff --git a/cmds/statsd/src/hash.cpp b/cmds/statsd/src/hash.cpp index c501c9f818b9..543a748adedb 100644 --- a/cmds/statsd/src/hash.cpp +++ b/cmds/statsd/src/hash.cpp @@ -16,6 +16,10 @@ #include "hash.h" +#ifndef FALLTHROUGH_INTENDED +#define FALLTHROUGH_INTENDED [[fallthrough]] +#endif + namespace android { namespace os { namespace statsd { @@ -67,8 +71,10 @@ uint32_t Hash32(const char *data, size_t n, uint32_t seed) { switch (n) { case 3: h ^= ByteAs32(data[2]) << 16; + FALLTHROUGH_INTENDED; case 2: h ^= ByteAs32(data[1]) << 8; + FALLTHROUGH_INTENDED; case 1: h ^= ByteAs32(data[0]); h *= m; @@ -104,16 +110,22 @@ uint64_t Hash64(const char* data, size_t n, uint64_t seed) { switch (n) { case 7: h ^= ByteAs64(data[6]) << 48; + FALLTHROUGH_INTENDED; case 6: h ^= ByteAs64(data[5]) << 40; + FALLTHROUGH_INTENDED; case 5: h ^= ByteAs64(data[4]) << 32; + FALLTHROUGH_INTENDED; case 4: h ^= ByteAs64(data[3]) << 24; + FALLTHROUGH_INTENDED; case 3: h ^= ByteAs64(data[2]) << 16; + FALLTHROUGH_INTENDED; case 2: h ^= ByteAs64(data[1]) << 8; + FALLTHROUGH_INTENDED; case 1: h ^= ByteAs64(data[0]); h *= m; diff --git a/config/hiddenapi-light-greylist.txt b/config/hiddenapi-light-greylist.txt index fbf5b5288928..dc399881a34b 100644 --- a/config/hiddenapi-light-greylist.txt +++ b/config/hiddenapi-light-greylist.txt @@ -573,7 +573,6 @@ Landroid/net/IConnectivityManager;->getTetherableWifiRegexs()[Ljava/lang/String; Landroid/net/IConnectivityManager;->getTetheredIfaces()[Ljava/lang/String; Landroid/net/IConnectivityManager;->getTetheringErroredIfaces()[Ljava/lang/String; Landroid/net/IConnectivityManager;->reportInetCondition(II)V -Landroid/net/IConnectivityManager;->setAirplaneMode(Z)V Landroid/net/IConnectivityManager;->startLegacyVpn(Lcom/android/internal/net/VpnProfile;)V Landroid/net/INetworkManagementEventObserver$Stub;-><init>()V Landroid/net/INetworkPolicyListener$Stub;-><init>()V @@ -2288,6 +2287,7 @@ Lcom/android/org/conscrypt/OpenSSLKey;->fromPrivateKey(Ljava/security/PrivateKey Lcom/android/org/conscrypt/OpenSSLKey;->getNativeRef()Lcom/android/org/conscrypt/NativeRef$EVP_PKEY; Lcom/android/org/conscrypt/OpenSSLKey;->getPublicKey()Ljava/security/PublicKey; Lcom/android/org/conscrypt/OpenSSLProvider;-><init>()V +Lcom/android/org/conscrypt/OpenSSLRandom;-><init>()V Lcom/android/org/conscrypt/OpenSSLSocketImpl;->getAlpnSelectedProtocol()[B Lcom/android/org/conscrypt/OpenSSLSocketImpl;->getChannelId()[B Lcom/android/org/conscrypt/OpenSSLSocketImpl;->getHostname()Ljava/lang/String; @@ -2860,6 +2860,7 @@ Ljavax/net/ssl/SSLServerSocketFactory;->defaultServerSocketFactory:Ljavax/net/ss Ljavax/net/ssl/SSLSocketFactory;->createSocket(Ljava/net/Socket;Ljava/io/InputStream;Z)Ljava/net/Socket; Ljavax/net/ssl/SSLSocketFactory;->defaultSocketFactory:Ljavax/net/ssl/SSLSocketFactory; Llibcore/icu/ICU;->addLikelySubtags(Ljava/util/Locale;)Ljava/util/Locale; +Llibcore/io/Libcore;->os:Llibcore/io/Os; Llibcore/io/Memory;->peekByte(J)B Llibcore/io/Memory;->peekByteArray(J[BII)V Llibcore/io/Memory;->peekInt(JZ)I diff --git a/config/hiddenapi-max-sdk-p-blacklist.txt b/config/hiddenapi-max-sdk-p-blacklist.txt new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/config/hiddenapi-max-sdk-p-blacklist.txt diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java index 73e98cd99f8f..d9e6fa203823 100644 --- a/core/java/android/bluetooth/BluetoothDevice.java +++ b/core/java/android/bluetooth/BluetoothDevice.java @@ -107,20 +107,6 @@ public final class BluetoothDevice implements Parcelable { "android.bluetooth.device.action.FOUND"; /** - * Broadcast Action: Remote device disappeared. - * <p>Sent when a remote device that was found in the last discovery is not - * found in the current discovery. - * <p>Always contains the extra field {@link #EXTRA_DEVICE}. - * <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive. - * - * @hide - */ - @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) - @UnsupportedAppUsage - public static final String ACTION_DISAPPEARED = - "android.bluetooth.device.action.DISAPPEARED"; - - /** * Broadcast Action: Bluetooth class of a remote device has changed. * <p>Always contains the extra fields {@link #EXTRA_DEVICE} and {@link * #EXTRA_CLASS}. diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 0fc55b4a7f09..2b6077040f13 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -3946,6 +3946,12 @@ public class Intent implements Parcelable, Cloneable { public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost"; /** + * An parcelable extra used with {@link #ACTION_SERVICE_STATE} representing the service state. + * @hide + */ + public static final String EXTRA_SERVICE_STATE = "android.intent.extra.SERVICE_STATE"; + + /** * The name of the extra used to define the text to be processed, as a * CharSequence. Note that this may be a styled CharSequence, so you must use * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it. diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 5cbd18538fd1..35db667922ca 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -5132,6 +5132,7 @@ public abstract class PackageManager { * @param packageName The name of the package to query * @throws IllegalArgumentException if the given package name is not installed */ + @Nullable public abstract String getInstallerPackageName(String packageName); /** diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java index caa99d5cb2a8..12c2149284b5 100644 --- a/core/java/android/hardware/camera2/CameraMetadata.java +++ b/core/java/android/hardware/camera2/CameraMetadata.java @@ -2082,7 +2082,7 @@ public abstract class CameraMetadata<TKey> { /** * <p>Optimized for dim settings where the main light source - * is a flame.</p> + * is a candle.</p> * @see CaptureRequest#CONTROL_SCENE_MODE */ public static final int CONTROL_SCENE_MODE_CANDLELIGHT = 15; diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 8333b817add0..1fbfa40d5d64 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -83,6 +83,7 @@ import java.util.Map; @SystemService(Context.CONNECTIVITY_SERVICE) public class ConnectivityManager { private static final String TAG = "ConnectivityManager"; + private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); /** * A change in network connectivity has occurred. A default connection has either @@ -2493,6 +2494,7 @@ public class ConnectivityManager { * {@hide} */ public void reportInetCondition(int networkType, int percentage) { + printStackTrace(); try { mService.reportInetCondition(networkType, percentage); } catch (RemoteException e) { @@ -2513,6 +2515,7 @@ public class ConnectivityManager { */ @Deprecated public void reportBadNetwork(Network network) { + printStackTrace(); try { // One of these will be ignored because it matches system's current state. // The other will trigger the necessary reevaluation. @@ -2535,6 +2538,7 @@ public class ConnectivityManager { * Internet using {@code network} or {@code false} if not. */ public void reportNetworkConnectivity(Network network, boolean hasConnectivity) { + printStackTrace(); try { mService.reportNetworkConnectivity(network, hasConnectivity); } catch (RemoteException e) { @@ -2727,8 +2731,11 @@ public class ConnectivityManager { * * @hide */ - @RequiresPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL) - @UnsupportedAppUsage + @RequiresPermission(anyOf = { + android.Manifest.permission.NETWORK_SETTINGS, + android.Manifest.permission.NETWORK_SETUP_WIZARD, + android.Manifest.permission.NETWORK_STACK}) + @SystemApi public void setAirplaneMode(boolean enable) { try { mService.setAirplaneMode(enable); @@ -3073,6 +3080,7 @@ public class ConnectivityManager { private NetworkRequest sendRequestForNetwork(NetworkCapabilities need, NetworkCallback callback, int timeoutMs, int action, int legacyType, CallbackHandler handler) { + printStackTrace(); checkCallbackNotNull(callback); Preconditions.checkArgument(action == REQUEST || need != null, "null NetworkCapabilities"); final NetworkRequest request; @@ -3332,6 +3340,7 @@ public class ConnectivityManager { * {@link NetworkCapabilities#NET_CAPABILITY_CAPTIVE_PORTAL}. */ public void requestNetwork(NetworkRequest request, PendingIntent operation) { + printStackTrace(); checkPendingIntentNotNull(operation); try { mService.pendingRequestForNetwork(request.networkCapabilities, operation); @@ -3355,6 +3364,7 @@ public class ConnectivityManager { * corresponding NetworkRequest you'd like to remove. Cannot be null. */ public void releaseNetworkRequest(PendingIntent operation) { + printStackTrace(); checkPendingIntentNotNull(operation); try { mService.releasePendingNetworkRequest(operation); @@ -3439,6 +3449,7 @@ public class ConnectivityManager { */ @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) public void registerNetworkCallback(NetworkRequest request, PendingIntent operation) { + printStackTrace(); checkPendingIntentNotNull(operation); try { mService.pendingListenForNetwork(request.networkCapabilities, operation); @@ -3520,6 +3531,7 @@ public class ConnectivityManager { * @param networkCallback The {@link NetworkCallback} used when making the request. */ public void unregisterNetworkCallback(NetworkCallback networkCallback) { + printStackTrace(); checkCallbackNotNull(networkCallback); final List<NetworkRequest> reqs = new ArrayList<>(); // Find all requests associated to this callback and stop callback triggers immediately. @@ -3948,4 +3960,19 @@ public class ConnectivityManager { throw e.rethrowFromSystemServer(); } } + + private void printStackTrace() { + if (DEBUG) { + final StackTraceElement[] callStack = Thread.currentThread().getStackTrace(); + final StringBuffer sb = new StringBuffer(); + for (int i = 3; i < callStack.length; i++) { + final String stackTrace = callStack[i].toString(); + if (stackTrace == null || stackTrace.contains("android.os")) { + break; + } + sb.append(" [").append(stackTrace).append("]"); + } + Log.d(TAG, "StackLog:" + sb.toString()); + } + } } diff --git a/core/java/android/os/DumpstateOptions.java b/core/java/android/os/DumpstateOptions.java new file mode 100644 index 000000000000..53037b2499cd --- /dev/null +++ b/core/java/android/os/DumpstateOptions.java @@ -0,0 +1,57 @@ +/* + * 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. + */ + +package android.os; + +/** + * Options passed to dumpstate service. + * + * @hide + */ +public final class DumpstateOptions implements Parcelable { + // If true the caller can get callbacks with per-section + // progress details. + private final boolean mGetSectionDetails; + // Name of the caller. + private final String mName; + + public DumpstateOptions(Parcel in) { + mGetSectionDetails = in.readBoolean(); + mName = in.readString(); + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeBoolean(mGetSectionDetails); + out.writeString(mName); + } + + public static final Parcelable.Creator<DumpstateOptions> CREATOR = + new Parcelable.Creator<DumpstateOptions>() { + public DumpstateOptions createFromParcel(Parcel in) { + return new DumpstateOptions(in); + } + + public DumpstateOptions[] newArray(int size) { + return new DumpstateOptions[size]; + } + }; +} diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl index 20ca19bc04aa..c9c42058bad0 100644 --- a/core/java/android/os/INetworkManagementService.aidl +++ b/core/java/android/os/INetworkManagementService.aidl @@ -388,10 +388,10 @@ interface INetworkManagementService /** * Setup a new physical network. - * @param permission null if no permissions required to access this network. PERMISSION_NETWORK - * or PERMISSION_SYSTEM to set respective permission. + * @param permission PERMISSION_NONE if no permissions required to access this network. + * PERMISSION_NETWORK or PERMISSION_SYSTEM to set respective permission. */ - void createPhysicalNetwork(int netId, String permission); + void createPhysicalNetwork(int netId, int permission); /** * Setup a new VPN. @@ -420,10 +420,10 @@ interface INetworkManagementService /** * Set permission for a network. - * @param permission null to clear permissions. PERMISSION_NETWORK or PERMISSION_SYSTEM to set - * permission. + * @param permission PERMISSION_NONE to clear permissions. + * PERMISSION_NETWORK or PERMISSION_SYSTEM to set permission. */ - void setNetworkPermission(int netId, String permission); + void setNetworkPermission(int netId, int permission); void setPermission(String permission, in int[] uids); void clearPermission(in int[] uids); diff --git a/core/java/android/os/Message.java b/core/java/android/os/Message.java index b303e10fa64b..c3f60a332a2b 100644 --- a/core/java/android/os/Message.java +++ b/core/java/android/os/Message.java @@ -366,7 +366,7 @@ public final class Message implements Parcelable { * the <em>target</em> {@link Handler} that is receiving this Message to * dispatch it. If * not set, the message will be dispatched to the receiving Handler's - * {@link Handler#handleMessage(Message Handler.handleMessage())}. + * {@link Handler#handleMessage(Message)}. */ public Runnable getCallback() { return callback; diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 29dbb83ca591..7370029878a0 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -7299,6 +7299,15 @@ public final class Settings { public static final String DIALER_DEFAULT_APPLICATION = "dialer_default_application"; /** + * Specifies the package name currently configured to be the default application to perform + * the user-defined call redirection service with Telecom. + * @hide + */ + @UnsupportedAppUsage + public static final String CALL_REDIRECTION_DEFAULT_APPLICATION = + "call_redirection_default_application"; + + /** * Specifies the package name currently configured to be the emergency assistance application * * @see android.telephony.TelephonyManager#ACTION_EMERGENCY_ASSISTANCE diff --git a/core/java/android/util/FeatureFlagUtils.java b/core/java/android/util/FeatureFlagUtils.java index cec0df02247c..959534d24f59 100644 --- a/core/java/android/util/FeatureFlagUtils.java +++ b/core/java/android/util/FeatureFlagUtils.java @@ -34,6 +34,8 @@ public class FeatureFlagUtils { public static final String FFLAG_PREFIX = "sys.fflag."; public static final String FFLAG_OVERRIDE_PREFIX = FFLAG_PREFIX + "override."; public static final String EMERGENCY_DIAL_SHORTCUTS = "settings_emergency_dial_shortcuts"; + public static final String PERSIST_PREFIX = "persist." + FFLAG_OVERRIDE_PREFIX; + public static final String HEARING_AID_SETTINGS = "settings_bluetooth_hearing_aid"; private static final Map<String, String> DEFAULT_FLAGS; static { @@ -46,6 +48,7 @@ public class FeatureFlagUtils { DEFAULT_FLAGS.put("settings_audio_switcher", "true"); DEFAULT_FLAGS.put("settings_systemui_theme", "true"); DEFAULT_FLAGS.put(EMERGENCY_DIAL_SHORTCUTS, "false"); + DEFAULT_FLAGS.put(HEARING_AID_SETTINGS, "true"); } /** diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index 10c32a3b7a36..486c836279ce 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -5369,6 +5369,7 @@ public class BatteryStatsImpl extends BatteryStats { if (DEBUG_HISTORY) Slog.v(TAG, "Phone started scanning to: " + Integer.toHexString(mHistoryCur.states)); mPhoneSignalScanningTimer.startRunningLocked(elapsedRealtime); + StatsLog.write(StatsLog.PHONE_SERVICE_STATE_CHANGED, state, simState, strengthBin); } } @@ -5380,6 +5381,7 @@ public class BatteryStatsImpl extends BatteryStats { + Integer.toHexString(mHistoryCur.states)); newHistory = true; mPhoneSignalScanningTimer.stopRunningLocked(elapsedRealtime); + StatsLog.write(StatsLog.PHONE_SERVICE_STATE_CHANGED, state, simState, strengthBin); } } diff --git a/core/java/com/android/internal/os/ProcessCpuTracker.java b/core/java/com/android/internal/os/ProcessCpuTracker.java index bf31c7d8ad85..1ee4269d974b 100644 --- a/core/java/com/android/internal/os/ProcessCpuTracker.java +++ b/core/java/com/android/internal/os/ProcessCpuTracker.java @@ -29,7 +29,6 @@ import android.util.Slog; import com.android.internal.util.FastPrintWriter; import libcore.io.IoUtils; -import libcore.io.Libcore; import java.io.File; import java.io.FileInputStream; diff --git a/core/java/com/android/internal/widget/AlertDialogLayout.java b/core/java/com/android/internal/widget/AlertDialogLayout.java index 9bf094891f3b..7a0174946671 100644 --- a/core/java/com/android/internal/widget/AlertDialogLayout.java +++ b/core/java/com/android/internal/widget/AlertDialogLayout.java @@ -18,6 +18,7 @@ package com.android.internal.widget; import android.annotation.AttrRes; import android.annotation.Nullable; +import android.annotation.UnsupportedAppUsage; import android.annotation.StyleRes; import android.content.Context; import android.graphics.drawable.Drawable; @@ -50,6 +51,7 @@ public class AlertDialogLayout extends LinearLayout { super(context); } + @UnsupportedAppUsage public AlertDialogLayout(@Nullable Context context, @Nullable AttributeSet attrs) { super(context, attrs); } diff --git a/core/java/com/android/internal/widget/ButtonBarLayout.java b/core/java/com/android/internal/widget/ButtonBarLayout.java index ab8be33599fa..0ca67438c5c3 100644 --- a/core/java/com/android/internal/widget/ButtonBarLayout.java +++ b/core/java/com/android/internal/widget/ButtonBarLayout.java @@ -16,6 +16,7 @@ package com.android.internal.widget; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; @@ -40,6 +41,7 @@ public class ButtonBarLayout extends LinearLayout { private int mMinimumHeight = 0; + @UnsupportedAppUsage public ButtonBarLayout(Context context, AttributeSet attrs) { super(context, attrs); diff --git a/core/java/com/android/internal/widget/DialogTitle.java b/core/java/com/android/internal/widget/DialogTitle.java index 7ea3d6b5bff0..405436c53ff0 100644 --- a/core/java/com/android/internal/widget/DialogTitle.java +++ b/core/java/com/android/internal/widget/DialogTitle.java @@ -16,6 +16,7 @@ package com.android.internal.widget; +import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.TypedArray; import android.text.Layout; @@ -37,6 +38,7 @@ public class DialogTitle extends TextView { super(context, attrs, defStyleAttr); } + @UnsupportedAppUsage public DialogTitle(Context context, AttributeSet attrs) { super(context, attrs); } diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index c3ba9ba82826..9341d9a48913 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -23,6 +23,7 @@ #include <atomic> #include <fcntl.h> #include <inttypes.h> +#include <mutex> #include <stdio.h> #include <sys/stat.h> #include <sys/types.h> @@ -69,6 +70,7 @@ static struct bindernative_offsets_t // Class state. jclass mClass; jmethodID mExecTransact; + jmethodID mGetInterfaceDescriptor; // Object state. jfieldID mObject; @@ -328,8 +330,32 @@ protected: env->DeleteGlobalRef(mObject); } - virtual status_t onTransact( - uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0) + const String16& getInterfaceDescriptor() const override + { + call_once(mPopulateDescriptor, [this] { + JNIEnv* env = javavm_to_jnienv(mVM); + + ALOGV("getInterfaceDescriptor() on %p calling object %p in env %p vm %p\n", this, mObject, env, mVM); + + jstring descriptor = (jstring)env->CallObjectMethod(mObject, gBinderOffsets.mGetInterfaceDescriptor); + + if (descriptor == nullptr) { + return; + } + + static_assert(sizeof(jchar) == sizeof(char16_t), ""); + const jchar* descriptorChars = env->GetStringChars(descriptor, nullptr); + const char16_t* rawDescriptor = reinterpret_cast<const char16_t*>(descriptorChars); + jsize rawDescriptorLen = env->GetStringLength(descriptor); + mDescriptor = String16(rawDescriptor, rawDescriptorLen); + env->ReleaseStringChars(descriptor, descriptorChars); + }); + + return mDescriptor; + } + + status_t onTransact( + uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0) override { JNIEnv* env = javavm_to_jnienv(mVM); @@ -378,7 +404,7 @@ protected: return res != JNI_FALSE ? NO_ERROR : UNKNOWN_TRANSACTION; } - virtual status_t dump(int fd, const Vector<String16>& args) + status_t dump(int fd, const Vector<String16>& args) override { return 0; } @@ -386,6 +412,9 @@ protected: private: JavaVM* const mVM; jobject const mObject; // GlobalRef to Java Binder + + mutable std::once_flag mPopulateDescriptor; + mutable String16 mDescriptor; }; // ---------------------------------------------------------------------------- @@ -939,6 +968,8 @@ static int int_register_android_os_Binder(JNIEnv* env) gBinderOffsets.mClass = MakeGlobalRefOrDie(env, clazz); gBinderOffsets.mExecTransact = GetMethodIDOrDie(env, clazz, "execTransact", "(IJJI)Z"); + gBinderOffsets.mGetInterfaceDescriptor = GetMethodIDOrDie(env, clazz, "getInterfaceDescriptor", + "()Ljava/lang/String;"); gBinderOffsets.mObject = GetFieldIDOrDie(env, clazz, "mObject", "J"); return RegisterMethodsOrDie( diff --git a/core/proto/OWNERS b/core/proto/OWNERS index ed42e2ee51a5..30a9a01c3448 100644 --- a/core/proto/OWNERS +++ b/core/proto/OWNERS @@ -7,6 +7,8 @@ jinyithu@google.com joeo@google.com kwekua@google.com singhtejinder@google.com +yanglu@google.com +yaochen@google.com # Frameworks ogunwale@google.com diff --git a/core/proto/android/telephony/enums.proto b/core/proto/android/telephony/enums.proto index 32975a5550f1..fba2e51937b3 100644 --- a/core/proto/android/telephony/enums.proto +++ b/core/proto/android/telephony/enums.proto @@ -61,3 +61,64 @@ enum SignalStrengthEnum { SIGNAL_STRENGTH_GOOD = 3; SIGNAL_STRENGTH_GREAT = 4; } + + +enum ServiceStateEnum { + /** + * Normal operation condition, the phone is registered + * with an operator either in home network or in roaming. + */ + SERVICE_STATE_IN_SERVICE = 0; + + /** + * Phone is not registered with any operator, the phone + * can be currently searching a new operator to register to, or not + * searching to registration at all, or registration is denied, or radio + * signal is not available. + */ + SERVICE_STATE_OUT_OF_SERVICE = 1; + + /** + * The phone is registered and locked. Only emergency numbers are allowed. {@more} + */ + SERVICE_STATE_EMERGENCY_ONLY = 2; + + /** + * Radio of telephony is explicitly powered off. + */ + SERVICE_STATE_POWER_OFF = 3; +} + +enum SimStateEnum { + SIM_STATE_UNKNOWN = 0; + /** SIM card state: no SIM card is available in the device */ + SIM_STATE_ABSENT = 1; + /** SIM card state: Locked: requires the user's SIM PIN to unlock */ + SIM_STATE_PIN_REQUIRED = 2; + /** SIM card state: Locked: requires the user's SIM PUK to unlock */ + SIM_STATE_PUK_REQUIRED = 3; + /** SIM card state: Locked: requires a network PIN to unlock */ + SIM_STATE_NETWORK_LOCKED = 4; + /** SIM card state: Ready */ + SIM_STATE_READY = 5; + /** SIM card state: SIM Card is NOT READY */ + SIM_STATE_NOT_READY = 6; + /** SIM card state: SIM Card Error, permanently disabled */ + SIM_STATE_PERM_DISABLED = 7; + /** SIM card state: SIM Card Error, present but faulty */ + SIM_STATE_CARD_IO_ERROR = 8; + /** SIM card state: SIM Card restricted, present but not usable due to + * carrier restrictions. + */ + SIM_STATE_CARD_RESTRICTED = 9; + /** + * SIM card state: Loaded: SIM card applications have been loaded + * @hide + */ + SIM_STATE_LOADED = 10; + /** + * SIM card state: SIM Card is present + * @hide + */ + SIM_STATE_PRESENT = 11; +} diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 73bb1fc1b4a7..0dabcd72bd86 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -138,7 +138,6 @@ <protected-broadcast android:name="android.bluetooth.device.action.MAS_INSTANCE" /> <protected-broadcast android:name="android.bluetooth.device.action.ALIAS_CHANGED" /> <protected-broadcast android:name="android.bluetooth.device.action.FOUND" /> - <protected-broadcast android:name="android.bluetooth.device.action.DISAPPEARED" /> <protected-broadcast android:name="android.bluetooth.device.action.CLASS_CHANGED" /> <protected-broadcast android:name="android.bluetooth.device.action.ACL_CONNECTED" /> <protected-broadcast android:name="android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED" /> @@ -1441,6 +1440,7 @@ <!-- Allows SetupWizard to call methods in Networking services <p>Not for use by any other third-party or privileged applications. + @SystemApi @hide This should only be used by SetupWizard. --> <permission android:name="android.permission.NETWORK_SETUP_WIZARD" diff --git a/core/res/res/xml/sms_short_codes.xml b/core/res/res/xml/sms_short_codes.xml index fb78b3b0533a..7b3d940b91f3 100644 --- a/core/res/res/xml/sms_short_codes.xml +++ b/core/res/res/xml/sms_short_codes.xml @@ -109,12 +109,12 @@ <!-- France: 5 digits, free: 3xxxx, premium [4-8]xxxx, plus EU: http://clients.txtnation.com/entries/161972-france-premium-sms-short-code-requirements, visual voicemail code for Orange: 21101 --> - <shortcode country="fr" premium="[4-8]\\d{4}" free="3\\d{4}|116\\d{3}|21101|20366" /> + <shortcode country="fr" premium="[4-8]\\d{4}" free="3\\d{4}|116\\d{3}|21101|20366|555|2051" /> <!-- United Kingdom (Great Britain): 4-6 digits, common codes [5-8]xxxx, plus EU: http://www.short-codes.com/media/Co-regulatoryCodeofPracticeforcommonshortcodes170206.pdf, visual voicemail code for EE: 887 --> - <shortcode country="gb" pattern="\\d{4,6}" premium="[5-8]\\d{4}" free="116\\d{3}|2020|35890|61002|61202|887|83669|34664|40406|60174|7726|37726" /> + <shortcode country="gb" pattern="\\d{4,6}" premium="[5-8]\\d{4}" free="116\\d{3}|2020|35890|61002|61202|887|83669|34664|40406|60174|7726|37726|88555|9017|9018" /> <!-- Georgia: 4 digits, known premium codes listed --> <shortcode country="ge" pattern="\\d{4}" premium="801[234]|888[239]" /> @@ -189,11 +189,14 @@ <!-- The Netherlands, 4 digits, known premium codes listed, plus EU --> <shortcode country="nl" pattern="\\d{4}" premium="4466|5040" free="116\\d{3}|2223|6225|2223" /> + <!-- Nigeria --> + <shortcode country="ng" pattern="\\d{1,5}" free="2441" /> + <!-- Norway: 4-5 digits (not confirmed), known premium codes listed --> <shortcode country="no" pattern="\\d{4,5}" premium="2201|222[67]" free="2171" /> <!-- New Zealand: 3-4 digits, known premium codes listed --> - <shortcode country="nz" pattern="\\d{3,4}" premium="3903|8995|4679" free="3067|3068|4053" /> + <shortcode country="nz" pattern="\\d{3,4}" premium="3903|8995|4679" free="1737|2141|3067|3068|3110|4006|4053|4061|4062|4202|4300|4334|4412|4575|5626|8006|8681" /> <!-- Peru: 4-5 digits (not confirmed), known premium codes listed --> <shortcode country="pe" pattern="\\d{4,5}" free="9963" /> @@ -209,7 +212,7 @@ <!-- Portugal: 5 digits, plus EU: http://clients.txtnation.com/entries/158326-portugal-premium-sms-short-code-regulations --> - <shortcode country="pt" premium="6[1289]\\d{3}" free="116\\d{3}|1262" /> + <shortcode country="pt" premium="6[1289]\\d{3}" free="116\\d{3}|1262|12666" /> <!-- Qatar: 1-5 digits (standard system default, not country specific) --> <shortcode country="qa" pattern="\\d{1,5}" free="92451" /> diff --git a/core/tests/coretests/Android.mk b/core/tests/coretests/Android.mk index e0d53933b33b..041fb7eeb6b3 100644 --- a/core/tests/coretests/Android.mk +++ b/core/tests/coretests/Android.mk @@ -47,7 +47,6 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ LOCAL_JAVA_LIBRARIES := \ android.test.runner \ - conscrypt \ telephony-common \ org.apache.http.legacy \ android.test.base \ @@ -67,10 +66,6 @@ LOCAL_RESOURCE_DIR := $(FrameworkCoreTests_intermediates) $(LOCAL_PATH)/res # Disable AAPT2 because the hacks below depend on the AAPT rules implementation LOCAL_USE_AAPT2 := false -# When AAPT2 is enabled it will need --warn-manifest-validation to fix: -# frameworks/base/core/tests/coretests/AndroidManifest.xml:26: error: unknown element <meta-data> found. -# TODO(b/79755007): Remove when AAPT2 recognizes the manifest elements. -# LOCAL_AAPT_FLAGS += --warn-manifest-validation include $(BUILD_PACKAGE) # Rules to copy all the test apks to the intermediate raw resource directory diff --git a/core/tests/coretests/apks/install_multi_package/Android.mk b/core/tests/coretests/apks/install_multi_package/Android.mk index 97275931be4b..3f163def9ce0 100644 --- a/core/tests/coretests/apks/install_multi_package/Android.mk +++ b/core/tests/coretests/apks/install_multi_package/Android.mk @@ -8,10 +8,6 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_PACKAGE_NAME := install_multi_package LOCAL_USE_AAPT2 := true -# Disable AAPT2 manifest checks to fix: -# frameworks/base/core/tests/coretests/apks/install_multi_package/AndroidManifest.xml:46: error: unexpected element <package> found in <manifest>. -# TODO(b/79755007): Remove when AAPT2 recognizes the manifest elements. -LOCAL_AAPT_FLAGS += --warn-manifest-validation include $(FrameworkCoreTests_BUILD_PACKAGE) #include $(BUILD_PACKAGE) diff --git a/core/tests/coretests/apks/install_verifier_bad/Android.mk b/core/tests/coretests/apks/install_verifier_bad/Android.mk index 679327c9b0df..745b4d32ccc4 100644 --- a/core/tests/coretests/apks/install_verifier_bad/Android.mk +++ b/core/tests/coretests/apks/install_verifier_bad/Android.mk @@ -6,9 +6,5 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_PACKAGE_NAME := install_verifier_bad LOCAL_USE_AAPT2 := true -# Disable AAPT2 manifest checks to fix: -# frameworks/base/core/tests/coretests/apks/install_verifier_bad/AndroidManifest.xml:19: error: unexpected element <package-verifier> found in <manifest>. -# TODO(b/79755007): Remove when AAPT2 recognizes the manifest elements. -LOCAL_AAPT_FLAGS += --warn-manifest-validation include $(FrameworkCoreTests_BUILD_PACKAGE) diff --git a/core/tests/coretests/apks/install_verifier_good/Android.mk b/core/tests/coretests/apks/install_verifier_good/Android.mk index 7d621b32900b..150fd8dd8701 100644 --- a/core/tests/coretests/apks/install_verifier_good/Android.mk +++ b/core/tests/coretests/apks/install_verifier_good/Android.mk @@ -6,9 +6,5 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_PACKAGE_NAME := install_verifier_good LOCAL_USE_AAPT2 := true -# Disable AAPT2 manifest checks to fix: -# frameworks/base/core/tests/coretests/apks/install_verifier_good/AndroidManifest.xml:19: error: unexpected element <package-verifier> found in <manifest>. -# TODO(b/79755007): Remove when AAPT2 recognizes the manifest elements. -LOCAL_AAPT_FLAGS += --warn-manifest-validation include $(FrameworkCoreTests_BUILD_PACKAGE) diff --git a/core/tests/coretests/src/android/content/pm/dex/DexMetadataHelperTest.java b/core/tests/coretests/src/android/content/pm/dex/DexMetadataHelperTest.java index 584257b1f6a9..e248a7771cab 100644 --- a/core/tests/coretests/src/android/content/pm/dex/DexMetadataHelperTest.java +++ b/core/tests/coretests/src/android/content/pm/dex/DexMetadataHelperTest.java @@ -45,7 +45,7 @@ import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import libcore.io.IoUtils; +import libcore.testing.io.TestIoUtils; import org.junit.After; import org.junit.Assert; @@ -63,7 +63,7 @@ public class DexMetadataHelperTest { @Before public void setUp() { - mTmpDir = IoUtils.createTemporaryDirectory("DexMetadataHelperTest"); + mTmpDir = TestIoUtils.createTemporaryDirectory("DexMetadataHelperTest"); } @After diff --git a/core/tests/coretests/src/android/os/FileUtilsTest.java b/core/tests/coretests/src/android/os/FileUtilsTest.java index 0bc3a2d879ab..17e34beb5215 100644 --- a/core/tests/coretests/src/android/os/FileUtilsTest.java +++ b/core/tests/coretests/src/android/os/FileUtilsTest.java @@ -32,7 +32,6 @@ import android.provider.DocumentsContract.Document; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; -import libcore.io.IoUtils; import libcore.io.Streams; import com.google.android.collect.Sets; @@ -79,7 +78,7 @@ public class FileUtilsTest { @After public void tearDown() throws Exception { - IoUtils.deleteContents(mDir); + FileUtils.deleteContents(mDir); FileUtils.deleteContents(mTarget); } diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java index 23be634da05f..32790e534e6b 100644 --- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java +++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java @@ -527,6 +527,7 @@ public class SettingsBackupTest { Settings.Secure.BACKUP_ENABLED, Settings.Secure.BACKUP_PROVISIONED, Settings.Secure.BACKUP_TRANSPORT, + Settings.Secure.CALL_REDIRECTION_DEFAULT_APPLICATION, Settings.Secure.CAMERA_LIFT_TRIGGER_ENABLED, // Candidate for backup? Settings.Secure.CARRIER_APPS_HANDLED, Settings.Secure.CMAS_ADDITIONAL_BROADCAST_PKG, diff --git a/core/tests/coretests/src/android/text/format/DateUtilsTest.java b/core/tests/coretests/src/android/text/format/DateUtilsTest.java index f8e3b4dfec56..872b71a5faa6 100644 --- a/core/tests/coretests/src/android/text/format/DateUtilsTest.java +++ b/core/tests/coretests/src/android/text/format/DateUtilsTest.java @@ -117,7 +117,7 @@ public class DateUtilsTest { @Test public void testFormatSameDayTime() { // This test assumes a default DateFormat.is24Hour setting. - DateFormat.is24Hour = null; + DateFormat.set24HourTimePref(null); Date date = new Date(109, 0, 19, 3, 30, 15); long fixedTime = date.getTime(); diff --git a/core/tests/overlaytests/device/test-apps/AppOverlayOne/Android.mk b/core/tests/overlaytests/device/test-apps/AppOverlayOne/Android.mk index edad4b26314c..97a3d0078e26 100644 --- a/core/tests/overlaytests/device/test-apps/AppOverlayOne/Android.mk +++ b/core/tests/overlaytests/device/test-apps/AppOverlayOne/Android.mk @@ -20,4 +20,6 @@ LOCAL_PACKAGE_NAME := OverlayDeviceTests_AppOverlayOne LOCAL_SDK_VERSION := current LOCAL_COMPATIBILITY_SUITE := device-tests LOCAL_CERTIFICATE := platform +LOCAL_USE_AAPT2 := true +LOCAL_AAPT_FLAGS := --no-resource-removal include $(BUILD_PACKAGE) diff --git a/core/tests/overlaytests/device/test-apps/AppOverlayTwo/Android.mk b/core/tests/overlaytests/device/test-apps/AppOverlayTwo/Android.mk index 3fae8e19fc5b..a3470255997d 100644 --- a/core/tests/overlaytests/device/test-apps/AppOverlayTwo/Android.mk +++ b/core/tests/overlaytests/device/test-apps/AppOverlayTwo/Android.mk @@ -20,4 +20,6 @@ LOCAL_PACKAGE_NAME := OverlayDeviceTests_AppOverlayTwo LOCAL_SDK_VERSION := current LOCAL_COMPATIBILITY_SUITE := device-tests LOCAL_CERTIFICATE := platform +LOCAL_USE_AAPT2 := true +LOCAL_AAPT_FLAGS := --no-resource-removal include $(BUILD_PACKAGE) diff --git a/core/tests/overlaytests/device/test-apps/FrameworkOverlay/Android.mk b/core/tests/overlaytests/device/test-apps/FrameworkOverlay/Android.mk index c352c0550034..e4819e138eba 100644 --- a/core/tests/overlaytests/device/test-apps/FrameworkOverlay/Android.mk +++ b/core/tests/overlaytests/device/test-apps/FrameworkOverlay/Android.mk @@ -20,4 +20,6 @@ LOCAL_PACKAGE_NAME := OverlayDeviceTests_FrameworkOverlay LOCAL_SDK_VERSION := current LOCAL_COMPATIBILITY_SUITE := device-tests LOCAL_CERTIFICATE := platform +LOCAL_USE_AAPT2 := true +LOCAL_AAPT_FLAGS := --no-resource-removal include $(BUILD_PACKAGE) diff --git a/core/tests/overlaytests/host/test-apps/UpdateOverlay/Android.mk b/core/tests/overlaytests/host/test-apps/UpdateOverlay/Android.mk index ab3faf0b158a..8656781e31e5 100644 --- a/core/tests/overlaytests/host/test-apps/UpdateOverlay/Android.mk +++ b/core/tests/overlaytests/host/test-apps/UpdateOverlay/Android.mk @@ -21,6 +21,8 @@ LOCAL_PACKAGE_NAME := OverlayHostTests_UpdateOverlay LOCAL_SDK_VERSION := current LOCAL_COMPATIBILITY_SUITE := general-tests LOCAL_STATIC_JAVA_LIBRARIES := android-support-test +LOCAL_USE_AAPT2 := true +LOCAL_AAPT_FLAGS := --no-resource-removal include $(BUILD_PACKAGE) my_package_prefix := com.android.server.om.hosttest.framework_overlay diff --git a/data/etc/privapp-permissions-platform.xml b/data/etc/privapp-permissions-platform.xml index 82b6a22d2740..0082f4bb0002 100644 --- a/data/etc/privapp-permissions-platform.xml +++ b/data/etc/privapp-permissions-platform.xml @@ -316,6 +316,7 @@ applications that come with the platform <permission name="android.permission.READ_FRAME_BUFFER"/> <permission name="android.permission.READ_LOWPAN_CREDENTIAL"/> <permission name="android.permission.REAL_GET_TASKS"/> + <permission name="android.permission.READ_PRIVILEGED_PHONE_STATE"/> <permission name="android.permission.REGISTER_CALL_PROVIDER"/> <permission name="android.permission.REGISTER_CONNECTION_MANAGER"/> <permission name="android.permission.REGISTER_SIM_SUBSCRIPTION"/> diff --git a/graphics/java/android/graphics/pdf/PdfEditor.java b/graphics/java/android/graphics/pdf/PdfEditor.java index 3821bc7ab063..21ce1b8392d2 100644 --- a/graphics/java/android/graphics/pdf/PdfEditor.java +++ b/graphics/java/android/graphics/pdf/PdfEditor.java @@ -27,7 +27,6 @@ import android.system.Os; import android.system.OsConstants; import dalvik.system.CloseGuard; import libcore.io.IoUtils; -import libcore.io.Libcore; import java.io.IOException; diff --git a/keystore/OWNERS b/keystore/OWNERS new file mode 100644 index 000000000000..a63ca46df2a6 --- /dev/null +++ b/keystore/OWNERS @@ -0,0 +1,4 @@ +jbires@google.com +jdanis@google.com +robbarnes@google.com +swillden@google.com diff --git a/libs/androidfw/Android.bp b/libs/androidfw/Android.bp index e39926beee41..140001d673dd 100644 --- a/libs/androidfw/Android.bp +++ b/libs/androidfw/Android.bp @@ -43,11 +43,14 @@ cc_library { "AssetManager2.cpp", "AttributeResolution.cpp", "ChunkIterator.cpp", + "ConfigDescription.cpp", "Idmap.cpp", "LoadedArsc.cpp", + "Locale.cpp", "LocaleData.cpp", "misc.cpp", "ObbFile.cpp", + "PosixUtils.cpp", "ResourceTypes.cpp", "ResourceUtils.cpp", "StreamingZipInflater.cpp", @@ -135,9 +138,11 @@ cc_test { "tests/AttributeResolution_test.cpp", "tests/ByteBucketArray_test.cpp", "tests/Config_test.cpp", + "tests/ConfigDescription_test.cpp", "tests/ConfigLocale_test.cpp", "tests/Idmap_test.cpp", "tests/LoadedArsc_test.cpp", + "tests/Locale_test.cpp", "tests/ResourceUtils_test.cpp", "tests/ResTable_test.cpp", "tests/Split_test.cpp", @@ -152,6 +157,7 @@ cc_test { srcs: [ "tests/BackupData_test.cpp", "tests/ObbFile_test.cpp", + "tests/PosixUtils_test.cpp", ], shared_libs: common_test_libs + ["libui"], }, diff --git a/libs/androidfw/ApkAssets.cpp b/libs/androidfw/ApkAssets.cpp index 8f58f74d4652..66a547723b2f 100644 --- a/libs/androidfw/ApkAssets.cpp +++ b/libs/androidfw/ApkAssets.cpp @@ -39,7 +39,7 @@ using base::unique_fd; static const std::string kResourcesArsc("resources.arsc"); -ApkAssets::ApkAssets(void* unmanaged_handle, const std::string& path) +ApkAssets::ApkAssets(ZipArchiveHandle unmanaged_handle, const std::string& path) : zip_handle_(unmanaged_handle, ::CloseArchive), path_(path) { } diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp index 9c1629bc36f5..04cc5bb30ade 100644 --- a/libs/androidfw/AssetManager2.cpp +++ b/libs/androidfw/AssetManager2.cpp @@ -67,10 +67,10 @@ AssetManager2::AssetManager2() { } bool AssetManager2::SetApkAssets(const std::vector<const ApkAssets*>& apk_assets, - bool invalidate_caches) { + bool invalidate_caches, bool filter_incompatible_configs) { apk_assets_ = apk_assets; BuildDynamicRefTable(); - RebuildFilterList(); + RebuildFilterList(filter_incompatible_configs); if (invalidate_caches) { InvalidateCaches(static_cast<uint32_t>(-1)); } @@ -825,7 +825,7 @@ uint32_t AssetManager2::GetResourceId(const std::string& resource_name, return 0u; } -void AssetManager2::RebuildFilterList() { +void AssetManager2::RebuildFilterList(bool filter_incompatible_configs) { for (PackageGroup& group : package_groups_) { for (ConfiguredPackage& impl : group.packages_) { // Destroy it. @@ -841,7 +841,7 @@ void AssetManager2::RebuildFilterList() { for (auto iter = spec->types; iter != iter_end; ++iter) { ResTable_config this_config; this_config.copyFromDtoH((*iter)->config); - if (this_config.match(configuration_)) { + if (!filter_incompatible_configs || this_config.match(configuration_)) { group.configurations.push_back(this_config); group.types.push_back(*iter); } diff --git a/tools/aapt2/ConfigDescription.cpp b/libs/androidfw/ConfigDescription.cpp index f621660cb8ad..1f3a89edb8af 100644 --- a/tools/aapt2/ConfigDescription.cpp +++ b/libs/androidfw/ConfigDescription.cpp @@ -14,22 +14,16 @@ * limitations under the License. */ -#include "ConfigDescription.h" - -#include <string> -#include <vector> - +#include "androidfw/ConfigDescription.h" +#include "androidfw/Locale.h" #include "androidfw/ResourceTypes.h" #include "androidfw/StringPiece.h" +#include "androidfw/Util.h" -#include "Locale.h" -#include "SdkConstants.h" -#include "util/Util.h" - -using android::ResTable_config; -using android::StringPiece; +#include <string> +#include <vector> -namespace aapt { +namespace android { static const char* kWildcardName = "any"; @@ -883,7 +877,7 @@ std::string ConfigDescription::GetBcp47LanguageTag(bool canonicalize) const { } std::string ConfigDescription::to_string() const { - const android::String8 str = toString(); + const String8 str = toString(); return std::string(str.string(), str.size()); } @@ -996,4 +990,4 @@ bool ConfigDescription::IsCompatibleWith(const ConfigDescription& o) const { return !ConflictsWith(o) && !Dominates(o) && !o.Dominates(*this); } -} // namespace aapt +} // namespace android diff --git a/libs/androidfw/LoadedArsc.cpp b/libs/androidfw/LoadedArsc.cpp index 04d506a2d71c..21f023dc0f05 100644 --- a/libs/androidfw/LoadedArsc.cpp +++ b/libs/androidfw/LoadedArsc.cpp @@ -203,6 +203,39 @@ static bool VerifyResTableEntry(const ResTable_type* type, uint32_t entry_offset return true; } +LoadedPackage::iterator::iterator(const LoadedPackage* lp, size_t ti, size_t ei) + : loadedPackage_(lp), + typeIndex_(ti), + entryIndex_(ei), + typeIndexEnd_(lp->resource_ids_.size() + 1) { + while (typeIndex_ < typeIndexEnd_ && loadedPackage_->resource_ids_[typeIndex_] == 0) { + typeIndex_++; + } +} + +LoadedPackage::iterator& LoadedPackage::iterator::operator++() { + while (typeIndex_ < typeIndexEnd_) { + if (entryIndex_ + 1 < loadedPackage_->resource_ids_[typeIndex_]) { + entryIndex_++; + break; + } + entryIndex_ = 0; + typeIndex_++; + if (typeIndex_ < typeIndexEnd_ && loadedPackage_->resource_ids_[typeIndex_] != 0) { + break; + } + } + return *this; +} + +uint32_t LoadedPackage::iterator::operator*() const { + if (typeIndex_ >= typeIndexEnd_) { + return 0; + } + return make_resid(loadedPackage_->package_id_, typeIndex_ + loadedPackage_->type_id_offset_, + entryIndex_); +} + const ResTable_entry* LoadedPackage::GetEntry(const ResTable_type* type_chunk, uint16_t entry_index) { uint32_t entry_offset = GetEntryOffset(type_chunk, entry_index); @@ -488,6 +521,7 @@ std::unique_ptr<const LoadedPackage> LoadedPackage::Load(const Chunk& chunk, std::unique_ptr<TypeSpecPtrBuilder>& builder_ptr = type_builder_map[type_spec->id - 1]; if (builder_ptr == nullptr) { builder_ptr = util::make_unique<TypeSpecPtrBuilder>(type_spec, idmap_entry_header); + loaded_package->resource_ids_.set(type_spec->id, entry_count); } else { LOG(WARNING) << StringPrintf("RES_TABLE_TYPE_SPEC_TYPE already defined for ID %02x", type_spec->id); diff --git a/tools/aapt2/Locale.cpp b/libs/androidfw/Locale.cpp index d81921f23904..2870066ccbba 100644 --- a/tools/aapt2/Locale.cpp +++ b/libs/androidfw/Locale.cpp @@ -14,7 +14,8 @@ * limitations under the License. */ -#include "Locale.h" +#include "androidfw/Locale.h" +#include "androidfw/Util.h" #include <ctype.h> @@ -22,12 +23,10 @@ #include <string> #include <vector> -#include "util/Util.h" - using ::android::ResTable_config; using ::android::StringPiece; -namespace aapt { +namespace android { void LocaleValue::set_language(const char* language_chars) { size_t i = 0; @@ -258,4 +257,4 @@ void LocaleValue::WriteTo(ResTable_config* out) const { } } -} // namespace aapt +} // namespace android diff --git a/libs/androidfw/PosixUtils.cpp b/libs/androidfw/PosixUtils.cpp new file mode 100644 index 000000000000..df0dd7ce463d --- /dev/null +++ b/libs/androidfw/PosixUtils.cpp @@ -0,0 +1,112 @@ +/* + * 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. + */ + +#ifdef _WIN32 +// nothing to see here +#else +#include <memory> +#include <string> +#include <vector> + +#include <sys/types.h> +#include <sys/wait.h> +#include <unistd.h> + +#include "android-base/logging.h" + +#include "androidfw/PosixUtils.h" + +namespace { + +std::unique_ptr<std::string> ReadFile(int fd) { + std::unique_ptr<std::string> str(new std::string()); + char buf[1024]; + ssize_t r; + while ((r = read(fd, buf, sizeof(buf))) > 0) { + str->append(buf, r); + } + if (r != 0) { + return nullptr; + } + return str; +} + +} + +namespace android { +namespace util { + +std::unique_ptr<ProcResult> ExecuteBinary(const std::vector<std::string>& argv) { + int stdout[2]; // stdout[0] read, stdout[1] write + if (pipe(stdout) != 0) { + PLOG(ERROR) << "pipe"; + return nullptr; + } + + int stderr[2]; // stdout[0] read, stdout[1] write + if (pipe(stderr) != 0) { + PLOG(ERROR) << "pipe"; + close(stdout[0]); + close(stdout[1]); + return nullptr; + } + + char const** argv0 = (char const**)malloc(sizeof(char*) * (argv.size() + 1)); + for (size_t i = 0; i < argv.size(); i++) { + argv0[i] = argv[i].c_str(); + } + argv0[argv.size()] = nullptr; + switch (fork()) { + case -1: // error + free(argv0); + PLOG(ERROR) << "fork"; + return nullptr; + case 0: // child + close(stdout[0]); + if (dup2(stdout[1], STDOUT_FILENO) == -1) { + abort(); + } + close(stderr[0]); + if (dup2(stderr[1], STDERR_FILENO) == -1) { + abort(); + } + execvp(argv0[0], const_cast<char* const*>(argv0)); + PLOG(ERROR) << "execv"; + abort(); + default: // parent + free(argv0); + close(stdout[1]); + close(stderr[1]); + int status; + wait(&status); + if (!WIFEXITED(status)) { + return nullptr; + } + std::unique_ptr<ProcResult> result(new ProcResult()); + result->status = status; + const auto out = ReadFile(stdout[0]); + result->stdout = out ? *out : ""; + close(stdout[0]); + const auto err = ReadFile(stderr[0]); + result->stderr = err ? *err : ""; + close(stderr[0]); + return result; + } +} + +} // namespace util +} // namespace android +#endif diff --git a/libs/androidfw/Util.cpp b/libs/androidfw/Util.cpp index 575cd18a36dd..59c9d640bb91 100644 --- a/libs/androidfw/Util.cpp +++ b/libs/androidfw/Util.cpp @@ -16,6 +16,7 @@ #include "androidfw/Util.h" +#include <algorithm> #include <string> #include "utils/ByteOrder.h" @@ -67,5 +68,28 @@ std::string Utf16ToUtf8(const StringPiece16& utf16) { return utf8; } +static std::vector<std::string> SplitAndTransform( + const StringPiece& str, char sep, const std::function<char(char)>& f) { + std::vector<std::string> parts; + const StringPiece::const_iterator end = std::end(str); + StringPiece::const_iterator start = std::begin(str); + StringPiece::const_iterator current; + do { + current = std::find(start, end, sep); + parts.emplace_back(str.substr(start, current).to_string()); + if (f) { + std::string& part = parts.back(); + std::transform(part.begin(), part.end(), part.begin(), f); + } + start = current + 1; + } while (current != end); + return parts; +} + +std::vector<std::string> SplitAndLowercase(const StringPiece& str, char sep) { + return SplitAndTransform(str, sep, ::tolower); +} + + } // namespace util } // namespace android diff --git a/libs/androidfw/include/androidfw/ApkAssets.h b/libs/androidfw/include/androidfw/ApkAssets.h index 69702e314442..db2d0382bcf6 100644 --- a/libs/androidfw/include/androidfw/ApkAssets.h +++ b/libs/androidfw/include/androidfw/ApkAssets.h @@ -27,6 +27,9 @@ #include "androidfw/LoadedArsc.h" #include "androidfw/misc.h" +struct ZipArchive; +typedef ZipArchive* ZipArchiveHandle; + namespace android { class LoadedIdmap; @@ -88,9 +91,9 @@ class ApkAssets { // Creates an Asset from any file on the file system. static std::unique_ptr<Asset> CreateAssetFromFile(const std::string& path); - ApkAssets(void* unmanaged_handle, const std::string& path); + ApkAssets(ZipArchiveHandle unmanaged_handle, const std::string& path); - using ZipArchivePtr = std::unique_ptr<void, void(*)(void*)>; + using ZipArchivePtr = std::unique_ptr<ZipArchive, void(*)(ZipArchiveHandle)>; ZipArchivePtr zip_handle_; const std::string path_; diff --git a/libs/androidfw/include/androidfw/AssetManager2.h b/libs/androidfw/include/androidfw/AssetManager2.h index ad31f6940438..2f0ee01639fe 100644 --- a/libs/androidfw/include/androidfw/AssetManager2.h +++ b/libs/androidfw/include/androidfw/AssetManager2.h @@ -96,7 +96,12 @@ class AssetManager2 { // Only pass invalidate_caches=false when it is known that the structure // change in ApkAssets is due to a safe addition of resources with completely // new resource IDs. - bool SetApkAssets(const std::vector<const ApkAssets*>& apk_assets, bool invalidate_caches = true); + // + // Only pass in filter_incompatible_configs=false when you want to load all + // configurations (including incompatible ones) such as when constructing an + // idmap. + bool SetApkAssets(const std::vector<const ApkAssets*>& apk_assets, bool invalidate_caches = true, + bool filter_incompatible_configs = true); inline const std::vector<const ApkAssets*> GetApkAssets() const { return apk_assets_; @@ -274,7 +279,7 @@ class AssetManager2 { // Triggers the re-construction of lists of types that match the set configuration. // This should always be called when mutating the AssetManager's configuration or ApkAssets set. - void RebuildFilterList(); + void RebuildFilterList(bool filter_incompatible_configs = true); // AssetManager2::GetBag(resid) wraps this function to track which resource ids have already // been seen while traversing bag parents. diff --git a/tools/aapt2/ConfigDescription.h b/libs/androidfw/include/androidfw/ConfigDescription.h index b46a50398217..29424c4462aa 100644 --- a/tools/aapt2/ConfigDescription.h +++ b/libs/androidfw/include/androidfw/ConfigDescription.h @@ -14,21 +14,52 @@ * limitations under the License. */ -#ifndef AAPT_CONFIG_DESCRIPTION_H -#define AAPT_CONFIG_DESCRIPTION_H +#ifndef ANDROIDFW_CONFIG_DESCRIPTION_H +#define ANDROIDFW_CONFIG_DESCRIPTION_H #include <ostream> #include "androidfw/ResourceTypes.h" #include "androidfw/StringPiece.h" -namespace aapt { +namespace android { + +using ApiVersion = int; + +enum : ApiVersion { + SDK_CUPCAKE = 3, + SDK_DONUT = 4, + SDK_ECLAIR = 5, + SDK_ECLAIR_0_1 = 6, + SDK_ECLAIR_MR1 = 7, + SDK_FROYO = 8, + SDK_GINGERBREAD = 9, + SDK_GINGERBREAD_MR1 = 10, + SDK_HONEYCOMB = 11, + SDK_HONEYCOMB_MR1 = 12, + SDK_HONEYCOMB_MR2 = 13, + SDK_ICE_CREAM_SANDWICH = 14, + SDK_ICE_CREAM_SANDWICH_MR1 = 15, + SDK_JELLY_BEAN = 16, + SDK_JELLY_BEAN_MR1 = 17, + SDK_JELLY_BEAN_MR2 = 18, + SDK_KITKAT = 19, + SDK_KITKAT_WATCH = 20, + SDK_LOLLIPOP = 21, + SDK_LOLLIPOP_MR1 = 22, + SDK_MARSHMALLOW = 23, + SDK_NOUGAT = 24, + SDK_NOUGAT_MR1 = 25, + SDK_O = 26, + SDK_O_MR1 = 27, + SDK_P = 28, +}; /* * Subclass of ResTable_config that adds convenient * initialization and comparison methods. */ -struct ConfigDescription : public android::ResTable_config { +struct ConfigDescription : public ResTable_config { /** * Returns an immutable default config. */ @@ -180,6 +211,6 @@ inline ::std::ostream& operator<<(::std::ostream& out, return out << o.toString().string(); } -} // namespace aapt +} // namespace android -#endif // AAPT_CONFIG_DESCRIPTION_H +#endif // ANDROIDFW_CONFIG_DESCRIPTION_H diff --git a/libs/androidfw/include/androidfw/LoadedArsc.h b/libs/androidfw/include/androidfw/LoadedArsc.h index 35ae5fcd9e7b..349b379778a6 100644 --- a/libs/androidfw/include/androidfw/LoadedArsc.h +++ b/libs/androidfw/include/androidfw/LoadedArsc.h @@ -78,6 +78,55 @@ using TypeSpecPtr = util::unique_cptr<TypeSpec>; class LoadedPackage { public: + class iterator { + public: + iterator& operator=(const iterator& rhs) { + loadedPackage_ = rhs.loadedPackage_; + typeIndex_ = rhs.typeIndex_; + entryIndex_ = rhs.entryIndex_; + return *this; + } + + bool operator==(const iterator& rhs) const { + return loadedPackage_ == rhs.loadedPackage_ && + typeIndex_ == rhs.typeIndex_ && + entryIndex_ == rhs.entryIndex_; + } + + bool operator!=(const iterator& rhs) const { + return !(*this == rhs); + } + + iterator operator++(int) { + size_t prevTypeIndex_ = typeIndex_; + size_t prevEntryIndex_ = entryIndex_; + operator++(); + return iterator(loadedPackage_, prevTypeIndex_, prevEntryIndex_); + } + + iterator& operator++(); + + uint32_t operator*() const; + + private: + friend class LoadedPackage; + + iterator(const LoadedPackage* lp, size_t ti, size_t ei); + + const LoadedPackage* loadedPackage_; + size_t typeIndex_; + size_t entryIndex_; + const size_t typeIndexEnd_; // STL style end, so one past the last element + }; + + iterator begin() const { + return iterator(this, 0, 0); + } + + iterator end() const { + return iterator(this, resource_ids_.size() + 1, 0); + } + static std::unique_ptr<const LoadedPackage> Load(const Chunk& chunk, const LoadedIdmap* loaded_idmap, bool system, bool load_as_shared_library); @@ -182,6 +231,7 @@ class LoadedPackage { bool overlay_ = false; ByteBucketArray<TypeSpecPtr> type_specs_; + ByteBucketArray<uint32_t> resource_ids_; std::vector<DynamicPackageEntry> dynamic_package_map_; }; diff --git a/tools/aapt2/Locale.h b/libs/androidfw/include/androidfw/Locale.h index 6d8b598415cc..484ed79a8efd 100644 --- a/tools/aapt2/Locale.h +++ b/libs/androidfw/include/androidfw/Locale.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef AAPT_LOCALE_VALUE_H -#define AAPT_LOCALE_VALUE_H +#ifndef ANDROIDFW_LOCALE_VALUE_H +#define ANDROIDFW_LOCALE_VALUE_H #include <string> #include <vector> @@ -23,7 +23,7 @@ #include "androidfw/ResourceTypes.h" #include "androidfw/StringPiece.h" -namespace aapt { +namespace android { /** * A convenience class to build and parse locales. @@ -112,6 +112,6 @@ bool LocaleValue::operator>(const LocaleValue& o) const { return compare(o) > 0; } -} // namespace aapt +} // namespace android -#endif // AAPT_LOCALE_VALUE_H +#endif // ANDROIDFW_LOCALE_VALUE_H diff --git a/libs/androidfw/include/androidfw/PosixUtils.h b/libs/androidfw/include/androidfw/PosixUtils.h new file mode 100644 index 000000000000..8fc3ee2733c7 --- /dev/null +++ b/libs/androidfw/include/androidfw/PosixUtils.h @@ -0,0 +1,36 @@ +/* + * 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 <memory> +#include <string> +#include <vector> + +namespace android { +namespace util { + +struct ProcResult { + int status; + std::string stdout; + std::string stderr; +}; + +// Fork, exec and wait for an external process. Return nullptr if the process could not be launched, +// otherwise a ProcResult containing the external process' exit status and captured stdout and +// stderr. +std::unique_ptr<ProcResult> ExecuteBinary(const std::vector<std::string>& argv); + +} // namespace util +} // namespace android diff --git a/libs/androidfw/include/androidfw/Util.h b/libs/androidfw/include/androidfw/Util.h index 6c9eee0b8835..10d088e02829 100644 --- a/libs/androidfw/include/androidfw/Util.h +++ b/libs/androidfw/include/androidfw/Util.h @@ -19,6 +19,7 @@ #include <cstdlib> #include <memory> +#include <vector> #include "android-base/macros.h" @@ -116,6 +117,8 @@ std::u16string Utf8ToUtf16(const StringPiece& utf8); // Converts a UTF-16 string to a UTF-8 string. std::string Utf16ToUtf8(const StringPiece16& utf16); +std::vector<std::string> SplitAndLowercase(const android::StringPiece& str, char sep); + } // namespace util } // namespace android diff --git a/libs/androidfw/include/androidfw/ZipFileRO.h b/libs/androidfw/include/androidfw/ZipFileRO.h index 03154d04def1..c221e3b7aeae 100644 --- a/libs/androidfw/include/androidfw/ZipFileRO.h +++ b/libs/androidfw/include/androidfw/ZipFileRO.h @@ -41,7 +41,8 @@ #include <unistd.h> #include <time.h> -typedef void* ZipArchiveHandle; +struct ZipArchive; +typedef ZipArchive* ZipArchiveHandle; namespace android { diff --git a/tools/aapt2/ConfigDescription_test.cpp b/libs/androidfw/tests/ConfigDescription_test.cpp index 1f351bf7481d..ce7f8054e2ca 100644 --- a/tools/aapt2/ConfigDescription_test.cpp +++ b/libs/androidfw/tests/ConfigDescription_test.cpp @@ -14,18 +14,16 @@ * limitations under the License. */ -#include "ConfigDescription.h" - -#include <string> - +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" -#include "SdkConstants.h" -#include "test/Test.h" +#include "android-base/logging.h" -using android::StringPiece; +#include "gtest/gtest.h" + +#include <string> -namespace aapt { +namespace android { static ::testing::AssertionResult TestParse( const StringPiece& input, ConfigDescription* config = nullptr) { @@ -140,9 +138,13 @@ TEST(ConfigDescriptionTest, ParseVrAttribute) { EXPECT_EQ(std::string("vrheadset-v26"), config.toString().string()); } -TEST(ConfigDescriptionTest, RangeQualifiersDoNotConflict) { - using test::ParseConfigOrDie; +static inline ConfigDescription ParseConfigOrDie(const android::StringPiece& str) { + ConfigDescription config; + CHECK(ConfigDescription::Parse(str, &config)) << "invalid configuration: " << str; + return config; +} +TEST(ConfigDescriptionTest, RangeQualifiersDoNotConflict) { EXPECT_FALSE(ParseConfigOrDie("large").ConflictsWith(ParseConfigOrDie("normal-land"))); EXPECT_FALSE(ParseConfigOrDie("long-hdpi").ConflictsWith(ParseConfigOrDie("xhdpi"))); EXPECT_FALSE(ParseConfigOrDie("sw600dp").ConflictsWith(ParseConfigOrDie("sw700dp"))); @@ -152,4 +154,4 @@ TEST(ConfigDescriptionTest, RangeQualifiersDoNotConflict) { EXPECT_FALSE(ParseConfigOrDie("600x400").ConflictsWith(ParseConfigOrDie("300x200"))); } -} // namespace aapt +} // namespace android diff --git a/libs/androidfw/tests/LoadedArsc_test.cpp b/libs/androidfw/tests/LoadedArsc_test.cpp index cae632ddea30..ffa48367c252 100644 --- a/libs/androidfw/tests/LoadedArsc_test.cpp +++ b/libs/androidfw/tests/LoadedArsc_test.cpp @@ -278,4 +278,52 @@ TEST(LoadedArscTest, LoadOverlay) { // sizeof(Res_value) might not be backwards compatible. TEST(LoadedArscTest, LoadingShouldBeForwardsAndBackwardsCompatible) { ASSERT_TRUE(false); } +TEST(LoadedArscTest, ResourceIdentifierIterator) { + std::string contents; + ASSERT_TRUE( + ReadFileFromZipToString(GetTestDataPath() + "/basic/basic.apk", "resources.arsc", &contents)); + + std::unique_ptr<const LoadedArsc> loaded_arsc = LoadedArsc::Load(StringPiece(contents)); + ASSERT_NE(nullptr, loaded_arsc); + + const std::vector<std::unique_ptr<const LoadedPackage>>& packages = loaded_arsc->GetPackages(); + ASSERT_EQ(1u, packages.size()); + EXPECT_EQ(std::string("com.android.basic"), packages[0]->GetPackageName()); + + const auto& loaded_package = packages[0]; + auto iter = loaded_package->begin(); + auto end = loaded_package->end(); + + ASSERT_NE(end, iter); + ASSERT_EQ(0x7f010000u, *iter++); + ASSERT_EQ(0x7f010001u, *iter++); + ASSERT_EQ(0x7f020000u, *iter++); + ASSERT_EQ(0x7f020001u, *iter++); + ASSERT_EQ(0x7f030000u, *iter++); + ASSERT_EQ(0x7f030001u, *iter++); + ASSERT_EQ(0x7f030002u, *iter++); // note: string without default, excluded by aapt2 dump + ASSERT_EQ(0x7f040000u, *iter++); + ASSERT_EQ(0x7f040001u, *iter++); + ASSERT_EQ(0x7f040002u, *iter++); + ASSERT_EQ(0x7f040003u, *iter++); + ASSERT_EQ(0x7f040004u, *iter++); + ASSERT_EQ(0x7f040005u, *iter++); + ASSERT_EQ(0x7f040006u, *iter++); + ASSERT_EQ(0x7f040007u, *iter++); + ASSERT_EQ(0x7f040008u, *iter++); + ASSERT_EQ(0x7f040009u, *iter++); + ASSERT_EQ(0x7f04000au, *iter++); + ASSERT_EQ(0x7f04000bu, *iter++); + ASSERT_EQ(0x7f04000cu, *iter++); + ASSERT_EQ(0x7f04000du, *iter++); + ASSERT_EQ(0x7f050000u, *iter++); + ASSERT_EQ(0x7f050001u, *iter++); + ASSERT_EQ(0x7f060000u, *iter++); + ASSERT_EQ(0x7f070000u, *iter++); + ASSERT_EQ(0x7f070001u, *iter++); + ASSERT_EQ(0x7f070002u, *iter++); + ASSERT_EQ(0x7f070003u, *iter++); + ASSERT_EQ(end, iter); +} + } // namespace android diff --git a/tools/aapt2/Locale_test.cpp b/libs/androidfw/tests/Locale_test.cpp index 68b4cae44e15..6b2ef5f6a381 100644 --- a/tools/aapt2/Locale_test.cpp +++ b/libs/androidfw/tests/Locale_test.cpp @@ -14,15 +14,14 @@ * limitations under the License. */ -#include "Locale.h" +#include "androidfw/Locale.h" +#include "androidfw/Util.h" #include <string> #include "gtest/gtest.h" -#include "util/Util.h" - -namespace aapt { +namespace android { static ::testing::AssertionResult TestLanguage(const char* input, const char* lang) { @@ -93,4 +92,4 @@ TEST(ConfigDescriptionTest, ParseLanguage) { EXPECT_TRUE(TestLanguageRegion("fr-rCA", "fr", "CA")); } -} // namespace aapt +} // namespace android diff --git a/libs/androidfw/tests/PosixUtils_test.cpp b/libs/androidfw/tests/PosixUtils_test.cpp new file mode 100644 index 000000000000..cf97f87a4163 --- /dev/null +++ b/libs/androidfw/tests/PosixUtils_test.cpp @@ -0,0 +1,55 @@ +/* + * 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 <utility> + +#include "androidfw/PosixUtils.h" + +#include "TestHelpers.h" + +using ::testing::IsNull; +using ::testing::NotNull; + +namespace android { +namespace util { + +TEST(PosixUtilsTest, AbsolutePathToBinary) { + const auto result = ExecuteBinary({"/bin/date", "--help"}); + ASSERT_THAT(result, NotNull()); + ASSERT_EQ(result->status, 0); + ASSERT_EQ(result->stdout.find("usage: date "), 0); +} + +TEST(PosixUtilsTest, RelativePathToBinary) { + const auto result = ExecuteBinary({"date", "--help"}); + ASSERT_THAT(result, NotNull()); + ASSERT_EQ(result->status, 0); + ASSERT_EQ(result->stdout.find("usage: date "), 0); +} + +TEST(PosixUtilsTest, BadParameters) { + const auto result = ExecuteBinary({"/bin/date", "--this-parameter-is-not-supported"}); + ASSERT_THAT(result, NotNull()); + ASSERT_NE(result->status, 0); +} + +TEST(PosixUtilsTest, NoSuchBinary) { + const auto result = ExecuteBinary({"/this/binary/does/not/exist"}); + ASSERT_THAT(result, IsNull()); +} + +} // android +} // util diff --git a/location/lib/Android.bp b/location/lib/Android.bp index 447195d6d532..b09335c6707f 100644 --- a/location/lib/Android.bp +++ b/location/lib/Android.bp @@ -18,4 +18,5 @@ java_sdk_library { name: "com.android.location.provider", srcs: ["java/**/*.java"], api_packages: ["com.android.location.provider"], + metalava_enabled: false, } diff --git a/media/lib/remotedisplay/Android.bp b/media/lib/remotedisplay/Android.bp index 1e9320d1414d..5f4b930f350e 100644 --- a/media/lib/remotedisplay/Android.bp +++ b/media/lib/remotedisplay/Android.bp @@ -14,22 +14,8 @@ // limitations under the License. // -droiddoc { - name: "com.android.media.remotedisplay.stubs-gen-docs", - srcs: [ - "java/**/*.java", - ], - args: " -hide 111 -hide 113 -hide 125 -hide 126 -hide 127 -hide 128 " + - " -stubpackages com.android.media.remotedisplay " + - " -nodocs ", - custom_template: "droiddoc-templates-sdk", - installable: false, -} - -java_library_static { - name: "com.android.media.remotedisplay.stubs", - srcs: [ - ":com.android.media.remotedisplay.stubs-gen-docs", - ], - sdk_version: "current", +java_sdk_library { + name: "com.android.media.remotedisplay", + srcs: ["java/**/*.java"], + api_packages: ["com.android.media.remotedisplay"], } diff --git a/media/lib/remotedisplay/Android.mk b/media/lib/remotedisplay/Android.mk deleted file mode 100644 index e88c0f1a8dc8..000000000000 --- a/media/lib/remotedisplay/Android.mk +++ /dev/null @@ -1,44 +0,0 @@ -# -# Copyright (C) 2013 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -LOCAL_PATH := $(call my-dir) - -# the remotedisplay library -# ============================================================ -include $(CLEAR_VARS) - -LOCAL_MODULE:= com.android.media.remotedisplay -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := $(call all-java-files-under, java) - -include $(BUILD_JAVA_LIBRARY) - - -# ==== com.android.media.remotedisplay.xml lib def ======================== -include $(CLEAR_VARS) - -LOCAL_MODULE := com.android.media.remotedisplay.xml -LOCAL_MODULE_TAGS := optional - -LOCAL_MODULE_CLASS := ETC - -# This will install the file in /system/etc/permissions -# -LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions - -LOCAL_SRC_FILES := $(LOCAL_MODULE) - -include $(BUILD_PREBUILT) diff --git a/media/lib/remotedisplay/api/current.txt b/media/lib/remotedisplay/api/current.txt new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/media/lib/remotedisplay/api/current.txt diff --git a/media/lib/remotedisplay/api/removed.txt b/media/lib/remotedisplay/api/removed.txt new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/media/lib/remotedisplay/api/removed.txt diff --git a/media/lib/remotedisplay/api/system-current.txt b/media/lib/remotedisplay/api/system-current.txt new file mode 100644 index 000000000000..69bbd35fce59 --- /dev/null +++ b/media/lib/remotedisplay/api/system-current.txt @@ -0,0 +1,52 @@ +package com.android.media.remotedisplay { + + public class RemoteDisplay { + ctor public RemoteDisplay(java.lang.String, java.lang.String); + method public java.lang.String getDescription(); + method public java.lang.String getId(); + method public java.lang.String getName(); + method public int getPresentationDisplayId(); + method public int getStatus(); + method public int getVolume(); + method public int getVolumeHandling(); + method public int getVolumeMax(); + method public void setDescription(java.lang.String); + method public void setName(java.lang.String); + method public void setPresentationDisplayId(int); + method public void setStatus(int); + method public void setVolume(int); + method public void setVolumeHandling(int); + method public void setVolumeMax(int); + field public static final int PLAYBACK_VOLUME_FIXED = 0; // 0x0 + field public static final int PLAYBACK_VOLUME_VARIABLE = 1; // 0x1 + field public static final int STATUS_AVAILABLE = 2; // 0x2 + field public static final int STATUS_CONNECTED = 4; // 0x4 + field public static final int STATUS_CONNECTING = 3; // 0x3 + field public static final int STATUS_IN_USE = 1; // 0x1 + field public static final int STATUS_NOT_AVAILABLE = 0; // 0x0 + } + + public abstract class RemoteDisplayProvider { + ctor public RemoteDisplayProvider(android.content.Context); + method public void addDisplay(com.android.media.remotedisplay.RemoteDisplay); + method public com.android.media.remotedisplay.RemoteDisplay findRemoteDisplay(java.lang.String); + method public android.os.IBinder getBinder(); + method public final android.content.Context getContext(); + method public int getDiscoveryMode(); + method public java.util.Collection<com.android.media.remotedisplay.RemoteDisplay> getDisplays(); + method public android.app.PendingIntent getSettingsPendingIntent(); + method public void onAdjustVolume(com.android.media.remotedisplay.RemoteDisplay, int); + method public void onConnect(com.android.media.remotedisplay.RemoteDisplay); + method public void onDisconnect(com.android.media.remotedisplay.RemoteDisplay); + method public void onDiscoveryModeChanged(int); + method public void onSetVolume(com.android.media.remotedisplay.RemoteDisplay, int); + method public void removeDisplay(com.android.media.remotedisplay.RemoteDisplay); + method public void updateDisplay(com.android.media.remotedisplay.RemoteDisplay); + field public static final int DISCOVERY_MODE_ACTIVE = 2; // 0x2 + field public static final int DISCOVERY_MODE_NONE = 0; // 0x0 + field public static final int DISCOVERY_MODE_PASSIVE = 1; // 0x1 + field public static final java.lang.String SERVICE_INTERFACE = "com.android.media.remotedisplay.RemoteDisplayProvider"; + } + +} + diff --git a/media/lib/remotedisplay/api/system-removed.txt b/media/lib/remotedisplay/api/system-removed.txt new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/media/lib/remotedisplay/api/system-removed.txt diff --git a/media/lib/remotedisplay/api/test-current.txt b/media/lib/remotedisplay/api/test-current.txt new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/media/lib/remotedisplay/api/test-current.txt diff --git a/media/lib/remotedisplay/api/test-removed.txt b/media/lib/remotedisplay/api/test-removed.txt new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/media/lib/remotedisplay/api/test-removed.txt diff --git a/media/lib/remotedisplay/com.android.media.remotedisplay.xml b/media/lib/remotedisplay/com.android.media.remotedisplay.xml deleted file mode 100644 index 77a91d23e1d8..000000000000 --- a/media/lib/remotedisplay/com.android.media.remotedisplay.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2013 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. ---> - -<permissions> - <library name="com.android.media.remotedisplay" - file="/system/framework/com.android.media.remotedisplay.jar" /> -</permissions> diff --git a/media/lib/remotedisplay/java/com/android/media/remotedisplay/RemoteDisplay.java b/media/lib/remotedisplay/java/com/android/media/remotedisplay/RemoteDisplay.java index dc9dd79eb2b1..8de414b45a4d 100644 --- a/media/lib/remotedisplay/java/com/android/media/remotedisplay/RemoteDisplay.java +++ b/media/lib/remotedisplay/java/com/android/media/remotedisplay/RemoteDisplay.java @@ -16,6 +16,7 @@ package com.android.media.remotedisplay; +import android.annotation.SystemApi; import android.media.RemoteDisplayState.RemoteDisplayInfo; import android.text.TextUtils; @@ -23,7 +24,10 @@ import java.util.Objects; /** * Represents a remote display that has been discovered. + * + * @hide */ +@SystemApi public class RemoteDisplay { private final RemoteDisplayInfo mMutableInfo; private RemoteDisplayInfo mImmutableInfo; diff --git a/media/lib/remotedisplay/java/com/android/media/remotedisplay/RemoteDisplayProvider.java b/media/lib/remotedisplay/java/com/android/media/remotedisplay/RemoteDisplayProvider.java index 4d3edb896eb5..7017e444d717 100644 --- a/media/lib/remotedisplay/java/com/android/media/remotedisplay/RemoteDisplayProvider.java +++ b/media/lib/remotedisplay/java/com/android/media/remotedisplay/RemoteDisplayProvider.java @@ -16,6 +16,7 @@ package com.android.media.remotedisplay; +import android.annotation.SystemApi; import android.app.PendingIntent; import android.app.Service; import android.content.Context; @@ -88,7 +89,10 @@ import java.util.Collection; * IMPORTANT: This class is effectively a public API for unbundled applications, and * must remain API stable. See README.txt in the root of this package for more information. * </p> + * + * @hide */ +@SystemApi public abstract class RemoteDisplayProvider { private static final int MSG_SET_CALLBACK = 1; private static final int MSG_SET_DISCOVERY_MODE = 2; diff --git a/media/lib/signer/Android.bp b/media/lib/signer/Android.bp index 3b2578754087..8c43683c2eec 100644 --- a/media/lib/signer/Android.bp +++ b/media/lib/signer/Android.bp @@ -18,4 +18,5 @@ java_sdk_library { name: "com.android.mediadrm.signer", srcs: ["java/**/*.java"], api_packages: ["com.android.mediadrm.signer"], + metalava_enabled: false, } diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java index cdaabdcda20f..d0ca04bb07c2 100644 --- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java +++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java @@ -184,7 +184,6 @@ public class DeviceDiscoveryService extends Service { if (shouldScan(mBluetoothFilters)) { final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(BluetoothDevice.ACTION_FOUND); - intentFilter.addAction(BluetoothDevice.ACTION_DISAPPEARED); mBluetoothBroadcastReceiver = new BluetoothBroadcastReceiver(); registerReceiver(mBluetoothBroadcastReceiver, intentFilter); diff --git a/packages/CtsShim/build/Android.mk b/packages/CtsShim/build/Android.mk index e645adc60b7c..03eb0d9aad5a 100644 --- a/packages/CtsShim/build/Android.mk +++ b/packages/CtsShim/build/Android.mk @@ -67,10 +67,6 @@ LOCAL_MULTILIB := both LOCAL_JNI_SHARED_LIBRARIES := libshim_jni LOCAL_USE_AAPT2 := true -# Disable AAPT2 manifest checks to fix: -# out/target/common/obj/APPS/CtsShimPriv_intermediates/AndroidManifest.xml:25: error: unexpected element <restrict-update> found in <manifest>. -# TODO(b/79755007): Remove when AAPT2 recognizes the manifest elements. -LOCAL_AAPT_FLAGS += --warn-manifest-validation include $(BUILD_PACKAGE) @@ -113,10 +109,6 @@ LOCAL_PACKAGE_NAME := CtsShim LOCAL_MANIFEST_FILE := shim/AndroidManifest.xml LOCAL_USE_AAPT2 := true -# Disable AAPT2 manifest checks to fix: -# frameworks/base/packages/CtsShim/build/shim/AndroidManifest.xml:25: error: unexpected element <restrict-update> found in <manifest>. -# TODO(b/79755007): Remove when AAPT2 recognizes the manifest elements. -LOCAL_AAPT_FLAGS += --warn-manifest-validation include $(BUILD_PACKAGE) diff --git a/packages/PrintSpooler/Android.bp b/packages/PrintSpooler/Android.bp new file mode 100644 index 000000000000..c40a81791302 --- /dev/null +++ b/packages/PrintSpooler/Android.bp @@ -0,0 +1,38 @@ +// Copyright (C) 2013 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +android_app { + name: "PrintSpooler", + + resource_dirs: ["res"], + + srcs: [ + "src/**/*.java", + "src/com/android/printspooler/renderer/IPdfRenderer.aidl", + "src/com/android/printspooler/renderer/IPdfEditor.aidl", + ], + + platform_apis: true, + + jni_libs: ["libprintspooler_jni"], + static_libs: [ + "android-support-v7-recyclerview", + "android-support-compat", + "android-support-media-compat", + "android-support-core-utils", + "android-support-core-ui", + "android-support-fragment", + "android-support-annotations", + ], +} diff --git a/packages/PrintSpooler/Android.mk b/packages/PrintSpooler/Android.mk deleted file mode 100644 index e356f38f10b3..000000000000 --- a/packages/PrintSpooler/Android.mk +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (C) 2013 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := optional - -LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res -LOCAL_USE_AAPT2 := true -LOCAL_SRC_FILES := $(call all-java-files-under, src) -LOCAL_SRC_FILES += \ - src/com/android/printspooler/renderer/IPdfRenderer.aidl \ - src/com/android/printspooler/renderer/IPdfEditor.aidl - -LOCAL_PACKAGE_NAME := PrintSpooler -LOCAL_PRIVATE_PLATFORM_APIS := true - -LOCAL_JNI_SHARED_LIBRARIES := libprintspooler_jni -LOCAL_STATIC_ANDROID_LIBRARIES := \ - android-support-v7-recyclerview \ - android-support-compat \ - android-support-media-compat \ - android-support-core-utils \ - android-support-core-ui \ - android-support-fragment - -LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-annotations - -include $(BUILD_PACKAGE) - -include $(call all-makefiles-under, $(LOCAL_PATH)) diff --git a/packages/PrintSpooler/tests/Android.mk b/packages/PrintSpooler/tests/Android.mk deleted file mode 100644 index 83e00ce089d2..000000000000 --- a/packages/PrintSpooler/tests/Android.mk +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -include $(call all-makefiles-under, $(LOCAL_PATH)) diff --git a/packages/PrintSpooler/tests/outofprocess/Android.bp b/packages/PrintSpooler/tests/outofprocess/Android.bp new file mode 100644 index 000000000000..e88074ee4b9c --- /dev/null +++ b/packages/PrintSpooler/tests/outofprocess/Android.bp @@ -0,0 +1,30 @@ +// Copyright (C) 2016 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +android_test { + name: "PrintSpoolerOutOfProcessTests", + + srcs: ["src/**/*.java"], + + libs: ["android.test.runner.stubs"], + static_libs: [ + "android-support-test", + "ub-uiautomator", + "mockito-target-minus-junit4", + "print-test-util-lib", + ], + + sdk_version: "test_current", + test_suites: ["device-tests"], +} diff --git a/packages/PrintSpooler/tests/outofprocess/Android.mk b/packages/PrintSpooler/tests/outofprocess/Android.mk deleted file mode 100644 index 161a60021e65..000000000000 --- a/packages/PrintSpooler/tests/outofprocess/Android.mk +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests - -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_JAVA_LIBRARIES := android.test.runner.stubs -LOCAL_STATIC_JAVA_LIBRARIES := android-support-test ub-uiautomator mockito-target-minus-junit4 print-test-util-lib - -LOCAL_PACKAGE_NAME := PrintSpoolerOutOfProcessTests -LOCAL_SDK_VERSION := current -LOCAL_COMPATIBILITY_SUITE := device-tests - -include $(BUILD_PACKAGE) diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java index 0b58c9dd0355..9d8336f14f85 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java @@ -97,7 +97,6 @@ public class BluetoothEventManager { addHandler(BluetoothAdapter.ACTION_DISCOVERY_STARTED, new ScanningStateChangedHandler(true)); addHandler(BluetoothAdapter.ACTION_DISCOVERY_FINISHED, new ScanningStateChangedHandler(false)); addHandler(BluetoothDevice.ACTION_FOUND, new DeviceFoundHandler()); - addHandler(BluetoothDevice.ACTION_DISAPPEARED, new DeviceDisappearedHandler()); addHandler(BluetoothDevice.ACTION_NAME_CHANGED, new NameChangedHandler()); addHandler(BluetoothDevice.ACTION_ALIAS_CHANGED, new NameChangedHandler()); @@ -280,24 +279,6 @@ public class BluetoothEventManager { } } - private class DeviceDisappearedHandler implements Handler { - public void onReceive(Context context, Intent intent, - BluetoothDevice device) { - CachedBluetoothDevice cachedDevice = mDeviceManager.findDevice(device); - if (cachedDevice == null) { - Log.w(TAG, "received ACTION_DISAPPEARED for an unknown device: " + device); - return; - } - if (CachedBluetoothDeviceManager.onDeviceDisappeared(cachedDevice)) { - synchronized (mCallbacks) { - for (BluetoothCallback callback : mCallbacks) { - callback.onDeviceDeleted(cachedDevice); - } - } - } - } - } - private class NameChangedHandler implements Handler { public void onReceive(Context context, Intent intent, BluetoothDevice device) { diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml index 8a5cb4a6d643..abce8cfd2d39 100644 --- a/packages/Shell/AndroidManifest.xml +++ b/packages/Shell/AndroidManifest.xml @@ -26,6 +26,7 @@ <uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="android.permission.CALL_PHONE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> + <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" /> <uses-permission android:name="android.permission.READ_CALENDAR" /> @@ -54,6 +55,7 @@ <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> <uses-permission android:name="android.permission.BROADCAST_STICKY" /> + <uses-permission android:name="android.permission.MANAGE_ACCESSIBILITY" /> <!-- Development tool permissions granted to the shell. --> <uses-permission android:name="android.permission.SET_DEBUG_APP" /> <uses-permission android:name="android.permission.SET_PROCESS_LIMIT" /> diff --git a/packages/SystemUI/res/layout/status_bar.xml b/packages/SystemUI/res/layout/status_bar.xml index f0436dea9207..d033057cdb78 100644 --- a/packages/SystemUI/res/layout/status_bar.xml +++ b/packages/SystemUI/res/layout/status_bar.xml @@ -49,11 +49,6 @@ android:paddingEnd="@dimen/status_bar_padding_end" android:orientation="horizontal" > - <ViewStub - android:id="@+id/operator_name" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout="@layout/operator_name" /> <FrameLayout android:layout_height="match_parent" android:layout_width="0dp" @@ -70,6 +65,12 @@ android:layout_width="match_parent" android:clipChildren="false" > + <ViewStub + android:id="@+id/operator_name" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout="@layout/operator_name" /> + <com.android.systemui.statusbar.policy.Clock android:id="@+id/clock" android:layout_width="wrap_content" diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java index 409a78391975..118f1e297779 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java @@ -47,6 +47,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, private final NotificationStackScrollLayout mStackScroller; private final HeadsUpStatusBarView mHeadsUpStatusBarView; private final View mClockView; + private final View mOperatorNameView; private final DarkIconDispatcher mDarkIconDispatcher; private final NotificationPanelView mPanelView; private final Consumer<ExpandableNotificationRow> @@ -61,8 +62,10 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, private final View.OnLayoutChangeListener mStackScrollLayoutChangeListener = (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> updatePanelTranslation(); + private boolean mAnimationsEnabled = true; Point mPoint; + public HeadsUpAppearanceController( NotificationIconAreaController notificationIconAreaController, HeadsUpManagerPhone headsUpManager, @@ -71,7 +74,8 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, statusbarView.findViewById(R.id.heads_up_status_bar_view), statusbarView.findViewById(R.id.notification_stack_scroller), statusbarView.findViewById(R.id.notification_panel), - statusbarView.findViewById(R.id.clock)); + statusbarView.findViewById(R.id.clock), + statusbarView.findViewById(R.id.operator_name_frame)); } @VisibleForTesting @@ -81,7 +85,8 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, HeadsUpStatusBarView headsUpStatusBarView, NotificationStackScrollLayout stackScroller, NotificationPanelView panelView, - View clockView) { + View clockView, + View operatorNameView) { mNotificationIconAreaController = notificationIconAreaController; mHeadsUpManager = headsUpManager; mHeadsUpManager.addListener(this); @@ -97,6 +102,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, mStackScroller.addOnLayoutChangeListener(mStackScrollLayoutChangeListener); mStackScroller.setHeadsUpAppearanceController(this); mClockView = clockView; + mOperatorNameView = operatorNameView; mDarkIconDispatcher = Dependency.get(DarkIconDispatcher.class); mDarkIconDispatcher.addDarkReceiver(this); } @@ -205,20 +211,52 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, mShown = isShown; if (isShown) { mHeadsUpStatusBarView.setVisibility(View.VISIBLE); - CrossFadeHelper.fadeIn(mHeadsUpStatusBarView, CONTENT_FADE_DURATION /* duration */, - CONTENT_FADE_DELAY /* delay */); - CrossFadeHelper.fadeOut(mClockView, CONTENT_FADE_DURATION/* duration */, - 0 /* delay */, () -> mClockView.setVisibility(View.INVISIBLE)); + show(mHeadsUpStatusBarView); + hide(mClockView, View.INVISIBLE); + if (mOperatorNameView != null) { + hide(mOperatorNameView, View.INVISIBLE); + } } else { - CrossFadeHelper.fadeIn(mClockView, CONTENT_FADE_DURATION /* duration */, - CONTENT_FADE_DELAY /* delay */); - CrossFadeHelper.fadeOut(mHeadsUpStatusBarView, CONTENT_FADE_DURATION/* duration */, - 0 /* delay */, () -> mHeadsUpStatusBarView.setVisibility(View.GONE)); - + show(mClockView); + if (mOperatorNameView != null) { + show(mOperatorNameView); + } + hide(mHeadsUpStatusBarView, View.GONE); } } } + /** + * Hides the view and sets the state to endState when finished. + * + * @param view The view to hide. + * @param endState One of {@link View#INVISIBLE} or {@link View#GONE}. + * @see View#setVisibility(int) + * + */ + private void hide(View view, int endState) { + if (mAnimationsEnabled) { + CrossFadeHelper.fadeOut(view, CONTENT_FADE_DURATION /* duration */, + 0 /* delay */, () -> view.setVisibility(endState)); + } else { + view.setVisibility(endState); + } + } + + private void show(View view) { + if (mAnimationsEnabled) { + CrossFadeHelper.fadeIn(view, CONTENT_FADE_DURATION /* duration */, + CONTENT_FADE_DELAY /* delay */); + } else { + view.setVisibility(View.VISIBLE); + } + } + + @VisibleForTesting + void setAnimationsEnabled(boolean enabled) { + mAnimationsEnabled = enabled; + } + @VisibleForTesting public boolean isShown() { return mShown; diff --git a/packages/SystemUI/src/com/android/systemui/tuner/TunablePadding.java b/packages/SystemUI/src/com/android/systemui/tuner/TunablePadding.java index af99236cc393..e85dee841715 100644 --- a/packages/SystemUI/src/com/android/systemui/tuner/TunablePadding.java +++ b/packages/SystemUI/src/com/android/systemui/tuner/TunablePadding.java @@ -51,7 +51,9 @@ public class TunablePadding implements Tunable { public void onTuningChanged(String key, String newValue) { int dimen = mDefaultSize; if (newValue != null) { - dimen = (int) (Integer.parseInt(newValue) * mDensity); + try { + dimen = (int) (Integer.parseInt(newValue) * mDensity); + } catch (NumberFormatException ex) {} } int left = mView.isLayoutRtl() ? FLAG_END : FLAG_START; int right = mView.isLayoutRtl() ? FLAG_START : FLAG_END; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java index 537bfd4be66c..3c5c0b883e08 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java @@ -61,6 +61,7 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { private ExpandableNotificationRow mFirst; private HeadsUpStatusBarView mHeadsUpStatusBarView; private HeadsUpManagerPhone mHeadsUpManager; + private View mOperatorNameView; @Before public void setUp() throws Exception { @@ -70,13 +71,15 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { mHeadsUpStatusBarView = new HeadsUpStatusBarView(mContext, mock(View.class), mock(TextView.class)); mHeadsUpManager = mock(HeadsUpManagerPhone.class); + mOperatorNameView = new View(mContext); mHeadsUpAppearanceController = new HeadsUpAppearanceController( mock(NotificationIconAreaController.class), mHeadsUpManager, mHeadsUpStatusBarView, mStackScroller, mPanelView, - new View(mContext)); + new View(mContext), + mOperatorNameView); mHeadsUpAppearanceController.setExpandedHeight(0.0f, 0.0f); } @@ -123,6 +126,22 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { } @Test + public void testOperatorNameViewUpdated() { + mHeadsUpAppearanceController.setAnimationsEnabled(false); + + mFirst.setPinned(true); + when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true); + when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry()); + mHeadsUpAppearanceController.onHeadsUpPinned(mFirst); + Assert.assertEquals(View.INVISIBLE, mOperatorNameView.getVisibility()); + + mFirst.setPinned(false); + when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false); + mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst); + Assert.assertEquals(View.VISIBLE, mOperatorNameView.getVisibility()); + } + + @Test public void testDestroy() { reset(mHeadsUpManager); reset(mDarkIconDispatcher); diff --git a/services/core/Android.bp b/services/core/Android.bp index cae15bad5414..8cfbda2de776 100644 --- a/services/core/Android.bp +++ b/services/core/Android.bp @@ -4,6 +4,7 @@ java_library_static { aidl: { include_dirs: [ "frameworks/native/aidl/binder", + "frameworks/native/cmds/dumpstate/binder", "system/core/storaged/binder", "system/netd/server/binder", "system/vold/binder", @@ -11,6 +12,7 @@ java_library_static { }, srcs: [ "java/**/*.java", + ":dumpstate_aidl", ":netd_aidl", ":netd_metrics_aidl", ":installd_aidl", @@ -43,6 +45,7 @@ java_library_static { "android.hardware.configstore-V1.0-java", "android.hardware.contexthub-V1.0-java", "android.hidl.manager-V1.0-java", + "netd_aidl_interface-java", ], } diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java index 99e0056254fd..49de4b157776 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -53,12 +53,16 @@ import android.os.Process; import android.os.RemoteCallbackList; import android.os.RemoteException; import android.os.SystemClock; +import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; import android.os.UserManagerInternal; import android.os.UserManagerInternal.UserRestrictionsListener; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; +import android.text.TextUtils; +import android.util.FeatureFlagUtils; +import android.util.Log; import android.util.Slog; import android.util.StatsLog; @@ -386,6 +390,15 @@ class BluetoothManagerService extends IBluetoothManager.Stub { mCallbacks = new RemoteCallbackList<IBluetoothManagerCallback>(); mStateChangeCallbacks = new RemoteCallbackList<IBluetoothStateChangeCallback>(); + // TODO: We need a more generic way to initialize the persist keys of FeatureFlagUtils + boolean isHearingAidEnabled; + String value = SystemProperties.get(FeatureFlagUtils.PERSIST_PREFIX + FeatureFlagUtils.HEARING_AID_SETTINGS); + if (!TextUtils.isEmpty(value)) { + isHearingAidEnabled = Boolean.parseBoolean(value); + Log.v(TAG, "set feature flag HEARING_AID_SETTINGS to " + isHearingAidEnabled); + FeatureFlagUtils.setEnabled(context, FeatureFlagUtils.HEARING_AID_SETTINGS, isHearingAidEnabled); + } + IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED); filter.addAction(BluetoothAdapter.ACTION_BLUETOOTH_ADDRESS_CHANGED); diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 5e8ffb79c493..b750d7959167 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -1679,6 +1679,16 @@ public class ConnectivityService extends IConnectivityManager.Stub "ConnectivityService"); } + private void enforceAnyPermissionOf(String... permissions) { + for (String permission : permissions) { + if (mContext.checkCallingOrSelfPermission(permission) == PERMISSION_GRANTED) { + return; + } + } + throw new SecurityException( + "Requires one of the following permissions: " + String.join(", ", permissions) + "."); + } + private void enforceInternetPermission() { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.INTERNET, @@ -1723,6 +1733,13 @@ public class ConnectivityService extends IConnectivityManager.Stub "ConnectivityService"); } + private void enforceNetworkStackSettingsOrSetup() { + enforceAnyPermissionOf( + android.Manifest.permission.NETWORK_SETTINGS, + android.Manifest.permission.NETWORK_SETUP_WIZARD, + android.Manifest.permission.NETWORK_STACK); + } + private boolean checkNetworkStackPermission() { return PERMISSION_GRANTED == mContext.checkCallingOrSelfPermission( android.Manifest.permission.NETWORK_STACK); @@ -1798,7 +1815,8 @@ public class ConnectivityService extends IConnectivityManager.Stub private void sendStickyBroadcast(Intent intent) { synchronized (this) { - if (!mSystemReady) { + if (!mSystemReady + && intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) { mInitialBroadcast = new Intent(intent); } intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); @@ -1847,8 +1865,6 @@ public class ConnectivityService extends IConnectivityManager.Stub mInitialBroadcast = null; } } - // load the global proxy at startup - mHandler.sendMessage(mHandler.obtainMessage(EVENT_APPLY_GLOBAL_HTTP_PROXY)); // Try bringing up tracker, but KeyStore won't be ready yet for secondary users so wait // for user to unlock device too. @@ -3089,7 +3105,7 @@ public class ConnectivityService extends IConnectivityManager.Stub break; } case EVENT_APPLY_GLOBAL_HTTP_PROXY: { - handleDeprecatedGlobalHttpProxy(); + mProxyTracker.loadDeprecatedGlobalHttpProxy(); break; } case EVENT_PROXY_HAS_CHANGED: { @@ -3479,30 +3495,7 @@ public class ConnectivityService extends IConnectivityManager.Stub ProxyInfo oldProxyInfo = oldLp == null ? null : oldLp.getHttpProxy(); if (!ProxyTracker.proxyInfoEqual(newProxyInfo, oldProxyInfo)) { - mProxyTracker.sendProxyBroadcast(mProxyTracker.getDefaultProxy()); - } - } - - private void handleDeprecatedGlobalHttpProxy() { - final String proxy = Settings.Global.getString(mContext.getContentResolver(), - Settings.Global.HTTP_PROXY); - if (!TextUtils.isEmpty(proxy)) { - String data[] = proxy.split(":"); - if (data.length == 0) { - return; - } - - final String proxyHost = data[0]; - int proxyPort = 8080; - if (data.length > 1) { - try { - proxyPort = Integer.parseInt(data[1]); - } catch (NumberFormatException e) { - return; - } - } - final ProxyInfo p = new ProxyInfo(proxyHost, proxyPort, ""); - setGlobalProxy(p); + mProxyTracker.sendProxyBroadcast(); } } @@ -4008,7 +4001,7 @@ public class ConnectivityService extends IConnectivityManager.Stub @Override public void setAirplaneMode(boolean enable) { - enforceConnectivityInternalPermission(); + enforceNetworkStackSettingsOrSetup(); final long ident = Binder.clearCallingIdentity(); try { final ContentResolver cr = mContext.getContentResolver(); @@ -4789,15 +4782,14 @@ public class ConnectivityService extends IConnectivityManager.Stub } } - private String getNetworkPermission(NetworkCapabilities nc) { - // TODO: make these permission strings AIDL constants instead. + private int getNetworkPermission(NetworkCapabilities nc) { if (!nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED)) { - return NetworkManagementService.PERMISSION_SYSTEM; + return INetd.PERMISSION_SYSTEM; } if (!nc.hasCapability(NET_CAPABILITY_FOREGROUND)) { - return NetworkManagementService.PERMISSION_NETWORK; + return INetd.PERMISSION_NETWORK; } - return null; + return INetd.PERMISSION_NONE; } /** @@ -4870,9 +4862,9 @@ public class ConnectivityService extends IConnectivityManager.Stub if (Objects.equals(nai.networkCapabilities, newNc)) return; - final String oldPermission = getNetworkPermission(nai.networkCapabilities); - final String newPermission = getNetworkPermission(newNc); - if (!Objects.equals(oldPermission, newPermission) && nai.created && !nai.isVPN()) { + final int oldPermission = getNetworkPermission(nai.networkCapabilities); + final int newPermission = getNetworkPermission(newNc); + if (oldPermission != newPermission && nai.created && !nai.isVPN()) { try { mNMS.setNetworkPermission(nai.network.netId, newPermission); } catch (RemoteException e) { @@ -5537,15 +5529,7 @@ public class ConnectivityService extends IConnectivityManager.Stub if (networkAgent.isVPN()) { // Temporarily disable the default proxy (not global). - synchronized (mProxyTracker.mProxyLock) { - if (!mProxyTracker.mDefaultProxyDisabled) { - mProxyTracker.mDefaultProxyDisabled = true; - if (mProxyTracker.mGlobalProxy == null - && mProxyTracker.mDefaultProxy != null) { - mProxyTracker.sendProxyBroadcast(null); - } - } - } + mProxyTracker.setDefaultProxyEnabled(false); // TODO: support proxy per network. } @@ -5567,15 +5551,7 @@ public class ConnectivityService extends IConnectivityManager.Stub } else if (state == NetworkInfo.State.DISCONNECTED) { networkAgent.asyncChannel.disconnect(); if (networkAgent.isVPN()) { - synchronized (mProxyTracker.mProxyLock) { - if (mProxyTracker.mDefaultProxyDisabled) { - mProxyTracker.mDefaultProxyDisabled = false; - if (mProxyTracker.mGlobalProxy == null - && mProxyTracker.mDefaultProxy != null) { - mProxyTracker.sendProxyBroadcast(mProxyTracker.mDefaultProxy); - } - } - } + mProxyTracker.setDefaultProxyEnabled(true); updateUids(networkAgent, networkAgent.networkCapabilities, null); } disconnectAndDestroyNetwork(networkAgent); diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java index ab0a56516ff4..ab5005927c4e 100644 --- a/services/core/java/com/android/server/NetworkManagementService.java +++ b/services/core/java/com/android/server/NetworkManagementService.java @@ -57,6 +57,7 @@ import android.content.ContentResolver; import android.content.Context; import android.net.ConnectivityManager; import android.net.INetd; +import android.net.TetherStatsParcel; import android.net.INetworkManagementEventObserver; import android.net.ITetheringStatsProvider; import android.net.InterfaceConfiguration; @@ -168,19 +169,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub */ public static final String LIMIT_GLOBAL_ALERT = "globalAlert"; - /** - * String to pass to netd to indicate that a network is only accessible - * to apps that have the CHANGE_NETWORK_STATE permission. - */ - public static final String PERMISSION_NETWORK = "NETWORK"; - - /** - * String to pass to netd to indicate that a network is only - * accessible to system apps and those with the CONNECTIVITY_INTERNAL - * permission. - */ - public static final String PERMISSION_SYSTEM = "SYSTEM"; - static class NetdResponseCode { /* Keep in sync with system/netd/server/ResponseCode.h */ public static final int InterfaceListResult = 110; @@ -221,6 +209,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub static final int DAEMON_MSG_MOBILE_CONN_REAL_TIME_INFO = 1; + static final boolean MODIFY_OPERATION_ADD = true; + static final boolean MODIFY_OPERATION_REMOVE = false; + /** * Binder context for this service */ @@ -1116,41 +1107,47 @@ public class NetworkManagementService extends INetworkManagementService.Stub @Override public void addRoute(int netId, RouteInfo route) { - modifyRoute("add", "" + netId, route); + modifyRoute(MODIFY_OPERATION_ADD, netId, route); } @Override public void removeRoute(int netId, RouteInfo route) { - modifyRoute("remove", "" + netId, route); + modifyRoute(MODIFY_OPERATION_REMOVE, netId, route); } - private void modifyRoute(String action, String netId, RouteInfo route) { + private void modifyRoute(boolean add, int netId, RouteInfo route) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - final Command cmd = new Command("network", "route", action, netId); - - // create triplet: interface dest-ip-addr/prefixlength gateway-ip-addr - cmd.appendArg(route.getInterface()); - cmd.appendArg(route.getDestination().toString()); + final String ifName = route.getInterface(); + final String dst = route.getDestination().toString(); + final String nextHop; switch (route.getType()) { case RouteInfo.RTN_UNICAST: if (route.hasGateway()) { - cmd.appendArg(route.getGateway().getHostAddress()); + nextHop = route.getGateway().getHostAddress(); + } else { + nextHop = INetd.NEXTHOP_NONE; } break; case RouteInfo.RTN_UNREACHABLE: - cmd.appendArg("unreachable"); + nextHop = INetd.NEXTHOP_UNREACHABLE; break; case RouteInfo.RTN_THROW: - cmd.appendArg("throw"); + nextHop = INetd.NEXTHOP_THROW; + break; + default: + nextHop = INetd.NEXTHOP_NONE; break; } - try { - mConnector.execute(cmd); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + if (add) { + mNetdService.networkAddRoute(netId, ifName, dst, nextHop); + } else { + mNetdService.networkRemoveRoute(netId, ifName, dst, nextHop); + } + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -1839,31 +1836,30 @@ public class NetworkManagementService extends INetworkManagementService.Stub return new NetworkStats(SystemClock.elapsedRealtime(), 0); } - final PersistableBundle bundle; + final TetherStatsParcel[] tetherStatsVec; try { - bundle = mNetdService.tetherGetStats(); + tetherStatsVec = mNetdService.tetherGetStats(); } catch (RemoteException | ServiceSpecificException e) { throw new IllegalStateException("problem parsing tethering stats: ", e); } final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), - bundle.size()); + tetherStatsVec.length); final NetworkStats.Entry entry = new NetworkStats.Entry(); - for (String iface : bundle.keySet()) { - long[] statsArray = bundle.getLongArray(iface); + for (TetherStatsParcel tetherStats : tetherStatsVec) { try { - entry.iface = iface; + entry.iface = tetherStats.iface; entry.uid = UID_TETHERING; entry.set = SET_DEFAULT; entry.tag = TAG_NONE; - entry.rxBytes = statsArray[INetd.TETHER_STATS_RX_BYTES]; - entry.rxPackets = statsArray[INetd.TETHER_STATS_RX_PACKETS]; - entry.txBytes = statsArray[INetd.TETHER_STATS_TX_BYTES]; - entry.txPackets = statsArray[INetd.TETHER_STATS_TX_PACKETS]; + entry.rxBytes = tetherStats.rxBytes; + entry.rxPackets = tetherStats.rxPackets; + entry.txBytes = tetherStats.txBytes; + entry.txPackets = tetherStats.txPackets; stats.combineValues(entry); } catch (ArrayIndexOutOfBoundsException e) { - throw new IllegalStateException("invalid tethering stats for " + iface, e); + throw new IllegalStateException("invalid tethering stats " + e); } } @@ -1911,44 +1907,21 @@ public class NetworkManagementService extends INetworkManagementService.Stub @Override public void addVpnUidRanges(int netId, UidRange[] ranges) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - Object[] argv = new Object[3 + MAX_UID_RANGES_PER_COMMAND]; - argv[0] = "users"; - argv[1] = "add"; - argv[2] = netId; - int argc = 3; - // Avoid overly long commands by limiting number of UID ranges per command. - for (int i = 0; i < ranges.length; i++) { - argv[argc++] = ranges[i].toString(); - if (i == (ranges.length - 1) || argc == argv.length) { - try { - mConnector.execute("network", Arrays.copyOf(argv, argc)); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - argc = 3; - } + + try { + mNetdService.networkAddUidRanges(netId, ranges); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @Override public void removeVpnUidRanges(int netId, UidRange[] ranges) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - Object[] argv = new Object[3 + MAX_UID_RANGES_PER_COMMAND]; - argv[0] = "users"; - argv[1] = "remove"; - argv[2] = netId; - int argc = 3; - // Avoid overly long commands by limiting number of UID ranges per command. - for (int i = 0; i < ranges.length; i++) { - argv[argc++] = ranges[i].toString(); - if (i == (ranges.length - 1) || argc == argv.length) { - try { - mConnector.execute("network", Arrays.copyOf(argv, argc)); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - argc = 3; - } + try { + mNetdService.networkRemoveUidRanges(netId, ranges); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2406,17 +2379,13 @@ public class NetworkManagementService extends INetworkManagementService.Stub } @Override - public void createPhysicalNetwork(int netId, String permission) { + public void createPhysicalNetwork(int netId, int permission) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - if (permission != null) { - mConnector.execute("network", "create", netId, permission); - } else { - mConnector.execute("network", "create", netId); - } - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkCreatePhysical(netId, permission); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2425,10 +2394,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - mConnector.execute("network", "create", netId, "vpn", hasDNS ? "1" : "0", - secure ? "1" : "0"); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkCreateVpn(netId, hasDNS, secure); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2449,20 +2417,24 @@ public class NetworkManagementService extends INetworkManagementService.Stub @Override public void addInterfaceToNetwork(String iface, int netId) { - modifyInterfaceInNetwork("add", "" + netId, iface); + modifyInterfaceInNetwork(MODIFY_OPERATION_ADD, netId, iface); } @Override public void removeInterfaceFromNetwork(String iface, int netId) { - modifyInterfaceInNetwork("remove", "" + netId, iface); + modifyInterfaceInNetwork(MODIFY_OPERATION_REMOVE, netId, iface); } - private void modifyInterfaceInNetwork(String action, String netId, String iface) { + private void modifyInterfaceInNetwork(boolean add, int netId, String iface) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - mConnector.execute("network", "interface", action, netId, iface); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + if (add) { + mNetdService.networkAddInterface(netId, iface); + } else { + mNetdService.networkRemoveInterface(netId, iface); + } + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2470,20 +2442,20 @@ public class NetworkManagementService extends INetworkManagementService.Stub public void addLegacyRouteForNetId(int netId, RouteInfo routeInfo, int uid) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - final Command cmd = new Command("network", "route", "legacy", uid, "add", netId); - - // create triplet: interface dest-ip-addr/prefixlength gateway-ip-addr final LinkAddress la = routeInfo.getDestinationLinkAddress(); - cmd.appendArg(routeInfo.getInterface()); - cmd.appendArg(la.getAddress().getHostAddress() + "/" + la.getPrefixLength()); + final String ifName = routeInfo.getInterface(); + final String dst = la.toString(); + final String nextHop; + if (routeInfo.hasGateway()) { - cmd.appendArg(routeInfo.getGateway().getHostAddress()); + nextHop = routeInfo.getGateway().getHostAddress(); + } else { + nextHop = ""; } - try { - mConnector.execute(cmd); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkAddLegacyRoute(netId, ifName, dst, nextHop, uid); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2492,9 +2464,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - mConnector.execute("network", "default", "set", netId); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkSetDefault(netId); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2503,49 +2475,41 @@ public class NetworkManagementService extends INetworkManagementService.Stub mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - mConnector.execute("network", "default", "clear"); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkClearDefault(); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @Override - public void setNetworkPermission(int netId, String permission) { + public void setNetworkPermission(int netId, int permission) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - if (permission != null) { - mConnector.execute("network", "permission", "network", "set", permission, netId); - } else { - mConnector.execute("network", "permission", "network", "clear", netId); - } - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkSetPermissionForNetwork(netId, permission); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } + private int parsePermission(String permission) { + if (permission.equals("NETWORK")) { + return INetd.PERMISSION_NETWORK; + } + if (permission.equals("SYSTEM")) { + return INetd.PERMISSION_SYSTEM; + } + return INetd.PERMISSION_NONE; + } @Override public void setPermission(String permission, int[] uids) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - Object[] argv = new Object[4 + MAX_UID_RANGES_PER_COMMAND]; - argv[0] = "permission"; - argv[1] = "user"; - argv[2] = "set"; - argv[3] = permission; - int argc = 4; - // Avoid overly long commands by limiting number of UIDs per command. - for (int i = 0; i < uids.length; ++i) { - argv[argc++] = uids[i]; - if (i == uids.length - 1 || argc == argv.length) { - try { - mConnector.execute("network", Arrays.copyOf(argv, argc)); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - argc = 4; - } + try { + mNetdService.networkSetPermissionForUser(parsePermission(permission), uids); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2553,22 +2517,10 @@ public class NetworkManagementService extends INetworkManagementService.Stub public void clearPermission(int[] uids) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - Object[] argv = new Object[3 + MAX_UID_RANGES_PER_COMMAND]; - argv[0] = "permission"; - argv[1] = "user"; - argv[2] = "clear"; - int argc = 3; - // Avoid overly long commands by limiting number of UIDs per command. - for (int i = 0; i < uids.length; ++i) { - argv[argc++] = uids[i]; - if (i == uids.length - 1 || argc == argv.length) { - try { - mConnector.execute("network", Arrays.copyOf(argv, argc)); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); - } - argc = 3; - } + try { + mNetdService.networkClearPermissionForUser(uids); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2577,9 +2529,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - mConnector.execute("network", "protect", "allow", uid); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkSetProtectAllow(uid); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @@ -2588,26 +2540,26 @@ public class NetworkManagementService extends INetworkManagementService.Stub mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); try { - mConnector.execute("network", "protect", "deny", uid); - } catch (NativeDaemonConnectorException e) { - throw e.rethrowAsParcelableException(); + mNetdService.networkSetProtectDeny(uid); + } catch (RemoteException | ServiceSpecificException e) { + throw new IllegalStateException(e); } } @Override public void addInterfaceToLocalNetwork(String iface, List<RouteInfo> routes) { - modifyInterfaceInNetwork("add", "local", iface); + modifyInterfaceInNetwork(MODIFY_OPERATION_ADD, INetd.NETID_LOCAL, iface); for (RouteInfo route : routes) { if (!route.isDefaultRoute()) { - modifyRoute("add", "local", route); + modifyRoute(MODIFY_OPERATION_ADD, INetd.NETID_LOCAL, route); } } } @Override public void removeInterfaceFromLocalNetwork(String iface) { - modifyInterfaceInNetwork("remove", "local", iface); + modifyInterfaceInNetwork(MODIFY_OPERATION_REMOVE, INetd.NETID_LOCAL, iface); } @Override @@ -2616,7 +2568,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub for (RouteInfo route : routes) { try { - modifyRoute("remove", "local", route); + modifyRoute(MODIFY_OPERATION_REMOVE, INetd.NETID_LOCAL, route); } catch (IllegalStateException e) { failures++; } diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 0f9fe83ba6a5..c17a4cf43854 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -49,7 +49,9 @@ import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.VoLteServiceState; import android.util.LocalLog; +import android.util.StatsLog; +import com.android.internal.annotations.VisibleForTesting; import com.android.internal.app.IBatteryStats; import com.android.internal.telephony.IOnSubscriptionsChangedListener; import com.android.internal.telephony.IPhoneStateListener; @@ -82,7 +84,8 @@ import java.util.NoSuchElementException; * Eventually we may want to remove the notion of dummy value but for now this * looks like the best approach. */ -class TelephonyRegistry extends ITelephonyRegistry.Stub { +@VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) +public class TelephonyRegistry extends ITelephonyRegistry.Stub { private static final String TAG = "TelephonyRegistry"; private static final boolean DBG = false; // STOPSHIP if true private static final boolean DBG_LOC = false; // STOPSHIP if true @@ -324,7 +327,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { // calls go through a oneway interface and local calls going through a // handler before they get to app code. - TelephonyRegistry(Context context) { + @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) + public TelephonyRegistry(Context context) { CellLocation location = CellLocation.getEmpty(); mContext = context; @@ -1681,8 +1685,12 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { try { if (state == TelephonyManager.CALL_STATE_IDLE) { mBatteryStats.notePhoneOff(); + StatsLog.write(StatsLog.PHONE_STATE_CHANGED, + StatsLog.PHONE_STATE_CHANGED__STATE__OFF); } else { mBatteryStats.notePhoneOn(); + StatsLog.write(StatsLog.PHONE_STATE_CHANGED, + StatsLog.PHONE_STATE_CHANGED__STATE__ON); } } catch (RemoteException e) { /* The remote entity disappeared, we can safely ignore the exception. */ diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java index 784d62e51966..302e1950b9a9 100644 --- a/services/core/java/com/android/server/am/ProcessList.java +++ b/services/core/java/com/android/server/am/ProcessList.java @@ -157,9 +157,11 @@ public final class ProcessList { // LMK_TARGET <minfree> <minkillprio> ... (up to 6 pairs) // LMK_PROCPRIO <pid> <uid> <prio> // LMK_PROCREMOVE <pid> + // LMK_PROCPURGE static final byte LMK_TARGET = 0; static final byte LMK_PROCPRIO = 1; static final byte LMK_PROCREMOVE = 2; + static final byte LMK_PROCPURGE = 3; // These are the various interesting memory levels that we will give to // the OOM killer. Note that the OOM killer only supports 6 slots, so we @@ -808,31 +810,46 @@ public final class ProcessList { return true; } + // Never call directly, use writeLmkd() instead + private static boolean writeLmkdCommand(ByteBuffer buf) { + try { + sLmkdOutputStream.write(buf.array(), 0, buf.position()); + } catch (IOException ex) { + Slog.w(TAG, "Error writing to lowmemorykiller socket"); + + try { + sLmkdSocket.close(); + } catch (IOException ex2) { + } + + sLmkdSocket = null; + return false; + } + return true; + } + private static void writeLmkd(ByteBuffer buf) { for (int i = 0; i < 3; i++) { if (sLmkdSocket == null) { - if (openLmkdSocket() == false) { - try { - Thread.sleep(1000); - } catch (InterruptedException ie) { - } - continue; + if (openLmkdSocket() == false) { + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { } - } - - try { - sLmkdOutputStream.write(buf.array(), 0, buf.position()); - return; - } catch (IOException ex) { - Slog.w(TAG, "Error writing to lowmemorykiller socket"); - - try { - sLmkdSocket.close(); - } catch (IOException ex2) { + continue; } - sLmkdSocket = null; + // Purge any previously registered pids + ByteBuffer purge_buf = ByteBuffer.allocate(4); + purge_buf.putInt(LMK_PROCPURGE); + if (writeLmkdCommand(purge_buf) == false) { + // Write failed, skip the rest and retry + continue; + } + } + if (writeLmkdCommand(buf)) { + return; } } } diff --git a/services/core/java/com/android/server/connectivity/NetworkMonitor.java b/services/core/java/com/android/server/connectivity/NetworkMonitor.java index ca9b25699c1c..30659c1e77a3 100644 --- a/services/core/java/com/android/server/connectivity/NetworkMonitor.java +++ b/services/core/java/com/android/server/connectivity/NetworkMonitor.java @@ -1031,6 +1031,11 @@ public class NetworkMonitor extends StateMachine { result.isPortal() /* isCaptivePortal */, startTime, endTime); + log("isCaptivePortal: isSuccessful()=" + result.isSuccessful() + + " isPortal()=" + result.isPortal() + + " RedirectUrl=" + result.redirectUrl + + " StartTime=" + startTime + " EndTime=" + endTime); + return result; } diff --git a/services/core/java/com/android/server/connectivity/ProxyTracker.java b/services/core/java/com/android/server/connectivity/ProxyTracker.java index b7bbd422458f..15468ff05c08 100644 --- a/services/core/java/com/android/server/connectivity/ProxyTracker.java +++ b/services/core/java/com/android/server/connectivity/ProxyTracker.java @@ -16,6 +16,12 @@ package com.android.server.connectivity; +import static android.provider.Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST; +import static android.provider.Settings.Global.GLOBAL_HTTP_PROXY_HOST; +import static android.provider.Settings.Global.GLOBAL_HTTP_PROXY_PAC; +import static android.provider.Settings.Global.GLOBAL_HTTP_PROXY_PORT; +import static android.provider.Settings.Global.HTTP_PROXY; + import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ContentResolver; @@ -47,16 +53,14 @@ public class ProxyTracker { @NonNull private final Context mContext; - // TODO : make this private and import as much managing logic from ConnectivityService as - // possible @NonNull - public final Object mProxyLock = new Object(); + private final Object mProxyLock = new Object(); // The global proxy is the proxy that is set device-wide, overriding any network-specific // proxy. Note however that proxies are hints ; the system does not enforce their use. Hence // this value is only for querying. @Nullable @GuardedBy("mProxyLock") - public ProxyInfo mGlobalProxy = null; + private ProxyInfo mGlobalProxy = null; // The default proxy is the proxy that applies to no particular network if the global proxy // is not set. Individual networks have their own settings that override this. This member // is set through setDefaultProxy, which is called when the default network changes proxies @@ -64,10 +68,10 @@ public class ProxyTracker { // when PacManager resolves the proxy. @Nullable @GuardedBy("mProxyLock") - public volatile ProxyInfo mDefaultProxy = null; - // Whether the default proxy is disabled. TODO : make this mDefaultProxyEnabled + private volatile ProxyInfo mDefaultProxy = null; + // Whether the default proxy is enabled. @GuardedBy("mProxyLock") - public boolean mDefaultProxyDisabled = false; + private boolean mDefaultProxyEnabled = true; // The object responsible for Proxy Auto Configuration (PAC). @NonNull @@ -85,7 +89,7 @@ public class ProxyTracker { @Nullable private static ProxyInfo canonicalizeProxyInfo(@Nullable final ProxyInfo proxy) { if (proxy != null && TextUtils.isEmpty(proxy.getHost()) - && (proxy.getPacFileUrl() == null || Uri.EMPTY.equals(proxy.getPacFileUrl()))) { + && Uri.EMPTY.equals(proxy.getPacFileUrl())) { return null; } return proxy; @@ -122,9 +126,9 @@ public class ProxyTracker { public ProxyInfo getDefaultProxy() { // This information is already available as a world read/writable jvm property. synchronized (mProxyLock) { - final ProxyInfo ret = mGlobalProxy; - if ((ret == null) && !mDefaultProxyDisabled) return mDefaultProxy; - return ret; + if (mGlobalProxy != null) return mGlobalProxy; + if (mDefaultProxyEnabled) return mDefaultProxy; + return null; } } @@ -146,11 +150,10 @@ public class ProxyTracker { */ public void loadGlobalProxy() { ContentResolver res = mContext.getContentResolver(); - String host = Settings.Global.getString(res, Settings.Global.GLOBAL_HTTP_PROXY_HOST); - int port = Settings.Global.getInt(res, Settings.Global.GLOBAL_HTTP_PROXY_PORT, 0); - String exclList = Settings.Global.getString(res, - Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST); - String pacFileUrl = Settings.Global.getString(res, Settings.Global.GLOBAL_HTTP_PROXY_PAC); + String host = Settings.Global.getString(res, GLOBAL_HTTP_PROXY_HOST); + int port = Settings.Global.getInt(res, GLOBAL_HTTP_PROXY_PORT, 0); + String exclList = Settings.Global.getString(res, GLOBAL_HTTP_PROXY_EXCLUSION_LIST); + String pacFileUrl = Settings.Global.getString(res, GLOBAL_HTTP_PROXY_PAC); if (!TextUtils.isEmpty(host) || !TextUtils.isEmpty(pacFileUrl)) { ProxyInfo proxyProperties; if (!TextUtils.isEmpty(pacFileUrl)) { @@ -167,19 +170,44 @@ public class ProxyTracker { mGlobalProxy = proxyProperties; } } + loadDeprecatedGlobalHttpProxy(); // TODO : shouldn't this function call mPacManager.setCurrentProxyScriptUrl ? } /** + * Read the global proxy from the deprecated Settings.Global.HTTP_PROXY setting and apply it. + */ + public void loadDeprecatedGlobalHttpProxy() { + final String proxy = Settings.Global.getString(mContext.getContentResolver(), HTTP_PROXY); + if (!TextUtils.isEmpty(proxy)) { + String data[] = proxy.split(":"); + if (data.length == 0) { + return; + } + + final String proxyHost = data[0]; + int proxyPort = 8080; + if (data.length > 1) { + try { + proxyPort = Integer.parseInt(data[1]); + } catch (NumberFormatException e) { + return; + } + } + final ProxyInfo p = new ProxyInfo(proxyHost, proxyPort, ""); + setGlobalProxy(p); + } + } + + /** * Sends the system broadcast informing apps about a new proxy configuration. * * Confusingly this method also sets the PAC file URL. TODO : separate this, it has nothing * to do in a "sendProxyBroadcast" method. - * @param proxyInfo the proxy spec, or null for no proxy. */ - // TODO : make the argument NonNull final and the method private - public void sendProxyBroadcast(@Nullable ProxyInfo proxyInfo) { - if (proxyInfo == null) proxyInfo = new ProxyInfo("", 0, ""); + public void sendProxyBroadcast() { + final ProxyInfo defaultProxy = getDefaultProxy(); + final ProxyInfo proxyInfo = null != defaultProxy ? defaultProxy : new ProxyInfo("", 0, ""); if (mPacManager.setCurrentProxyScriptUrl(proxyInfo)) return; if (DBG) Slog.d(TAG, "sending Proxy Broadcast for " + proxyInfo); Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION); @@ -232,16 +260,15 @@ public class ProxyTracker { final ContentResolver res = mContext.getContentResolver(); final long token = Binder.clearCallingIdentity(); try { - Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_HOST, host); - Settings.Global.putInt(res, Settings.Global.GLOBAL_HTTP_PROXY_PORT, port); - Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST, - exclList); - Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_PAC, pacFileUrl); + Settings.Global.putString(res, GLOBAL_HTTP_PROXY_HOST, host); + Settings.Global.putInt(res, GLOBAL_HTTP_PROXY_PORT, port); + Settings.Global.putString(res, GLOBAL_HTTP_PROXY_EXCLUSION_LIST, exclList); + Settings.Global.putString(res, GLOBAL_HTTP_PROXY_PAC, pacFileUrl); } finally { Binder.restoreCallingIdentity(token); } - sendProxyBroadcast(mGlobalProxy == null ? mDefaultProxy : proxyInfo); + sendProxyBroadcast(); } } @@ -253,10 +280,7 @@ public class ProxyTracker { */ public void setDefaultProxy(@Nullable ProxyInfo proxyInfo) { synchronized (mProxyLock) { - if (mDefaultProxy != null && mDefaultProxy.equals(proxyInfo)) { - return; - } - if (mDefaultProxy == proxyInfo) return; // catches repeated nulls + if (Objects.equals(mDefaultProxy, proxyInfo)) return; if (proxyInfo != null && !proxyInfo.isValid()) { if (DBG) Slog.d(TAG, "Invalid proxy properties, ignoring: " + proxyInfo); return; @@ -271,14 +295,32 @@ public class ProxyTracker { && (!Uri.EMPTY.equals(proxyInfo.getPacFileUrl())) && proxyInfo.getPacFileUrl().equals(mGlobalProxy.getPacFileUrl())) { mGlobalProxy = proxyInfo; - sendProxyBroadcast(mGlobalProxy); + sendProxyBroadcast(); return; } mDefaultProxy = proxyInfo; if (mGlobalProxy != null) return; - if (!mDefaultProxyDisabled) { - sendProxyBroadcast(proxyInfo); + if (mDefaultProxyEnabled) { + sendProxyBroadcast(); + } + } + } + + /** + * Enable or disable the default proxy. + * + * This sets the flag for enabling/disabling the default proxy and sends the broadcast + * if applicable. + * @param enabled whether the default proxy should be enabled. + */ + public void setDefaultProxyEnabled(final boolean enabled) { + synchronized (mProxyLock) { + if (mDefaultProxyEnabled != enabled) { + mDefaultProxyEnabled = enabled; + if (mGlobalProxy == null && mDefaultProxy != null) { + sendProxyBroadcast(); + } } } } diff --git a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java index 390c0ccb3c6e..1fcb37f7aecc 100644 --- a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java +++ b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java @@ -60,8 +60,6 @@ import android.util.proto.ProtoOutputStream; import dalvik.system.VMRuntime; import libcore.io.IoUtils; -import libcore.io.Libcore; -import libcore.io.Streams; import java.io.BufferedReader; import java.io.File; diff --git a/services/core/java/com/android/server/pm/dex/TEST_MAPPING b/services/core/java/com/android/server/pm/dex/TEST_MAPPING index ad5255904d20..c93af2a5ba41 100644 --- a/services/core/java/com/android/server/pm/dex/TEST_MAPPING +++ b/services/core/java/com/android/server/pm/dex/TEST_MAPPING @@ -1,19 +1,12 @@ { "presubmit": [ { - "name": "DexLoggerTests" - }, - { - "name": "DexManagerTests" - }, - { - "name": "DexoptOptionsTests" - }, - { - "name": "DexoptUtilsTest" - }, - { - "name": "PackageDexUsageTests" + "name": "FrameworksServicesTests", + "options": [ + { + "include-filter": "com.android.server.pm.dex" + } + ] }, { "name": "DexLoggerIntegrationTests" diff --git a/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java b/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java index 1cba1c7bed1b..a55b49fe028d 100644 --- a/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java +++ b/services/core/java/com/android/server/policy/keyguard/KeyguardStateMonitor.java @@ -95,10 +95,22 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub { mIsShowing = showing; mCallback.onShowingChanged(); - try { - mKeystoreService.onKeyguardVisibilityChanged(showing, mCurrentUserId); - } catch (RemoteException e) { - Slog.e(TAG, "Error informing keystore of screen lock", e); + int retry = 2; + while (retry > 0) { + try { + mKeystoreService.onKeyguardVisibilityChanged(showing, mCurrentUserId); + break; + } catch (RemoteException e) { + if (retry == 2) { + Slog.w(TAG, "Error informing keystore of screen lock. Keystore may have died" + + " -> refreshing service token and retrying"); + mKeystoreService = IKeystoreService.Stub.asInterface(ServiceManager + .getService("android.security.keystore")); + } else { + Slog.e(TAG, "Error informing keystore of screen lock after retrying once", e); + } + --retry; + } } } diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp index 306f73aa704b..07cdd05ca893 100644 --- a/services/core/jni/Android.bp +++ b/services/core/jni/Android.bp @@ -57,17 +57,6 @@ cc_library_static { "frameworks/native/services", "system/gatekeeper/include", ], - - product_variables: { - arc: { - cflags: [ - "-DUSE_ARC", - ], - srcs: [ - "com_android_server_ArcVideoService.cpp", - ], - } - } } cc_defaults { @@ -142,7 +131,6 @@ cc_defaults { shared_libs: [ "libarcbridge", "libarcbridgeservice", - "libarcvideobridge", "libchrome", "libmojo", ], diff --git a/services/core/jni/com_android_server_ArcVideoService.cpp b/services/core/jni/com_android_server_ArcVideoService.cpp deleted file mode 100644 index f93cd905a584..000000000000 --- a/services/core/jni/com_android_server_ArcVideoService.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2016, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -//#define LOG_NDEBUG 0 -#define LOG_TAG "ArcVideoService" - -#include <binder/IPCThreadState.h> -#include <binder/IServiceManager.h> -#include <media/arcvideobridge/IArcVideoBridge.h> -#include <utils/Log.h> - -#include <base/bind.h> -#include <base/bind_helpers.h> -#include <mojo/edk/embedder/embedder.h> -#include <mojo/public/cpp/bindings/binding.h> - -#include <arc/ArcBridgeSupport.h> -#include <arc/ArcService.h> -#include <arc/Future.h> -#include <arc/IArcBridgeService.h> -#include <arc/MojoProcessSupport.h> -#include <components/arc/common/video.mojom.h> - -namespace { - -// [MinVersion] of OnVideoInstanceReady method in arc_bridge.mojom. -constexpr int kMinimumArcBridgeHostVersion = 6; - -void onCaptureResult(arc::Future<arc::MojoBootstrapResult>* future, uint32_t version, - mojo::ScopedHandle handle, const std::string& token) { - mojo::edk::ScopedPlatformHandle scoped_platform_handle; - MojoResult result = - mojo::edk::PassWrappedPlatformHandle(handle.release().value(), &scoped_platform_handle); - if (result != MOJO_RESULT_OK) { - ALOGE("Received invalid file descriptor."); - future->set(arc::MojoBootstrapResult()); - return; - } - - base::ScopedFD fd(scoped_platform_handle.release().handle); - future->set(arc::MojoBootstrapResult(std::move(fd), token, version)); -} - -} // namespace - -namespace arc { - -class VideoService : public mojom::VideoInstance, - public ArcService, - public android::BnArcVideoBridge { -public: - explicit VideoService(MojoProcessSupport* mojoProcessSupport) - : mMojoProcessSupport(mojoProcessSupport), mBinding(this) { - mMojoProcessSupport->arc_bridge_support().requestArcBridgeProxyAsync( - this, kMinimumArcBridgeHostVersion); - } - - ~VideoService() override { mMojoProcessSupport->disconnect(&mBinding, &mHostPtr); } - - // VideoInstance overrides: - void InitDeprecated(mojom::VideoHostPtr hostPtr) override { - Init(std::move(hostPtr), base::Bind(&base::DoNothing)); - } - - void Init(mojom::VideoHostPtr hostPtr, const InitCallback& callback) override { - ALOGV("Init"); - mHostPtr = std::move(hostPtr); - // A method must be called while we are still in a Mojo thread so the - // proxy can perform lazy initialization and be able to be called from - // non-Mojo threads later. - // This also caches the version number so it can be obtained by calling - // .version(). - mHostPtr.QueryVersion(base::Bind( - [](const InitCallback& callback, uint32_t version) { - ALOGI("VideoService ready (version=%d)", version); - callback.Run(); - }, - callback)); - ALOGV("Init done"); - } - - // ArcService overrides: - void ready(mojom::ArcBridgeHostPtr* bridgeHost) override { - (*bridgeHost)->OnVideoInstanceReady(mBinding.CreateInterfacePtrAndBind()); - } - - void versionMismatch(uint32_t version) override { - ALOGE("ArcBridgeHost version %d, does not support video (version %d)\n", version, - kMinimumArcBridgeHostVersion); - } - - // BnArcVideoBridge overrides: - MojoBootstrapResult bootstrapVideoAcceleratorFactory() override { - ALOGV("VideoService::bootstrapVideoAcceleratorFactory"); - - Future<MojoBootstrapResult> future; - mMojoProcessSupport->mojo_thread().getTaskRunner()->PostTask( - FROM_HERE, base::Bind(&VideoService::bootstrapVideoAcceleratorFactoryOnMojoThread, - base::Unretained(this), &future)); - return future.get(); - } - - int32_t hostVersion() override { - ALOGV("VideoService::hostVersion"); - return mHostPtr.version(); - } - -private: - void bootstrapVideoAcceleratorFactoryOnMojoThread(Future<MojoBootstrapResult>* future) { - if (!mHostPtr) { - ALOGE("mHostPtr is not ready yet"); - future->set(MojoBootstrapResult()); - return; - } - mHostPtr->OnBootstrapVideoAcceleratorFactory( - base::Bind(&onCaptureResult, base::Unretained(future), mHostPtr.version())); - } - - // Outlives VideoService. - MojoProcessSupport* const mMojoProcessSupport; - mojo::Binding<mojom::VideoInstance> mBinding; - mojom::VideoHostPtr mHostPtr; -}; - -} // namespace arc - -namespace android { - -int register_android_server_ArcVideoService() { - defaultServiceManager()->addService( - String16("android.os.IArcVideoBridge"), - new arc::VideoService(arc::MojoProcessSupport::getLeakyInstance())); - return 0; -} - -} // namespace android diff --git a/services/core/jni/onload.cpp b/services/core/jni/onload.cpp index 0ebef37c1f2f..bb6e6840f3b4 100644 --- a/services/core/jni/onload.cpp +++ b/services/core/jni/onload.cpp @@ -54,9 +54,6 @@ int register_android_server_SyntheticPasswordManager(JNIEnv* env); int register_android_server_GraphicsStatsService(JNIEnv* env); int register_android_hardware_display_DisplayViewport(JNIEnv* env); int register_android_server_net_NetworkStatsService(JNIEnv* env); -#ifdef USE_ARC -int register_android_server_ArcVideoService(); -#endif }; using namespace android; @@ -104,8 +101,5 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) register_android_server_GraphicsStatsService(env); register_android_hardware_display_DisplayViewport(env); register_android_server_net_NetworkStatsService(env); -#ifdef USE_ARC - register_android_server_ArcVideoService(); -#endif return JNI_VERSION_1_4; } diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 82a28954a8c6..439f313e0f0a 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -459,6 +459,12 @@ public final class SystemServer { } } + // Diagnostic to ensure that the system is in a base healthy state. Done here as a common + // non-zygote process. + if (!VMRuntime.hasBootImageSpaces()) { + Slog.wtf(TAG, "Runtime is not running with a boot image!"); + } + // Loop forever. Looper.loop(); throw new RuntimeException("Main thread loop unexpectedly exited"); diff --git a/services/net/java/android/net/ip/IpNeighborMonitor.java b/services/net/java/android/net/ip/IpNeighborMonitor.java index fc07aa1ecd17..9512f1be66ef 100644 --- a/services/net/java/android/net/ip/IpNeighborMonitor.java +++ b/services/net/java/android/net/ip/IpNeighborMonitor.java @@ -40,7 +40,6 @@ import android.util.Log; import com.android.internal.util.BitUtils; import libcore.io.IoUtils; -import libcore.io.Libcore; import java.io.FileDescriptor; import java.net.InetAddress; diff --git a/services/net/java/android/net/ip/RouterAdvertisementDaemon.java b/services/net/java/android/net/ip/RouterAdvertisementDaemon.java index 9d686efcb2ab..d197d017acce 100644 --- a/services/net/java/android/net/ip/RouterAdvertisementDaemon.java +++ b/services/net/java/android/net/ip/RouterAdvertisementDaemon.java @@ -28,7 +28,6 @@ import android.net.TrafficStats; import android.net.util.InterfaceParams; import android.system.ErrnoException; import android.system.Os; -import android.system.StructGroupReq; import android.system.StructTimeval; import android.util.Log; diff --git a/services/net/java/android/net/netlink/NetlinkSocket.java b/services/net/java/android/net/netlink/NetlinkSocket.java index cfcba3a84f51..40098c1532b1 100644 --- a/services/net/java/android/net/netlink/NetlinkSocket.java +++ b/services/net/java/android/net/netlink/NetlinkSocket.java @@ -32,7 +32,6 @@ import android.system.Os; import android.system.StructTimeval; import android.util.Log; import libcore.io.IoUtils; -import libcore.io.Libcore; import java.io.FileDescriptor; import java.io.InterruptedIOException; diff --git a/services/robotests/Android.mk b/services/robotests/Android.mk index 3d7fdbdd7436..de54c4b537e4 100644 --- a/services/robotests/Android.mk +++ b/services/robotests/Android.mk @@ -80,7 +80,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ LOCAL_JAVA_LIBRARIES := \ junit \ - platform-robolectric-3.6.1-prebuilt + platform-robolectric-3.6.2-prebuilt LOCAL_INSTRUMENTATION_FOR := FrameworksServicesLib LOCAL_MODULE := FrameworksServicesRoboTests @@ -105,4 +105,4 @@ LOCAL_TEST_PACKAGE := FrameworksServicesLib LOCAL_INSTRUMENT_SOURCE_DIRS := $(dir $(LOCAL_PATH))backup/java -include prebuilts/misc/common/robolectric/3.6.1/run_robotests.mk +include prebuilts/misc/common/robolectric/3.6.2/run_robotests.mk diff --git a/services/tests/wmtests/src/com/android/server/am/ActivityLaunchParamsModifierTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityLaunchParamsModifierTests.java index 089dc61fc250..f741c70e4821 100644 --- a/services/tests/wmtests/src/com/android/server/am/ActivityLaunchParamsModifierTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityLaunchParamsModifierTests.java @@ -16,16 +16,6 @@ package com.android.server.am; -import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; -import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; - -import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_DONE; -import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_SKIP; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import android.app.ActivityOptions; import android.content.pm.ActivityInfo; import android.graphics.Rect; @@ -34,16 +24,26 @@ import android.support.test.filters.MediumTest; import android.support.test.runner.AndroidJUnit4; import com.android.server.am.LaunchParamsController.LaunchParams; - +import org.junit.runner.RunWith; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; + +import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; +import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; +import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_DONE; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.doAnswer; + +import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_SKIP; /** * Tests for exercising resizing bounds due to activity options. * * Build/Install/Run: - * atest WmTests:ActivityLaunchParamsModifierTests + * atest FrameworksServicesTests:ActivityLaunchParamsModifierTests */ @MediumTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/am/ActivityManagerInternalTest.java b/services/tests/servicestests/src/com/android/server/am/ActivityManagerInternalTest.java index f393d14e1cfb..bce87dc58819 100644 --- a/services/tests/wmtests/src/com/android/server/am/ActivityManagerInternalTest.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityManagerInternalTest.java @@ -33,8 +33,17 @@ import org.mockito.MockitoAnnotations; /** * Test class for {@link ActivityManagerInternal}. * - * Build/Install/Run: - * atest WmTests:ActivityManagerInternalTest + * To run the tests, use + * + * runtest -c com.android.server.am.ActivityManagerInternalTest frameworks-services + * + * or the following steps: + * + * Build: m FrameworksServicesTests + * Install: adb install -r \ + * ${ANDROID_PRODUCT_OUT}/data/app/FrameworksServicesTests/FrameworksServicesTests.apk + * Run: adb shell am instrument -e class com.android.server.am.ActivityManagerInternalTest -w \ + * com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner */ @RunWith(AndroidJUnit4.class) public class ActivityManagerInternalTest { diff --git a/services/tests/wmtests/src/com/android/server/am/ActivityManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/am/ActivityManagerServiceTest.java index c41197dca2d7..c70d1e18c871 100644 --- a/services/tests/wmtests/src/com/android/server/am/ActivityManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityManagerServiceTest.java @@ -28,7 +28,6 @@ import static android.app.ActivityManager.PROCESS_STATE_RECEIVER; import static android.app.ActivityManager.PROCESS_STATE_SERVICE; import static android.app.ActivityManager.PROCESS_STATE_TOP; import static android.util.DebugUtils.valueToString; - import static com.android.server.am.ActivityManagerInternalTest.CustomThread; import static com.android.server.am.ActivityManagerService.DISPATCH_UIDS_CHANGED_UI_MSG; import static com.android.server.am.ActivityManagerService.Injector; @@ -89,8 +88,17 @@ import java.util.function.Function; /** * Test class for {@link ActivityManagerService}. * - * Build/Install/Run: - * atest WmTests:ActivityManagerServiceTest + * To run the tests, use + * + * runtest -c com.android.server.am.ActivityManagerServiceTest frameworks-services + * + * or the following steps: + * + * Build: m FrameworksServicesTests + * Install: adb install -r \ + * ${ANDROID_PRODUCT_OUT}/data/app/FrameworksServicesTests/FrameworksServicesTests.apk + * Run: adb shell am instrument -e class com.android.server.am.ActivityManagerServiceTest -w \ + * com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner */ @SmallTest @RunWith(AndroidJUnit4.class) @@ -822,4 +830,4 @@ public class ActivityManagerServiceTest { mRestricted = restricted; } } -} +}
\ No newline at end of file diff --git a/services/tests/wmtests/src/com/android/server/am/ActivityManagerTest.java b/services/tests/servicestests/src/com/android/server/am/ActivityManagerTest.java index a2f942e7f96e..ba25b1659bd2 100644 --- a/services/tests/wmtests/src/com/android/server/am/ActivityManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityManagerTest.java @@ -18,18 +18,13 @@ package com.android.server.am; import android.app.ActivityManager; import android.app.IActivityManager; -import android.os.RemoteException; +import android.os.ServiceManager; import android.os.UserHandle; +import android.os.RemoteException; import android.test.AndroidTestCase; import java.util.List; -/** - * Tests for {@link ActivityManager}. - * - * Build/Install/Run: - * atest WmTests:ActivityManagerTest - */ public class ActivityManagerTest extends AndroidTestCase { IActivityManager service; diff --git a/services/tests/wmtests/src/com/android/server/am/ActivityRecordTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityRecordTests.java index 616cc0f4007f..5ee1c405bb0e 100644 --- a/services/tests/wmtests/src/com/android/server/am/ActivityRecordTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityRecordTests.java @@ -22,7 +22,11 @@ import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE; import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE; import static android.view.Display.DEFAULT_DISPLAY; +import static com.android.server.am.ActivityStack.ActivityState.DESTROYED; +import static com.android.server.am.ActivityStack.ActivityState.DESTROYING; +import static com.android.server.am.ActivityStack.ActivityState.FINISHING; import static com.android.server.am.ActivityStack.ActivityState.INITIALIZING; +import static com.android.server.am.ActivityStack.ActivityState.PAUSED; import static com.android.server.am.ActivityStack.ActivityState.PAUSING; import static com.android.server.am.ActivityStack.ActivityState.STOPPED; import static com.android.server.am.ActivityStack.REMOVE_TASK_MODE_MOVING; @@ -53,16 +57,17 @@ import android.support.test.filters.MediumTest; import android.support.test.runner.AndroidJUnit4; import android.util.MutableBoolean; +import org.junit.runner.RunWith; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; -import org.junit.runner.RunWith; import org.mockito.invocation.InvocationOnMock; /** * Tests for the {@link ActivityRecord} class. * * Build/Install/Run: - * atest WmTests:com.android.server.am.ActivityRecordTests + * atest FrameworksServicesTests:com.android.server.am.ActivityRecordTests */ @MediumTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/am/ActivityStackSupervisorTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStackSupervisorTests.java index 2209b66e3ed6..1ce41a641935 100644 --- a/services/tests/wmtests/src/com/android/server/am/ActivityStackSupervisorTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityStackSupervisorTests.java @@ -62,7 +62,7 @@ import java.util.ArrayList; * Tests for the {@link ActivityStackSupervisor} class. * * Build/Install/Run: - * atest WmTests:ActivityStackSupervisorTests + * atest FrameworksServicesTests:com.android.server.am.ActivityStackSupervisorTests */ @MediumTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/am/ActivityStackTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java index cac264b81198..01425ed51b55 100644 --- a/services/tests/wmtests/src/com/android/server/am/ActivityStackTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityStackTests.java @@ -33,9 +33,13 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import android.content.pm.ActivityInfo; import android.os.UserHandle; @@ -43,15 +47,15 @@ import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; +import org.junit.runner.RunWith; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; /** * Tests for the {@link ActivityStack} class. * * Build/Install/Run: - * atest WmTests:ActivityStackTests + * atest FrameworksServicesTests:com.android.server.am.ActivityStackTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/am/ActivityStartControllerTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStartControllerTests.java index 37a5a17caf47..7948e4cfcaaa 100644 --- a/services/tests/wmtests/src/com/android/server/am/ActivityStartControllerTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityStartControllerTests.java @@ -19,13 +19,6 @@ package com.android.server.am; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - import android.content.Intent; import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; @@ -34,8 +27,15 @@ import android.support.test.runner.AndroidJUnit4; import com.android.server.am.ActivityStackSupervisor.PendingActivityLaunch; import com.android.server.am.ActivityStarter.Factory; -import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.Test; + +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.times; import java.util.Random; @@ -43,7 +43,7 @@ import java.util.Random; * Tests for the {@link ActivityStartController} class. * * Build/Install/Run: - * atest WmTests:ActivityStartControllerTests + * atest FrameworksServicesTests:ActivityStartControllerTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/am/ActivityStartInterceptorTest.java b/services/tests/servicestests/src/com/android/server/am/ActivityStartInterceptorTest.java index 8f2d2844fc9e..b4b34c507942 100644 --- a/services/tests/wmtests/src/com/android/server/am/ActivityStartInterceptorTest.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityStartInterceptorTest.java @@ -55,7 +55,7 @@ import org.mockito.MockitoAnnotations; * Unit tests for {@link ActivityStartInterceptorTest}. * * Build/Install/Run: - * bit WmTests:ActivityStartInterceptorTest + * bit FrameworksServicesTests:com.android.server.am.ActivityStartInterceptorTest */ @SmallTest public class ActivityStartInterceptorTest { diff --git a/services/tests/wmtests/src/com/android/server/am/ActivityStarterTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java index 048df43916e0..1520859d4aac 100644 --- a/services/tests/wmtests/src/com/android/server/am/ActivityStarterTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java @@ -32,26 +32,10 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; -import static android.content.Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED; - -import static com.android.server.am.ActivityManagerService.ANIMATE; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.anyBoolean; -import static org.mockito.Mockito.anyInt; -import static org.mockito.Mockito.anyObject; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; import android.app.ActivityOptions; import android.app.IApplicationThread; +import android.content.ComponentName; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo.WindowLayout; @@ -66,18 +50,39 @@ import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import android.view.Gravity; +import org.junit.runner.RunWith; +import org.junit.Test; + +import static android.content.Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED; +import static com.android.server.am.ActivityManagerService.ANIMATE; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.anyBoolean; +import static org.mockito.Mockito.anyInt; +import static org.mockito.Mockito.anyObject; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.times; + import com.android.internal.os.BatteryStatsImpl; +import com.android.server.am.ActivityStarter.Factory; import com.android.server.am.LaunchParamsController.LaunchParamsModifier; import com.android.server.am.TaskRecord.TaskRecordFactory; -import org.junit.Test; -import org.junit.runner.RunWith; +import java.util.ArrayList; /** * Tests for the {@link ActivityStarter} class. * * Build/Install/Run: - * atest WmTests:ActivityStarterTests + * atest FrameworksServicesTests:ActivityStarterTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/am/ActivityTestsBase.java b/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java index d9a346b6c589..1cd111fce0ec 100644 --- a/services/tests/wmtests/src/com/android/server/am/ActivityTestsBase.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java @@ -21,17 +21,21 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.view.Display.DEFAULT_DISPLAY; - +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyBoolean; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import android.app.ActivityOptions; +import com.android.server.wm.DisplayWindowController; + +import org.junit.Rule; +import org.mockito.invocation.InvocationOnMock; + import android.app.IApplicationThread; import android.content.ComponentName; import android.content.Context; @@ -48,21 +52,20 @@ import android.service.voice.IVoiceInteractionSession; import android.support.test.InstrumentationRegistry; import android.testing.DexmakerShareClassLoaderRule; + import com.android.internal.app.IVoiceInteractor; + import com.android.server.AttributeCache; import com.android.server.wm.AppWindowContainerController; -import com.android.server.wm.DisplayWindowController; import com.android.server.wm.PinnedStackWindowController; import com.android.server.wm.StackWindowController; import com.android.server.wm.TaskWindowContainerController; import com.android.server.wm.WindowManagerService; import com.android.server.wm.WindowTestUtils; - import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; + /** * A base class to handle common operations in activity related unit tests. diff --git a/services/tests/wmtests/src/com/android/server/am/AppErrorDialogTest.java b/services/tests/servicestests/src/com/android/server/am/AppErrorDialogTest.java index 2289dfc08d0c..3d11c4c84ff1 100644 --- a/services/tests/wmtests/src/com/android/server/am/AppErrorDialogTest.java +++ b/services/tests/servicestests/src/com/android/server/am/AppErrorDialogTest.java @@ -32,10 +32,7 @@ import org.junit.runner.RunWith; import java.io.File; /** - * Tests for {@link AppErrorDialog}. - * - * Build/Install/Run: - * atest WmTests:AppErrorDialogTest + * runtest -c com.android.server.am.AppErrorDialogTest frameworks-services */ @RunWith(AndroidJUnit4.class) @SmallTest diff --git a/services/tests/wmtests/src/com/android/server/am/AssistDataRequesterTest.java b/services/tests/servicestests/src/com/android/server/am/AssistDataRequesterTest.java index 285a84f5972b..ce88d849a1d4 100644 --- a/services/tests/wmtests/src/com/android/server/am/AssistDataRequesterTest.java +++ b/services/tests/servicestests/src/com/android/server/am/AssistDataRequesterTest.java @@ -62,8 +62,7 @@ import java.util.concurrent.TimeUnit; * Note: Currently, we only support fetching the screenshot for the current application, so the * screenshot checks are hardcoded accordingly. * - * Build/Install/Run: - * atest WmTests:AssistDataRequesterTest + * runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/am/AssistDataRequesterTest.java */ @MediumTest @RunWith(AndroidJUnit4.class) diff --git a/services/tests/wmtests/src/com/android/server/am/ClientLifecycleManagerTests.java b/services/tests/servicestests/src/com/android/server/am/ClientLifecycleManagerTests.java index 3098db267a74..ef6d5e81b472 100644 --- a/services/tests/wmtests/src/com/android/server/am/ClientLifecycleManagerTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ClientLifecycleManagerTests.java @@ -1,19 +1,3 @@ -/* - * 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 - */ - package com.android.server.am; import static org.mockito.Mockito.mock; @@ -31,12 +15,6 @@ import android.support.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; -/** - * Test class for {@link ClientLifecycleManager}. - * - * Build/Install/Run: - * atest WmTests:ClientLifecycleManagerTests - */ @RunWith(AndroidJUnit4.class) @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/am/CoreSettingsObserverTest.java b/services/tests/servicestests/src/com/android/server/am/CoreSettingsObserverTest.java index adf3f940820a..da30c11be81a 100644 --- a/services/tests/wmtests/src/com/android/server/am/CoreSettingsObserverTest.java +++ b/services/tests/servicestests/src/com/android/server/am/CoreSettingsObserverTest.java @@ -37,6 +37,7 @@ import com.android.server.AppOpsService; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -47,8 +48,17 @@ import java.io.File; /** * Test class for {@link CoreSettingsObserver}. * - * Build/Install/Run: - * atest WmTests:CoreSettingsObserverTest + * To run the tests, use + * + * runtest -c com.android.server.am.CoreSettingsObserverTest frameworks-services + * + * or the following steps: + * + * Build: m FrameworksServicesTests + * Install: adb install -r \ + * ${ANDROID_PRODUCT_OUT}/data/app/FrameworksServicesTests/FrameworksServicesTests.apk + * Run: adb shell am instrument -e class com.android.server.am.CoreSettingsObserverTest -w \ + * com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner */ @SmallTest @RunWith(AndroidJUnit4.class) diff --git a/services/tests/wmtests/src/com/android/server/am/GlobalSettingsToPropertiesMapperTest.java b/services/tests/servicestests/src/com/android/server/am/GlobalSettingsToPropertiesMapperTest.java index b1e0b51366bd..d9b3e1c0173b 100644 --- a/services/tests/wmtests/src/com/android/server/am/GlobalSettingsToPropertiesMapperTest.java +++ b/services/tests/servicestests/src/com/android/server/am/GlobalSettingsToPropertiesMapperTest.java @@ -36,9 +36,6 @@ import java.util.Map; /** * Tests for {@link GlobalSettingsToPropertiesMapper} - * - * Build/Install/Run: - * atest WmTests:GlobalSettingsToPropertiesMapperTest */ @RunWith(AndroidJUnit4.class) @SmallTest diff --git a/services/tests/wmtests/src/com/android/server/am/LaunchParamsControllerTests.java b/services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java index 5f2bc4d3fea4..161c2875bf49 100644 --- a/services/tests/wmtests/src/com/android/server/am/LaunchParamsControllerTests.java +++ b/services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java @@ -16,14 +16,20 @@ package com.android.server.am; -import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; +import android.app.ActivityOptions; +import android.content.pm.ActivityInfo.WindowLayout; +import android.platform.test.annotations.Presubmit; +import android.support.test.filters.MediumTest; +import android.support.test.runner.AndroidJUnit4; -import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_CONTINUE; -import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_DONE; -import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_SKIP; +import com.android.server.am.LaunchParamsController.LaunchParams; +import org.junit.runner.RunWith; +import org.junit.Before; +import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import com.android.server.am.LaunchParamsController.LaunchParamsModifier; + +import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.doNothing; @@ -34,24 +40,18 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import android.app.ActivityOptions; -import android.content.pm.ActivityInfo.WindowLayout; -import android.platform.test.annotations.Presubmit; -import android.support.test.filters.MediumTest; -import android.support.test.runner.AndroidJUnit4; - -import com.android.server.am.LaunchParamsController.LaunchParams; -import com.android.server.am.LaunchParamsController.LaunchParamsModifier; +import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_DONE; +import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_CONTINUE; +import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_SKIP; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; /** * Tests for exercising {@link LaunchParamsController}. * * Build/Install/Run: - * atest WmTests:LaunchParamsControllerTests + * atest FrameworksServicesTests:LaunchParamsControllerTests */ @MediumTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/am/LockTaskControllerTest.java b/services/tests/servicestests/src/com/android/server/am/LockTaskControllerTest.java index a2e976922b7b..f46d712df65b 100644 --- a/services/tests/wmtests/src/com/android/server/am/LockTaskControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/am/LockTaskControllerTest.java @@ -35,20 +35,9 @@ import static android.telecom.TelecomManager.EMERGENCY_DIALER_COMPONENT; import static com.android.server.am.LockTaskController.STATUS_BAR_MASK_LOCKED; import static com.android.server.am.LockTaskController.STATUS_BAR_MASK_PINNED; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.*; import android.app.StatusBarManager; import android.app.admin.DevicePolicyManager; @@ -87,7 +76,7 @@ import org.mockito.verification.VerificationMode; * Unit tests for {@link LockTaskController}. * * Build/Install/Run: - * bit WmTests:LockTaskControllerTest + * bit FrameworksServicesTests:com.android.server.am.LockTaskControllerTest */ @Presubmit @SmallTest diff --git a/services/tests/wmtests/src/com/android/server/am/MemoryStatUtilTest.java b/services/tests/servicestests/src/com/android/server/am/MemoryStatUtilTest.java index 18b0988f9726..5518ca5bd8cc 100644 --- a/services/tests/wmtests/src/com/android/server/am/MemoryStatUtilTest.java +++ b/services/tests/servicestests/src/com/android/server/am/MemoryStatUtilTest.java @@ -16,9 +16,9 @@ package com.android.server.am; -import static com.android.server.am.MemoryStatUtil.MemoryStat; import static com.android.server.am.MemoryStatUtil.parseMemoryStatFromMemcg; import static com.android.server.am.MemoryStatUtil.parseMemoryStatFromProcfs; +import static com.android.server.am.MemoryStatUtil.MemoryStat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -29,12 +29,6 @@ import android.support.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; -/** - * Tests for {@link MemoryStatUtil}. - * - * Build/Install/Run: - * atest WmTests:MemoryStatUtilTest - */ @RunWith(AndroidJUnit4.class) @SmallTest public class MemoryStatUtilTest { diff --git a/services/tests/wmtests/src/com/android/server/am/PendingRemoteAnimationRegistryTest.java b/services/tests/servicestests/src/com/android/server/am/PendingRemoteAnimationRegistryTest.java index f812ee6f1fda..2baf9952cb9e 100644 --- a/services/tests/wmtests/src/com/android/server/am/PendingRemoteAnimationRegistryTest.java +++ b/services/tests/servicestests/src/com/android/server/am/PendingRemoteAnimationRegistryTest.java @@ -20,11 +20,14 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import android.annotation.Nullable; import android.app.ActivityOptions; +import android.os.Handler; import android.platform.test.annotations.Presubmit; import android.support.test.filters.FlakyTest; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; +import android.util.ArrayMap; import android.view.RemoteAnimationAdapter; import com.android.server.testutils.OffsettableClock; @@ -37,10 +40,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; /** - * Tests for {@link PendingRemoteAnimationRegistry}. - * - * Build/Install/Run: - * atest WmTests:PendingRemoteAnimationRegistryTest + * atest PendingRemoteAnimationRegistryTest */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/am/PersistentConnectionTest.java b/services/tests/servicestests/src/com/android/server/am/PersistentConnectionTest.java index 5c42081d4655..54f93a88a387 100644 --- a/services/tests/wmtests/src/com/android/server/am/PersistentConnectionTest.java +++ b/services/tests/servicestests/src/com/android/server/am/PersistentConnectionTest.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.android.server.am; import static org.mockito.ArgumentMatchers.any; @@ -42,12 +41,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -/** - * Tests for {@link PersistentConnection}. - * - * Build/Install/Run: - * atest WmTests:PersistentConnectionTest - */ @SmallTest public class PersistentConnectionTest extends AndroidTestCase { private static class MyConnection extends PersistentConnection<IDeviceAdminService> { diff --git a/services/tests/wmtests/src/com/android/server/am/RecentTasksTest.java b/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java index 739467a48d16..b73ac8934cb0 100644 --- a/services/tests/wmtests/src/com/android/server/am/RecentTasksTest.java +++ b/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java @@ -35,12 +35,16 @@ import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; import static java.lang.Integer.MAX_VALUE; +import android.annotation.TestApi; import android.app.ActivityManager; import android.app.ActivityManager.RecentTaskInfo; import android.app.ActivityManager.RunningTaskInfo; +import android.app.WindowConfiguration; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; @@ -49,6 +53,7 @@ import android.content.pm.UserInfo; import android.content.res.Configuration; import android.graphics.Rect; import android.os.Bundle; +import android.os.Debug; import android.os.Looper; import android.os.RemoteException; import android.os.SystemClock; @@ -75,10 +80,7 @@ import java.util.Random; import java.util.Set; /** - * Tests for {@link RecentTasks}. - * - * Build/Install/Run: - * atest WmTests:RecentTasksTest + * atest FrameworksServicesTests:RecentTasksTest */ @MediumTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/am/RecentsAnimationTest.java b/services/tests/servicestests/src/com/android/server/am/RecentsAnimationTest.java index ee576e310982..eefd973112f5 100644 --- a/services/tests/wmtests/src/com/android/server/am/RecentsAnimationTest.java +++ b/services/tests/servicestests/src/com/android/server/am/RecentsAnimationTest.java @@ -16,13 +16,15 @@ package com.android.server.am; +import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; - +import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK; +import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static com.android.server.wm.RecentsAnimationController.REORDER_KEEP_IN_PLACE; - import static org.mockito.Mockito.any; +import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; @@ -37,18 +39,13 @@ import android.support.test.InstrumentationRegistry; import android.support.test.filters.MediumTest; import android.support.test.runner.AndroidJUnit4; import android.view.IRecentsAnimationRunner; - import com.android.server.AttributeCache; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; /** - * Tests for {@link RecentsAnimation}. - * - * Build/Install/Run: - * atest WmTests:RecentsAnimationTest + * atest FrameworksServicesTests:RecentsAnimationTest */ @MediumTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/am/RunningTasksTest.java b/services/tests/servicestests/src/com/android/server/am/RunningTasksTest.java index 4e5fbd8f8279..c6ce7e1188e8 100644 --- a/services/tests/wmtests/src/com/android/server/am/RunningTasksTest.java +++ b/services/tests/servicestests/src/com/android/server/am/RunningTasksTest.java @@ -41,11 +41,8 @@ import org.junit.runner.RunWith; import java.util.ArrayList; - /** - * Tests for {@link RunningTasks}. - * - * Build/Install/Run: - * atest WmTests:RunningTasksTest +/** + * runtest --path frameworks/base/services/tests/servicestests/src/com/android/server/am/RunningTasksTest.java */ @MediumTest @Presubmit @@ -126,4 +123,4 @@ public class RunningTasksTest extends ActivityTestsBase { .build(); return task; } -} +}
\ No newline at end of file diff --git a/services/tests/wmtests/src/com/android/server/am/SafeActivityOptionsTest.java b/services/tests/servicestests/src/com/android/server/am/SafeActivityOptionsTest.java index 3f05c8c7e9f5..168bc1782d56 100644 --- a/services/tests/wmtests/src/com/android/server/am/SafeActivityOptionsTest.java +++ b/services/tests/servicestests/src/com/android/server/am/SafeActivityOptionsTest.java @@ -27,12 +27,6 @@ import android.support.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; -/** - * Tests for {@link SafeActivityOptions}. - * - * Build/Install/Run: - * atest WmTests:SafeActivityOptionsTest - */ @MediumTest @Presubmit @FlakyTest diff --git a/services/tests/wmtests/src/com/android/server/am/TaskLaunchParamsModifierTests.java b/services/tests/servicestests/src/com/android/server/am/TaskLaunchParamsModifierTests.java index 7fb63d3d4355..3d323f0eb783 100644 --- a/services/tests/wmtests/src/com/android/server/am/TaskLaunchParamsModifierTests.java +++ b/services/tests/servicestests/src/com/android/server/am/TaskLaunchParamsModifierTests.java @@ -16,29 +16,37 @@ package com.android.server.am; -import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; -import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; - -import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_CONTINUE; - -import static org.junit.Assert.assertEquals; - import android.content.pm.ActivityInfo.WindowLayout; import android.graphics.Rect; import android.platform.test.annotations.Presubmit; import android.support.test.filters.MediumTest; import android.support.test.runner.AndroidJUnit4; + import android.view.Gravity; +import org.junit.runner.RunWith; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; + +import org.mockito.invocation.InvocationOnMock; + +import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; +import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; + +import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_CONTINUE; + +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.doAnswer; +import static org.junit.Assert.assertEquals; + /** * Tests for exercising resizing task bounds. * * Build/Install/Run: - * atest WmTests:TaskLaunchParamsModifierTests + * atest FrameworksServicesTests:TaskLaunchParamsModifierTests */ @MediumTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/am/TaskPersisterTest.java b/services/tests/servicestests/src/com/android/server/am/TaskPersisterTest.java index cdafb5258a34..9e6055d55e0f 100644 --- a/services/tests/wmtests/src/com/android/server/am/TaskPersisterTest.java +++ b/services/tests/servicestests/src/com/android/server/am/TaskPersisterTest.java @@ -17,16 +17,20 @@ package com.android.server.am; import android.content.pm.UserInfo; +import android.os.Environment; import android.os.UserHandle; import android.os.UserManager; import android.test.AndroidTestCase; +import android.util.Log; import android.util.SparseBooleanArray; +import com.android.server.am.TaskPersister; + +import java.io.File; +import java.util.Random; + /** - * Tests for {@link TaskPersister}. - * - * Build/Install/Run: - * atest WmTests:TaskPersisterTest + * atest FrameworksServicesTests:TaskPersisterTest */ public class TaskPersisterTest extends AndroidTestCase { private static final String TEST_USER_NAME = "AM-Test-User"; diff --git a/services/tests/wmtests/src/com/android/server/am/TaskRecordTests.java b/services/tests/servicestests/src/com/android/server/am/TaskRecordTests.java index dbb3e7ee4183..057fdc8c10bb 100644 --- a/services/tests/wmtests/src/com/android/server/am/TaskRecordTests.java +++ b/services/tests/servicestests/src/com/android/server/am/TaskRecordTests.java @@ -29,16 +29,20 @@ import android.app.ActivityManager; import android.content.ComponentName; import android.content.Intent; import android.content.pm.ActivityInfo; +import android.content.res.XmlResourceParser; import android.graphics.Rect; import android.platform.test.annotations.Presubmit; import android.service.voice.IVoiceInteractionSession; +import android.support.test.InstrumentationRegistry; import android.support.test.filters.MediumTest; import android.support.test.runner.AndroidJUnit4; import android.util.Xml; +import com.android.frameworks.servicestests.R; import com.android.internal.app.IVoiceInteractor; import com.android.server.am.TaskRecord.TaskRecordFactory; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -53,13 +57,15 @@ import java.io.FileReader; import java.io.IOException; import java.io.OutputStream; import java.io.Reader; +import java.nio.file.Files; import java.util.ArrayList; +import java.util.Comparator; /** * Tests for exercising {@link TaskRecord}. * * Build/Install/Run: - * atest WmTests:TaskRecordTests + * atest FrameworksServicesTests:com.android.server.am.TaskRecordTests */ @MediumTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/am/TaskStackChangedListenerTest.java b/services/tests/servicestests/src/com/android/server/am/TaskStackChangedListenerTest.java index 28689cb701c9..0359096892bb 100644 --- a/services/tests/wmtests/src/com/android/server/am/TaskStackChangedListenerTest.java +++ b/services/tests/servicestests/src/com/android/server/am/TaskStackChangedListenerTest.java @@ -17,7 +17,6 @@ package com.android.server.am; import static android.support.test.InstrumentationRegistry.getInstrumentation; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -33,30 +32,23 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; +import android.content.res.Resources.Theme; import android.os.RemoteException; import android.support.test.InstrumentationRegistry; import android.support.test.filters.MediumTest; import android.support.test.runner.AndroidJUnit4; import android.support.test.uiautomator.UiDevice; import android.text.TextUtils; - +import android.util.Pair; import com.android.internal.annotations.GuardedBy; - +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -/** - * Tests for {@link TaskStackListener}. - * - * Build/Install/Run: - * atest WmTests:TaskStackChangedListenerTest - */ @MediumTest @RunWith(AndroidJUnit4.class) public class TaskStackChangedListenerTest { diff --git a/services/tests/wmtests/src/com/android/server/am/UserControllerTest.java b/services/tests/servicestests/src/com/android/server/am/UserControllerTest.java index fb5ded51489f..cc4f51987523 100644 --- a/services/tests/wmtests/src/com/android/server/am/UserControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/am/UserControllerTest.java @@ -16,30 +16,6 @@ package com.android.server.am; -import static android.content.pm.PackageManager.PERMISSION_GRANTED; -import static android.testing.DexmakerShareClassLoaderRule.runWithDexmakerShareClassLoader; - -import static com.android.server.am.UserController.CONTINUE_USER_SWITCH_MSG; -import static com.android.server.am.UserController.REPORT_LOCKED_BOOT_COMPLETE_MSG; -import static com.android.server.am.UserController.REPORT_USER_SWITCH_COMPLETE_MSG; -import static com.android.server.am.UserController.REPORT_USER_SWITCH_MSG; -import static com.android.server.am.UserController.SYSTEM_USER_CURRENT_MSG; -import static com.android.server.am.UserController.SYSTEM_USER_START_MSG; -import static com.android.server.am.UserController.USER_SWITCH_TIMEOUT_MSG; - -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.when; - import android.app.IUserSwitchObserver; import android.content.Context; import android.content.IIntentReceiver; @@ -72,11 +48,30 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import static android.content.pm.PackageManager.PERMISSION_GRANTED; +import static android.testing.DexmakerShareClassLoaderRule.runWithDexmakerShareClassLoader; +import static com.android.server.am.UserController.CONTINUE_USER_SWITCH_MSG; +import static com.android.server.am.UserController.REPORT_LOCKED_BOOT_COMPLETE_MSG; +import static com.android.server.am.UserController.REPORT_USER_SWITCH_COMPLETE_MSG; +import static com.android.server.am.UserController.REPORT_USER_SWITCH_MSG; +import static com.android.server.am.UserController.SYSTEM_USER_CURRENT_MSG; +import static com.android.server.am.UserController.SYSTEM_USER_START_MSG; +import static com.android.server.am.UserController.USER_SWITCH_TIMEOUT_MSG; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyBoolean; +import static org.mockito.Matchers.anyInt; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.when; + /** - * Tests for {@link UserController}. - * - * Build/Install/Run: - * atest WmTests:UserControllerTest + * Usage: bit FrameworksServicesTests:com.android.server.am.UserControllerTest */ @Presubmit public class UserControllerTest extends AndroidTestCase { diff --git a/services/tests/wmtests/src/com/android/server/policy/FakeWindowState.java b/services/tests/servicestests/src/com/android/server/policy/FakeWindowState.java index 7487d4490d9a..7487d4490d9a 100644 --- a/services/tests/wmtests/src/com/android/server/policy/FakeWindowState.java +++ b/services/tests/servicestests/src/com/android/server/policy/FakeWindowState.java diff --git a/services/tests/wmtests/src/com/android/server/policy/PhoneWindowManagerInsetsTest.java b/services/tests/servicestests/src/com/android/server/policy/PhoneWindowManagerInsetsTest.java index 7e18ce78c9d1..7e18ce78c9d1 100644 --- a/services/tests/wmtests/src/com/android/server/policy/PhoneWindowManagerInsetsTest.java +++ b/services/tests/servicestests/src/com/android/server/policy/PhoneWindowManagerInsetsTest.java diff --git a/services/tests/wmtests/src/com/android/server/policy/PhoneWindowManagerLayoutTest.java b/services/tests/servicestests/src/com/android/server/policy/PhoneWindowManagerLayoutTest.java index 97a716f6bd99..97a716f6bd99 100644 --- a/services/tests/wmtests/src/com/android/server/policy/PhoneWindowManagerLayoutTest.java +++ b/services/tests/servicestests/src/com/android/server/policy/PhoneWindowManagerLayoutTest.java diff --git a/services/tests/wmtests/src/com/android/server/policy/PhoneWindowManagerTest.java b/services/tests/servicestests/src/com/android/server/policy/PhoneWindowManagerTest.java index 30665b56c8dc..30665b56c8dc 100644 --- a/services/tests/wmtests/src/com/android/server/policy/PhoneWindowManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/policy/PhoneWindowManagerTest.java diff --git a/services/tests/wmtests/src/com/android/server/policy/PhoneWindowManagerTestBase.java b/services/tests/servicestests/src/com/android/server/policy/PhoneWindowManagerTestBase.java index 2c47a9432eff..2c47a9432eff 100644 --- a/services/tests/wmtests/src/com/android/server/policy/PhoneWindowManagerTestBase.java +++ b/services/tests/servicestests/src/com/android/server/policy/PhoneWindowManagerTestBase.java diff --git a/services/tests/wmtests/src/com/android/server/wm/AnimatingAppWindowTokenRegistryTest.java b/services/tests/servicestests/src/com/android/server/wm/AnimatingAppWindowTokenRegistryTest.java index a396946db247..164c80b2427a 100644 --- a/services/tests/wmtests/src/com/android/server/wm/AnimatingAppWindowTokenRegistryTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/AnimatingAppWindowTokenRegistryTest.java @@ -18,10 +18,13 @@ package com.android.server.wm; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; - +import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; +import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; - +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; @@ -30,9 +33,12 @@ import android.support.test.filters.FlakyTest; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; +import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -40,7 +46,7 @@ import org.mockito.MockitoAnnotations; * Tests for the {@link TaskStack} class. * * Build/Install/Run: - * atest WmTests:AnimatingAppWindowTokenRegistryTest + * atest FrameworksServicesTests:com.android.server.wm.AnimatingAppWindowTokenRegistryTest */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java b/services/tests/servicestests/src/com/android/server/wm/AppTransitionTests.java index 6b3266d2f0a0..be7d781799fa 100644 --- a/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/AppTransitionTests.java @@ -20,7 +20,6 @@ import static android.view.WindowManager.TRANSIT_ACTIVITY_OPEN; import static android.view.WindowManager.TRANSIT_CRASHING_ACTIVITY_CLOSE; import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY; import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE; - import static org.junit.Assert.assertEquals; import android.content.Context; @@ -37,8 +36,7 @@ import org.junit.runner.RunWith; /** * Test class for {@link AppTransition}. * - * Build/Install/Run: - * atest WmTests:AppTransitionTests + * atest AppTransitionTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/AppWindowContainerControllerTests.java b/services/tests/servicestests/src/com/android/server/wm/AppWindowContainerControllerTests.java index 09a084737def..e0645b1f4bfb 100644 --- a/services/tests/wmtests/src/com/android/server/wm/AppWindowContainerControllerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/AppWindowContainerControllerTests.java @@ -16,32 +16,30 @@ package com.android.server.wm; +import android.support.test.filters.FlakyTest; +import org.junit.Test; + +import android.platform.test.annotations.Presubmit; +import android.support.test.InstrumentationRegistry; +import android.support.test.filters.SmallTest; +import android.support.test.runner.AndroidJUnit4; + import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.content.res.Configuration.EMPTY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; -import android.platform.test.annotations.Presubmit; -import android.support.test.InstrumentationRegistry; -import android.support.test.filters.FlakyTest; -import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; - import com.android.server.wm.WindowTestUtils.TestTaskWindowContainerController; -import org.junit.Test; - /** * Test class for {@link AppWindowContainerController}. * - * Build/Install/Run: - * atest WmTests:AppWindowContainerControllerTests + * atest FrameworksServicesTests:com.android.server.wm.AppWindowContainerControllerTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java b/services/tests/servicestests/src/com/android/server/wm/AppWindowTokenTests.java index 8dedb584ae59..f6599dcaf87e 100644 --- a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/AppWindowTokenTests.java @@ -16,6 +16,16 @@ package com.android.server.wm; +import org.junit.Test; +import org.junit.runner.RunWith; + +import android.platform.test.annotations.Presubmit; +import android.support.test.filters.FlakyTest; +import android.support.test.filters.SmallTest; +import android.support.test.runner.AndroidJUnit4; +import android.view.Surface; +import android.view.WindowManager; + import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; @@ -28,27 +38,15 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.TRANSIT_UNSET; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; - -import android.platform.test.annotations.Presubmit; -import android.support.test.filters.FlakyTest; -import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; -import android.view.Surface; -import android.view.WindowManager; - -import org.junit.Test; -import org.junit.runner.RunWith; - /** * Tests for the {@link AppWindowToken} class. * * Build/Install/Run: - * atest WmTests:AppWindowTokenTests + * atest FrameworksServicesTests:com.android.server.wm.AppWindowTokenTests */ @SmallTest // TODO: b/68267650 diff --git a/services/tests/wmtests/src/com/android/server/wm/BoundsAnimationControllerTests.java b/services/tests/servicestests/src/com/android/server/wm/BoundsAnimationControllerTests.java index 7fbb4ee3b0b4..ff631e74e004 100644 --- a/services/tests/wmtests/src/com/android/server/wm/BoundsAnimationControllerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/BoundsAnimationControllerTests.java @@ -21,12 +21,6 @@ import static com.android.server.wm.BoundsAnimationController.SCHEDULE_PIP_MODE_ import static com.android.server.wm.BoundsAnimationController.SCHEDULE_PIP_MODE_CHANGED_ON_START; import static com.android.server.wm.BoundsAnimationController.SchedulePipModeChangedState; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - import android.animation.ValueAnimator; import android.content.Context; import android.graphics.Rect; @@ -38,12 +32,23 @@ import android.support.test.annotation.UiThreadTest; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; -import com.android.server.wm.BoundsAnimationController.BoundsAnimator; import com.android.server.wm.WindowManagerInternal.AppTransitionListener; import org.junit.Test; import org.junit.runner.RunWith; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.android.server.wm.BoundsAnimationController.BoundsAnimator; + /** * Test class for {@link BoundsAnimationController} to ensure that it sends the right callbacks * depending on the various interactions. @@ -55,7 +60,7 @@ import org.junit.runner.RunWith; * appropriately. * * Build/Install/Run: - * bit WmTests:BoundsAnimationControllerTests + * bit FrameworksServicesTests:com.android.server.wm.BoundsAnimationControllerTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/ConfigurationContainerTests.java b/services/tests/servicestests/src/com/android/server/wm/ConfigurationContainerTests.java index 6a6f9543842f..192e1564ae8d 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ConfigurationContainerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/ConfigurationContainerTests.java @@ -17,6 +17,7 @@ package com.android.server.wm; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; +import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; @@ -27,7 +28,6 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; import static android.content.res.Configuration.EMPTY; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -35,7 +35,6 @@ import android.content.res.Configuration; import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; - import org.junit.Test; import org.junit.runner.RunWith; @@ -46,7 +45,7 @@ import java.util.List; * Test class for {@link ConfigurationContainer}. * * Build/Install/Run: - * atest WmTests:ConfigurationContainerTests + * bit FrameworksServicesTests:com.android.server.wm.ConfigurationContainerTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java b/services/tests/servicestests/src/com/android/server/wm/DimmerTests.java index a12a802f0920..6769e40dca78 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/DimmerTests.java @@ -38,10 +38,8 @@ import org.junit.Test; import org.junit.runner.RunWith; /** - * Tests for {@link Dimmer}. - * * Build/Install/Run: - * atest WmTests:DimmerTests; + * atest FrameworksServicesTests:com.android.server.wm.DimmerTests; */ @Presubmit @RunWith(AndroidJUnit4.class) diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java index a9744ea2dc1a..ac196f9c80dc 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/DisplayContentTests.java @@ -28,7 +28,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_ import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION; - import static com.android.server.wm.WindowContainer.POSITION_TOP; import static org.hamcrest.Matchers.is; @@ -39,6 +38,9 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import org.junit.Test; +import org.junit.runner.RunWith; + import android.annotation.SuppressLint; import android.content.res.Configuration; import android.graphics.Rect; @@ -55,9 +57,6 @@ import android.view.Surface; import com.android.server.wm.utils.WmDisplayCutout; -import org.junit.Test; -import org.junit.runner.RunWith; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -68,7 +67,7 @@ import java.util.List; * Tests for the {@link DisplayContent} class. * * Build/Install/Run: - * atest WmTests:DisplayContentTests + * atest com.android.server.wm.DisplayContentTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java b/services/tests/servicestests/src/com/android/server/wm/DragDropControllerTests.java index 68b09982be98..a09656c7dc92 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/DragDropControllerTests.java @@ -19,7 +19,6 @@ package com.android.server.wm; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; - import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.any; @@ -40,23 +39,19 @@ import android.view.InputChannel; import android.view.SurfaceControl; import android.view.SurfaceSession; import android.view.View; - import com.android.internal.annotations.GuardedBy; import com.android.server.LocalServices; - +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - /** * Tests for the {@link DragDropController} class. * - * Build/Install/Run: - * atest WmTests:DragDropControllerTests + * atest com.android.server.wm.DragDropControllerTests */ @SmallTest @RunWith(AndroidJUnit4.class) diff --git a/services/tests/wmtests/src/com/android/server/wm/PinnedStackControllerTest.java b/services/tests/servicestests/src/com/android/server/wm/PinnedStackControllerTest.java index f0faf28fd129..96745fa5956e 100644 --- a/services/tests/wmtests/src/com/android/server/wm/PinnedStackControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/PinnedStackControllerTest.java @@ -2,15 +2,6 @@ package com.android.server.wm; import static android.view.Display.DEFAULT_DISPLAY; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import android.os.RemoteException; import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; @@ -23,12 +14,15 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -/** - * Tests for {@link PinnedStackController}. - * - * Build/Install/Run: - * atest WmTests:PinnedStackControllerTest - */ +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + @SmallTest @Presubmit @RunWith(AndroidJUnit4.class) diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java b/services/tests/servicestests/src/com/android/server/wm/RecentsAnimationControllerTest.java index fdebaa6df18c..a2af9b80fe36 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/RecentsAnimationControllerTest.java @@ -19,10 +19,8 @@ package com.android.server.wm; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.view.Display.DEFAULT_DISPLAY; - import static com.android.server.wm.RecentsAnimationController.REORDER_KEEP_IN_PLACE; import static com.android.server.wm.RecentsAnimationController.REORDER_MOVE_TO_ORIGINAL_POSITION; - import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.atLeast; @@ -37,9 +35,7 @@ import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import android.view.IRecentsAnimationRunner; import android.view.SurfaceControl; - import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -47,10 +43,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; /** - * Tests for {@link RecentsAnimationController}. - * - * Build/Install/Run: - * atest WmTests:RecentsAnimationControllerTest + * atest FrameworksServicesTests:com.android.server.wm.RecentsAnimationControllerTest */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java b/services/tests/servicestests/src/com/android/server/wm/RemoteAnimationControllerTest.java index 383e53fafeea..95361f03fe4b 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/RemoteAnimationControllerTest.java @@ -31,6 +31,7 @@ import android.graphics.Rect; import android.os.Binder; import android.os.IInterface; import android.platform.test.annotations.Presubmit; +import android.support.test.filters.FlakyTest; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import android.view.IRemoteAnimationFinishedCallback; @@ -52,10 +53,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; /** - * Tests for {@link RemoteAnimationController}. - * - * Build/Install/Run: - * atest WmTests:RemoteAnimationControllerTest + * atest FrameworksServicesTests:com.android.server.wm.RemoteAnimationControllerTest */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java b/services/tests/servicestests/src/com/android/server/wm/RootWindowContainerTests.java index 317f36cc2077..204e26cee532 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/RootWindowContainerTests.java @@ -1,21 +1,22 @@ package com.android.server.wm; -import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.junit.runner.RunWith; import android.content.res.Configuration; import android.graphics.Rect; + import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; -import org.junit.Test; -import org.junit.runner.RunWith; +import static org.junit.Assert.assertTrue; /** * Tests for the {@link RootWindowContainer} class. * * Build/Install/Run: - * atest WmTests:RootWindowContainerTests + * atest FrameworksServicesTests:com.android.server.wm.RootWindowContainerTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/ScreenDecorWindowTests.java b/services/tests/servicestests/src/com/android/server/wm/ScreenDecorWindowTests.java index 7e7cfed991ba..a2ccee46e0c9 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ScreenDecorWindowTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/ScreenDecorWindowTests.java @@ -32,7 +32,6 @@ import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; import static android.view.WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; - import static org.junit.Assert.assertEquals; import android.app.Activity; @@ -71,7 +70,7 @@ import java.util.function.BooleanSupplier; * Tests for the {@link android.view.WindowManager.LayoutParams#PRIVATE_FLAG_IS_SCREEN_DECOR} flag. * * Build/Install/Run: - * atest WmTests:ScreenDecorWindowTests + * atest FrameworksServicesTests:com.android.server.wm.ScreenDecorWindowTests */ // TODO: Add test for FLAG_FULLSCREEN which hides the status bar and also other flags. // TODO: Test non-Activity windows. diff --git a/services/tests/wmtests/src/com/android/server/wm/StackWindowControllerTests.java b/services/tests/servicestests/src/com/android/server/wm/StackWindowControllerTests.java index fb2986c0212d..ab0a2bd86dd8 100644 --- a/services/tests/wmtests/src/com/android/server/wm/StackWindowControllerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/StackWindowControllerTests.java @@ -16,24 +16,25 @@ package com.android.server.wm; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - import android.graphics.Rect; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; + import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; -import org.junit.Test; -import org.junit.runner.RunWith; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; /** * Test class for {@link StackWindowController}. * * Build/Install/Run: - * atest WmTests:StackWindowControllerTests + * atest FrameworksServicesTests:StackWindowControllerTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/SurfaceAnimationRunnerTest.java b/services/tests/servicestests/src/com/android/server/wm/SurfaceAnimationRunnerTest.java index 9ea370284fc2..edac8a5202d7 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SurfaceAnimationRunnerTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/SurfaceAnimationRunnerTest.java @@ -16,6 +16,7 @@ package com.android.server.wm; +import static java.util.concurrent.TimeUnit.SECONDS; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -23,11 +24,11 @@ import static org.mockito.Mockito.any; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static java.util.concurrent.TimeUnit.SECONDS; - +import android.animation.AnimationHandler; import android.animation.AnimationHandler.AnimationFrameCallbackProvider; import android.animation.ValueAnimator; import android.graphics.Matrix; @@ -36,6 +37,7 @@ import android.platform.test.annotations.Presubmit; import android.support.test.filters.FlakyTest; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; +import android.util.Log; import android.view.Choreographer; import android.view.Choreographer.FrameCallback; import android.view.SurfaceControl; @@ -44,6 +46,7 @@ import android.view.animation.Animation; import android.view.animation.TranslateAnimation; import com.android.server.wm.LocalAnimationAdapter.AnimationSpec; +import com.android.server.wm.SurfaceAnimationRunner.AnimatorFactory; import org.junit.Before; import org.junit.Rule; @@ -58,8 +61,7 @@ import java.util.concurrent.CountDownLatch; /** * Test class for {@link SurfaceAnimationRunner}. * - * Build/Install/Run: - * atest WmTests:SurfaceAnimationRunnerTest + * atest FrameworksServicesTests:com.android.server.wm.SurfaceAnimationRunnerTest */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/SurfaceAnimatorTest.java b/services/tests/servicestests/src/com/android/server/wm/SurfaceAnimatorTest.java index 66f4b194a5ac..16b84581de39 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SurfaceAnimatorTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/SurfaceAnimatorTest.java @@ -46,11 +46,12 @@ import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import java.util.ArrayList; + /** * Test class for {@link SurfaceAnimatorTest}. * - * Build/Install/Run: - * atest WmTests:SurfaceAnimatorTest + * atest FrameworksServicesTests:com.android.server.wm.SurfaceAnimatorTest */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskPositionerTests.java b/services/tests/servicestests/src/com/android/server/wm/TaskPositionerTests.java index ae730895f5d7..7bf7dd78711c 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskPositionerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/TaskPositionerTests.java @@ -16,14 +16,10 @@ package com.android.server.wm; -import static com.android.server.wm.TaskPositioner.MIN_ASPECT; -import static com.android.server.wm.WindowManagerService.dipToPixel; -import static com.android.server.wm.WindowState.MINIMUM_VISIBLE_HEIGHT_IN_DP; -import static com.android.server.wm.WindowState.MINIMUM_VISIBLE_WIDTH_IN_DP; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; import android.graphics.Rect; import android.support.test.filters.SmallTest; @@ -32,16 +28,18 @@ import android.util.DisplayMetrics; import android.util.Log; import android.view.Display; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; +import static com.android.server.wm.TaskPositioner.MIN_ASPECT; +import static com.android.server.wm.WindowManagerService.dipToPixel; +import static com.android.server.wm.WindowState.MINIMUM_VISIBLE_HEIGHT_IN_DP; +import static com.android.server.wm.WindowState.MINIMUM_VISIBLE_WIDTH_IN_DP; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; /** * Tests for the {@link TaskPositioner} class. * - * Build/Install/Run: - * atest WmTests:TaskPositionerTests + * runtest frameworks-services -c com.android.server.wm.TaskPositionerTests */ @SmallTest @RunWith(AndroidJUnit4.class) diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskPositioningControllerTests.java b/services/tests/servicestests/src/com/android/server/wm/TaskPositioningControllerTests.java index 659ec41c30c4..6070516669b5 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskPositioningControllerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/TaskPositioningControllerTests.java @@ -17,7 +17,6 @@ package com.android.server.wm; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -31,7 +30,6 @@ import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import android.view.InputChannel; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -39,8 +37,7 @@ import org.junit.runner.RunWith; /** * Tests for the {@link TaskPositioningController} class. * - * Build/Install/Run: - * atest WmTests:TaskPositioningControllerTests + * atest com.android.server.wm.TaskPositioningControllerTests */ @SmallTest @RunWith(AndroidJUnit4.class) diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotCacheTest.java b/services/tests/servicestests/src/com/android/server/wm/TaskSnapshotCacheTest.java index 1aefa277e84f..649de4a783fa 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotCacheTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/TaskSnapshotCacheTest.java @@ -17,7 +17,6 @@ package com.android.server.wm; import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; - import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNull; @@ -32,8 +31,7 @@ import org.junit.runner.RunWith; /** * Test class for {@link TaskSnapshotCache}. * - * Build/Install/Run: - * atest WmTests:TaskSnapshotCacheTest + * runtest frameworks-services -c com.android.server.wm.TaskSnapshotCacheTest */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotControllerTest.java b/services/tests/servicestests/src/com/android/server/wm/TaskSnapshotControllerTest.java index 77521a652ca3..5650050f0420 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/TaskSnapshotControllerTest.java @@ -19,11 +19,10 @@ package com.android.server.wm; import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; import static android.view.WindowManager.LayoutParams.FLAG_SECURE; import static android.view.WindowManager.TRANSIT_UNSET; - -import static com.android.server.wm.TaskSnapshotController.SNAPSHOT_MODE_APP_THEME; -import static com.android.server.wm.TaskSnapshotController.SNAPSHOT_MODE_REAL; - +import static com.android.server.wm.TaskSnapshotController.*; import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; @@ -31,15 +30,13 @@ import android.support.test.runner.AndroidJUnit4; import android.util.ArraySet; import com.google.android.collect.Sets; - import org.junit.Test; import org.junit.runner.RunWith; /** * Test class for {@link TaskSnapshotController}. * - * Build/Install/Run: - * atest WmTests:TaskSnapshotControllerTest + * runtest frameworks-services -c com.android.server.wm.TaskSnapshotControllerTest */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterLoaderTest.java b/services/tests/servicestests/src/com/android/server/wm/TaskSnapshotPersisterLoaderTest.java index ed81dafe3205..325d42aa6293 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterLoaderTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/TaskSnapshotPersisterLoaderTest.java @@ -18,12 +18,12 @@ package com.android.server.wm; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import android.app.ActivityManager.TaskSnapshot; import android.content.res.Configuration; @@ -33,8 +33,8 @@ import android.platform.test.annotations.Presubmit; import android.support.test.filters.MediumTest; import android.support.test.runner.AndroidJUnit4; import android.util.ArraySet; -import android.view.View; +import android.view.View; import com.android.server.wm.TaskSnapshotPersister.RemoveObsoleteFilesQueueItem; import org.junit.Test; @@ -45,8 +45,7 @@ import java.io.File; /** * Test class for {@link TaskSnapshotPersister} and {@link TaskSnapshotLoader} * - * Build/Install/Run: - * atest WmTests:TaskSnapshotPersisterLoaderTest + * atest FrameworksServicesTests:TaskSnapshotPersisterLoaderTest */ @MediumTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java b/services/tests/servicestests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java index 8b8604365fa1..8b8604365fa1 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java +++ b/services/tests/servicestests/src/com/android/server/wm/TaskSnapshotPersisterTestBase.java diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java b/services/tests/servicestests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java index 287fff554a61..b19373efd1b0 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java @@ -19,7 +19,6 @@ package com.android.server.wm; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; - import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyInt; @@ -48,8 +47,7 @@ import org.junit.runner.RunWith; /** * Test class for {@link TaskSnapshotSurface}. * - * Build/Install/Run: - * atest WmTests:TaskSnapshotSurfaceTest + * runtest frameworks-services -c com.android.server.wm.TaskSnapshotSurfaceTest */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskStackContainersTests.java b/services/tests/servicestests/src/com/android/server/wm/TaskStackContainersTests.java index e66b0d9c841d..ca1994f85ccf 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskStackContainersTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/TaskStackContainersTests.java @@ -18,25 +18,26 @@ package com.android.server.wm; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.Before; +import org.junit.After; + import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - /** * Tests for the {@link DisplayContent.TaskStackContainers} container in {@link DisplayContent}. * * Build/Install/Run: - * atest WmTests:TaskStackContainersTests + * bit FrameworksServicesTests:com.android.server.wm.TaskStackContainersTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java b/services/tests/servicestests/src/com/android/server/wm/TaskStackTests.java index 0deb4af542c4..eaf71f0dc5b3 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/TaskStackTests.java @@ -16,24 +16,27 @@ package com.android.server.wm; -import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; -import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.Test; +import org.junit.runner.RunWith; import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; -import org.junit.Test; -import org.junit.runner.RunWith; +import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; +import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; /** * Tests for the {@link TaskStack} class. * * Build/Install/Run: - * atest WmTests:TaskStackTests + * bit FrameworksServicesTests:com.android.server.wm.TaskStackTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskWindowContainerControllerTests.java b/services/tests/servicestests/src/com/android/server/wm/TaskWindowContainerControllerTests.java index e734bc0615c6..1dd9365825cf 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskWindowContainerControllerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/TaskWindowContainerControllerTests.java @@ -16,23 +16,22 @@ package com.android.server.wm; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; - import org.junit.Test; import org.junit.runner.RunWith; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + /** * Test class for {@link TaskWindowContainerController}. * * Build/Install/Run: - * atest WmTests:TaskWindowContainerControllerTests + * bit FrameworksServicesTests:com.android.server.wm.TaskWindowContainerControllerTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/TestIWindow.java b/services/tests/servicestests/src/com/android/server/wm/TestIWindow.java index 032f4162b48e..353aa7deb534 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TestIWindow.java +++ b/services/tests/servicestests/src/com/android/server/wm/TestIWindow.java @@ -16,6 +16,8 @@ package com.android.server.wm; +import com.android.internal.os.IResultReceiver; + import android.graphics.Rect; import android.os.Bundle; import android.os.ParcelFileDescriptor; @@ -25,8 +27,6 @@ import android.view.DisplayCutout; import android.view.DragEvent; import android.view.IWindow; -import com.android.internal.os.IResultReceiver; - public class TestIWindow extends IWindow.Stub { @Override public void executeCommand(String command, String parameters, diff --git a/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java b/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java index ee028ba4262b..ee028ba4262b 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java +++ b/services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java diff --git a/services/tests/wmtests/src/com/android/server/wm/UnknownAppVisibilityControllerTest.java b/services/tests/servicestests/src/com/android/server/wm/UnknownAppVisibilityControllerTest.java index 903352b7bec5..a5c47deb2c06 100644 --- a/services/tests/wmtests/src/com/android/server/wm/UnknownAppVisibilityControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/UnknownAppVisibilityControllerTest.java @@ -29,8 +29,7 @@ import org.junit.runner.RunWith; /** * Test class for {@link AppTransition}. * - * Build/Install/Run: - * atest WmTests:UnknownAppVisibilityControllerTest + * runtest frameworks-services -c com.android.server.wm.UnknownAppVisibilityControllerTest */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java b/services/tests/servicestests/src/com/android/server/wm/WallpaperControllerTests.java index 71ead204c9df..71ead204c9df 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WallpaperControllerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/WallpaperControllerTests.java diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowAnimationSpecTest.java b/services/tests/servicestests/src/com/android/server/wm/WindowAnimationSpecTest.java index aac905e8ffd4..ca520ed76be6 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowAnimationSpecTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowAnimationSpecTest.java @@ -40,8 +40,7 @@ import org.junit.runner.RunWith; /** * Tests for the {@link WindowAnimationSpec} class. * - * Build/Install/Run: - * atest WmTests:WindowAnimationSpecTest + * atest FrameworksServicesTests:com.android.server.wm.WindowAnimationSpecTest */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowConfigurationTests.java b/services/tests/servicestests/src/com/android/server/wm/WindowConfigurationTests.java index 9c59a1748dbf..513c1ecda990 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowConfigurationTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowConfigurationTests.java @@ -16,16 +16,7 @@ package com.android.server.wm; -import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; -import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; -import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; -import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; -import static android.app.WindowConfiguration.WINDOW_CONFIG_APP_BOUNDS; -import static android.app.WindowConfiguration.WINDOW_CONFIG_WINDOWING_MODE; -import static android.content.pm.ActivityInfo.CONFIG_WINDOW_CONFIGURATION; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import org.junit.Test; import android.app.WindowConfiguration; import android.content.res.Configuration; @@ -36,13 +27,22 @@ import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import android.view.DisplayInfo; -import org.junit.Test; +import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; +import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; +import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; +import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; +import static android.app.WindowConfiguration.WINDOW_CONFIG_APP_BOUNDS; +import static android.app.WindowConfiguration.WINDOW_CONFIG_WINDOWING_MODE; +import static android.content.pm.ActivityInfo.CONFIG_WINDOW_CONFIGURATION; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; /** * Test class to for {@link android.app.WindowConfiguration}. * * Build/Install/Run: - * atest WmTests:WindowConfigurationTests + * bit FrameworksServicesTests:com.android.server.wm.WindowConfigurationTests */ @SmallTest @FlakyTest(bugId = 74078662) diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowContainerControllerTests.java b/services/tests/servicestests/src/com/android/server/wm/WindowContainerControllerTests.java index 05f7c347f0b8..502cb6e27c68 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerControllerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowContainerControllerTests.java @@ -16,26 +16,26 @@ package com.android.server.wm; -import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; -import static android.content.res.Configuration.EMPTY; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - +import android.app.WindowConfiguration; import android.content.res.Configuration; -import android.platform.test.annotations.Presubmit; import android.support.test.filters.FlakyTest; +import org.junit.Test; + +import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; -import org.junit.Test; +import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; +import static android.content.res.Configuration.EMPTY; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; /** * Test class for {@link WindowContainerController}. * * Build/Install/Run: - * atest WmTests:WindowContainerControllerTests + * bit FrameworksServicesTests:com.android.server.wm.WindowContainerControllerTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java b/services/tests/servicestests/src/com/android/server/wm/WindowContainerTests.java index 5beeee151497..6c7830e5cf79 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowContainerTests.java @@ -16,6 +16,20 @@ package com.android.server.wm; +import android.support.test.filters.FlakyTest; +import android.view.SurfaceControl; +import android.view.SurfaceSession; +import org.junit.Test; +import org.junit.runner.RunWith; + +import android.content.res.Configuration; +import android.graphics.Rect; +import android.platform.test.annotations.Presubmit; +import android.support.test.filters.SmallTest; +import android.support.test.runner.AndroidJUnit4; + +import java.util.Comparator; + import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; @@ -30,6 +44,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; + import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyFloat; import static org.mockito.Mockito.eq; @@ -38,25 +53,11 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import android.content.res.Configuration; -import android.graphics.Rect; -import android.platform.test.annotations.Presubmit; -import android.support.test.filters.FlakyTest; -import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; -import android.view.SurfaceControl; -import android.view.SurfaceSession; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.Comparator; - /** * Test class for {@link WindowContainer}. * * Build/Install/Run: - * atest WmTests:WindowContainerTests + * atest FrameworksServicesTests:com.android.server.wm.WindowContainerTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTraversalTests.java b/services/tests/servicestests/src/com/android/server/wm/WindowContainerTraversalTests.java index e1acd78c5bc6..e07639933b7a 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTraversalTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowContainerTraversalTests.java @@ -20,10 +20,9 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; - -import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import static org.mockito.Matchers.eq; import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; @@ -32,13 +31,12 @@ import android.support.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mock; + import java.util.function.Consumer; /** * Tests for {@link WindowContainer#forAllWindows} and various implementations. - * - * Build/Install/Run: - * atest WmTests:WindowContainerTraversalTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowFrameTests.java b/services/tests/servicestests/src/com/android/server/wm/WindowFrameTests.java index 6a00de473a85..5a563320f9cb 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowFrameTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowFrameTests.java @@ -16,12 +16,9 @@ package com.android.server.wm; -import static android.view.DisplayCutout.fromBoundingRect; -import static android.view.WindowManager.LayoutParams.FILL_PARENT; -import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; import android.app.ActivityManager.TaskDescription; import android.content.res.Configuration; @@ -34,17 +31,18 @@ import android.view.Gravity; import android.view.IWindow; import android.view.WindowManager; -import com.android.server.wm.utils.WmDisplayCutout; +import static android.view.DisplayCutout.fromBoundingRect; +import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; +import static android.view.WindowManager.LayoutParams.FILL_PARENT; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import com.android.server.wm.utils.WmDisplayCutout; /** * Tests for the {@link WindowState#computeFrameLw} method and other window frame machinery. * - * Build/Install/Run: - * atest WmTests:WindowFrameTests + * Build/Install/Run: bit FrameworksServicesTests:com.android.server.wm.WindowFrameTests */ @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceRule.java b/services/tests/servicestests/src/com/android/server/wm/WindowManagerServiceRule.java index d91079e3bb1b..d91079e3bb1b 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceRule.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowManagerServiceRule.java diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceRuleTest.java b/services/tests/servicestests/src/com/android/server/wm/WindowManagerServiceRuleTest.java index 6cf6d7bc96ec..6cf6d7bc96ec 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceRuleTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowManagerServiceRuleTest.java diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/servicestests/src/com/android/server/wm/WindowStateTests.java index 0f07e7eb3090..85e846db60b7 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowStateTests.java @@ -16,6 +16,17 @@ package com.android.server.wm; +import android.view.WindowManager; +import org.junit.Test; +import org.junit.runner.RunWith; + +import android.platform.test.annotations.Presubmit; +import android.support.test.filters.FlakyTest; +import android.support.test.filters.SmallTest; +import android.support.test.runner.AndroidJUnit4; + +import java.util.LinkedList; + import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; @@ -44,22 +55,10 @@ import static org.mockito.Mockito.reset; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; -import android.platform.test.annotations.Presubmit; -import android.support.test.filters.FlakyTest; -import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; -import android.view.WindowManager; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.LinkedList; - /** * Tests for the {@link WindowState} class. * - * Build/Install/Run: - * atest WmTests:WindowStateTests + * atest FrameworksServicesTests:com.android.server.wm.WindowStateTests */ @SmallTest @FlakyTest(bugId = 74078662) diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowSurfacePlacerTest.java b/services/tests/servicestests/src/com/android/server/wm/WindowSurfacePlacerTest.java index 13f791634e4f..e173b7db2da7 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowSurfacePlacerTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowSurfacePlacerTest.java @@ -20,7 +20,6 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.view.WindowManager.TRANSIT_TASK_CLOSE; import static android.view.WindowManager.TRANSIT_TASK_OPEN; - import static junit.framework.Assert.assertEquals; import android.platform.test.annotations.Presubmit; @@ -32,12 +31,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -/** - * Tests for {@link WindowSurfacePlacer}. - * - * Build/Install/Run: - * atest WmTests:WindowSurfacePlacerTest - */ @SmallTest @Presubmit @RunWith(AndroidJUnit4.class) diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestUtils.java b/services/tests/servicestests/src/com/android/server/wm/WindowTestUtils.java index 6ab9c3010dd5..2e4740b57255 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowTestUtils.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowTestUtils.java @@ -16,12 +16,21 @@ package com.android.server.wm; +import android.app.ActivityManager; +import android.content.Context; +import android.content.res.Configuration; +import android.graphics.Rect; +import android.os.Binder; +import android.os.IBinder; +import android.view.IApplicationToken; +import android.view.IWindow; +import android.view.WindowManager; + import static android.app.AppOpsManager.OP_NONE; import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static com.android.server.wm.WindowContainer.POSITION_TOP; - import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyBoolean; import static org.mockito.Mockito.anyFloat; @@ -30,15 +39,6 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import android.app.ActivityManager; -import android.content.res.Configuration; -import android.graphics.Rect; -import android.os.Binder; -import android.os.IBinder; -import android.view.IApplicationToken; -import android.view.IWindow; -import android.view.WindowManager; - import org.mockito.invocation.InvocationOnMock; /** diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/servicestests/src/com/android/server/wm/WindowTestsBase.java index 473a287e3d9c..473a287e3d9c 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowTestsBase.java diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTokenTests.java b/services/tests/servicestests/src/com/android/server/wm/WindowTokenTests.java index 5ea87b14f746..e3b717435052 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowTokenTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowTokenTests.java @@ -16,29 +16,29 @@ package com.android.server.wm; +import org.junit.Test; +import org.junit.runner.RunWith; + +import android.platform.test.annotations.Presubmit; +import android.support.test.filters.FlakyTest; +import android.support.test.filters.SmallTest; +import android.support.test.runner.AndroidJUnit4; + import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_TOAST; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; - -import android.platform.test.annotations.Presubmit; -import android.support.test.filters.FlakyTest; -import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; +import static org.mockito.Mockito.mock; /** * Tests for the {@link WindowToken} class. * * Build/Install/Run: - * atest WmTests:WindowTokenTests + * bit FrameworksServicesTests:com.android.server.wm.WindowTokenTests */ @SmallTest @FlakyTest(bugId = 74078662) diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTracingTest.java b/services/tests/servicestests/src/com/android/server/wm/WindowTracingTest.java index f60ae75b85f2..50852548f525 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowTracingTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowTracingTest.java @@ -30,12 +30,13 @@ import static org.mockito.Mockito.verifyZeroInteractions; import android.content.Context; import android.platform.test.annotations.Presubmit; import android.support.test.InstrumentationRegistry; -import android.support.test.filters.FlakyTest; import android.support.test.filters.SmallTest; +import android.support.test.filters.FlakyTest; import android.support.test.runner.AndroidJUnit4; import android.util.proto.ProtoOutputStream; import com.android.internal.util.Preconditions; +import com.android.server.wm.WindowManagerTraceProto; import org.junit.After; import org.junit.Before; @@ -53,7 +54,7 @@ import java.nio.charset.StandardCharsets; * Test class for {@link WindowTracing}. * * Build/Install/Run: - * atest WmTests:WindowTracingTest + * bit FrameworksServicesTests:com.android.server.wm.WindowTracingTest */ @SmallTest @FlakyTest(bugId = 74078662) diff --git a/services/tests/wmtests/src/com/android/server/wm/ZOrderingTests.java b/services/tests/servicestests/src/com/android/server/wm/ZOrderingTests.java index a730b5cf84e6..547be551c842 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ZOrderingTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/ZOrderingTests.java @@ -27,14 +27,15 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; +import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL; import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY; import android.platform.test.annotations.Presubmit; -import android.support.test.filters.FlakyTest; import android.support.test.filters.SmallTest; +import android.support.test.filters.FlakyTest; import android.support.test.runner.AndroidJUnit4; import android.view.SurfaceControl; import android.view.SurfaceSession; @@ -50,7 +51,7 @@ import java.util.LinkedList; * Tests for the {@link WindowLayersController} class. * * Build/Install/Run: - * atest WmTests:ZOrderingTests + * bit FrameworksServicesTests:com.android.server.wm.ZOrderingTests */ @SmallTest @FlakyTest(bugId = 74078662) diff --git a/services/tests/wmtests/src/com/android/server/wm/utils/CoordinateTransformsTest.java b/services/tests/servicestests/src/com/android/server/wm/utils/CoordinateTransformsTest.java index f0f3023f1f17..40a10e04c893 100644 --- a/services/tests/wmtests/src/com/android/server/wm/utils/CoordinateTransformsTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/utils/CoordinateTransformsTest.java @@ -21,11 +21,10 @@ import static android.view.Surface.ROTATION_180; import static android.view.Surface.ROTATION_270; import static android.view.Surface.ROTATION_90; -import static com.android.server.wm.utils.CoordinateTransforms - .transformPhysicalToLogicalCoordinates; +import static com.android.server.wm.utils.CoordinateTransforms.transformPhysicalToLogicalCoordinates; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.*; import android.graphics.Matrix; import android.graphics.Point; @@ -36,12 +35,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ErrorCollector; -/** - * Tests for {@link CoordinateTransforms}. - * - * Build/Install/Run: - * atest WmTests:CoordinateTransformsTest - */ public class CoordinateTransformsTest { private static final int W = 200; @@ -102,4 +95,4 @@ public class CoordinateTransformsTest { public interface DevicePointAssertable { void mapsToLogicalPoint(int x, int y); } -} +}
\ No newline at end of file diff --git a/services/tests/wmtests/src/com/android/server/wm/utils/InsetUtilsTest.java b/services/tests/servicestests/src/com/android/server/wm/utils/InsetUtilsTest.java index ff3d883056e4..d0f0fe315bcf 100644 --- a/services/tests/wmtests/src/com/android/server/wm/utils/InsetUtilsTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/utils/InsetUtilsTest.java @@ -22,16 +22,11 @@ import android.graphics.Rect; import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; +import android.util.Pair; import org.junit.Test; import org.junit.runner.RunWith; -/** - * Tests for {@link InsetUtils}. - * - * Build/Install/Run: - * atest WmTests:InsetUtilsTest - */ @RunWith(AndroidJUnit4.class) @SmallTest @Presubmit diff --git a/services/tests/wmtests/src/com/android/server/wm/utils/RotationCacheTest.java b/services/tests/servicestests/src/com/android/server/wm/utils/RotationCacheTest.java index c800fa2fe6b1..6bbc7eb56688 100644 --- a/services/tests/wmtests/src/com/android/server/wm/utils/RotationCacheTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/utils/RotationCacheTest.java @@ -29,16 +29,13 @@ import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import android.util.Pair; +import com.android.server.wm.utils.RotationCache.RotationDependentComputation; + +import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -/** - * Tests for {@link RotationCache}. - * - * Build/Install/Run: - * atest WmTests:RotationCacheTest - */ @RunWith(AndroidJUnit4.class) @SmallTest @FlakyTest(bugId = 74078662) diff --git a/services/tests/wmtests/src/com/android/server/wm/utils/WmDisplayCutoutTest.java b/services/tests/servicestests/src/com/android/server/wm/utils/WmDisplayCutoutTest.java index f4c208b4ce0e..f7addf6c77f9 100644 --- a/services/tests/wmtests/src/com/android/server/wm/utils/WmDisplayCutoutTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/utils/WmDisplayCutoutTest.java @@ -16,6 +16,7 @@ package com.android.server.wm.utils; + import static android.view.DisplayCutout.NO_CUTOUT; import static android.view.DisplayCutout.fromBoundingRect; @@ -37,8 +38,7 @@ import java.util.Arrays; /** * Tests for {@link WmDisplayCutout} * - * Build/Install/Run: - * atest WmTests:WmDisplayCutoutTest + * Run with: atest WmDisplayCutoutTest */ @RunWith(AndroidJUnit4.class) @SmallTest diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ScheduleCalendarTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ScheduleCalendarTest.java index 942a07acbf9f..96ac93536a8a 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/ScheduleCalendarTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/ScheduleCalendarTest.java @@ -121,7 +121,7 @@ public class ScheduleCalendarTest extends UiServiceTestCase { cal.set(Calendar.MINUTE, 15); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); - mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay() + 1}; + mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay(1)}; mScheduleInfo.startHour = 1; mScheduleInfo.endHour = 3; mScheduleInfo.startMinute = 15; @@ -149,7 +149,7 @@ public class ScheduleCalendarTest extends UiServiceTestCase { cal.set(Calendar.MINUTE, 15); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); - mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay() + 1}; + mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay(1)}; mScheduleInfo.startHour = 22; mScheduleInfo.endHour = 3; mScheduleInfo.startMinute = 15; @@ -250,7 +250,7 @@ public class ScheduleCalendarTest extends UiServiceTestCase { calAlarm.add(Calendar.DATE, 1); // add a day // ScheduleInfo: day 1, day 2: 9pm-7am - mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay() + 1}; + mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay(1)}; mScheduleInfo.startHour = 21; mScheduleInfo.endHour = 7; mScheduleInfo.startMinute = 0; @@ -418,7 +418,7 @@ public class ScheduleCalendarTest extends UiServiceTestCase { now.set(Calendar.MILLISECOND, 0); now.add(Calendar.DATE, 1); // add a day - mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay() + 1}; + mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay(1)}; mScheduleInfo.startHour = 22; mScheduleInfo.startMinute = 15; mScheduleInfo.endHour = 3; @@ -446,7 +446,7 @@ public class ScheduleCalendarTest extends UiServiceTestCase { now.set(Calendar.MILLISECOND, 0); now.add(Calendar.DATE, 1); // add a day - mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay() + 1}; + mScheduleInfo.days = new int[] {getTodayDay(), getTodayDay(1)}; mScheduleInfo.startHour = 22; mScheduleInfo.startMinute = 15; mScheduleInfo.endHour = 3; @@ -464,4 +464,10 @@ public class ScheduleCalendarTest extends UiServiceTestCase { private int getTodayDay() { return new GregorianCalendar().get(Calendar.DAY_OF_WEEK); } + + private int getTodayDay(int offset) { + Calendar cal = new GregorianCalendar(); + cal.add(Calendar.DATE, offset); + return cal.get(Calendar.DAY_OF_WEEK); + } } diff --git a/services/tests/wmtests/Android.mk b/services/tests/wmtests/Android.mk index cd289740ea1e..0f8b18ab92cf 100644 --- a/services/tests/wmtests/Android.mk +++ b/services/tests/wmtests/Android.mk @@ -14,14 +14,9 @@ LOCAL_SRC_FILES := \ $(call all-java-files-under, ../servicestests/utils) LOCAL_STATIC_JAVA_LIBRARIES := \ - frameworks-base-testutils \ - services.core \ - android-support-test \ + androidx-test \ mockito-target-minus-junit4 \ platform-test-annotations \ - truth-prebuilt \ - testables \ - ub-uiautomator \ LOCAL_JAVA_LIBRARIES := \ android.test.mock \ diff --git a/services/tests/wmtests/AndroidManifest.xml b/services/tests/wmtests/AndroidManifest.xml index 7e4bd42c8c55..1fb947309028 100644 --- a/services/tests/wmtests/AndroidManifest.xml +++ b/services/tests/wmtests/AndroidManifest.xml @@ -22,30 +22,10 @@ android:minSdkVersion="1" android:targetSdkVersion="28" /> - <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> - <uses-permission android:name="android.permission.WAKE_LOCK" /> - <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" /> - <uses-permission android:name="android.permission.MANAGE_ACTIVITY_STACKS" /> - <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" /> - <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> - <uses-permission android:name="android.permission.STATUS_BAR_SERVICE" /> - <uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" /> - <uses-permission android:name="android.permission.READ_FRAME_BUFFER" /> - <uses-permission android:name="android.permission.GET_TOP_ACTIVITY_INFO" /> - <uses-permission android:name="android.permission.REORDER_TASKS" /> - <uses-permission android:name="android.permission.MANAGE_USERS" /> - - <application android:testOnly="true"> - <activity android:name="com.android.server.am.TaskStackChangedListenerTest$ActivityA" /> - <activity android:name="com.android.server.am.TaskStackChangedListenerTest$ActivityB" /> - <activity android:name="com.android.server.am.TaskStackChangedListenerTest$ActivityRequestedOrientationChange" /> - <activity android:name="com.android.server.am.TaskStackChangedListenerTest$ActivityTaskChangeCallbacks" /> - <activity android:name="com.android.server.am.TaskStackChangedListenerTest$ActivityTaskDescriptionChange" /> - <activity android:name="com.android.server.wm.ScreenDecorWindowTests$TestActivity" /> - </application> + <application android:testOnly="true" /> <instrumentation - android:name="android.support.test.runner.AndroidJUnitRunner" + android:name="androidx.test.runner.AndroidJUnitRunner" android:label="Window Manager Tests" android:targetPackage="com.android.frameworks.wmtests" /> </manifest> diff --git a/services/tests/wmtests/AndroidTest.xml b/services/tests/wmtests/AndroidTest.xml index 38a62ae9bbe3..2717ef901216 100644 --- a/services/tests/wmtests/AndroidTest.xml +++ b/services/tests/wmtests/AndroidTest.xml @@ -24,9 +24,9 @@ </target_preparer> <option name="test-tag" value="WmTests" /> - <test class="com.android.tradefed.testtype.AndroidJUnitTest" > + <test class="com.android.tradefed.testtype.AndroidJUnitTest"> <option name="package" value="com.android.frameworks.wmtests" /> - <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" /> - <option name="hidden-api-checks" value="false"/> + <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" /> + <option name="hidden-api-checks" value="false" /> </test> </configuration> diff --git a/services/tests/wmtests/src/com/android/server/am/DummyAmTests.java b/services/tests/wmtests/src/com/android/server/am/DummyAmTests.java new file mode 100644 index 000000000000..023e4ab6636f --- /dev/null +++ b/services/tests/wmtests/src/com/android/server/am/DummyAmTests.java @@ -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. + */ + +package com.android.server.am; + +import android.platform.test.annotations.Presubmit; + +import org.junit.Test; + +import androidx.test.filters.FlakyTest; + +/** + * Dummy test for com.android.server.am. + * TODO(b/113800711): Remove this class once the actual tests are moved from servicestests. + */ +public class DummyAmTests { + + @Presubmit + @Test + public void preSubmitTest() {} + + @FlakyTest + @Presubmit + @Test + public void flakyPreSubmitTest() {} + + @Test + public void postSubmitTest() {} + + @FlakyTest + @Test + public void flakyPostSubmitTest() {} +} diff --git a/services/tests/wmtests/src/com/android/server/wm/DummyWmTests.java b/services/tests/wmtests/src/com/android/server/wm/DummyWmTests.java new file mode 100644 index 000000000000..aecb2783badd --- /dev/null +++ b/services/tests/wmtests/src/com/android/server/wm/DummyWmTests.java @@ -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. + */ + +package com.android.server.wm; + +import android.platform.test.annotations.Presubmit; + +import org.junit.Test; + +import androidx.test.filters.FlakyTest; + +/** + * Dummy test for com.android.server.wm + * TODO(b/113800711): Remove this class once the actual tests are moved from servicestests. + */ +public class DummyWmTests { + + @Presubmit + @Test + public void preSubmitTest() {} + + @FlakyTest + @Presubmit + @Test + public void flakyPreSubmitTest() {} + + @Test + public void postSubmitTest() {} + + @FlakyTest + @Test + public void flakyPostSubmitTest() {} +} diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index 08bc9bcc4003..daa09f574651 100644 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -397,7 +397,19 @@ public final class Call { public static final int PROPERTY_WIFI = 0x00000008; /** - * Call is using high definition audio. + * When set, the UI should indicate to the user that a call is using high definition + * audio. + * <p> + * The underlying {@link ConnectionService} is responsible for reporting this + * property. It is important to note that this property is not intended to report the + * actual audio codec being used for a Call, but whether the call should be indicated + * to the user as high definition. + * <p> + * The Android Telephony stack reports this property for calls based on a number + * of factors, including which audio codec is used and whether a call is using an HD + * codec end-to-end. Some mobile operators choose to suppress display of an HD indication, + * and in these cases this property will not be set for a call even if the underlying audio + * codec is in fact "high definition". */ public static final int PROPERTY_HIGH_DEF_AUDIO = 0x00000010; diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index d33a537f2194..3127b3584dd9 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -676,7 +676,7 @@ public class TelecomManager { /** * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public static TelecomManager from(Context context) { return (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); } diff --git a/telephony/java/android/provider/Telephony.java b/telephony/java/android/provider/Telephony.java index 7e63230b9abc..d48f21b6dfcd 100644 --- a/telephony/java/android/provider/Telephony.java +++ b/telephony/java/android/provider/Telephony.java @@ -3213,7 +3213,6 @@ public final class Telephony { values.put(CDMA_ERI_ICON_INDEX, state.getCdmaEriIconIndex()); values.put(CDMA_ERI_ICON_MODE, state.getCdmaEriIconMode()); values.put(IS_EMERGENCY_ONLY, state.isEmergencyOnly()); - values.put(IS_DATA_ROAMING_FROM_REGISTRATION, state.getDataRoamingFromRegistration()); values.put(IS_USING_CARRIER_AGGREGATION, state.isUsingCarrierAggregation()); return values; } diff --git a/telephony/java/android/telephony/NeighboringCellInfo.java b/telephony/java/android/telephony/NeighboringCellInfo.java index 79298fd54c50..ac38efb4d029 100644 --- a/telephony/java/android/telephony/NeighboringCellInfo.java +++ b/telephony/java/android/telephony/NeighboringCellInfo.java @@ -34,8 +34,8 @@ import android.os.Parcelable; * Received Signal Strength and Cell ID location. * * @deprecated This class should not be used by any app targeting - * {@link Build.VERSION_CODES.Q Android Q} or higher. Instead callers should use - * {@Link android.telephony.CellInfo CellInfo}. + * {@link android.os.Build.VERSION_CODES#Q Android Q} or higher. Instead callers should use + * {@link android.telephony.CellInfo CellInfo}. */ @Deprecated public class NeighboringCellInfo implements Parcelable diff --git a/telephony/java/android/telephony/NetworkRegistrationState.java b/telephony/java/android/telephony/NetworkRegistrationState.java index c3931557feb3..b312f8478413 100644 --- a/telephony/java/android/telephony/NetworkRegistrationState.java +++ b/telephony/java/android/telephony/NetworkRegistrationState.java @@ -95,6 +95,13 @@ public class NetworkRegistrationState implements Parcelable { @RegState private final int mRegState; + /** + * Save the {@link ServiceState.RoamingType roaming type}. it can be overridden roaming type + * from resource overlay or carrier config. + */ + @ServiceState.RoamingType + private int mRoamingType; + private final int mAccessNetworkTechnology; private final int mRejectCause; @@ -140,6 +147,8 @@ public class NetworkRegistrationState implements Parcelable { mDomain = domain; mTransportType = transportType; mRegState = regState; + mRoamingType = (regState == REG_STATE_ROAMING) + ? ServiceState.ROAMING_TYPE_UNKNOWN : ServiceState.ROAMING_TYPE_NOT_ROAMING; mAccessNetworkTechnology = accessNetworkTechnology; mRejectCause = rejectCause; mAvailableServices = availableServices; @@ -182,6 +191,7 @@ public class NetworkRegistrationState implements Parcelable { mDomain = source.readInt(); mTransportType = source.readInt(); mRegState = source.readInt(); + mRoamingType = source.readInt(); mAccessNetworkTechnology = source.readInt(); mRejectCause = source.readInt(); mEmergencyOnly = source.readBoolean(); @@ -211,6 +221,31 @@ public class NetworkRegistrationState implements Parcelable { } /** + * @return {@code true} if registered on roaming network, {@code false} otherwise. + */ + public boolean isRoaming() { + return mRoamingType != ServiceState.ROAMING_TYPE_NOT_ROAMING; + } + + /** + * Set {@link ServiceState.RoamingType roaming type}. This could override + * roaming type based on resource overlay or carrier config. + * @hide + */ + public void setRoamingType(@ServiceState.RoamingType int roamingType) { + mRoamingType = roamingType; + } + + /** + * @return {@link ServiceState.RoamingType roaming type}. This could return + * overridden roaming type based on resource overlay or carrier config. + * @hide + */ + public @ServiceState.RoamingType int getRoamingType() { + return mRoamingType; + } + + /** * @return Whether emergency is enabled. */ public boolean isEmergencyEnabled() { return mEmergencyOnly; } @@ -280,6 +315,7 @@ public class NetworkRegistrationState implements Parcelable { .append(" domain=").append((mDomain == DOMAIN_CS) ? "CS" : "PS") .append("transportType=").append(mTransportType) .append(" regState=").append(regStateToString(mRegState)) + .append(" roamingType=").append(mRoamingType) .append(" accessNetworkTechnology=") .append(TelephonyManager.getNetworkTypeName(mAccessNetworkTechnology)) .append(" rejectCause=").append(mRejectCause) @@ -293,9 +329,9 @@ public class NetworkRegistrationState implements Parcelable { @Override public int hashCode() { - return Objects.hash(mDomain, mTransportType, mRegState, mAccessNetworkTechnology, - mRejectCause, mEmergencyOnly, mAvailableServices, mCellIdentity, - mVoiceSpecificStates, mDataSpecificStates); + return Objects.hash(mDomain, mTransportType, mRegState, mRoamingType, + mAccessNetworkTechnology, mRejectCause, mEmergencyOnly, mAvailableServices, + mCellIdentity, mVoiceSpecificStates, mDataSpecificStates); } @Override @@ -310,6 +346,7 @@ public class NetworkRegistrationState implements Parcelable { return mDomain == other.mDomain && mTransportType == other.mTransportType && mRegState == other.mRegState + && mRoamingType == other.mRoamingType && mAccessNetworkTechnology == other.mAccessNetworkTechnology && mRejectCause == other.mRejectCause && mEmergencyOnly == other.mEmergencyOnly @@ -325,6 +362,7 @@ public class NetworkRegistrationState implements Parcelable { dest.writeInt(mDomain); dest.writeInt(mTransportType); dest.writeInt(mRegState); + dest.writeInt(mRoamingType); dest.writeInt(mAccessNetworkTechnology); dest.writeInt(mRejectCause); dest.writeBoolean(mEmergencyOnly); diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java index bd6a59d7492c..498be968265f 100644 --- a/telephony/java/android/telephony/PhoneStateListener.java +++ b/telephony/java/android/telephony/PhoneStateListener.java @@ -23,6 +23,7 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; +import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.IPhoneStateListener; import java.lang.ref.WeakReference; @@ -778,8 +779,12 @@ public class PhoneStateListener { } } + /** + * @hide + */ + @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) @UnsupportedAppUsage - IPhoneStateListener callback = new IPhoneStateListenerStub(this); + public final IPhoneStateListener callback = new IPhoneStateListenerStub(this); private void log(String s) { Rlog.d(LOG_TAG, s); diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java index 7469186a5d51..bfbcd5751bf4 100644 --- a/telephony/java/android/telephony/ServiceState.java +++ b/telephony/java/android/telephony/ServiceState.java @@ -20,6 +20,8 @@ import android.annotation.IntDef; import android.annotation.SystemApi; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; +import android.content.Intent; +import android.os.Build; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; @@ -57,7 +59,7 @@ public class ServiceState implements Parcelable { * Normal operation condition, the phone is registered * with an operator either in home network or in roaming. */ - public static final int STATE_IN_SERVICE = 0; + public static final int STATE_IN_SERVICE = TelephonyProtoEnums.SERVICE_STATE_IN_SERVICE; // 0 /** * Phone is not registered with any operator, the phone @@ -65,17 +67,19 @@ public class ServiceState implements Parcelable { * searching to registration at all, or registration is denied, or radio * signal is not available. */ - public static final int STATE_OUT_OF_SERVICE = 1; + public static final int STATE_OUT_OF_SERVICE = + TelephonyProtoEnums.SERVICE_STATE_OUT_OF_SERVICE; // 1 /** * The phone is registered and locked. Only emergency numbers are allowed. {@more} */ - public static final int STATE_EMERGENCY_ONLY = 2; + public static final int STATE_EMERGENCY_ONLY = + TelephonyProtoEnums.SERVICE_STATE_EMERGENCY_ONLY; // 2 /** * Radio of telephony is explicitly powered off. */ - public static final int STATE_POWER_OFF = 3; + public static final int STATE_POWER_OFF = TelephonyProtoEnums.SERVICE_STATE_POWER_OFF; // 3 /** @hide */ @Retention(RetentionPolicy.SOURCE) @@ -198,6 +202,15 @@ public class ServiceState implements Parcelable { private int mVoiceRegState = STATE_OUT_OF_SERVICE; private int mDataRegState = STATE_OUT_OF_SERVICE; + /** @hide */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = { "ROAMING_TYPE_" }, value = { + ROAMING_TYPE_NOT_ROAMING, + ROAMING_TYPE_UNKNOWN, + ROAMING_TYPE_DOMESTIC, + ROAMING_TYPE_INTERNATIONAL + }) + public @interface RoamingType {} /** * Roaming type * HOME : in home network @@ -228,15 +241,13 @@ public class ServiceState implements Parcelable { */ public static final int UNKNOWN_ID = -1; - private int mVoiceRoamingType; - private int mDataRoamingType; private String mVoiceOperatorAlphaLong; private String mVoiceOperatorAlphaShort; private String mVoiceOperatorNumeric; private String mDataOperatorAlphaLong; private String mDataOperatorAlphaShort; private String mDataOperatorNumeric; - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) private boolean mIsManualNetworkSelection; private boolean mIsEmergencyOnly; @@ -246,9 +257,9 @@ public class ServiceState implements Parcelable { @UnsupportedAppUsage private boolean mCssIndicator; - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) private int mNetworkId; - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) private int mSystemId; @UnsupportedAppUsage private int mCdmaRoamingIndicator; @@ -259,8 +270,6 @@ public class ServiceState implements Parcelable { @UnsupportedAppUsage private int mCdmaEriIconMode; - private boolean mIsDataRoamingFromRegistration; - @UnsupportedAppUsage private boolean mIsUsingCarrierAggregation; @@ -332,8 +341,6 @@ public class ServiceState implements Parcelable { protected void copyFrom(ServiceState s) { mVoiceRegState = s.mVoiceRegState; mDataRegState = s.mDataRegState; - mVoiceRoamingType = s.mVoiceRoamingType; - mDataRoamingType = s.mDataRoamingType; mVoiceOperatorAlphaLong = s.mVoiceOperatorAlphaLong; mVoiceOperatorAlphaShort = s.mVoiceOperatorAlphaShort; mVoiceOperatorNumeric = s.mVoiceOperatorNumeric; @@ -351,7 +358,6 @@ public class ServiceState implements Parcelable { mCdmaEriIconIndex = s.mCdmaEriIconIndex; mCdmaEriIconMode = s.mCdmaEriIconMode; mIsEmergencyOnly = s.mIsEmergencyOnly; - mIsDataRoamingFromRegistration = s.mIsDataRoamingFromRegistration; mIsUsingCarrierAggregation = s.mIsUsingCarrierAggregation; mChannelNumber = s.mChannelNumber; mCellBandwidths = s.mCellBandwidths == null ? null : @@ -367,8 +373,6 @@ public class ServiceState implements Parcelable { public ServiceState(Parcel in) { mVoiceRegState = in.readInt(); mDataRegState = in.readInt(); - mVoiceRoamingType = in.readInt(); - mDataRoamingType = in.readInt(); mVoiceOperatorAlphaLong = in.readString(); mVoiceOperatorAlphaShort = in.readString(); mVoiceOperatorNumeric = in.readString(); @@ -386,7 +390,6 @@ public class ServiceState implements Parcelable { mCdmaEriIconIndex = in.readInt(); mCdmaEriIconMode = in.readInt(); mIsEmergencyOnly = in.readInt() != 0; - mIsDataRoamingFromRegistration = in.readInt() != 0; mIsUsingCarrierAggregation = in.readInt() != 0; mLteEarfcnRsrpBoost = in.readInt(); mNetworkRegistrationStates = new ArrayList<>(); @@ -398,8 +401,6 @@ public class ServiceState implements Parcelable { public void writeToParcel(Parcel out, int flags) { out.writeInt(mVoiceRegState); out.writeInt(mDataRegState); - out.writeInt(mVoiceRoamingType); - out.writeInt(mDataRoamingType); out.writeString(mVoiceOperatorAlphaLong); out.writeString(mVoiceOperatorAlphaShort); out.writeString(mVoiceOperatorNumeric); @@ -417,7 +418,6 @@ public class ServiceState implements Parcelable { out.writeInt(mCdmaEriIconIndex); out.writeInt(mCdmaEriIconMode); out.writeInt(mIsEmergencyOnly ? 1 : 0); - out.writeInt(mIsDataRoamingFromRegistration ? 1 : 0); out.writeInt(mIsUsingCarrierAggregation ? 1 : 0); out.writeInt(mLteEarfcnRsrpBoost); out.writeList(mNetworkRegistrationStates); @@ -457,7 +457,7 @@ public class ServiceState implements Parcelable { * * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public int getVoiceRegState() { return mVoiceRegState; } @@ -472,7 +472,7 @@ public class ServiceState implements Parcelable { * * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public int getDataRegState() { return mDataRegState; } @@ -533,19 +533,23 @@ public class ServiceState implements Parcelable { * @return roaming status * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public boolean getVoiceRoaming() { - return mVoiceRoamingType != ROAMING_TYPE_NOT_ROAMING; + return getVoiceRoamingType() != ROAMING_TYPE_NOT_ROAMING; } - /** * Get current voice network roaming type * @return roaming type * @hide */ @UnsupportedAppUsage - public int getVoiceRoamingType() { - return mVoiceRoamingType; + public @RoamingType int getVoiceRoamingType() { + final NetworkRegistrationState regState = getNetworkRegistrationState( + NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TransportType.WWAN); + if (regState != null) { + return regState.getRoamingType(); + } + return ROAMING_TYPE_NOT_ROAMING; } /** @@ -553,21 +557,9 @@ public class ServiceState implements Parcelable { * @return roaming type * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public boolean getDataRoaming() { - return mDataRoamingType != ROAMING_TYPE_NOT_ROAMING; - } - - /** - * Set whether data network registration state is roaming - * - * This should only be set to the roaming value received - * once the data registration phase has completed. - * @hide - */ - @UnsupportedAppUsage - public void setDataRoamingFromRegistration(boolean dataRoaming) { - mIsDataRoamingFromRegistration = dataRoaming; + return getDataRoamingType() != ROAMING_TYPE_NOT_ROAMING; } /** @@ -576,7 +568,12 @@ public class ServiceState implements Parcelable { * @hide */ public boolean getDataRoamingFromRegistration() { - return mIsDataRoamingFromRegistration; + final NetworkRegistrationState regState = getNetworkRegistrationState( + NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN); + if (regState != null) { + return (regState.getRegState() == NetworkRegistrationState.REG_STATE_ROAMING); + } + return false; } /** @@ -585,8 +582,13 @@ public class ServiceState implements Parcelable { * @hide */ @UnsupportedAppUsage - public int getDataRoamingType() { - return mDataRoamingType; + public @RoamingType int getDataRoamingType() { + final NetworkRegistrationState regState = getNetworkRegistrationState( + NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN); + if (regState != null) { + return regState.getRoamingType(); + } + return ROAMING_TYPE_NOT_ROAMING; } /** @@ -759,8 +761,6 @@ public class ServiceState implements Parcelable { return Objects.hash( mVoiceRegState, mDataRegState, - mVoiceRoamingType, - mDataRoamingType, mChannelNumber, mCellBandwidths, mVoiceOperatorAlphaLong, @@ -780,7 +780,6 @@ public class ServiceState implements Parcelable { mCdmaEriIconIndex, mCdmaEriIconMode, mIsEmergencyOnly, - mIsDataRoamingFromRegistration, mIsUsingCarrierAggregation, mLteEarfcnRsrpBoost, mNetworkRegistrationStates); @@ -794,8 +793,6 @@ public class ServiceState implements Parcelable { return (mVoiceRegState == s.mVoiceRegState && mDataRegState == s.mDataRegState && mIsManualNetworkSelection == s.mIsManualNetworkSelection - && mVoiceRoamingType == s.mVoiceRoamingType - && mDataRoamingType == s.mDataRoamingType && mChannelNumber == s.mChannelNumber && Arrays.equals(mCellBandwidths, s.mCellBandwidths) && equalsHandlesNulls(mVoiceOperatorAlphaLong, s.mVoiceOperatorAlphaLong) @@ -813,7 +810,6 @@ public class ServiceState implements Parcelable { && equalsHandlesNulls(mCdmaDefaultRoamingIndicator, s.mCdmaDefaultRoamingIndicator) && mIsEmergencyOnly == s.mIsEmergencyOnly - && mIsDataRoamingFromRegistration == s.mIsDataRoamingFromRegistration && mIsUsingCarrierAggregation == s.mIsUsingCarrierAggregation) && (mNetworkRegistrationStates == null ? s.mNetworkRegistrationStates == null : s.mNetworkRegistrationStates != null && @@ -933,8 +929,6 @@ public class ServiceState implements Parcelable { .append(", mChannelNumber=").append(mChannelNumber) .append(", duplexMode()=").append(getDuplexMode()) .append(", mCellBandwidths=").append(Arrays.toString(mCellBandwidths)) - .append(", mVoiceRoamingType=").append(getRoamingLogString(mVoiceRoamingType)) - .append(", mDataRoamingType=").append(getRoamingLogString(mDataRoamingType)) .append(", mVoiceOperatorAlphaLong=").append(mVoiceOperatorAlphaLong) .append(", mVoiceOperatorAlphaShort=").append(mVoiceOperatorAlphaShort) .append(", mDataOperatorAlphaLong=").append(mDataOperatorAlphaLong) @@ -951,7 +945,6 @@ public class ServiceState implements Parcelable { .append(", mCdmaRoamingIndicator=").append(mCdmaRoamingIndicator) .append(", mCdmaDefaultRoamingIndicator=").append(mCdmaDefaultRoamingIndicator) .append(", mIsEmergencyOnly=").append(mIsEmergencyOnly) - .append(", mIsDataRoamingFromRegistration=").append(mIsDataRoamingFromRegistration) .append(", mIsUsingCarrierAggregation=").append(mIsUsingCarrierAggregation) .append(", mLteEarfcnRsrpBoost=").append(mLteEarfcnRsrpBoost) .append(", mNetworkRegistrationStates=").append(mNetworkRegistrationStates) @@ -962,8 +955,6 @@ public class ServiceState implements Parcelable { if (DBG) Rlog.d(LOG_TAG, "[ServiceState] setNullState=" + state); mVoiceRegState = state; mDataRegState = state; - mVoiceRoamingType = ROAMING_TYPE_NOT_ROAMING; - mDataRoamingType = ROAMING_TYPE_NOT_ROAMING; mChannelNumber = -1; mCellBandwidths = new int[0]; mVoiceOperatorAlphaLong = null; @@ -983,7 +974,6 @@ public class ServiceState implements Parcelable { mCdmaEriIconIndex = -1; mCdmaEriIconMode = -1; mIsEmergencyOnly = false; - mIsDataRoamingFromRegistration = false; mIsUsingCarrierAggregation = false; mLteEarfcnRsrpBoost = 0; mNetworkRegistrationStates = new ArrayList<>(); @@ -1029,32 +1019,50 @@ public class ServiceState implements Parcelable { } public void setRoaming(boolean roaming) { - mVoiceRoamingType = (roaming ? ROAMING_TYPE_UNKNOWN : ROAMING_TYPE_NOT_ROAMING); - mDataRoamingType = mVoiceRoamingType; + setVoiceRoaming(roaming); + setDataRoaming(roaming); } /** @hide */ @UnsupportedAppUsage public void setVoiceRoaming(boolean roaming) { - mVoiceRoamingType = (roaming ? ROAMING_TYPE_UNKNOWN : ROAMING_TYPE_NOT_ROAMING); + setVoiceRoamingType(roaming ? ROAMING_TYPE_UNKNOWN : ROAMING_TYPE_NOT_ROAMING); } /** @hide */ @UnsupportedAppUsage - public void setVoiceRoamingType(int type) { - mVoiceRoamingType = type; + public void setVoiceRoamingType(@RoamingType int type) { + NetworkRegistrationState regState = getNetworkRegistrationState( + NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TransportType.WWAN); + if (regState == null) { + regState = new NetworkRegistrationState( + NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TransportType.WWAN, + ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, + false, null, null); + addNetworkRegistrationState(regState); + } + regState.setRoamingType(type); } /** @hide */ @UnsupportedAppUsage public void setDataRoaming(boolean dataRoaming) { - mDataRoamingType = (dataRoaming ? ROAMING_TYPE_UNKNOWN : ROAMING_TYPE_NOT_ROAMING); + setDataRoamingType(dataRoaming ? ROAMING_TYPE_UNKNOWN : ROAMING_TYPE_NOT_ROAMING); } /** @hide */ @UnsupportedAppUsage - public void setDataRoamingType(int type) { - mDataRoamingType = type; + public void setDataRoamingType(@RoamingType int type) { + NetworkRegistrationState regState = getNetworkRegistrationState( + NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN); + if (regState == null) { + regState = new NetworkRegistrationState( + NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN, + ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, + false, null, null); + addNetworkRegistrationState(regState); + } + regState.setRoamingType(type); } /** @@ -1166,30 +1174,10 @@ public class ServiceState implements Parcelable { */ @UnsupportedAppUsage private void setFromNotifierBundle(Bundle m) { - mVoiceRegState = m.getInt("voiceRegState"); - mDataRegState = m.getInt("dataRegState"); - mVoiceRoamingType = m.getInt("voiceRoamingType"); - mDataRoamingType = m.getInt("dataRoamingType"); - mVoiceOperatorAlphaLong = m.getString("operator-alpha-long"); - mVoiceOperatorAlphaShort = m.getString("operator-alpha-short"); - mVoiceOperatorNumeric = m.getString("operator-numeric"); - mDataOperatorAlphaLong = m.getString("data-operator-alpha-long"); - mDataOperatorAlphaShort = m.getString("data-operator-alpha-short"); - mDataOperatorNumeric = m.getString("data-operator-numeric"); - mIsManualNetworkSelection = m.getBoolean("manual"); - mRilVoiceRadioTechnology = m.getInt("radioTechnology"); - mRilDataRadioTechnology = m.getInt("dataRadioTechnology"); - mCssIndicator = m.getBoolean("cssIndicator"); - mNetworkId = m.getInt("networkId"); - mSystemId = m.getInt("systemId"); - mCdmaRoamingIndicator = m.getInt("cdmaRoamingIndicator"); - mCdmaDefaultRoamingIndicator = m.getInt("cdmaDefaultRoamingIndicator"); - mIsEmergencyOnly = m.getBoolean("emergencyOnly"); - mIsDataRoamingFromRegistration = m.getBoolean("isDataRoamingFromRegistration"); - mIsUsingCarrierAggregation = m.getBoolean("isUsingCarrierAggregation"); - mLteEarfcnRsrpBoost = m.getInt("LteEarfcnRsrpBoost"); - mChannelNumber = m.getInt("ChannelNumber"); - mCellBandwidths = m.getIntArray("CellBandwidths"); + ServiceState ssFromBundle = m.getParcelable(Intent.EXTRA_SERVICE_STATE); + if (ssFromBundle != null) { + copyFrom(ssFromBundle); + } } /** @@ -1200,10 +1188,13 @@ public class ServiceState implements Parcelable { */ @UnsupportedAppUsage public void fillInNotifierBundle(Bundle m) { + m.putParcelable(Intent.EXTRA_SERVICE_STATE, this); + // serviceState already consists of below entries. + // for backward compatibility, we continue fill in below entries. m.putInt("voiceRegState", mVoiceRegState); m.putInt("dataRegState", mDataRegState); - m.putInt("voiceRoamingType", mVoiceRoamingType); - m.putInt("dataRoamingType", mDataRoamingType); + m.putInt("dataRoamingType", getDataRoamingType()); + m.putInt("voiceRoamingType", getVoiceRoamingType()); m.putString("operator-alpha-long", mVoiceOperatorAlphaLong); m.putString("operator-alpha-short", mVoiceOperatorAlphaShort); m.putString("operator-numeric", mVoiceOperatorNumeric); @@ -1219,7 +1210,7 @@ public class ServiceState implements Parcelable { m.putInt("cdmaRoamingIndicator", mCdmaRoamingIndicator); m.putInt("cdmaDefaultRoamingIndicator", mCdmaDefaultRoamingIndicator); m.putBoolean("emergencyOnly", mIsEmergencyOnly); - m.putBoolean("isDataRoamingFromRegistration", mIsDataRoamingFromRegistration); + m.putBoolean("isDataRoamingFromRegistration", getDataRoamingFromRegistration()); m.putBoolean("isUsingCarrierAggregation", mIsUsingCarrierAggregation); m.putInt("LteEarfcnRsrpBoost", mLteEarfcnRsrpBoost); m.putInt("ChannelNumber", mChannelNumber); diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index ad169017552f..876655c44cdb 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -32,15 +32,18 @@ import android.annotation.SystemService; import android.annotation.UnsupportedAppUsage; import android.app.BroadcastOptions; import android.app.PendingIntent; +import android.app.job.JobService; import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources; +import android.database.ContentObserver; import android.net.INetworkPolicyManager; import android.net.NetworkCapabilities; import android.net.Uri; +import android.os.Build; import android.os.Handler; import android.os.Looper; import android.os.Message; @@ -115,6 +118,52 @@ public class SubscriptionManager { @UnsupportedAppUsage public static final Uri CONTENT_URI = Uri.parse("content://telephony/siminfo"); + + /** + * Generates a content {@link Uri} used to receive updates on simInfo change + * on the given subscriptionId + * @param subscriptionId the subscriptionId to receive updates on + * @return the Uri used to observe carrier identity changes + * @hide + */ + public static Uri getUriForSubscriptionId(int subscriptionId) { + return Uri.withAppendedPath(CONTENT_URI, String.valueOf(subscriptionId)); + } + + /** + * A content {@link Uri} used to receive updates on wfc enabled user setting. + * <p> + * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the + * subscription wfc enabled {@link SubscriptionManager#WFC_IMS_ENABLED} + * while your app is running. You can also use a {@link JobService} to ensure your app + * is notified of changes to the {@link Uri} even when it is not running. + * Note, however, that using a {@link JobService} does not guarantee timely delivery of + * updates to the {@link Uri}. + * To be notified of changes to a specific subId, append subId to the URI + * {@link Uri#withAppendedPath(Uri, String)}. + * @hide + */ + @SystemApi + public static final Uri WFC_ENABLED_CONTENT_URI = Uri.withAppendedPath(CONTENT_URI, "wfc"); + + /** + * A content {@link Uri} used to receive updates on enhanced 4g user setting. + * <p> + * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the + * subscription enhanced 4G enabled {@link SubscriptionManager#ENHANCED_4G_MODE_ENABLED} + * while your app is running. You can also use a {@link JobService} to ensure your app + * is notified of changes to the {@link Uri} even when it is not running. + * Note, however, that using a {@link JobService} does not guarantee timely delivery of + * updates to the {@link Uri}. + * To be notified of changes to a specific subId, append subId to the URI + * {@link Uri#withAppendedPath(Uri, String)}. + * @hide + */ + @SystemApi + public static final Uri ENHANCED_4G_ENABLED_CONTENT_URI = Uri.withAppendedPath( + CONTENT_URI, "enhanced_4g"); + + /** * TelephonyProvider unique key column name is the subscription id. * <P>Type: TEXT (String)</P> @@ -1320,7 +1369,7 @@ public class SubscriptionManager { } /** @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public static int getPhoneId(int subId) { if (!isValidSubscriptionId(subId)) { if (DBG) { @@ -1602,7 +1651,7 @@ public class SubscriptionManager { * Check if the subscription ID is usable. * * A usable subscription ID has a valid value except some special values such as - * {@link DEFAULT_SUBSCRIPTION_ID}. It can be used for subscription functions. + * {@link #DEFAULT_SUBSCRIPTION_ID}. It can be used for subscription functions. * * @param subscriptionId the subscription ID * @return {@code true} if the subscription ID is usable; {@code false} otherwise. @@ -1616,7 +1665,7 @@ public class SubscriptionManager { * usable subId means its neither a INVALID_SUBSCRIPTION_ID nor a DEFAULT_SUB_ID. * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public static boolean isUsableSubIdValue(int subId) { return subId >= MIN_SUBSCRIPTION_ID_VALUE && subId <= MAX_SUBSCRIPTION_ID_VALUE; } @@ -1634,7 +1683,7 @@ public class SubscriptionManager { } /** @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public static void putPhoneIdAndSubIdExtra(Intent intent, int phoneId) { int[] subIds = SubscriptionManager.getSubId(phoneId); if (subIds != null && subIds.length > 0) { @@ -2159,7 +2208,12 @@ public class SubscriptionManager { /** * Set preferred default data. - * Set on which slot default data will be on. + * Set on which slot most cellular data will be on. + * It's also usually what we set up internet connection on. + * + * PreferredData overwrites user setting of default data subscription. And it's used + * by ANAS or carrier apps to switch primary and CBRS subscription dynamically in multi-SIM + * devices. * * @param slotId which slot is preferred to for cellular data. * @hide @@ -2173,20 +2227,21 @@ public class SubscriptionManager { } /** - * Get User downloaded Profiles. + * Get opportunistic data Profiles. * - * Provide all available user downloaded profile on the phone. - * @param slotId on which phone the switch will operate on + * Provide all available user downloaded profiles on phone which are used only for + * opportunistic data. + * @param slotIndex slot on which the profiles are queried from. */ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) - List<SubscriptionInfo> getOpportunisticSubscriptions(int slotId) { + public List<SubscriptionInfo> getOpportunisticSubscriptions(int slotIndex) { String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>"; List<SubscriptionInfo> subInfoList = null; try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - subInfoList = iSub.getOpportunisticSubscriptions(slotId, pkgForDebug); + subInfoList = iSub.getOpportunisticSubscriptions(slotIndex, pkgForDebug); } } catch (RemoteException ex) { // ignore it diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 48f38fca9266..fd2f2fbacccc 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -41,6 +41,7 @@ import android.net.NetworkStats; import android.net.Uri; import android.os.AsyncTask; import android.os.BatteryStats; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.PersistableBundle; @@ -60,12 +61,14 @@ import android.telephony.ims.aidl.IImsMmTelFeature; import android.telephony.ims.aidl.IImsRcsFeature; import android.telephony.ims.aidl.IImsRegistration; import android.telephony.ims.stub.ImsRegistrationImplBase; +import android.text.TextUtils; import android.util.Log; import com.android.ims.internal.IImsServiceFeatureCallback; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telecom.ITelecomService; import com.android.internal.telephony.CellNetworkScanResult; +import com.android.internal.telephony.IAns; import com.android.internal.telephony.IPhoneSubInfo; import com.android.internal.telephony.ITelephony; import com.android.internal.telephony.ITelephonyRegistry; @@ -228,7 +231,8 @@ public class TelephonyManager { /** @hide /* @deprecated - use getSystemService as described above */ - @UnsupportedAppUsage + @Deprecated + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public static TelephonyManager getDefault() { return sInstance; } @@ -317,7 +321,7 @@ public class TelephonyManager { } /** {@hide} */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public static TelephonyManager from(Context context) { return (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); } @@ -1877,7 +1881,7 @@ public class TelephonyManager { * @param subId * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getNetworkOperatorName(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_ALPHA, ""); @@ -1905,7 +1909,7 @@ public class TelephonyManager { * @param subId * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getNetworkOperator(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); return getNetworkOperatorForPhone(phoneId); @@ -2229,7 +2233,7 @@ public class TelephonyManager { * @hide */ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public int getDataNetworkType(int subId) { try{ ITelephony telephony = getITelephony(); @@ -2265,7 +2269,7 @@ public class TelephonyManager { * @hide */ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public int getVoiceNetworkType(int subId) { try{ ITelephony telephony = getITelephony(); @@ -2418,39 +2422,46 @@ public class TelephonyManager { * * These are the ordinal value of IccCardConstants.State. */ - public static final int SIM_STATE_UNKNOWN = 0; + + public static final int SIM_STATE_UNKNOWN = TelephonyProtoEnums.SIM_STATE_UNKNOWN; // 0 /** SIM card state: no SIM card is available in the device */ - public static final int SIM_STATE_ABSENT = 1; + public static final int SIM_STATE_ABSENT = TelephonyProtoEnums.SIM_STATE_ABSENT; // 1 /** SIM card state: Locked: requires the user's SIM PIN to unlock */ - public static final int SIM_STATE_PIN_REQUIRED = 2; + public static final int SIM_STATE_PIN_REQUIRED = + TelephonyProtoEnums.SIM_STATE_PIN_REQUIRED; // 2 /** SIM card state: Locked: requires the user's SIM PUK to unlock */ - public static final int SIM_STATE_PUK_REQUIRED = 3; + public static final int SIM_STATE_PUK_REQUIRED = + TelephonyProtoEnums.SIM_STATE_PUK_REQUIRED; // 3 /** SIM card state: Locked: requires a network PIN to unlock */ - public static final int SIM_STATE_NETWORK_LOCKED = 4; + public static final int SIM_STATE_NETWORK_LOCKED = + TelephonyProtoEnums.SIM_STATE_NETWORK_LOCKED; // 4 /** SIM card state: Ready */ - public static final int SIM_STATE_READY = 5; + public static final int SIM_STATE_READY = TelephonyProtoEnums.SIM_STATE_READY; // 5 /** SIM card state: SIM Card is NOT READY */ - public static final int SIM_STATE_NOT_READY = 6; + public static final int SIM_STATE_NOT_READY = TelephonyProtoEnums.SIM_STATE_NOT_READY; // 6 /** SIM card state: SIM Card Error, permanently disabled */ - public static final int SIM_STATE_PERM_DISABLED = 7; + public static final int SIM_STATE_PERM_DISABLED = + TelephonyProtoEnums.SIM_STATE_PERM_DISABLED; // 7 /** SIM card state: SIM Card Error, present but faulty */ - public static final int SIM_STATE_CARD_IO_ERROR = 8; + public static final int SIM_STATE_CARD_IO_ERROR = + TelephonyProtoEnums.SIM_STATE_CARD_IO_ERROR; // 8 /** SIM card state: SIM Card restricted, present but not usable due to * carrier restrictions. */ - public static final int SIM_STATE_CARD_RESTRICTED = 9; + public static final int SIM_STATE_CARD_RESTRICTED = + TelephonyProtoEnums.SIM_STATE_CARD_RESTRICTED; // 9 /** * SIM card state: Loaded: SIM card applications have been loaded * @hide */ @SystemApi - public static final int SIM_STATE_LOADED = 10; + public static final int SIM_STATE_LOADED = TelephonyProtoEnums.SIM_STATE_LOADED; // 10 /** * SIM card state: SIM Card is present * @hide */ @SystemApi - public static final int SIM_STATE_PRESENT = 11; + public static final int SIM_STATE_PRESENT = TelephonyProtoEnums.SIM_STATE_PRESENT; // 11 /** * Extra included in {@link #ACTION_SIM_CARD_STATE_CHANGED} and @@ -2741,7 +2752,7 @@ public class TelephonyManager { * @param subId for which SimOperator is returned * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getSimOperator(int subId) { return getSimOperatorNumeric(subId); } @@ -2755,7 +2766,7 @@ public class TelephonyManager { * @see #getSimState * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getSimOperatorNumeric() { int subId = mSubId; if (!SubscriptionManager.isUsableSubIdValue(subId)) { @@ -2784,7 +2795,7 @@ public class TelephonyManager { * @param subId for which SimOperator is returned * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getSimOperatorNumeric(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); return getSimOperatorNumericForPhone(phoneId); @@ -2798,7 +2809,7 @@ public class TelephonyManager { * @param phoneId for which SimOperator is returned * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getSimOperatorNumericForPhone(int phoneId) { return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, ""); @@ -2825,7 +2836,7 @@ public class TelephonyManager { * @param subId for which SimOperatorName is returned * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getSimOperatorName(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); return getSimOperatorNameForPhone(phoneId); @@ -2855,7 +2866,7 @@ public class TelephonyManager { * @param subId for which SimCountryIso is returned * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getSimCountryIso(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); return getSimCountryIsoForPhone(phoneId); @@ -3045,7 +3056,7 @@ public class TelephonyManager { * @hide */ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getSubscriberId(int subId) { try { IPhoneSubInfo info = getSubscriberInfo(); @@ -3430,7 +3441,7 @@ public class TelephonyManager { * @hide */ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public String getMsisdn(int subId) { try { IPhoneSubInfo info = getSubscriberInfo(); @@ -4396,7 +4407,7 @@ public class TelephonyManager { /** * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) private ITelephony getITelephony() { return ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE)); } @@ -4412,6 +4423,10 @@ public class TelephonyManager { return ITelephonyRegistry.Stub.asInterface(ServiceManager.getService("telephony.registry")); } + private IAns getIAns() { + return IAns.Stub.asInterface(ServiceManager.getService("ians")); + } + // // // PhoneStateListener @@ -5374,7 +5389,7 @@ public class TelephonyManager { @UnsupportedAppUsage public static String getTelephonyProperty(String property, String defaultVal) { String propVal = SystemProperties.get(property); - return propVal == null ? defaultVal : propVal; + return TextUtils.isEmpty(propVal) ? defaultVal : propVal; } /** @hide */ @@ -7917,7 +7932,7 @@ public class TelephonyManager { * either READ_PRIVILEGED_PHONE_STATE or READ_PHONE_STATE to retrieve the information. * @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) public ServiceState getServiceStateForSubscriber(int subId) { try { ITelephony service = getITelephony(); @@ -8603,7 +8618,6 @@ public class TelephonyManager { return UNKNOWN_CARRIER_ID_LIST_VERSION; } - /** * How many modems can have simultaneous data connections. * @hide @@ -8621,4 +8635,62 @@ public class TelephonyManager { } return 0; } + + /** + * Enable or disable AlternativeNetworkService. + * + * This method should be called to enable or disable + * AlternativeNetwork service on the device. + * + * <p> + * Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} + * + * @param enable enable(True) or disable(False) + * @return returns true if successfully set. + * @hide + */ + @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) + public boolean setAlternativeNetworkState(boolean enable) { + String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>"; + boolean ret = false; + try { + IAns iAlternativeNetworkService = getIAns(); + if (iAlternativeNetworkService != null) { + ret = iAlternativeNetworkService.setEnable(enable, pkgForDebug); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "enableAlternativeNetwork RemoteException", ex); + } + + return ret; + } + + /** + * is AlternativeNetworkService enabled + * + * This method should be called to determine if the AlternativeNetworkService is + * enabled + * + * <p> + * Requires Permission: + * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * @hide + */ + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) + public boolean isAlternativeNetworkEnabled() { + String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>"; + boolean isEnabled = false; + + try { + IAns iAlternativeNetworkService = getIAns(); + if (iAlternativeNetworkService != null) { + isEnabled = iAlternativeNetworkService.isEnabled(pkgForDebug); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "enableAlternativeNetwork RemoteException", ex); + } + + return isEnabled; + } } diff --git a/telephony/java/android/telephony/data/ApnSetting.java b/telephony/java/android/telephony/data/ApnSetting.java index 951bed468eda..8379f8cefda0 100644 --- a/telephony/java/android/telephony/data/ApnSetting.java +++ b/telephony/java/android/telephony/data/ApnSetting.java @@ -634,33 +634,33 @@ public class ApnSetting implements Parcelable { int maxConns, int waitTime, int maxConnsTime, int mtu, int mvnoType, String mvnoMatchData, int apnSetId) { return new Builder() - .setId(id) - .setOperatorNumeric(operatorNumeric) - .setEntryName(entryName) - .setApnName(apnName) - .setProxyAddress(proxyAddress) - .setProxyPort(proxyPort) - .setMmsc(mmsc) - .setMmsProxyAddress(mmsProxyAddress) - .setMmsProxyPort(mmsProxyPort) - .setUser(user) - .setPassword(password) - .setAuthType(authType) - .setApnTypeBitmask(mApnTypeBitmask) - .setProtocol(protocol) - .setRoamingProtocol(roamingProtocol) - .setCarrierEnabled(carrierEnabled) - .setNetworkTypeBitmask(networkTypeBitmask) - .setProfileId(profileId) - .setModemCognitive(modemCognitive) - .setMaxConns(maxConns) - .setWaitTime(waitTime) - .setMaxConnsTime(maxConnsTime) - .setMtu(mtu) - .setMvnoType(mvnoType) - .setMvnoMatchData(mvnoMatchData) - .setApnSetId(apnSetId) - .buildWithoutCheck(); + .setId(id) + .setOperatorNumeric(operatorNumeric) + .setEntryName(entryName) + .setApnName(apnName) + .setProxyAddress(proxyAddress) + .setProxyPort(proxyPort) + .setMmsc(mmsc) + .setMmsProxyAddress(mmsProxyAddress) + .setMmsProxyPort(mmsProxyPort) + .setUser(user) + .setPassword(password) + .setAuthType(authType) + .setApnTypeBitmask(mApnTypeBitmask) + .setProtocol(protocol) + .setRoamingProtocol(roamingProtocol) + .setCarrierEnabled(carrierEnabled) + .setNetworkTypeBitmask(networkTypeBitmask) + .setProfileId(profileId) + .setModemCognitive(modemCognitive) + .setMaxConns(maxConns) + .setWaitTime(waitTime) + .setMaxConnsTime(maxConnsTime) + .setMtu(mtu) + .setMvnoType(mvnoType) + .setMvnoMatchData(mvnoMatchData) + .setApnSetId(apnSetId) + .buildWithoutCheck(); } /** @hide */ @@ -692,56 +692,56 @@ public class ApnSetting implements Parcelable { } return makeApnSetting( - cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers._ID)), - cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.NUMERIC)), - cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.NAME)), - cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.APN)), - cursor.getString( - cursor.getColumnIndexOrThrow(Telephony.Carriers.PROXY)), - portFromString(cursor.getString( - cursor.getColumnIndexOrThrow(Telephony.Carriers.PORT))), - UriFromString(cursor.getString( - cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSC))), - cursor.getString( - cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSPROXY)), - portFromString(cursor.getString( - cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSPORT))), - cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.USER)), - cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PASSWORD)), - cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.AUTH_TYPE)), - apnTypesBitmask, - getProtocolIntFromString( - cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROTOCOL))), - getProtocolIntFromString( + cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers._ID)), + cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.NUMERIC)), + cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.NAME)), + cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.APN)), + cursor.getString( + cursor.getColumnIndexOrThrow(Telephony.Carriers.PROXY)), + portFromString(cursor.getString( + cursor.getColumnIndexOrThrow(Telephony.Carriers.PORT))), + UriFromString(cursor.getString( + cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSC))), + cursor.getString( + cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSPROXY)), + portFromString(cursor.getString( + cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSPORT))), + cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.USER)), + cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PASSWORD)), + cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.AUTH_TYPE)), + apnTypesBitmask, + getProtocolIntFromString( + cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROTOCOL))), + getProtocolIntFromString( + cursor.getString(cursor.getColumnIndexOrThrow( + Telephony.Carriers.ROAMING_PROTOCOL))), + cursor.getInt(cursor.getColumnIndexOrThrow( + Telephony.Carriers.CARRIER_ENABLED)) == 1, + networkTypeBitmask, + cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROFILE_ID)), + cursor.getInt(cursor.getColumnIndexOrThrow( + Telephony.Carriers.MODEM_COGNITIVE)) == 1, + cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.MAX_CONNS)), + cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.WAIT_TIME)), + cursor.getInt(cursor.getColumnIndexOrThrow( + Telephony.Carriers.MAX_CONNS_TIME)), + cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.MTU)), + getMvnoTypeIntFromString( + cursor.getString(cursor.getColumnIndexOrThrow( + Telephony.Carriers.MVNO_TYPE))), cursor.getString(cursor.getColumnIndexOrThrow( - Telephony.Carriers.ROAMING_PROTOCOL))), - cursor.getInt(cursor.getColumnIndexOrThrow( - Telephony.Carriers.CARRIER_ENABLED)) == 1, - networkTypeBitmask, - cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROFILE_ID)), - cursor.getInt(cursor.getColumnIndexOrThrow( - Telephony.Carriers.MODEM_COGNITIVE)) == 1, - cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.MAX_CONNS)), - cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.WAIT_TIME)), - cursor.getInt(cursor.getColumnIndexOrThrow( - Telephony.Carriers.MAX_CONNS_TIME)), - cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.MTU)), - getMvnoTypeIntFromString( - cursor.getString(cursor.getColumnIndexOrThrow( - Telephony.Carriers.MVNO_TYPE))), - cursor.getString(cursor.getColumnIndexOrThrow( - Telephony.Carriers.MVNO_MATCH_DATA)), - cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.APN_SET_ID))); + Telephony.Carriers.MVNO_MATCH_DATA)), + cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.APN_SET_ID))); } /** @hide */ public static ApnSetting makeApnSetting(ApnSetting apn) { return makeApnSetting(apn.mId, apn.mOperatorNumeric, apn.mEntryName, apn.mApnName, - apn.mProxyAddress, apn.mProxyPort, apn.mMmsc, apn.mMmsProxyAddress, - apn.mMmsProxyPort, apn.mUser, apn.mPassword, apn.mAuthType, apn.mApnTypeBitmask, - apn.mProtocol, apn.mRoamingProtocol, apn.mCarrierEnabled, apn.mNetworkTypeBitmask, - apn.mProfileId, apn.mModemCognitive, apn.mMaxConns, apn.mWaitTime, - apn.mMaxConnsTime, apn.mMtu, apn.mMvnoType, apn.mMvnoMatchData, apn.mApnSetId); + apn.mProxyAddress, apn.mProxyPort, apn.mMmsc, apn.mMmsProxyAddress, + apn.mMmsProxyPort, apn.mUser, apn.mPassword, apn.mAuthType, apn.mApnTypeBitmask, + apn.mProtocol, apn.mRoamingProtocol, apn.mCarrierEnabled, apn.mNetworkTypeBitmask, + apn.mProfileId, apn.mModemCognitive, apn.mMaxConns, apn.mWaitTime, + apn.mMaxConnsTime, apn.mMtu, apn.mMvnoType, apn.mMvnoMatchData, apn.mApnSetId); } /** @@ -931,16 +931,16 @@ public class ApnSetting implements Parcelable { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("[ApnSettingV5] ") - .append(mEntryName) - .append(", ").append(mId) - .append(", ").append(mOperatorNumeric) - .append(", ").append(mApnName) - .append(", ").append(mProxyAddress) - .append(", ").append(UriToString(mMmsc)) - .append(", ").append(mMmsProxyAddress) - .append(", ").append(portToString(mMmsProxyPort)) - .append(", ").append(portToString(mProxyPort)) - .append(", ").append(mAuthType).append(", "); + .append(mEntryName) + .append(", ").append(mId) + .append(", ").append(mOperatorNumeric) + .append(", ").append(mApnName) + .append(", ").append(mProxyAddress) + .append(", ").append(UriToString(mMmsc)) + .append(", ").append(mMmsProxyAddress) + .append(", ").append(portToString(mMmsProxyPort)) + .append(", ").append(portToString(mProxyPort)) + .append(", ").append(mAuthType).append(", "); final String[] types = getApnTypesStringFromBitmask(mApnTypeBitmask).split(","); sb.append(TextUtils.join(" | ", types)); sb.append(", ").append(PROTOCOL_INT_MAP.get(mProtocol)); @@ -1022,31 +1022,31 @@ public class ApnSetting implements Parcelable { ApnSetting other = (ApnSetting) o; return mEntryName.equals(other.mEntryName) - && Objects.equals(mId, other.mId) - && Objects.equals(mOperatorNumeric, other.mOperatorNumeric) - && Objects.equals(mApnName, other.mApnName) - && Objects.equals(mProxyAddress, other.mProxyAddress) - && Objects.equals(mMmsc, other.mMmsc) - && Objects.equals(mMmsProxyAddress, other.mMmsProxyAddress) - && Objects.equals(mMmsProxyPort, other.mMmsProxyPort) - && Objects.equals(mProxyPort, other.mProxyPort) - && Objects.equals(mUser, other.mUser) - && Objects.equals(mPassword, other.mPassword) - && Objects.equals(mAuthType, other.mAuthType) - && Objects.equals(mApnTypeBitmask, other.mApnTypeBitmask) - && Objects.equals(mProtocol, other.mProtocol) - && Objects.equals(mRoamingProtocol, other.mRoamingProtocol) - && Objects.equals(mCarrierEnabled, other.mCarrierEnabled) - && Objects.equals(mProfileId, other.mProfileId) - && Objects.equals(mModemCognitive, other.mModemCognitive) - && Objects.equals(mMaxConns, other.mMaxConns) - && Objects.equals(mWaitTime, other.mWaitTime) - && Objects.equals(mMaxConnsTime, other.mMaxConnsTime) - && Objects.equals(mMtu, other.mMtu) - && Objects.equals(mMvnoType, other.mMvnoType) - && Objects.equals(mMvnoMatchData, other.mMvnoMatchData) - && Objects.equals(mNetworkTypeBitmask, other.mNetworkTypeBitmask) - && Objects.equals(mApnSetId, other.mApnSetId); + && Objects.equals(mId, other.mId) + && Objects.equals(mOperatorNumeric, other.mOperatorNumeric) + && Objects.equals(mApnName, other.mApnName) + && Objects.equals(mProxyAddress, other.mProxyAddress) + && Objects.equals(mMmsc, other.mMmsc) + && Objects.equals(mMmsProxyAddress, other.mMmsProxyAddress) + && Objects.equals(mMmsProxyPort, other.mMmsProxyPort) + && Objects.equals(mProxyPort,other.mProxyPort) + && Objects.equals(mUser, other.mUser) + && Objects.equals(mPassword, other.mPassword) + && Objects.equals(mAuthType, other.mAuthType) + && Objects.equals(mApnTypeBitmask, other.mApnTypeBitmask) + && Objects.equals(mProtocol, other.mProtocol) + && Objects.equals(mRoamingProtocol, other.mRoamingProtocol) + && Objects.equals(mCarrierEnabled, other.mCarrierEnabled) + && Objects.equals(mProfileId, other.mProfileId) + && Objects.equals(mModemCognitive, other.mModemCognitive) + && Objects.equals(mMaxConns, other.mMaxConns) + && Objects.equals(mWaitTime, other.mWaitTime) + && Objects.equals(mMaxConnsTime, other.mMaxConnsTime) + && Objects.equals(mMtu, other.mMtu) + && Objects.equals(mMvnoType, other.mMvnoType) + && Objects.equals(mMvnoMatchData, other.mMvnoMatchData) + && Objects.equals(mNetworkTypeBitmask, other.mNetworkTypeBitmask) + && Objects.equals(mApnSetId, other.mApnSetId); } /** @@ -1069,29 +1069,29 @@ public class ApnSetting implements Parcelable { ApnSetting other = (ApnSetting) o; return mEntryName.equals(other.mEntryName) - && Objects.equals(mOperatorNumeric, other.mOperatorNumeric) - && Objects.equals(mApnName, other.mApnName) - && Objects.equals(mProxyAddress, other.mProxyAddress) - && Objects.equals(mMmsc, other.mMmsc) - && Objects.equals(mMmsProxyAddress, other.mMmsProxyAddress) - && Objects.equals(mMmsProxyPort, other.mMmsProxyPort) - && Objects.equals(mProxyPort, other.mProxyPort) - && Objects.equals(mUser, other.mUser) - && Objects.equals(mPassword, other.mPassword) - && Objects.equals(mAuthType, other.mAuthType) - && Objects.equals(mApnTypeBitmask, other.mApnTypeBitmask) - && (isDataRoaming || Objects.equals(mProtocol, other.mProtocol)) - && (!isDataRoaming || Objects.equals(mRoamingProtocol, other.mRoamingProtocol)) - && Objects.equals(mCarrierEnabled, other.mCarrierEnabled) - && Objects.equals(mProfileId, other.mProfileId) - && Objects.equals(mModemCognitive, other.mModemCognitive) - && Objects.equals(mMaxConns, other.mMaxConns) - && Objects.equals(mWaitTime, other.mWaitTime) - && Objects.equals(mMaxConnsTime, other.mMaxConnsTime) - && Objects.equals(mMtu, other.mMtu) - && Objects.equals(mMvnoType, other.mMvnoType) - && Objects.equals(mMvnoMatchData, other.mMvnoMatchData) - && Objects.equals(mApnSetId, other.mApnSetId); + && Objects.equals(mOperatorNumeric, other.mOperatorNumeric) + && Objects.equals(mApnName, other.mApnName) + && Objects.equals(mProxyAddress, other.mProxyAddress) + && Objects.equals(mMmsc, other.mMmsc) + && Objects.equals(mMmsProxyAddress, other.mMmsProxyAddress) + && Objects.equals(mMmsProxyPort, other.mMmsProxyPort) + && Objects.equals(mProxyPort, other.mProxyPort) + && Objects.equals(mUser, other.mUser) + && Objects.equals(mPassword, other.mPassword) + && Objects.equals(mAuthType, other.mAuthType) + && Objects.equals(mApnTypeBitmask, other.mApnTypeBitmask) + && (isDataRoaming || Objects.equals(mProtocol,other.mProtocol)) + && (!isDataRoaming || Objects.equals(mRoamingProtocol, other.mRoamingProtocol)) + && Objects.equals(mCarrierEnabled, other.mCarrierEnabled) + && Objects.equals(mProfileId, other.mProfileId) + && Objects.equals(mModemCognitive, other.mModemCognitive) + && Objects.equals(mMaxConns, other.mMaxConns) + && Objects.equals(mWaitTime, other.mWaitTime) + && Objects.equals(mMaxConnsTime, other.mMaxConnsTime) + && Objects.equals(mMtu, other.mMtu) + && Objects.equals(mMvnoType, other.mMvnoType) + && Objects.equals(mMvnoMatchData, other.mMvnoMatchData) + && Objects.equals(mApnSetId, other.mApnSetId); } /** @@ -1103,22 +1103,22 @@ public class ApnSetting implements Parcelable { */ public boolean similar(ApnSetting other) { return (!this.canHandleType(TYPE_DUN) - && !other.canHandleType(TYPE_DUN) - && Objects.equals(this.mApnName, other.mApnName) - && !typeSameAny(this, other) - && xorEquals(this.mProxyAddress, other.mProxyAddress) - && xorEqualsInt(this.mProxyPort, other.mProxyPort) - && xorEquals(this.mProtocol, other.mProtocol) - && xorEquals(this.mRoamingProtocol, other.mRoamingProtocol) - && Objects.equals(this.mCarrierEnabled, other.mCarrierEnabled) - && Objects.equals(this.mProfileId, other.mProfileId) - && Objects.equals(this.mMvnoType, other.mMvnoType) - && Objects.equals(this.mMvnoMatchData, other.mMvnoMatchData) - && xorEquals(this.mMmsc, other.mMmsc) - && xorEquals(this.mMmsProxyAddress, other.mMmsProxyAddress) - && xorEqualsInt(this.mMmsProxyPort, other.mMmsProxyPort)) - && Objects.equals(this.mNetworkTypeBitmask, other.mNetworkTypeBitmask) - && Objects.equals(mApnSetId, other.mApnSetId); + && !other.canHandleType(TYPE_DUN) + && Objects.equals(this.mApnName, other.mApnName) + && !typeSameAny(this, other) + && xorEquals(this.mProxyAddress, other.mProxyAddress) + && xorEqualsInt(this.mProxyPort, other.mProxyPort) + && xorEquals(this.mProtocol, other.mProtocol) + && xorEquals(this.mRoamingProtocol, other.mRoamingProtocol) + && Objects.equals(this.mCarrierEnabled, other.mCarrierEnabled) + && Objects.equals(this.mProfileId, other.mProfileId) + && Objects.equals(this.mMvnoType, other.mMvnoType) + && Objects.equals(this.mMvnoMatchData, other.mMvnoMatchData) + && xorEquals(this.mMmsc, other.mMmsc) + && xorEquals(this.mMmsProxyAddress, other.mMmsProxyAddress) + && xorEqualsInt(this.mMmsProxyPort, other.mMmsProxyPort)) + && Objects.equals(this.mNetworkTypeBitmask, other.mNetworkTypeBitmask) + && Objects.equals(mApnSetId, other.mApnSetId); } // Equal or one is null. @@ -1343,13 +1343,13 @@ public class ApnSetting implements Parcelable { new Parcelable.Creator<ApnSetting>() { @Override public ApnSetting createFromParcel(Parcel in) { - return readFromParcel(in); - } + return readFromParcel(in); + } @Override public ApnSetting[] newArray(int size) { - return new ApnSetting[size]; - } + return new ApnSetting[size]; + } }; /** diff --git a/telephony/java/com/android/internal/telephony/IAns.aidl b/telephony/java/com/android/internal/telephony/IAns.aidl new file mode 100755 index 000000000000..6eb8d666cb1e --- /dev/null +++ b/telephony/java/com/android/internal/telephony/IAns.aidl @@ -0,0 +1,52 @@ +/* + * 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. + */ + +package com.android.internal.telephony; + + +interface IAns { + + /** + * Enable or disable Alternative Network service. + * + * This method should be called to enable or disable + * AlternativeNetwork service on the device. + * + * <p> + * Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} + * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * + * @param enable enable(True) or disable(False) + * @param callingPackage caller's package name + * @return returns true if successfully set. + */ + boolean setEnable(boolean enable, String callingPackage); + + /** + * is Alternative Network service enabled + * + * This method should be called to determine if the Alternative Network service is enabled + * + * <p> + * Requires Permission: + * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * + * @param callingPackage caller's package name + */ + boolean isEnabled(String callingPackage); +} diff --git a/test-base/Android.bp b/test-base/Android.bp index 0b8a02a815d9..4d765d3e5f3f 100644 --- a/test-base/Android.bp +++ b/test-base/Android.bp @@ -37,7 +37,8 @@ java_sdk_library { "junit.framework", ], - droiddoc_options: ["stubsourceonly"], + droiddoc_options: ["-stubsourceonly"], + metalava_enabled: false, compile_dex: true, } diff --git a/test-mock/Android.bp b/test-mock/Android.bp index 5eba01779f46..37158e5fe0b9 100644 --- a/test-mock/Android.bp +++ b/test-mock/Android.bp @@ -26,5 +26,6 @@ java_sdk_library { ], srcs_lib_whitelist_pkgs: ["android"], + metalava_enabled: false, compile_dex: true, } diff --git a/test-runner/Android.bp b/test-runner/Android.bp index ea615b920df6..0a0d50cc330c 100644 --- a/test-runner/Android.bp +++ b/test-runner/Android.bp @@ -40,7 +40,8 @@ java_sdk_library { "junit.textui", ], - droiddoc_options: ["stubsourceonly"], + droiddoc_options: ["-stubsourceonly"], + metalava_enabled: false, compile_dex: true } diff --git a/tests/ActivityTests/Android.mk b/tests/ActivityTests/Android.mk index 4c68c8bb40c2..94294f6b062a 100644 --- a/tests/ActivityTests/Android.mk +++ b/tests/ActivityTests/Android.mk @@ -10,9 +10,5 @@ LOCAL_MODULE_TAGS := tests LOCAL_CERTIFICATE := platform LOCAL_USE_AAPT2 := true -# Disable AAPT2 manifest checks to fix: -# frameworks/base/tests/ActivityTests/AndroidManifest.xml:42: error: unexpected element <preferred> found in <manifest><application><activity>. -# TODO(b/79755007): Remove when AAPT2 recognizes the manifest elements. -LOCAL_AAPT_FLAGS += --warn-manifest-validation include $(BUILD_PACKAGE) diff --git a/tests/NetworkSecurityConfigTest/Android.mk b/tests/NetworkSecurityConfigTest/Android.mk index c225e170c377..a6c21db16846 100644 --- a/tests/NetworkSecurityConfigTest/Android.mk +++ b/tests/NetworkSecurityConfigTest/Android.mk @@ -7,7 +7,6 @@ LOCAL_CERTIFICATE := platform LOCAL_JAVA_LIBRARIES := \ android.test.runner \ - conscrypt \ android.test.base \ LOCAL_STATIC_JAVA_LIBRARIES := junit diff --git a/tests/RemoteDisplayProvider/Android.mk b/tests/RemoteDisplayProvider/Android.mk index e827ec20ae3e..43bf0243b55b 100644 --- a/tests/RemoteDisplayProvider/Android.mk +++ b/tests/RemoteDisplayProvider/Android.mk @@ -18,9 +18,9 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_PACKAGE_NAME := RemoteDisplayProviderTest LOCAL_MODULE_TAGS := tests -LOCAL_SDK_VERSION := current +LOCAL_SDK_VERSION := system_current LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_RESOURCE_DIR = $(LOCAL_PATH)/res -LOCAL_JAVA_LIBRARIES := com.android.media.remotedisplay.stubs +LOCAL_JAVA_LIBRARIES := com.android.media.remotedisplay LOCAL_CERTIFICATE := platform include $(BUILD_PACKAGE) diff --git a/tests/net/Android.mk b/tests/net/Android.mk index 750e2fb6f6b4..132135dc89bc 100644 --- a/tests/net/Android.mk +++ b/tests/net/Android.mk @@ -63,7 +63,8 @@ LOCAL_JNI_SHARED_LIBRARIES := \ libunwindstack \ libutilscallstack \ libziparchive \ - libz + libz \ + netd_aidl_interface-cpp LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk @@ -92,7 +93,8 @@ LOCAL_SHARED_LIBRARIES := \ liblog \ libcutils \ libnativehelper \ - libnetdaidl + libnetdaidl \ + netd_aidl_interface-cpp LOCAL_STATIC_LIBRARIES := \ libpcap \ diff --git a/tools/aapt2/Android.bp b/tools/aapt2/Android.bp index 48cfc4453d8f..750fb56b2792 100644 --- a/tools/aapt2/Android.bp +++ b/tools/aapt2/Android.bp @@ -120,7 +120,6 @@ cc_library_host_static { "util/BigBuffer.cpp", "util/Files.cpp", "util/Util.cpp", - "ConfigDescription.cpp", "Debug.cpp", "DominatorTree.cpp", "Flags.cpp", @@ -130,7 +129,6 @@ cc_library_host_static { "java/ManifestClassGenerator.cpp", "java/ProguardRules.cpp", "LoadedApk.cpp", - "Locale.cpp", "Resource.cpp", "ResourceParser.cpp", "ResourceTable.cpp", diff --git a/tools/aapt2/DominatorTree.cpp b/tools/aapt2/DominatorTree.cpp index 118a385e2253..ff18033c641a 100644 --- a/tools/aapt2/DominatorTree.cpp +++ b/tools/aapt2/DominatorTree.cpp @@ -19,8 +19,9 @@ #include <algorithm> #include "android-base/logging.h" +#include "androidfw/ConfigDescription.h" -#include "ConfigDescription.h" +using ::android::ConfigDescription; namespace aapt { diff --git a/tools/aapt2/DominatorTree_test.cpp b/tools/aapt2/DominatorTree_test.cpp index efc523fcf59b..fe4f951a5cd0 100644 --- a/tools/aapt2/DominatorTree_test.cpp +++ b/tools/aapt2/DominatorTree_test.cpp @@ -23,6 +23,8 @@ #include "test/Test.h" #include "util/Util.h" +using ::android::ConfigDescription; + namespace aapt { namespace { diff --git a/tools/aapt2/OWNERS b/tools/aapt2/OWNERS index 23ec5ab0d1f3..f1903a5a54a7 100644 --- a/tools/aapt2/OWNERS +++ b/tools/aapt2/OWNERS @@ -1,2 +1,3 @@ set noparent toddke@google.com +rtmitchell@google.com
\ No newline at end of file diff --git a/tools/aapt2/Resource.h b/tools/aapt2/Resource.h index 6fcf0f6d19cd..1c1aeddf158a 100644 --- a/tools/aapt2/Resource.h +++ b/tools/aapt2/Resource.h @@ -24,10 +24,10 @@ #include <tuple> #include <vector> +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" #include "utils/JenkinsHash.h" -#include "ConfigDescription.h" #include "Source.h" namespace aapt { @@ -171,7 +171,7 @@ struct ResourceFile { ResourceName name; // Configuration - ConfigDescription config; + android::ConfigDescription config; // Type Type type; @@ -189,7 +189,7 @@ struct ResourceFile { */ struct ResourceKey { ResourceName name; - ConfigDescription config; + android::ConfigDescription config; }; bool operator<(const ResourceKey& a, const ResourceKey& b); @@ -201,16 +201,16 @@ bool operator<(const ResourceKey& a, const ResourceKey& b); */ struct ResourceKeyRef { ResourceNameRef name; - ConfigDescription config; + android::ConfigDescription config; ResourceKeyRef() = default; - ResourceKeyRef(const ResourceNameRef& n, const ConfigDescription& c) + ResourceKeyRef(const ResourceNameRef& n, const android::ConfigDescription& c) : name(n), config(c) {} /** * Prevent taking a reference to a temporary. This is bad. */ - ResourceKeyRef(ResourceName&& n, const ConfigDescription& c) = delete; + ResourceKeyRef(ResourceName&& n, const android::ConfigDescription& c) = delete; }; bool operator<(const ResourceKeyRef& a, const ResourceKeyRef& b); diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp index 7f48544c0ae4..39ca80bbcf51 100644 --- a/tools/aapt2/ResourceParser.cpp +++ b/tools/aapt2/ResourceParser.cpp @@ -34,6 +34,7 @@ using ::aapt::ResourceUtils::StringBuilder; using ::aapt::text::Utf8Iterator; +using ::android::ConfigDescription; using ::android::StringPiece; namespace aapt { diff --git a/tools/aapt2/ResourceParser.h b/tools/aapt2/ResourceParser.h index fb9dbd0cd0fd..6cc7b76c1ad1 100644 --- a/tools/aapt2/ResourceParser.h +++ b/tools/aapt2/ResourceParser.h @@ -20,9 +20,9 @@ #include <memory> #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" -#include "ConfigDescription.h" #include "Diagnostics.h" #include "ResourceTable.h" #include "ResourceValues.h" @@ -53,7 +53,7 @@ struct ResourceParserOptions { class ResourceParser { public: ResourceParser(IDiagnostics* diag, ResourceTable* table, const Source& source, - const ConfigDescription& config, + const android::ConfigDescription& config, const ResourceParserOptions& options = {}); bool Parse(xml::XmlPullParser* parser); @@ -110,7 +110,7 @@ class ResourceParser { IDiagnostics* diag_; ResourceTable* table_; Source source_; - ConfigDescription config_; + android::ConfigDescription config_; ResourceParserOptions options_; }; diff --git a/tools/aapt2/ResourceParser_test.cpp b/tools/aapt2/ResourceParser_test.cpp index 41b4041efb7a..9de43c02fdca 100644 --- a/tools/aapt2/ResourceParser_test.cpp +++ b/tools/aapt2/ResourceParser_test.cpp @@ -29,6 +29,7 @@ using ::aapt::io::StringInputStream; using ::aapt::test::StrValueEq; using ::aapt::test::ValueEq; +using ::android::ConfigDescription; using ::android::Res_value; using ::android::ResTable_map; using ::android::StringPiece; diff --git a/tools/aapt2/ResourceTable.cpp b/tools/aapt2/ResourceTable.cpp index d0faac30425a..c2274d04cc8c 100644 --- a/tools/aapt2/ResourceTable.cpp +++ b/tools/aapt2/ResourceTable.cpp @@ -23,9 +23,9 @@ #include "android-base/logging.h" #include "android-base/stringprintf.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/ResourceTypes.h" -#include "ConfigDescription.h" #include "NameMangler.h" #include "ResourceValues.h" #include "ValueVisitor.h" @@ -33,6 +33,7 @@ #include "util/Util.h" using ::aapt::text::IsValidResourceEntryName; +using ::android::ConfigDescription; using ::android::StringPiece; using ::android::base::StringPrintf; diff --git a/tools/aapt2/ResourceTable.h b/tools/aapt2/ResourceTable.h index 8534eaaf0366..7b19a3188a76 100644 --- a/tools/aapt2/ResourceTable.h +++ b/tools/aapt2/ResourceTable.h @@ -17,7 +17,6 @@ #ifndef AAPT_RESOURCE_TABLE_H #define AAPT_RESOURCE_TABLE_H -#include "ConfigDescription.h" #include "Diagnostics.h" #include "Resource.h" #include "ResourceValues.h" @@ -26,6 +25,7 @@ #include "io/File.h" #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" #include <functional> @@ -66,7 +66,7 @@ struct Overlayable { class ResourceConfigValue { public: // The configuration for which this value is defined. - const ConfigDescription config; + const android::ConfigDescription config; // The product for which this value is defined. const std::string product; @@ -74,7 +74,7 @@ class ResourceConfigValue { // The actual Value. std::unique_ptr<Value> value; - ResourceConfigValue(const ConfigDescription& config, const android::StringPiece& product) + ResourceConfigValue(const android::ConfigDescription& config, const android::StringPiece& product) : config(config), product(product.to_string()) {} private: @@ -103,14 +103,14 @@ class ResourceEntry { explicit ResourceEntry(const android::StringPiece& name) : name(name.to_string()) {} - ResourceConfigValue* FindValue(const ConfigDescription& config); + ResourceConfigValue* FindValue(const android::ConfigDescription& config); - ResourceConfigValue* FindValue(const ConfigDescription& config, + ResourceConfigValue* FindValue(const android::ConfigDescription& config, const android::StringPiece& product); - ResourceConfigValue* FindOrCreateValue(const ConfigDescription& config, + ResourceConfigValue* FindOrCreateValue(const android::ConfigDescription& config, const android::StringPiece& product); - std::vector<ResourceConfigValue*> FindAllValues(const ConfigDescription& config); + std::vector<ResourceConfigValue*> FindAllValues(const android::ConfigDescription& config); template <typename Func> std::vector<ResourceConfigValue*> FindValuesIf(Func f) { @@ -182,29 +182,30 @@ class ResourceTable { // When a collision of resources occurs, this method decides which value to keep. static CollisionResult ResolveValueCollision(Value* existing, Value* incoming); - bool AddResource(const ResourceNameRef& name, const ConfigDescription& config, + bool AddResource(const ResourceNameRef& name, const android::ConfigDescription& config, const android::StringPiece& product, std::unique_ptr<Value> value, IDiagnostics* diag); bool AddResourceWithId(const ResourceNameRef& name, const ResourceId& res_id, - const ConfigDescription& config, const android::StringPiece& product, - std::unique_ptr<Value> value, IDiagnostics* diag); + const android::ConfigDescription& config, + const android::StringPiece& product, std::unique_ptr<Value> value, + IDiagnostics* diag); - bool AddFileReference(const ResourceNameRef& name, const ConfigDescription& config, + bool AddFileReference(const ResourceNameRef& name, const android::ConfigDescription& config, const Source& source, const android::StringPiece& path, IDiagnostics* diag); - bool AddFileReferenceMangled(const ResourceNameRef& name, const ConfigDescription& config, + bool AddFileReferenceMangled(const ResourceNameRef& name, const android::ConfigDescription& config, const Source& source, const android::StringPiece& path, io::IFile* file, IDiagnostics* diag); // Same as AddResource, but doesn't verify the validity of the name. This is used // when loading resources from an existing binary resource table that may have mangled names. - bool AddResourceMangled(const ResourceNameRef& name, const ConfigDescription& config, + bool AddResourceMangled(const ResourceNameRef& name, const android::ConfigDescription& config, const android::StringPiece& product, std::unique_ptr<Value> value, IDiagnostics* diag); bool AddResourceWithIdMangled(const ResourceNameRef& name, const ResourceId& id, - const ConfigDescription& config, + const android::ConfigDescription& config, const android::StringPiece& product, std::unique_ptr<Value> value, IDiagnostics* diag); @@ -277,11 +278,12 @@ class ResourceTable { IDiagnostics* diag); bool AddResourceImpl(const ResourceNameRef& name, const ResourceId& res_id, - const ConfigDescription& config, const android::StringPiece& product, - std::unique_ptr<Value> value, NameValidator name_validator, - const CollisionResolverFunc& conflict_resolver, IDiagnostics* diag); + const android::ConfigDescription& config, + const android::StringPiece& product, std::unique_ptr<Value> value, + NameValidator name_validator, const CollisionResolverFunc& conflict_resolver, + IDiagnostics* diag); - bool AddFileReferenceImpl(const ResourceNameRef& name, const ConfigDescription& config, + bool AddFileReferenceImpl(const ResourceNameRef& name, const android::ConfigDescription& config, const Source& source, const android::StringPiece& path, io::IFile* file, NameValidator name_validator, IDiagnostics* diag); diff --git a/tools/aapt2/ResourceTable_test.cpp b/tools/aapt2/ResourceTable_test.cpp index 7fa8ea2f7f94..1a1f73fa4bb9 100644 --- a/tools/aapt2/ResourceTable_test.cpp +++ b/tools/aapt2/ResourceTable_test.cpp @@ -24,6 +24,7 @@ #include <ostream> #include <string> +using ::android::ConfigDescription; using ::android::StringPiece; using ::testing::Eq; using ::testing::NotNull; diff --git a/tools/aapt2/ResourceUtils.cpp b/tools/aapt2/ResourceUtils.cpp index 560077cc322c..82d9e041b41a 100644 --- a/tools/aapt2/ResourceUtils.cpp +++ b/tools/aapt2/ResourceUtils.cpp @@ -31,6 +31,7 @@ #include "util/Util.h" using ::aapt::text::Utf8Iterator; +using ::android::ConfigDescription; using ::android::StringPiece; using ::android::StringPiece16; using ::android::base::StringPrintf; diff --git a/tools/aapt2/ResourceUtils.h b/tools/aapt2/ResourceUtils.h index 7af2fe06b908..e2f1c89bfd4c 100644 --- a/tools/aapt2/ResourceUtils.h +++ b/tools/aapt2/ResourceUtils.h @@ -20,6 +20,7 @@ #include <functional> #include <memory> +#include "androidfw/ConfigDescription.h" #include "androidfw/ResourceTypes.h" #include "androidfw/StringPiece.h" @@ -219,7 +220,8 @@ std::string BuildResourceFileName(const ResourceFile& res_file, // Parses the binary form of a resource value. `type` is used as a hint to know when a value is // an ID versus a False boolean value, etc. `config` is for sorting strings in the string pool. -std::unique_ptr<Item> ParseBinaryResValue(const ResourceType& type, const ConfigDescription& config, +std::unique_ptr<Item> ParseBinaryResValue(const ResourceType& type, + const android::ConfigDescription& config, const android::ResStringPool& src_pool, const android::Res_value& res_value, StringPool* dst_pool); diff --git a/tools/aapt2/StringPool.h b/tools/aapt2/StringPool.h index f5b464de2ea5..1006ca970dc5 100644 --- a/tools/aapt2/StringPool.h +++ b/tools/aapt2/StringPool.h @@ -24,9 +24,9 @@ #include <vector> #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" -#include "ConfigDescription.h" #include "Diagnostics.h" #include "util/BigBuffer.h" @@ -60,12 +60,12 @@ class StringPool { kLowPriority = 0xffffffffu, }; uint32_t priority = kNormalPriority; - ConfigDescription config; + android::ConfigDescription config; Context() = default; - Context(uint32_t p, const ConfigDescription& c) : priority(p), config(c) {} + Context(uint32_t p, const android::ConfigDescription& c) : priority(p), config(c) {} explicit Context(uint32_t p) : priority(p) {} - explicit Context(const ConfigDescription& c) : priority(kNormalPriority), config(c) { + explicit Context(const android::ConfigDescription& c) : priority(kNormalPriority), config(c) { } }; diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp index ab8a4b77a89d..411ad747faa3 100644 --- a/tools/aapt2/cmd/Compile.cpp +++ b/tools/aapt2/cmd/Compile.cpp @@ -21,11 +21,11 @@ #include "android-base/errors.h" #include "android-base/file.h" #include "android-base/utf8.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/zero_copy_stream_impl_lite.h" -#include "ConfigDescription.h" #include "Diagnostics.h" #include "Flags.h" #include "ResourceParser.h" @@ -50,6 +50,7 @@ using ::aapt::io::FileInputStream; using ::aapt::text::Printer; +using ::android::ConfigDescription; using ::android::StringPiece; using ::android::base::SystemErrorCodeToString; using ::google::protobuf::io::CopyingOutputStreamAdaptor; diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp index db42e7cb3e02..60cab5db1b1f 100644 --- a/tools/aapt2/cmd/Link.cpp +++ b/tools/aapt2/cmd/Link.cpp @@ -24,13 +24,13 @@ #include "android-base/errors.h" #include "android-base/file.h" #include "android-base/stringprintf.h" +#include "androidfw/Locale.h" #include "androidfw/StringPiece.h" #include "AppInfo.h" #include "Debug.h" #include "Flags.h" #include "LoadedApk.h" -#include "Locale.h" #include "NameMangler.h" #include "ResourceUtils.h" #include "ResourceValues.h" @@ -68,6 +68,7 @@ #include "xml/XmlDom.h" using ::aapt::io::FileInputStream; +using ::android::ConfigDescription; using ::android::StringPiece; using ::android::base::StringPrintf; @@ -105,6 +106,7 @@ struct LinkOptions { bool no_version_vectors = false; bool no_version_transitions = false; bool no_resource_deduping = false; + bool no_resource_removal = false; bool no_xml_namespaces = false; bool do_not_compress_anything = false; std::unordered_set<std::string> extensions_to_not_compress; @@ -1806,10 +1808,12 @@ class LinkCommand { // Before we process anything, remove the resources whose default values don't exist. // We want to force any references to these to fail the build. - if (!NoDefaultResourceRemover{}.Consume(context_, &final_table_)) { - context_->GetDiagnostics()->Error(DiagMessage() - << "failed removing resources with no defaults"); - return 1; + if (!options_.no_resource_removal) { + if (!NoDefaultResourceRemover{}.Consume(context_, &final_table_)) { + context_->GetDiagnostics()->Error(DiagMessage() + << "failed removing resources with no defaults"); + return 1; + } } ReferenceLinker linker; @@ -2084,6 +2088,10 @@ int Link(const std::vector<StringPiece>& args, IDiagnostics* diagnostics) { "Disables automatic deduping of resources with\n" "identical values across compatible configurations.", &options.no_resource_deduping) + .OptionalSwitch("--no-resource-removal", + "Disables automatic removal of resources without defaults. Use this only\n" + "when building runtime resource overlay packages.", + &options.no_resource_removal) .OptionalSwitch("--enable-sparse-encoding", "Enables encoding sparse entries using a binary search tree.\n" "This decreases APK size at the cost of resource retrieval performance.", diff --git a/tools/aapt2/cmd/Optimize.cpp b/tools/aapt2/cmd/Optimize.cpp index 9c76119f9504..45297a7f8997 100644 --- a/tools/aapt2/cmd/Optimize.cpp +++ b/tools/aapt2/cmd/Optimize.cpp @@ -20,6 +20,7 @@ #include "android-base/file.h" #include "android-base/stringprintf.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/ResourceTypes.h" #include "androidfw/StringPiece.h" @@ -45,6 +46,7 @@ using ::aapt::configuration::Abi; using ::aapt::configuration::OutputArtifact; +using ::android::ConfigDescription; using ::android::ResTable_config; using ::android::StringPiece; using ::android::base::ReadFileToString; diff --git a/tools/aapt2/cmd/Util.cpp b/tools/aapt2/cmd/Util.cpp index 8b3a6701b409..25010c52235c 100644 --- a/tools/aapt2/cmd/Util.cpp +++ b/tools/aapt2/cmd/Util.cpp @@ -19,15 +19,17 @@ #include <vector> #include "android-base/logging.h" +#include "androidfw/ConfigDescription.h" +#include "androidfw/Locale.h" -#include "ConfigDescription.h" -#include "Locale.h" #include "ResourceUtils.h" #include "ValueVisitor.h" #include "split/TableSplitter.h" #include "util/Maybe.h" #include "util/Util.h" +using ::android::ConfigDescription; +using ::android::LocaleValue; using ::android::StringPiece; namespace aapt { diff --git a/tools/aapt2/compile/PseudolocaleGenerator.cpp b/tools/aapt2/compile/PseudolocaleGenerator.cpp index 36c24bc4a0fd..c5de9e058907 100644 --- a/tools/aapt2/compile/PseudolocaleGenerator.cpp +++ b/tools/aapt2/compile/PseudolocaleGenerator.cpp @@ -24,6 +24,7 @@ #include "compile/Pseudolocalizer.h" #include "util/Util.h" +using ::android::ConfigDescription; using ::android::StringPiece; using ::android::StringPiece16; diff --git a/tools/aapt2/compile/PseudolocaleGenerator_test.cpp b/tools/aapt2/compile/PseudolocaleGenerator_test.cpp index 711558aa51c1..31358020ab60 100644 --- a/tools/aapt2/compile/PseudolocaleGenerator_test.cpp +++ b/tools/aapt2/compile/PseudolocaleGenerator_test.cpp @@ -19,6 +19,8 @@ #include "test/Test.h" #include "util/Util.h" +using ::android::ConfigDescription; + namespace aapt { TEST(PseudolocaleGeneratorTest, PseudolocalizeStyledString) { diff --git a/tools/aapt2/configuration/ConfigurationParser.cpp b/tools/aapt2/configuration/ConfigurationParser.cpp index 902334b98d00..dd06b38f6c01 100644 --- a/tools/aapt2/configuration/ConfigurationParser.cpp +++ b/tools/aapt2/configuration/ConfigurationParser.cpp @@ -25,8 +25,8 @@ #include "android-base/file.h" #include "android-base/logging.h" +#include "androidfw/ConfigDescription.h" -#include "ConfigDescription.h" #include "Diagnostics.h" #include "ResourceUtils.h" #include "configuration/ConfigurationParser.internal.h" @@ -40,6 +40,8 @@ #include "xml/XmlDom.h" #include "xml/XmlUtil.h" +using ::android::ConfigDescription; + namespace aapt { namespace { diff --git a/tools/aapt2/configuration/ConfigurationParser.h b/tools/aapt2/configuration/ConfigurationParser.h index 7f1d4453f9b3..b9e3be9393c9 100644 --- a/tools/aapt2/configuration/ConfigurationParser.h +++ b/tools/aapt2/configuration/ConfigurationParser.h @@ -22,7 +22,8 @@ #include <unordered_map> #include <vector> -#include "ConfigDescription.h" +#include "androidfw/ConfigDescription.h" + #include "Diagnostics.h" #include "util/Maybe.h" @@ -109,8 +110,8 @@ struct OutputArtifact { std::string name; int version; std::vector<Abi> abis; - std::vector<ConfigDescription> screen_densities; - std::vector<ConfigDescription> locales; + std::vector<android::ConfigDescription> screen_densities; + std::vector<android::ConfigDescription> locales; Maybe<AndroidSdk> android_sdk; std::vector<DeviceFeature> features; std::vector<GlTexture> textures; diff --git a/tools/aapt2/configuration/ConfigurationParser.internal.h b/tools/aapt2/configuration/ConfigurationParser.internal.h index f071a69fc9e3..c541688bc018 100644 --- a/tools/aapt2/configuration/ConfigurationParser.internal.h +++ b/tools/aapt2/configuration/ConfigurationParser.internal.h @@ -17,6 +17,8 @@ #ifndef AAPT2_CONFIGURATIONPARSER_INTERNAL_H #define AAPT2_CONFIGURATIONPARSER_INTERNAL_H +#include "androidfw/ConfigDescription.h" + #include "configuration/ConfigurationParser.h" #include <algorithm> @@ -148,8 +150,8 @@ struct PostProcessingConfiguration { Maybe<std::string> artifact_format; Group<Abi> abi_groups; - Group<ConfigDescription> screen_density_groups; - Group<ConfigDescription> locale_groups; + Group<android::ConfigDescription> screen_density_groups; + Group<android::ConfigDescription> locale_groups; Group<DeviceFeature> device_feature_groups; Group<GlTexture> gl_texture_groups; Entry<AndroidSdk> android_sdks; diff --git a/tools/aapt2/configuration/ConfigurationParser_test.cpp b/tools/aapt2/configuration/ConfigurationParser_test.cpp index febbb2ed11a0..960880a8daa6 100644 --- a/tools/aapt2/configuration/ConfigurationParser_test.cpp +++ b/tools/aapt2/configuration/ConfigurationParser_test.cpp @@ -26,6 +26,8 @@ #include "test/Test.h" #include "xml/XmlDom.h" +using ::android::ConfigDescription; + namespace aapt { namespace configuration { diff --git a/tools/aapt2/filter/ConfigFilter.cpp b/tools/aapt2/filter/ConfigFilter.cpp index 5fbe77e98144..9d10d595882a 100644 --- a/tools/aapt2/filter/ConfigFilter.cpp +++ b/tools/aapt2/filter/ConfigFilter.cpp @@ -16,9 +16,10 @@ #include "filter/ConfigFilter.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/ResourceTypes.h" -#include "ConfigDescription.h" +using ::android::ConfigDescription; namespace aapt { diff --git a/tools/aapt2/filter/ConfigFilter.h b/tools/aapt2/filter/ConfigFilter.h index ebb81519dceb..c4b7e4356df9 100644 --- a/tools/aapt2/filter/ConfigFilter.h +++ b/tools/aapt2/filter/ConfigFilter.h @@ -20,7 +20,7 @@ #include <set> #include <utility> -#include "ConfigDescription.h" +#include "androidfw/ConfigDescription.h" namespace aapt { @@ -34,7 +34,7 @@ class IConfigFilter { /** * Returns true if the filter matches the configuration, false otherwise. */ - virtual bool Match(const ConfigDescription& config) const = 0; + virtual bool Match(const android::ConfigDescription& config) const = 0; }; /** @@ -46,12 +46,12 @@ class IConfigFilter { */ class AxisConfigFilter : public IConfigFilter { public: - void AddConfig(ConfigDescription config); + void AddConfig(android::ConfigDescription config); - bool Match(const ConfigDescription& config) const override; + bool Match(const android::ConfigDescription& config) const override; private: - std::set<std::pair<ConfigDescription, uint32_t>> configs_; + std::set<std::pair<android::ConfigDescription, uint32_t>> configs_; uint32_t config_mask_ = 0; }; diff --git a/tools/aapt2/format/binary/BinaryResourceParser.h b/tools/aapt2/format/binary/BinaryResourceParser.h index a1f9f83edfb6..2bdc051f4e29 100644 --- a/tools/aapt2/format/binary/BinaryResourceParser.h +++ b/tools/aapt2/format/binary/BinaryResourceParser.h @@ -20,6 +20,7 @@ #include <string> #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/ResourceTypes.h" #include "ResourceTable.h" @@ -54,22 +55,28 @@ class BinaryResourceParser { bool ParseType(const ResourceTablePackage* package, const android::ResChunk_header* chunk); bool ParseLibrary(const android::ResChunk_header* chunk); - std::unique_ptr<Item> ParseValue(const ResourceNameRef& name, const ConfigDescription& config, + std::unique_ptr<Item> ParseValue(const ResourceNameRef& name, + const android::ConfigDescription& config, const android::Res_value& value); - std::unique_ptr<Value> ParseMapEntry(const ResourceNameRef& name, const ConfigDescription& config, + std::unique_ptr<Value> ParseMapEntry(const ResourceNameRef& name, + const android::ConfigDescription& config, const android::ResTable_map_entry* map); - std::unique_ptr<Style> ParseStyle(const ResourceNameRef& name, const ConfigDescription& config, + std::unique_ptr<Style> ParseStyle(const ResourceNameRef& name, + const android::ConfigDescription& config, const android::ResTable_map_entry* map); - std::unique_ptr<Attribute> ParseAttr(const ResourceNameRef& name, const ConfigDescription& config, + std::unique_ptr<Attribute> ParseAttr(const ResourceNameRef& name, + const android::ConfigDescription& config, const android::ResTable_map_entry* map); - std::unique_ptr<Array> ParseArray(const ResourceNameRef& name, const ConfigDescription& config, + std::unique_ptr<Array> ParseArray(const ResourceNameRef& name, + const android::ConfigDescription& config, const android::ResTable_map_entry* map); - std::unique_ptr<Plural> ParsePlural(const ResourceNameRef& name, const ConfigDescription& config, + std::unique_ptr<Plural> ParsePlural(const ResourceNameRef& name, + const android::ConfigDescription& config, const android::ResTable_map_entry* map); /** diff --git a/tools/aapt2/format/proto/ProtoDeserialize.cpp b/tools/aapt2/format/proto/ProtoDeserialize.cpp index 3b101b7152be..d1b2fdb84afc 100644 --- a/tools/aapt2/format/proto/ProtoDeserialize.cpp +++ b/tools/aapt2/format/proto/ProtoDeserialize.cpp @@ -19,13 +19,15 @@ #include "android-base/logging.h" #include "android-base/macros.h" #include "androidfw/ResourceTypes.h" +#include "androidfw/Locale.h" -#include "Locale.h" #include "ResourceTable.h" #include "ResourceUtils.h" #include "ResourceValues.h" #include "ValueVisitor.h" +using ::android::ConfigDescription; +using ::android::LocaleValue; using ::android::ResStringPool; namespace aapt { diff --git a/tools/aapt2/format/proto/ProtoDeserialize.h b/tools/aapt2/format/proto/ProtoDeserialize.h index 0c581a17fa2e..723a1c095a50 100644 --- a/tools/aapt2/format/proto/ProtoDeserialize.h +++ b/tools/aapt2/format/proto/ProtoDeserialize.h @@ -18,9 +18,9 @@ #define AAPT_FORMAT_PROTO_PROTODESERIALIZE_H #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/ResourceTypes.h" -#include "ConfigDescription.h" #include "Configuration.pb.h" #include "ResourceTable.h" #include "ResourceValues.h" @@ -34,14 +34,15 @@ namespace aapt { std::unique_ptr<Value> DeserializeValueFromPb(const pb::Value& pb_value, const android::ResStringPool& src_pool, - const ConfigDescription& config, + const android::ConfigDescription& config, StringPool* value_pool, io::IFileCollection* files, std::string* out_error); std::unique_ptr<Item> DeserializeItemFromPb(const pb::Item& pb_item, const android::ResStringPool& src_pool, - const ConfigDescription& config, StringPool* value_pool, - io::IFileCollection* files, std::string* out_error); + const android::ConfigDescription& config, + StringPool* value_pool, io::IFileCollection* files, + std::string* out_error); std::unique_ptr<xml::XmlResource> DeserializeXmlResourceFromPb(const pb::XmlNode& pb_node, std::string* out_error); @@ -49,8 +50,8 @@ std::unique_ptr<xml::XmlResource> DeserializeXmlResourceFromPb(const pb::XmlNode bool DeserializeXmlFromPb(const pb::XmlNode& pb_node, xml::Element* out_el, StringPool* value_pool, std::string* out_error); -bool DeserializeConfigFromPb(const pb::Configuration& pb_config, ConfigDescription* out_config, - std::string* out_error); +bool DeserializeConfigFromPb(const pb::Configuration& pb_config, + android::ConfigDescription* out_config, std::string* out_error); // Optional io::IFileCollection used to lookup references to files in the ResourceTable. bool DeserializeTableFromPb(const pb::ResourceTable& pb_table, io::IFileCollection* files, diff --git a/tools/aapt2/format/proto/ProtoSerialize.cpp b/tools/aapt2/format/proto/ProtoSerialize.cpp index 411cc29630fe..7e35ea7bb7a3 100644 --- a/tools/aapt2/format/proto/ProtoSerialize.cpp +++ b/tools/aapt2/format/proto/ProtoSerialize.cpp @@ -19,6 +19,8 @@ #include "ValueVisitor.h" #include "util/BigBuffer.h" +using android::ConfigDescription; + namespace aapt { void SerializeStringPoolToPb(const StringPool& pool, pb::StringPool* out_pb_pool, IDiagnostics* diag) { diff --git a/tools/aapt2/format/proto/ProtoSerialize.h b/tools/aapt2/format/proto/ProtoSerialize.h index 951494ca8a0d..c40e5dd51da6 100644 --- a/tools/aapt2/format/proto/ProtoSerialize.h +++ b/tools/aapt2/format/proto/ProtoSerialize.h @@ -18,8 +18,8 @@ #define AAPT_FORMAT_PROTO_PROTOSERIALIZE_H #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" -#include "ConfigDescription.h" #include "Configuration.pb.h" #include "ResourceTable.h" #include "ResourceValues.h" @@ -49,7 +49,7 @@ void SerializeXmlResourceToPb(const xml::XmlResource& resource, pb::XmlNode* out void SerializeStringPoolToPb(const StringPool& pool, pb::StringPool* out_pb_pool, IDiagnostics* diag); // Serializes a ConfigDescription into its protobuf representation. -void SerializeConfig(const ConfigDescription& config, pb::Configuration* out_pb_config); +void SerializeConfig(const android::ConfigDescription& config, pb::Configuration* out_pb_config); // Serializes a ResourceTable into its protobuf representation. void SerializeTableToPb(const ResourceTable& table, pb::ResourceTable* out_table, IDiagnostics* diag); diff --git a/tools/aapt2/format/proto/ProtoSerialize_test.cpp b/tools/aapt2/format/proto/ProtoSerialize_test.cpp index 21fdbd8a4c1e..a0d92f7b9308 100644 --- a/tools/aapt2/format/proto/ProtoSerialize_test.cpp +++ b/tools/aapt2/format/proto/ProtoSerialize_test.cpp @@ -20,6 +20,7 @@ #include "format/proto/ProtoDeserialize.h" #include "test/Test.h" +using ::android::ConfigDescription; using ::android::StringPiece; using ::testing::Eq; using ::testing::IsEmpty; diff --git a/tools/aapt2/java/ProguardRules_test.cpp b/tools/aapt2/java/ProguardRules_test.cpp index 37d1a5fbaeb8..f774e3a1245a 100644 --- a/tools/aapt2/java/ProguardRules_test.cpp +++ b/tools/aapt2/java/ProguardRules_test.cpp @@ -21,6 +21,7 @@ #include "test/Test.h" using ::aapt::io::StringOutputStream; +using ::android::ConfigDescription; using ::testing::HasSubstr; using ::testing::Not; diff --git a/tools/aapt2/link/AutoVersioner.cpp b/tools/aapt2/link/AutoVersioner.cpp index f80c6e9b34d3..960c7d46cc98 100644 --- a/tools/aapt2/link/AutoVersioner.cpp +++ b/tools/aapt2/link/AutoVersioner.cpp @@ -20,14 +20,16 @@ #include "android-base/logging.h" -#include "ConfigDescription.h" #include "ResourceTable.h" #include "SdkConstants.h" #include "ValueVisitor.h" +using android::ConfigDescription; + namespace aapt { -bool ShouldGenerateVersionedResource(const ResourceEntry* entry, const ConfigDescription& config, +bool ShouldGenerateVersionedResource(const ResourceEntry* entry, + const ConfigDescription& config, const ApiVersion sdk_version_to_generate) { // We assume the caller is trying to generate a version greater than the current configuration. CHECK(sdk_version_to_generate > config.sdkVersion); diff --git a/tools/aapt2/link/AutoVersioner_test.cpp b/tools/aapt2/link/AutoVersioner_test.cpp index 49639f8ad549..1117472f104b 100644 --- a/tools/aapt2/link/AutoVersioner_test.cpp +++ b/tools/aapt2/link/AutoVersioner_test.cpp @@ -16,9 +16,11 @@ #include "link/Linkers.h" -#include "ConfigDescription.h" +#include "androidfw/ConfigDescription.h" + #include "test/Test.h" +using ::android::ConfigDescription; using ::testing::NotNull; namespace aapt { diff --git a/tools/aapt2/link/Linkers.h b/tools/aapt2/link/Linkers.h index 3c9c4767b3d1..c9b8d3993959 100644 --- a/tools/aapt2/link/Linkers.h +++ b/tools/aapt2/link/Linkers.h @@ -21,6 +21,7 @@ #include <unordered_set> #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" #include "Resource.h" @@ -32,7 +33,6 @@ namespace aapt { class ResourceTable; class ResourceEntry; -struct ConfigDescription; // Defines the context in which a resource value is defined. Most resources are defined with the // implicit package name of their compilation context. Understanding the package name of a resource @@ -43,12 +43,14 @@ struct CallSite { // Determines whether a versioned resource should be created. If a versioned resource already // exists, it takes precedence. -bool ShouldGenerateVersionedResource(const ResourceEntry* entry, const ConfigDescription& config, +bool ShouldGenerateVersionedResource(const ResourceEntry* entry, + const android::ConfigDescription& config, const ApiVersion sdk_version_to_generate); // Finds the next largest ApiVersion of the config which is identical to the given config except // for sdkVersion. -ApiVersion FindNextApiVersionForConfig(const ResourceEntry* entry, const ConfigDescription& config); +ApiVersion FindNextApiVersionForConfig(const ResourceEntry* entry, + const android::ConfigDescription& config); class AutoVersioner : public IResourceTableConsumer { public: diff --git a/tools/aapt2/link/ManifestFixer.cpp b/tools/aapt2/link/ManifestFixer.cpp index ee4e70288994..7180a9918abe 100644 --- a/tools/aapt2/link/ManifestFixer.cpp +++ b/tools/aapt2/link/ManifestFixer.cpp @@ -252,6 +252,7 @@ bool ManifestFixer::BuildRules(xml::XmlActionExecutor* executor, xml::XmlNodeAction component_action; component_action.Action(RequiredNameIsJavaClassName); component_action["intent-filter"] = intent_filter_action; + component_action["preferred"] = intent_filter_action; component_action["meta-data"] = meta_data_action; // Manifest actions. @@ -346,6 +347,7 @@ bool ManifestFixer::BuildRules(xml::XmlActionExecutor* executor, manifest_action["uses-permission"]; manifest_action["uses-permission-sdk-23"]; manifest_action["permission"]; + manifest_action["permission"]["meta-data"] = meta_data_action; manifest_action["permission-tree"]; manifest_action["permission-group"]; manifest_action["uses-configuration"]; @@ -355,6 +357,8 @@ bool ManifestFixer::BuildRules(xml::XmlActionExecutor* executor, manifest_action["compatible-screens"]; manifest_action["compatible-screens"]["screen"]; manifest_action["supports-gl-texture"]; + manifest_action["restrict-update"]; + manifest_action["package-verifier"]; manifest_action["meta-data"] = meta_data_action; manifest_action["uses-split"].Action(RequiredNameIsJavaPackage); @@ -376,6 +380,7 @@ bool ManifestFixer::BuildRules(xml::XmlActionExecutor* executor, uses_static_library_action.Action(RequiredNameIsJavaPackage); uses_static_library_action.Action(RequiredAndroidAttribute("version")); uses_static_library_action.Action(RequiredAndroidAttribute("certDigest")); + uses_static_library_action["additional-certificate"]; if (options_.debug_mode) { application_action.Action([&](xml::Element* el) -> bool { @@ -399,6 +404,8 @@ bool ManifestFixer::BuildRules(xml::XmlActionExecutor* executor, application_action["provider"]["grant-uri-permission"]; application_action["provider"]["path-permission"]; + manifest_action["package"] = manifest_action; + return true; } diff --git a/tools/aapt2/link/NoDefaultResourceRemover.cpp b/tools/aapt2/link/NoDefaultResourceRemover.cpp index cfb4b26aba02..13054bf14c78 100644 --- a/tools/aapt2/link/NoDefaultResourceRemover.cpp +++ b/tools/aapt2/link/NoDefaultResourceRemover.cpp @@ -14,12 +14,16 @@ * limitations under the License. */ +#include "androidfw/Locale.h" + #include "link/NoDefaultResourceRemover.h" #include <algorithm> #include "ResourceTable.h" +using android::ConfigDescription; + namespace aapt { static bool IsDefaultConfigRequired(const ConfigDescription& config) { diff --git a/tools/aapt2/link/ProductFilter_test.cpp b/tools/aapt2/link/ProductFilter_test.cpp index 86dd56ad8f5b..dd4767463711 100644 --- a/tools/aapt2/link/ProductFilter_test.cpp +++ b/tools/aapt2/link/ProductFilter_test.cpp @@ -18,6 +18,8 @@ #include "test/Test.h" +using ::android::ConfigDescription; + namespace aapt { TEST(ProductFilterTest, SelectTwoProducts) { diff --git a/tools/aapt2/optimize/MultiApkGenerator.cpp b/tools/aapt2/optimize/MultiApkGenerator.cpp index 588b3316e6fa..aa9f9ab4798f 100644 --- a/tools/aapt2/optimize/MultiApkGenerator.cpp +++ b/tools/aapt2/optimize/MultiApkGenerator.cpp @@ -20,6 +20,7 @@ #include <regex> #include <string> +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" #include "LoadedApk.h" @@ -43,6 +44,7 @@ using ::aapt::configuration::AndroidSdk; using ::aapt::configuration::OutputArtifact; using ::aapt::xml::kSchemaAndroid; using ::aapt::xml::XmlResource; +using ::android::ConfigDescription; using ::android::StringPiece; /** diff --git a/tools/aapt2/optimize/MultiApkGenerator.h b/tools/aapt2/optimize/MultiApkGenerator.h index c8588791662a..4a5a6c3d5915 100644 --- a/tools/aapt2/optimize/MultiApkGenerator.h +++ b/tools/aapt2/optimize/MultiApkGenerator.h @@ -22,6 +22,8 @@ #include <unordered_set> #include <vector> +#include "androidfw/ConfigDescription.h" + #include "Diagnostics.h" #include "LoadedApk.h" #include "configuration/ConfigurationParser.h" @@ -66,7 +68,7 @@ class MultiApkGenerator { /** * Adds the <screen> elements to the parent node for the provided density configuration. */ - void AddScreens(const ConfigDescription& config, xml::Element* parent); + void AddScreens(const android::ConfigDescription& config, xml::Element* parent); LoadedApk* apk_; IAaptContext* context_; diff --git a/tools/aapt2/optimize/MultiApkGenerator_test.cpp b/tools/aapt2/optimize/MultiApkGenerator_test.cpp index 80eb737fa682..7d87eb8831e8 100644 --- a/tools/aapt2/optimize/MultiApkGenerator_test.cpp +++ b/tools/aapt2/optimize/MultiApkGenerator_test.cpp @@ -31,6 +31,8 @@ #include "test/Context.h" #include "test/Test.h" +using ::android::ConfigDescription; + namespace aapt { namespace { diff --git a/tools/aapt2/optimize/ResourceDeduper.cpp b/tools/aapt2/optimize/ResourceDeduper.cpp index 9d16268a276e..ee2dfbce7c06 100644 --- a/tools/aapt2/optimize/ResourceDeduper.cpp +++ b/tools/aapt2/optimize/ResourceDeduper.cpp @@ -21,6 +21,8 @@ #include "DominatorTree.h" #include "ResourceTable.h" +using android::ConfigDescription; + namespace aapt { namespace { diff --git a/tools/aapt2/optimize/ResourceDeduper_test.cpp b/tools/aapt2/optimize/ResourceDeduper_test.cpp index d9f384c095ca..2e098aec4f8d 100644 --- a/tools/aapt2/optimize/ResourceDeduper_test.cpp +++ b/tools/aapt2/optimize/ResourceDeduper_test.cpp @@ -20,6 +20,7 @@ #include "test/Test.h" using ::aapt::test::HasValue; +using ::android::ConfigDescription; using ::testing::Not; namespace aapt { diff --git a/tools/aapt2/optimize/VersionCollapser.cpp b/tools/aapt2/optimize/VersionCollapser.cpp index cc1fc1e6910b..f9856047ac40 100644 --- a/tools/aapt2/optimize/VersionCollapser.cpp +++ b/tools/aapt2/optimize/VersionCollapser.cpp @@ -21,6 +21,8 @@ #include "ResourceTable.h" +using android::ConfigDescription; + namespace aapt { template <typename Iterator, typename Pred> diff --git a/tools/aapt2/process/SymbolTable.cpp b/tools/aapt2/process/SymbolTable.cpp index 70efbf5d17b2..a844a43698e5 100644 --- a/tools/aapt2/process/SymbolTable.cpp +++ b/tools/aapt2/process/SymbolTable.cpp @@ -21,15 +21,16 @@ #include "android-base/logging.h" #include "android-base/stringprintf.h" #include "androidfw/AssetManager.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/ResourceTypes.h" -#include "ConfigDescription.h" #include "NameMangler.h" #include "Resource.h" #include "ResourceUtils.h" #include "ValueVisitor.h" #include "util/Util.h" +using ::android::ConfigDescription; using ::android::StringPiece; using ::android::StringPiece16; diff --git a/tools/aapt2/split/TableSplitter.cpp b/tools/aapt2/split/TableSplitter.cpp index e99174302d26..1dd5502202b2 100644 --- a/tools/aapt2/split/TableSplitter.cpp +++ b/tools/aapt2/split/TableSplitter.cpp @@ -24,11 +24,13 @@ #include <vector> #include "android-base/logging.h" +#include "androidfw/ConfigDescription.h" -#include "ConfigDescription.h" #include "ResourceTable.h" #include "util/Util.h" +using ::android::ConfigDescription; + namespace aapt { using ConfigClaimedMap = std::unordered_map<ResourceConfigValue*, bool>; diff --git a/tools/aapt2/split/TableSplitter.h b/tools/aapt2/split/TableSplitter.h index 6aec2576261e..91afaa37e2d4 100644 --- a/tools/aapt2/split/TableSplitter.h +++ b/tools/aapt2/split/TableSplitter.h @@ -20,8 +20,8 @@ #include <set> #include <vector> #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" -#include "ConfigDescription.h" #include "ResourceTable.h" #include "filter/ConfigFilter.h" #include "process/IResourceTableConsumer.h" @@ -29,7 +29,7 @@ namespace aapt { struct SplitConstraints { - std::set<ConfigDescription> configs; + std::set<android::ConfigDescription> configs; }; struct TableSplitterOptions { diff --git a/tools/aapt2/split/TableSplitter_test.cpp b/tools/aapt2/split/TableSplitter_test.cpp index d52f4b446b8f..cdf07386c70f 100644 --- a/tools/aapt2/split/TableSplitter_test.cpp +++ b/tools/aapt2/split/TableSplitter_test.cpp @@ -18,6 +18,8 @@ #include "test/Test.h" +using ::android::ConfigDescription; + namespace aapt { TEST(TableSplitterTest, NoSplitPreferredDensity) { diff --git a/tools/aapt2/test/Builders.cpp b/tools/aapt2/test/Builders.cpp index c4eab1269e4e..f33ae3155192 100644 --- a/tools/aapt2/test/Builders.cpp +++ b/tools/aapt2/test/Builders.cpp @@ -28,6 +28,7 @@ using ::aapt::configuration::AndroidSdk; using ::aapt::configuration::ConfiguredArtifact; using ::aapt::configuration::GetOrCreateGroup; using ::aapt::io::StringInputStream; +using ::android::ConfigDescription; using ::android::StringPiece; namespace aapt { diff --git a/tools/aapt2/test/Builders.h b/tools/aapt2/test/Builders.h index fd5262af6e48..a88b11e1334e 100644 --- a/tools/aapt2/test/Builders.h +++ b/tools/aapt2/test/Builders.h @@ -20,6 +20,7 @@ #include <memory> #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "Resource.h" #include "ResourceTable.h" @@ -40,7 +41,8 @@ class ResourceTableBuilder { ResourceTableBuilder& SetPackageId(const android::StringPiece& package_name, uint8_t id); ResourceTableBuilder& AddSimple(const android::StringPiece& name, const ResourceId& id = {}); - ResourceTableBuilder& AddSimple(const android::StringPiece& name, const ConfigDescription& config, + ResourceTableBuilder& AddSimple(const android::StringPiece& name, + const android::ConfigDescription& config, const ResourceId& id = {}); ResourceTableBuilder& AddReference(const android::StringPiece& name, const android::StringPiece& ref); @@ -51,7 +53,8 @@ class ResourceTableBuilder { ResourceTableBuilder& AddString(const android::StringPiece& name, const ResourceId& id, const android::StringPiece& str); ResourceTableBuilder& AddString(const android::StringPiece& name, const ResourceId& id, - const ConfigDescription& config, const android::StringPiece& str); + const android::ConfigDescription& config, + const android::StringPiece& str); ResourceTableBuilder& AddFileReference(const android::StringPiece& name, const android::StringPiece& path, io::IFile* file = nullptr); @@ -60,12 +63,13 @@ class ResourceTableBuilder { io::IFile* file = nullptr); ResourceTableBuilder& AddFileReference(const android::StringPiece& name, const android::StringPiece& path, - const ConfigDescription& config, + const android::ConfigDescription& config, io::IFile* file = nullptr); ResourceTableBuilder& AddValue(const android::StringPiece& name, std::unique_ptr<Value> value); ResourceTableBuilder& AddValue(const android::StringPiece& name, const ResourceId& id, std::unique_ptr<Value> value); - ResourceTableBuilder& AddValue(const android::StringPiece& name, const ConfigDescription& config, + ResourceTableBuilder& AddValue(const android::StringPiece& name, + const android::ConfigDescription& config, const ResourceId& id, std::unique_ptr<Value> value); ResourceTableBuilder& SetSymbolState(const android::StringPiece& name, const ResourceId& id, Visibility::Level level, bool allow_new = false); @@ -163,8 +167,8 @@ class ArtifactBuilder { ArtifactBuilder& SetName(const std::string& name); ArtifactBuilder& SetVersion(int version); ArtifactBuilder& AddAbi(configuration::Abi abi); - ArtifactBuilder& AddDensity(const ConfigDescription& density); - ArtifactBuilder& AddLocale(const ConfigDescription& locale); + ArtifactBuilder& AddDensity(const android::ConfigDescription& density); + ArtifactBuilder& AddLocale(const android::ConfigDescription& locale); ArtifactBuilder& SetAndroidSdk(int min_sdk); configuration::OutputArtifact Build(); diff --git a/tools/aapt2/test/Common.cpp b/tools/aapt2/test/Common.cpp index 0fabbc4070e7..b54c155ddc2f 100644 --- a/tools/aapt2/test/Common.cpp +++ b/tools/aapt2/test/Common.cpp @@ -16,6 +16,8 @@ #include "test/Common.h" +using android::ConfigDescription; + namespace aapt { namespace test { diff --git a/tools/aapt2/test/Common.h b/tools/aapt2/test/Common.h index aca161a5189d..50b41f1cb1e8 100644 --- a/tools/aapt2/test/Common.h +++ b/tools/aapt2/test/Common.h @@ -21,11 +21,11 @@ #include "android-base/logging.h" #include "android-base/macros.h" +#include "androidfw/ConfigDescription.h" #include "androidfw/StringPiece.h" #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "ConfigDescription.h" #include "Debug.h" #include "ResourceTable.h" #include "ResourceUtils.h" @@ -45,15 +45,15 @@ inline ResourceName ParseNameOrDie(const android::StringPiece& str) { return ref.ToResourceName(); } -inline ConfigDescription ParseConfigOrDie(const android::StringPiece& str) { - ConfigDescription config; - CHECK(ConfigDescription::Parse(str, &config)) << "invalid configuration: " << str; +inline android::ConfigDescription ParseConfigOrDie(const android::StringPiece& str) { + android::ConfigDescription config; + CHECK(android::ConfigDescription::Parse(str, &config)) << "invalid configuration: " << str; return config; } template <typename T = Value> T* GetValueForConfigAndProduct(ResourceTable* table, const android::StringPiece& res_name, - const ConfigDescription& config, + const android::ConfigDescription& config, const android::StringPiece& product) { Maybe<ResourceTable::SearchResult> result = table->FindResource(ParseNameOrDie(res_name)); if (result) { @@ -68,12 +68,12 @@ T* GetValueForConfigAndProduct(ResourceTable* table, const android::StringPiece& template <> Value* GetValueForConfigAndProduct<Value>(ResourceTable* table, const android::StringPiece& res_name, - const ConfigDescription& config, + const android::ConfigDescription& config, const android::StringPiece& product); template <typename T = Value> T* GetValueForConfig(ResourceTable* table, const android::StringPiece& res_name, - const ConfigDescription& config) { + const android::ConfigDescription& config) { return GetValueForConfigAndProduct<T>(table, res_name, config, {}); } diff --git a/tools/hiddenapi/sort_api.sh b/tools/hiddenapi/sort_api.sh index 76a2f2d6eba1..7cdcf18bb3fc 100755 --- a/tools/hiddenapi/sort_api.sh +++ b/tools/hiddenapi/sort_api.sh @@ -21,4 +21,6 @@ A=( $(uniq <<< "${A[*]}") ) A=( ${C[*]} ${A[*]} ) unset IFS # Dump array back into the file -printf '%s\n' "${A[@]}" > "$dest_list" +if [ ${#A[@]} -neq 0 ]; then + printf '%s\n' "${A[@]}" > "$dest_list" +fi diff --git a/wifi/tests/src/android/net/wifi/hotspot2/pps/HomeSpTest.java b/wifi/tests/src/android/net/wifi/hotspot2/pps/HomeSpTest.java index 5c9df6a0186c..c7993e308d17 100644 --- a/wifi/tests/src/android/net/wifi/hotspot2/pps/HomeSpTest.java +++ b/wifi/tests/src/android/net/wifi/hotspot2/pps/HomeSpTest.java @@ -189,8 +189,7 @@ public class HomeSpTest { Map<String, Long> homeNetworkIds = new HashMap<>(); byte[] rawSsidBytes = new byte[33]; Arrays.fill(rawSsidBytes, (byte) 'a'); - homeNetworkIds.put( - StringFactory.newStringFromBytes(rawSsidBytes, StandardCharsets.UTF_8), 0x1234L); + homeNetworkIds.put(new String(rawSsidBytes, StandardCharsets.UTF_8), 0x1234L); homeSp.setHomeNetworkIds(homeNetworkIds); assertFalse(homeSp.validate()); } |