diff options
51 files changed, 629 insertions, 279 deletions
diff --git a/boot/hiddenapi/hiddenapi-max-target-o.txt b/boot/hiddenapi/hiddenapi-max-target-o.txt index e346ebf827ae..eddb1621a4fa 100644 --- a/boot/hiddenapi/hiddenapi-max-target-o.txt +++ b/boot/hiddenapi/hiddenapi-max-target-o.txt @@ -35278,14 +35278,6 @@ Landroid/net/DhcpResults;->setLeaseDuration(I)V Landroid/net/DhcpResults;->setServerAddress(Ljava/lang/String;)Z Landroid/net/DhcpResults;->setVendorInfo(Ljava/lang/String;)V Landroid/net/DhcpResults;->TAG:Ljava/lang/String; -Landroid/net/EthernetManager;-><init>(Landroid/content/Context;Landroid/net/IEthernetManager;)V -Landroid/net/EthernetManager;->mContext:Landroid/content/Context; -Landroid/net/EthernetManager;->mHandler:Landroid/os/Handler; -Landroid/net/EthernetManager;->mListeners:Ljava/util/ArrayList; -Landroid/net/EthernetManager;->mService:Landroid/net/IEthernetManager; -Landroid/net/EthernetManager;->mServiceListener:Landroid/net/IEthernetServiceListener$Stub; -Landroid/net/EthernetManager;->MSG_AVAILABILITY_CHANGED:I -Landroid/net/EthernetManager;->TAG:Ljava/lang/String; Landroid/net/EventLogTags;-><init>()V Landroid/net/EventLogTags;->NTP_FAILURE:I Landroid/net/EventLogTags;->NTP_SUCCESS:I @@ -35319,39 +35311,6 @@ Landroid/net/http/X509TrustManagerExtensions;->mCheckServerTrusted:Ljava/lang/re Landroid/net/http/X509TrustManagerExtensions;->mDelegate:Lcom/android/org/conscrypt/TrustManagerImpl; Landroid/net/http/X509TrustManagerExtensions;->mIsSameTrustConfiguration:Ljava/lang/reflect/Method; Landroid/net/http/X509TrustManagerExtensions;->mTrustManager:Ljavax/net/ssl/X509TrustManager; -Landroid/net/IEthernetManager$Stub$Proxy;-><init>(Landroid/os/IBinder;)V -Landroid/net/IEthernetManager$Stub$Proxy;->addListener(Landroid/net/IEthernetServiceListener;)V -Landroid/net/IEthernetManager$Stub$Proxy;->getAvailableInterfaces()[Ljava/lang/String; -Landroid/net/IEthernetManager$Stub$Proxy;->getConfiguration(Ljava/lang/String;)Landroid/net/IpConfiguration; -Landroid/net/IEthernetManager$Stub$Proxy;->getInterfaceDescriptor()Ljava/lang/String; -Landroid/net/IEthernetManager$Stub$Proxy;->isAvailable(Ljava/lang/String;)Z -Landroid/net/IEthernetManager$Stub$Proxy;->mRemote:Landroid/os/IBinder; -Landroid/net/IEthernetManager$Stub$Proxy;->removeListener(Landroid/net/IEthernetServiceListener;)V -Landroid/net/IEthernetManager$Stub$Proxy;->setConfiguration(Ljava/lang/String;Landroid/net/IpConfiguration;)V -Landroid/net/IEthernetManager$Stub;-><init>()V -Landroid/net/IEthernetManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/net/IEthernetManager; -Landroid/net/IEthernetManager$Stub;->DESCRIPTOR:Ljava/lang/String; -Landroid/net/IEthernetManager$Stub;->TRANSACTION_addListener:I -Landroid/net/IEthernetManager$Stub;->TRANSACTION_getAvailableInterfaces:I -Landroid/net/IEthernetManager$Stub;->TRANSACTION_getConfiguration:I -Landroid/net/IEthernetManager$Stub;->TRANSACTION_isAvailable:I -Landroid/net/IEthernetManager$Stub;->TRANSACTION_removeListener:I -Landroid/net/IEthernetManager$Stub;->TRANSACTION_setConfiguration:I -Landroid/net/IEthernetManager;->addListener(Landroid/net/IEthernetServiceListener;)V -Landroid/net/IEthernetManager;->getAvailableInterfaces()[Ljava/lang/String; -Landroid/net/IEthernetManager;->getConfiguration(Ljava/lang/String;)Landroid/net/IpConfiguration; -Landroid/net/IEthernetManager;->isAvailable(Ljava/lang/String;)Z -Landroid/net/IEthernetManager;->removeListener(Landroid/net/IEthernetServiceListener;)V -Landroid/net/IEthernetManager;->setConfiguration(Ljava/lang/String;Landroid/net/IpConfiguration;)V -Landroid/net/IEthernetServiceListener$Stub$Proxy;-><init>(Landroid/os/IBinder;)V -Landroid/net/IEthernetServiceListener$Stub$Proxy;->getInterfaceDescriptor()Ljava/lang/String; -Landroid/net/IEthernetServiceListener$Stub$Proxy;->mRemote:Landroid/os/IBinder; -Landroid/net/IEthernetServiceListener$Stub$Proxy;->onAvailabilityChanged(Ljava/lang/String;Z)V -Landroid/net/IEthernetServiceListener$Stub;-><init>()V -Landroid/net/IEthernetServiceListener$Stub;->asInterface(Landroid/os/IBinder;)Landroid/net/IEthernetServiceListener; -Landroid/net/IEthernetServiceListener$Stub;->DESCRIPTOR:Ljava/lang/String; -Landroid/net/IEthernetServiceListener$Stub;->TRANSACTION_onAvailabilityChanged:I -Landroid/net/IEthernetServiceListener;->onAvailabilityChanged(Ljava/lang/String;Z)V Landroid/net/IIpConnectivityMetrics$Stub$Proxy;-><init>(Landroid/os/IBinder;)V Landroid/net/IIpConnectivityMetrics$Stub$Proxy;->addNetdEventCallback(ILandroid/net/INetdEventCallback;)Z Landroid/net/IIpConnectivityMetrics$Stub$Proxy;->getInterfaceDescriptor()Ljava/lang/String; diff --git a/core/api/current.txt b/core/api/current.txt index 8337cb61455e..da0c7ed8dc70 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -9755,12 +9755,16 @@ package android.content { method @Nullable public long[] getLongArrayExtra(String); method public long getLongExtra(String, long); method @Nullable public String getPackage(); - method @Nullable public android.os.Parcelable[] getParcelableArrayExtra(String); - method @Nullable public <T extends android.os.Parcelable> java.util.ArrayList<T> getParcelableArrayListExtra(String); - method @Nullable public <T extends android.os.Parcelable> T getParcelableExtra(String); + method @Deprecated @Nullable public android.os.Parcelable[] getParcelableArrayExtra(String); + method @Nullable public <T> T[] getParcelableArrayExtra(@Nullable String, @NonNull Class<T>); + method @Deprecated @Nullable public <T extends android.os.Parcelable> java.util.ArrayList<T> getParcelableArrayListExtra(String); + method @Nullable public <T> java.util.ArrayList<T> getParcelableArrayListExtra(@Nullable String, @NonNull Class<? extends T>); + method @Deprecated @Nullable public <T extends android.os.Parcelable> T getParcelableExtra(String); + method @Nullable public <T> T getParcelableExtra(@Nullable String, @NonNull Class<T>); method @Nullable public String getScheme(); method @Nullable public android.content.Intent getSelector(); - method @Nullable public java.io.Serializable getSerializableExtra(String); + method @Deprecated @Nullable public java.io.Serializable getSerializableExtra(String); + method @Nullable public <T extends java.io.Serializable> T getSerializableExtra(@Nullable String, @NonNull Class<T>); method @Nullable public short[] getShortArrayExtra(String); method public short getShortExtra(String, short); method @Nullable public android.graphics.Rect getSourceBounds(); @@ -25203,16 +25207,9 @@ package android.net { method public int getUid(); } - public final class EthernetNetworkSpecifier extends android.net.NetworkSpecifier implements android.os.Parcelable { - ctor public EthernetNetworkSpecifier(@NonNull String); - method public int describeContents(); - method @Nullable public String getInterfaceName(); - method public void writeToParcel(@NonNull android.os.Parcel, int); - field @NonNull public static final android.os.Parcelable.Creator<android.net.EthernetNetworkSpecifier> CREATOR; - } - public final class Ikev2VpnProfile extends android.net.PlatformVpnProfile { method @NonNull public java.util.List<java.lang.String> getAllowedAlgorithms(); + method @Nullable public android.net.ipsec.ike.IkeTunnelConnectionParams getIkeTunnelConnectionParams(); method public int getMaxMtu(); method @Nullable public String getPassword(); method @Nullable public byte[] getPresharedKey(); @@ -25507,11 +25504,13 @@ package android.net { public class VpnManager { method public void deleteProvisionedVpnProfile(); + method @Nullable public android.net.VpnProfileState getProvisionedVpnProfileState(); method @Nullable public android.content.Intent provisionVpnProfile(@NonNull android.net.PlatformVpnProfile); method @Deprecated public void startProvisionedVpnProfile(); method @NonNull public String startProvisionedVpnProfileSession(); method public void stopProvisionedVpnProfile(); field public static final String ACTION_VPN_MANAGER_EVENT = "android.net.action.VPN_MANAGER_EVENT"; + field public static final String CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED = "android.net.category.EVENT_ALWAYS_ON_STATE_CHANGED"; field public static final String CATEGORY_EVENT_DEACTIVATED_BY_USER = "android.net.category.EVENT_DEACTIVATED_BY_USER"; field public static final String CATEGORY_EVENT_IKE_ERROR = "android.net.category.EVENT_IKE_ERROR"; field public static final String CATEGORY_EVENT_NETWORK_ERROR = "android.net.category.EVENT_NETWORK_ERROR"; @@ -25528,6 +25527,22 @@ package android.net { field public static final String EXTRA_UNDERLYING_LINK_PROPERTIES = "android.net.extra.UNDERLYING_LINK_PROPERTIES"; field public static final String EXTRA_UNDERLYING_NETWORK = "android.net.extra.UNDERLYING_NETWORK"; field public static final String EXTRA_UNDERLYING_NETWORK_CAPABILITIES = "android.net.extra.UNDERLYING_NETWORK_CAPABILITIES"; + field public static final String EXTRA_VPN_PROFILE_STATE = "android.net.extra.VPN_PROFILE_STATE"; + } + + public final class VpnProfileState implements android.os.Parcelable { + ctor public VpnProfileState(int, @Nullable String, boolean, boolean); + method public int describeContents(); + method @Nullable public String getSessionId(); + method public int getState(); + method public boolean isAlwaysOn(); + method public boolean isLockdownEnabled(); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator<android.net.VpnProfileState> CREATOR; + field public static final int STATE_CONNECTED = 2; // 0x2 + field public static final int STATE_CONNECTING = 1; // 0x1 + field public static final int STATE_DISCONNECTED = 0; // 0x0 + field public static final int STATE_FAILED = 3; // 0x3 } public class VpnService extends android.app.Service { @@ -42040,6 +42055,7 @@ package android.telephony.data { method public int getNetworkTypeBitmask(); method public String getOperatorNumeric(); method public String getPassword(); + method public int getProfileId(); method public int getProtocol(); method @Deprecated public java.net.InetAddress getProxyAddress(); method public String getProxyAddressAsString(); @@ -42047,6 +42063,7 @@ package android.telephony.data { method public int getRoamingProtocol(); method public String getUser(); method public boolean isEnabled(); + method public boolean isPersistent(); method public void writeToParcel(@NonNull android.os.Parcel, int); field public static final int AUTH_TYPE_CHAP = 2; // 0x2 field public static final int AUTH_TYPE_NONE = 0; // 0x0 diff --git a/core/api/module-lib-current.txt b/core/api/module-lib-current.txt index a6278f87f485..9db3cdc1f03c 100644 --- a/core/api/module-lib-current.txt +++ b/core/api/module-lib-current.txt @@ -193,22 +193,6 @@ package android.media.session { package android.net { - public class EthernetManager { - method @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) public void addInterfaceStateListener(@NonNull java.util.concurrent.Executor, @NonNull android.net.EthernetManager.InterfaceStateListener); - method public void removeInterfaceStateListener(@NonNull android.net.EthernetManager.InterfaceStateListener); - method public void setIncludeTestInterfaces(boolean); - field public static final int ROLE_CLIENT = 1; // 0x1 - field public static final int ROLE_NONE = 0; // 0x0 - field public static final int ROLE_SERVER = 2; // 0x2 - field public static final int STATE_ABSENT = 0; // 0x0 - field public static final int STATE_LINK_DOWN = 1; // 0x1 - field public static final int STATE_LINK_UP = 2; // 0x2 - } - - public static interface EthernetManager.InterfaceStateListener { - method public void onInterfaceStateChanged(@NonNull String, int, int, @Nullable android.net.IpConfiguration); - } - public class LocalSocket implements java.io.Closeable { ctor public LocalSocket(@NonNull java.io.FileDescriptor); } @@ -219,7 +203,8 @@ package android.net { method @Nullable @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public android.telephony.SubscriptionPlan getSubscriptionPlan(@NonNull android.net.NetworkTemplate); method @RequiresPermission(android.Manifest.permission.OBSERVE_NETWORK_POLICY) public boolean isUidNetworkingBlocked(int, boolean); method @RequiresPermission(android.Manifest.permission.OBSERVE_NETWORK_POLICY) public boolean isUidRestrictedOnMeteredNetworks(int); - method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void notifyStatsProviderWarningOrLimitReached(); + method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void notifyStatsProviderLimitReached(); + method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public void notifyStatsProviderWarningReached(); method @RequiresPermission(android.Manifest.permission.OBSERVE_NETWORK_POLICY) public void registerNetworkPolicyCallback(@Nullable java.util.concurrent.Executor, @NonNull android.net.NetworkPolicyManager.NetworkPolicyCallback); method @RequiresPermission(android.Manifest.permission.OBSERVE_NETWORK_POLICY) public void unregisterNetworkPolicyCallback(@NonNull android.net.NetworkPolicyManager.NetworkPolicyCallback); } diff --git a/core/api/system-current.txt b/core/api/system-current.txt index bb9af143b4b4..6145886a47e4 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -7063,45 +7063,6 @@ package android.metrics { package android.net { - public class EthernetManager { - method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK, android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}) public void connectNetwork(@NonNull String, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.BiConsumer<android.net.Network,android.net.EthernetNetworkManagementException>); - method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK, android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}) public void disconnectNetwork(@NonNull String, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.BiConsumer<android.net.Network,android.net.EthernetNetworkManagementException>); - method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public android.net.EthernetManager.TetheredInterfaceRequest requestTetheredInterface(@NonNull java.util.concurrent.Executor, @NonNull android.net.EthernetManager.TetheredInterfaceCallback); - method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK, android.Manifest.permission.MANAGE_ETHERNET_NETWORKS}) public void updateConfiguration(@NonNull String, @NonNull android.net.EthernetNetworkUpdateRequest, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.BiConsumer<android.net.Network,android.net.EthernetNetworkManagementException>); - } - - public static interface EthernetManager.TetheredInterfaceCallback { - method public void onAvailable(@NonNull String); - method public void onUnavailable(); - } - - public static class EthernetManager.TetheredInterfaceRequest { - method public void release(); - } - - public final class EthernetNetworkManagementException extends java.lang.RuntimeException implements android.os.Parcelable { - ctor public EthernetNetworkManagementException(@NonNull String); - method public int describeContents(); - method public void writeToParcel(@NonNull android.os.Parcel, int); - field @NonNull public static final android.os.Parcelable.Creator<android.net.EthernetNetworkManagementException> CREATOR; - } - - public final class EthernetNetworkUpdateRequest implements android.os.Parcelable { - method public int describeContents(); - method @NonNull public android.net.IpConfiguration getIpConfiguration(); - method @Nullable public android.net.NetworkCapabilities getNetworkCapabilities(); - method public void writeToParcel(@NonNull android.os.Parcel, int); - field @NonNull public static final android.os.Parcelable.Creator<android.net.EthernetNetworkUpdateRequest> CREATOR; - } - - public static final class EthernetNetworkUpdateRequest.Builder { - ctor public EthernetNetworkUpdateRequest.Builder(); - ctor public EthernetNetworkUpdateRequest.Builder(@NonNull android.net.EthernetNetworkUpdateRequest); - method @NonNull public android.net.EthernetNetworkUpdateRequest build(); - method @NonNull public android.net.EthernetNetworkUpdateRequest.Builder setIpConfiguration(@NonNull android.net.IpConfiguration); - method @NonNull public android.net.EthernetNetworkUpdateRequest.Builder setNetworkCapabilities(@Nullable android.net.NetworkCapabilities); - } - public final class MatchAllNetworkSpecifier extends android.net.NetworkSpecifier implements android.os.Parcelable { ctor public MatchAllNetworkSpecifier(); method public int describeContents(); diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index 6a0a2892cb96..aee66a29f278 100644 --- a/core/java/android/app/SystemServiceRegistry.java +++ b/core/java/android/app/SystemServiceRegistry.java @@ -125,8 +125,6 @@ import android.media.tv.tunerresourcemanager.ITunerResourceManager; import android.media.tv.tunerresourcemanager.TunerResourceManager; import android.net.ConnectivityFrameworkInitializer; import android.net.ConnectivityFrameworkInitializerTiramisu; -import android.net.EthernetManager; -import android.net.IEthernetManager; import android.net.INetworkPolicyManager; import android.net.IPacProxyManager; import android.net.IVpnManager; @@ -764,15 +762,6 @@ public final class SystemServiceRegistry { return new LowpanManager(ctx.getOuterContext(), service); }}); - registerService(Context.ETHERNET_SERVICE, EthernetManager.class, - new CachedServiceFetcher<EthernetManager>() { - @Override - public EthernetManager createService(ContextImpl ctx) throws ServiceNotFoundException { - IBinder b = ServiceManager.getServiceOrThrow(Context.ETHERNET_SERVICE); - IEthernetManager service = IEthernetManager.Stub.asInterface(b); - return new EthernetManager(ctx.getOuterContext(), service); - }}); - registerService(Context.WIFI_NL80211_SERVICE, WifiNl80211Manager.class, new CachedServiceFetcher<WifiNl80211Manager>() { @Override diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 8a5e097c2a73..22c838c2f7bb 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -8581,8 +8581,12 @@ public class Intent implements Parcelable, Cloneable { * @return the value of an item previously added with putExtra(), * or null if no Parcelable value was found. * + * @deprecated Use the type-safer {@link #getParcelableExtra(String, Class)} starting from + * Android {@link Build.VERSION_CODES#TIRAMISU}. + * * @see #putExtra(String, Parcelable) */ + @Deprecated public @Nullable <T extends Parcelable> T getParcelableExtra(String name) { return mExtras == null ? null : mExtras.<T>getParcelable(name); } @@ -8591,12 +8595,31 @@ public class Intent implements Parcelable, Cloneable { * Retrieve extended data from the intent. * * @param name The name of the desired item. + * @param clazz The type of the object expected. + * + * @return the value of an item previously added with putExtra(), + * or null if no Parcelable value was found. + * + * @see #putExtra(String, Parcelable) + */ + public @Nullable <T> T getParcelableExtra(@Nullable String name, @NonNull Class<T> clazz) { + return mExtras == null ? null : mExtras.getParcelable(name, clazz); + } + + /** + * Retrieve extended data from the intent. + * + * @param name The name of the desired item. * * @return the value of an item previously added with putExtra(), * or null if no Parcelable[] value was found. * + * @deprecated Use the type-safer {@link #getParcelableArrayExtra(String, Class)} starting from + * Android {@link Build.VERSION_CODES#TIRAMISU}. + * * @see #putExtra(String, Parcelable[]) */ + @Deprecated public @Nullable Parcelable[] getParcelableArrayExtra(String name) { return mExtras == null ? null : mExtras.getParcelableArray(name); } @@ -8605,13 +8628,34 @@ public class Intent implements Parcelable, Cloneable { * Retrieve extended data from the intent. * * @param name The name of the desired item. + * @param clazz The type of the items inside the array. This is only verified when unparceling. + * + * @return the value of an item previously added with putExtra(), + * or null if no Parcelable[] value was found. + * + * @see #putExtra(String, Parcelable[]) + */ + @SuppressLint({"ArrayReturn", "NullableCollection"}) + public @Nullable <T> T[] getParcelableArrayExtra(@Nullable String name, + @NonNull Class<T> clazz) { + return mExtras == null ? null : mExtras.getParcelableArray(name, clazz); + } + + /** + * Retrieve extended data from the intent. + * + * @param name The name of the desired item. * * @return the value of an item previously added with * putParcelableArrayListExtra(), or null if no * ArrayList<Parcelable> value was found. * + * @deprecated Use the type-safer {@link #getParcelableArrayListExtra(String, Class)} starting + * from Android {@link Build.VERSION_CODES#TIRAMISU}. + * * @see #putParcelableArrayListExtra(String, ArrayList) */ + @Deprecated public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) { return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name); } @@ -8620,10 +8664,32 @@ public class Intent implements Parcelable, Cloneable { * Retrieve extended data from the intent. * * @param name The name of the desired item. + * @param clazz The type of the items inside the array list. This is only verified when + * unparceling. + * + * @return the value of an item previously added with + * putParcelableArrayListExtra(), or null if no + * ArrayList<Parcelable> value was found. + * + * @see #putParcelableArrayListExtra(String, ArrayList) + */ + @SuppressLint({"ConcreteCollection", "NullableCollection"}) + public @Nullable <T> ArrayList<T> getParcelableArrayListExtra(@Nullable String name, + @NonNull Class<? extends T> clazz) { + return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name, clazz); + } + + /** + * Retrieve extended data from the intent. + * + * @param name The name of the desired item. * * @return the value of an item previously added with putExtra(), * or null if no Serializable value was found. * + * @deprecated Use the type-safer {@link #getSerializableExtra(String, Class)} starting from + * Android {@link Build.VERSION_CODES#TIRAMISU}. + * * @see #putExtra(String, Serializable) */ public @Nullable Serializable getSerializableExtra(String name) { @@ -8634,6 +8700,22 @@ public class Intent implements Parcelable, Cloneable { * Retrieve extended data from the intent. * * @param name The name of the desired item. + * @param clazz The type of the object expected. + * + * @return the value of an item previously added with putExtra(), + * or null if no Serializable value was found. + * + * @see #putExtra(String, Serializable) + */ + public @Nullable <T extends Serializable> T getSerializableExtra(@Nullable String name, + @NonNull Class<T> clazz) { + return mExtras == null ? null : mExtras.getSerializable(name, clazz); + } + + /** + * Retrieve extended data from the intent. + * + * @param name The name of the desired item. * * @return the value of an item previously added with * putIntegerArrayListExtra(), or null if no diff --git a/core/java/android/content/pm/SHORTCUT_OWNERS b/core/java/android/content/pm/SHORTCUT_OWNERS index 3688d5a3a4c7..f8bba473336d 100644 --- a/core/java/android/content/pm/SHORTCUT_OWNERS +++ b/core/java/android/content/pm/SHORTCUT_OWNERS @@ -1,7 +1,6 @@ set noparent +pinyaoting@google.com +sunnygoyal@google.com omakoto@google.com yamasani@google.com -sunnygoyal@google.com -mett@google.com -pinyaoting@google.com diff --git a/core/java/android/net/IVpnManager.aidl b/core/java/android/net/IVpnManager.aidl index 070efa363cc0..b4647cabe1bc 100644 --- a/core/java/android/net/IVpnManager.aidl +++ b/core/java/android/net/IVpnManager.aidl @@ -17,6 +17,7 @@ package android.net; import android.net.Network; +import android.net.VpnProfileState; import com.android.internal.net.LegacyVpnInfo; import com.android.internal.net.VpnConfig; @@ -40,6 +41,7 @@ interface IVpnManager { void deleteVpnProfile(String packageName); String startVpnProfile(String packageName); void stopVpnProfile(String packageName); + VpnProfileState getProvisionedVpnProfileState(String packageName); /** Always-on VPN APIs */ boolean isAlwaysOnVpnPackageSupported(int userId, String packageName); diff --git a/core/java/android/net/Ikev2VpnProfile.java b/core/java/android/net/Ikev2VpnProfile.java index 0fd3e034291b..3abe83bd3373 100644 --- a/core/java/android/net/Ikev2VpnProfile.java +++ b/core/java/android/net/Ikev2VpnProfile.java @@ -142,6 +142,7 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { private final boolean mIsMetered; // Defaults in builder private final int mMaxMtu; // Defaults in builder private final boolean mIsRestrictedToTestNetworks; + @Nullable private final IkeTunnelConnectionParams mIkeTunConnParams; private Ikev2VpnProfile( int type, @@ -160,7 +161,8 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { int maxMtu, boolean restrictToTestNetworks, boolean excludeLocalRoutes, - boolean requiresInternetValidation) { + boolean requiresInternetValidation, + @Nullable IkeTunnelConnectionParams ikeTunConnParams) { super(type, excludeLocalRoutes, requiresInternetValidation); checkNotNull(serverAddr, MISSING_PARAM_MSG_TMPL, "Server address"); @@ -190,6 +192,8 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { mMaxMtu = maxMtu; mIsRestrictedToTestNetworks = restrictToTestNetworks; + mIkeTunConnParams = ikeTunConnParams; + validate(); } @@ -375,6 +379,12 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { return mMaxMtu; } + /** Retrieves the ikeTunnelConnectionParams contains IKEv2 configurations, if any was set. */ + @Nullable + public IkeTunnelConnectionParams getIkeTunnelConnectionParams() { + return mIkeTunConnParams; + } + /** * Returns whether or not this VPN profile is restricted to test networks. * @@ -403,7 +413,8 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { mMaxMtu, mIsRestrictedToTestNetworks, mExcludeLocalRoutes, - mRequiresInternetValidation); + mRequiresInternetValidation, + mIkeTunConnParams); } @Override @@ -429,7 +440,8 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { && mMaxMtu == other.mMaxMtu && mIsRestrictedToTestNetworks == other.mIsRestrictedToTestNetworks && mExcludeLocalRoutes == other.mExcludeLocalRoutes - && mRequiresInternetValidation == other.mRequiresInternetValidation; + && mRequiresInternetValidation == other.mRequiresInternetValidation + && Objects.equals(mIkeTunConnParams, other.mIkeTunConnParams); } /** @@ -504,6 +516,7 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { @NonNull public static Ikev2VpnProfile fromVpnProfile(@NonNull VpnProfile profile) throws GeneralSecurityException { + // TODO: Build the VpnProfile from mIkeTunConnParams if it exists. final Builder builder = new Builder(profile.server, profile.ipsecIdentifier); builder.setProxy(profile.proxy); builder.setAllowedAlgorithms(profile.getAllowedAlgorithms()); @@ -788,7 +801,7 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { private int mMaxMtu = PlatformVpnProfile.MAX_MTU_DEFAULT; private boolean mIsRestrictedToTestNetworks = false; private boolean mExcludeLocalRoutes = false; - @Nullable private IkeTunnelConnectionParams mIkeTunConnParams; + @Nullable private final IkeTunnelConnectionParams mIkeTunConnParams; /** * Creates a new builder with the basic parameters of an IKEv2/IPsec VPN. @@ -803,6 +816,8 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { mServerAddr = serverAddr; mUserIdentity = identity; + + mIkeTunConnParams = null; } /** @@ -1135,7 +1150,8 @@ public final class Ikev2VpnProfile extends PlatformVpnProfile { mMaxMtu, mIsRestrictedToTestNetworks, mExcludeLocalRoutes, - mRequiresInternetValidation); + mRequiresInternetValidation, + mIkeTunConnParams); } } } diff --git a/core/java/android/net/NetworkPolicyManager.java b/core/java/android/net/NetworkPolicyManager.java index 0e39f425c0fa..3f92eb1d9a40 100644 --- a/core/java/android/net/NetworkPolicyManager.java +++ b/core/java/android/net/NetworkPolicyManager.java @@ -525,9 +525,11 @@ public class NetworkPolicyManager { * * @param subId the subscriber to get the subscription plans for. * @param callingPackage the name of the package making the call. + * @return the active {@link SubscriptionPlan}s for the given subscription id, or + * {@code null} if not found. * @hide */ - @NonNull + @Nullable public SubscriptionPlan[] getSubscriptionPlans(int subId, @NonNull String callingPackage) { try { return mService.getSubscriptionPlans(subId, callingPackage); @@ -540,7 +542,7 @@ public class NetworkPolicyManager { * Get subscription plan for the given networkTemplate. * * @param template the networkTemplate to get the subscription plan for. - * @return the active {@link SubscriptionPlan} for the given template, or + * @return the active {@link SubscriptionPlan}s for the given template, or * {@code null} if not found. * @hide */ @@ -558,6 +560,24 @@ public class NetworkPolicyManager { } /** + * Notifies that the specified {@link NetworkStatsProvider} has reached its warning threshold + * which was set through {@link NetworkStatsProvider#onSetWarningAndLimit(String, long, long)}. + * + * @hide + */ + @RequiresPermission(anyOf = { + NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, + android.Manifest.permission.NETWORK_STACK}) + @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) + public void notifyStatsProviderWarningReached() { + try { + mService.notifyStatsProviderWarningOrLimitReached(); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** * Notifies that the specified {@link NetworkStatsProvider} has reached its quota * which was set through {@link NetworkStatsProvider#onSetLimit(String, long)} or * {@link NetworkStatsProvider#onSetWarningAndLimit(String, long, long)}. @@ -568,7 +588,7 @@ public class NetworkPolicyManager { NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) - public void notifyStatsProviderWarningOrLimitReached() { + public void notifyStatsProviderLimitReached() { try { mService.notifyStatsProviderWarningOrLimitReached(); } catch (RemoteException e) { diff --git a/core/java/android/net/SntpClient.java b/core/java/android/net/SntpClient.java index 0eb4cf3ecadf..b05f7cf241e3 100644 --- a/core/java/android/net/SntpClient.java +++ b/core/java/android/net/SntpClient.java @@ -60,7 +60,7 @@ public class SntpClient { private static final int TRANSMIT_TIME_OFFSET = 40; private static final int NTP_PACKET_SIZE = 48; - private static final int NTP_PORT = 123; + public static final int STANDARD_NTP_PORT = 123; private static final int NTP_MODE_CLIENT = 3; private static final int NTP_MODE_SERVER = 4; private static final int NTP_MODE_BROADCAST = 5; @@ -108,18 +108,21 @@ public class SntpClient { * Sends an SNTP request to the given host and processes the response. * * @param host host name of the server. + * @param port port of the server. * @param timeout network timeout in milliseconds. the timeout doesn't include the DNS lookup * time, and it applies to each individual query to the resolved addresses of * the NTP server. * @param network network over which to send the request. * @return true if the transaction was successful. */ - public boolean requestTime(String host, int timeout, Network network) { + public boolean requestTime(String host, int port, int timeout, Network network) { final Network networkForResolv = network.getPrivateDnsBypassingCopy(); try { final InetAddress[] addresses = networkForResolv.getAllByName(host); for (int i = 0; i < addresses.length; i++) { - if (requestTime(addresses[i], NTP_PORT, timeout, networkForResolv)) return true; + if (requestTime(addresses[i], port, timeout, networkForResolv)) { + return true; + } } } catch (UnknownHostException e) { Log.w(TAG, "Unknown host: " + host); diff --git a/core/java/android/net/VpnManager.java b/core/java/android/net/VpnManager.java index c51444cd31b6..ae7d91f92cb7 100644 --- a/core/java/android/net/VpnManager.java +++ b/core/java/android/net/VpnManager.java @@ -161,6 +161,23 @@ public class VpnManager { "android.net.category.EVENT_DEACTIVATED_BY_USER"; /** + * The always-on state of this VPN was changed + * + * <p>This may be the result of a user changing VPN settings, or a Device Policy Manager app + * having changed the VPN policy. + */ + @SdkConstant(SdkConstant.SdkConstantType.INTENT_CATEGORY) + public static final String CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED = + "android.net.category.EVENT_ALWAYS_ON_STATE_CHANGED"; + + /** + * The VpnProfileState at the time that this event occurred. + * + * <p>This extra may be null if the VPN was revoked by the user, or the profile was deleted. + */ + public static final String EXTRA_VPN_PROFILE_STATE = "android.net.extra.VPN_PROFILE_STATE"; + + /** * The key of the session that experienced this event, as a {@code String}. * * This is the same key that was returned by {@link #startProvisionedVpnProfileSession}. @@ -403,6 +420,21 @@ public class VpnManager { } /** + * Retrieve the VpnProfileState for the profile provisioned by the calling package. + * + * @return the VpnProfileState with current information, or null if there was no profile + * provisioned by the calling package. + */ + @Nullable + public VpnProfileState getProvisionedVpnProfileState() { + try { + return mService.getProvisionedVpnProfileState(mContext.getOpPackageName()); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** * Resets all VPN settings back to factory defaults. * @hide */ diff --git a/core/java/android/net/VpnProfileState.aidl b/core/java/android/net/VpnProfileState.aidl new file mode 100644 index 000000000000..add6386eda75 --- /dev/null +++ b/core/java/android/net/VpnProfileState.aidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2022 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.net; + +parcelable VpnProfileState;
\ No newline at end of file diff --git a/core/java/android/net/VpnProfileState.java b/core/java/android/net/VpnProfileState.java new file mode 100644 index 000000000000..c69ea1a8c220 --- /dev/null +++ b/core/java/android/net/VpnProfileState.java @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2022 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.net; + +import android.annotation.IntDef; +import android.annotation.NonNull; +import android.annotation.Nullable; +import android.os.Parcel; +import android.os.Parcelable; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Describe the state of VPN. + */ +public final class VpnProfileState implements Parcelable { + /** The VPN has not been started, or some other VPN is active. */ + public static final int STATE_DISCONNECTED = 0; + /** The VPN is attempting to connect, potentially after a failure. */ + public static final int STATE_CONNECTING = 1; + /** The VPN was established successfully. */ + public static final int STATE_CONNECTED = 2; + /** A non-recoverable error has occurred, and will not be retried. */ + public static final int STATE_FAILED = 3; + /** @hide */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = {"STATE_"}, value = { + STATE_CONNECTED, + STATE_CONNECTING, + STATE_DISCONNECTED, + STATE_FAILED, + }) + public @interface State {} + + @State private final int mState; + private final String mSessionKey; + private final boolean mAlwaysOn; + private final boolean mLockdown; + + public VpnProfileState(@State int state, @Nullable String sessionKey, boolean alwaysOn, + boolean lockdown) { + mState = state; + mSessionKey = sessionKey; + mAlwaysOn = alwaysOn; + mLockdown = lockdown; + } + + /** + * Returns the state of the Platform VPN + * + * <p>This state represents the internal connection state of the VPN. This state may diverge + * from the VPN Network's state during error and recovery handling. + */ + @State public int getState() { + return mState; + } + + /** + * Retrieves the Session Key + * + * <p>The session key is an ephemeral key uniquely identifying the session for a Platform VPN. + * The lifetime of this key is tied to the lifetime of the VPN session. In other words, + * reprovisioning of the VPN profile, restarting of the device, or manually restarting the + * platform VPN session will result in a new VPN session, and a new key. + * + * @return the unique key for the platform VPN session, or null if it is not running. + */ + @Nullable + public String getSessionId() { + return mSessionKey; + } + + /** + * Returns the always-on status of the PlatformVpnProfile. + * + * <p>If the PlatformVpnProfile is set to be running in always-on mode, the system will ensure + * that the profile is always started, and restarting it when necessary (e.g. after reboot). + * + * <p>Always-on can be set by an appropriately privileged user via the Settings VPN menus, or by + * the Device Policy Manager app programmatically. + * + * See DevicePolicyManager#setAlwaysOnVpnPackage(ComponentName, String, boolean, Set) + */ + public boolean isAlwaysOn() { + return mAlwaysOn; + } + + /** + * Returns the lockdown mode status of the PlatformVpnProfile. + * + * <p>In lockdown mode, the system will ensure that apps are not allowed to bypass the VPN, + * including during startup or failure of the VPN. + * + * <p>Lockdown mode can be set by an appropriately privileged user via the Settings VPN menus, + * or by the Device Policy Manager app programmatically. + * + * See DevicePolicyManager#setAlwaysOnVpnPackage(ComponentName, String, boolean, Set) + */ + public boolean isLockdownEnabled() { + return mLockdown; + } + + /** + * Implement the Parcelable interface + */ + public int describeContents() { + return 0; + } + + /** + * Implement the Parcelable interface + */ + public void writeToParcel(@NonNull Parcel out, int flags) { + out.writeInt(mState); + out.writeString(mSessionKey); + out.writeBoolean(mAlwaysOn); + out.writeBoolean(mLockdown); + } + + @NonNull + public static final Parcelable.Creator<VpnProfileState> CREATOR = + new Parcelable.Creator<VpnProfileState>() { + public VpnProfileState createFromParcel(Parcel in) { + return new VpnProfileState(in); + } + + public VpnProfileState[] newArray(int size) { + return new VpnProfileState[size]; + } + }; + + private VpnProfileState(Parcel in) { + mState = in.readInt(); + mSessionKey = in.readString(); + mAlwaysOn = in.readBoolean(); + mLockdown = in.readBoolean(); + } +} diff --git a/core/java/android/os/storage/IStorageManager.aidl b/core/java/android/os/storage/IStorageManager.aidl index 5bf1b04b8e53..ef33543ba7ad 100644 --- a/core/java/android/os/storage/IStorageManager.aidl +++ b/core/java/android/os/storage/IStorageManager.aidl @@ -125,7 +125,6 @@ interface IStorageManager { boolean isUserKeyUnlocked(int userId) = 65; void prepareUserStorage(in String volumeUuid, int userId, int serialNumber, int flags) = 66; void destroyUserStorage(in String volumeUuid, int userId, int flags) = 67; - boolean isConvertibleToFBE() = 68; void addUserKeyAuth(int userId, int serialNumber, in byte[] secret) = 70; void fixateNewestUserKeyAuth(int userId) = 71; void fstrim(int flags, IVoldTaskListener listener) = 72; diff --git a/core/java/android/util/NtpTrustedTime.java b/core/java/android/util/NtpTrustedTime.java index aebc5e86605a..01a037ae3495 100644 --- a/core/java/android/util/NtpTrustedTime.java +++ b/core/java/android/util/NtpTrustedTime.java @@ -140,6 +140,10 @@ public class NtpTrustedTime implements TrustedTime { /** An in-memory config override for use during tests. */ @Nullable + private Integer mPortForTests; + + /** An in-memory config override for use during tests. */ + @Nullable private Duration mTimeoutForTests; // Declared volatile and accessed outside of synchronized blocks to avoid blocking reads during @@ -163,9 +167,11 @@ public class NtpTrustedTime implements TrustedTime { * Overrides the NTP server config for tests. Passing {@code null} to a parameter clears the * test value, i.e. so the normal value will be used next time. */ - public void setServerConfigForTests(@Nullable String hostname, @Nullable Duration timeout) { + public void setServerConfigForTests( + @Nullable String hostname, @Nullable Integer port, @Nullable Duration timeout) { synchronized (this) { mHostnameForTests = hostname; + mPortForTests = port; mTimeoutForTests = timeout; } } @@ -195,8 +201,9 @@ public class NtpTrustedTime implements TrustedTime { if (LOGD) Log.d(TAG, "forceRefresh() from cache miss"); final SntpClient client = new SntpClient(); final String serverName = connectionInfo.getServer(); + final int port = connectionInfo.getPort(); final int timeoutMillis = connectionInfo.getTimeoutMillis(); - if (client.requestTime(serverName, timeoutMillis, network)) { + if (client.requestTime(serverName, port, timeoutMillis, network)) { long ntpCertainty = client.getRoundTripTime() / 2; mTimeResult = new TimeResult( client.getNtpTime(), client.getNtpTimeReference(), ntpCertainty); @@ -297,10 +304,12 @@ public class NtpTrustedTime implements TrustedTime { private static class NtpConnectionInfo { @NonNull private final String mServer; + private final int mPort; private final int mTimeoutMillis; - NtpConnectionInfo(@NonNull String server, int timeoutMillis) { + NtpConnectionInfo(@NonNull String server, int port, int timeoutMillis) { mServer = Objects.requireNonNull(server); + mPort = port; mTimeoutMillis = timeoutMillis; } @@ -309,6 +318,11 @@ public class NtpTrustedTime implements TrustedTime { return mServer; } + @NonNull + public int getPort() { + return mPort; + } + int getTimeoutMillis() { return mTimeoutMillis; } @@ -317,6 +331,7 @@ public class NtpTrustedTime implements TrustedTime { public String toString() { return "NtpConnectionInfo{" + "mServer='" + mServer + '\'' + + ", mPort='" + mPort + '\'' + ", mTimeoutMillis=" + mTimeoutMillis + '}'; } @@ -341,6 +356,13 @@ public class NtpTrustedTime implements TrustedTime { } } + final Integer port; + if (mPortForTests != null) { + port = mPortForTests; + } else { + port = SntpClient.STANDARD_NTP_PORT; + } + final int timeoutMillis; if (mTimeoutForTests != null) { timeoutMillis = (int) mTimeoutForTests.toMillis(); @@ -350,7 +372,8 @@ public class NtpTrustedTime implements TrustedTime { timeoutMillis = Settings.Global.getInt( resolver, Settings.Global.NTP_TIMEOUT, defaultTimeoutMillis); } - return TextUtils.isEmpty(hostname) ? null : new NtpConnectionInfo(hostname, timeoutMillis); + return TextUtils.isEmpty(hostname) ? null : + new NtpConnectionInfo(hostname, port, timeoutMillis); } /** Prints debug information. */ diff --git a/core/tests/coretests/src/android/net/SntpClientTest.java b/core/tests/coretests/src/android/net/SntpClientTest.java index b400b9bf41dd..1299d7ff2dae 100644 --- a/core/tests/coretests/src/android/net/SntpClientTest.java +++ b/core/tests/coretests/src/android/net/SntpClientTest.java @@ -293,7 +293,8 @@ public class SntpClientTest { @Test public void testDnsResolutionFailure() throws Exception { - assertFalse(mClient.requestTime("ntp.server.doesnotexist.example", 5000, mNetwork)); + assertFalse(mClient.requestTime("ntp.server.doesnotexist.example", + SntpClient.STANDARD_NTP_PORT, 5000, mNetwork)); } @Test diff --git a/core/tests/coretests/src/com/android/internal/os/LooperStatsTest.java b/core/tests/coretests/src/com/android/internal/os/LooperStatsTest.java index b89e8bce5fc9..625f52a87ecf 100644 --- a/core/tests/coretests/src/com/android/internal/os/LooperStatsTest.java +++ b/core/tests/coretests/src/com/android/internal/os/LooperStatsTest.java @@ -232,7 +232,7 @@ public final class LooperStatsTest { assertThat(entry3.handlerClassName).isEqualTo( "com.android.internal.os.LooperStatsTest$TestHandlerSecond"); assertThat(entry3.messageName).startsWith( - "com.android.internal.os.LooperStatsTest$$ExternalSyntheticLambda4"); + "com.android.internal.os.LooperStatsTest$$ExternalSyntheticLambda"); assertThat(entry3.messageCount).isEqualTo(1); assertThat(entry3.recordedMessageCount).isEqualTo(1); assertThat(entry3.exceptionCount).isEqualTo(0); diff --git a/data/etc/privapp-permissions-platform.xml b/data/etc/privapp-permissions-platform.xml index c9abee296b73..e608a74a1cf8 100644 --- a/data/etc/privapp-permissions-platform.xml +++ b/data/etc/privapp-permissions-platform.xml @@ -292,6 +292,8 @@ applications that come with the platform <!-- Needed for test only --> <permission name="android.permission.BATTERY_PREDICTION"/> <permission name="android.permission.BATTERY_STATS"/> + <!-- BLUETOOTH_PRIVILEGED is needed for test only --> + <permission name="android.permission.BLUETOOTH_PRIVILEGED"/> <permission name="android.permission.BIND_APPWIDGET"/> <permission name="android.permission.CHANGE_APP_IDLE_STATE"/> <permission name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/> diff --git a/media/java/android/media/MediaActionSound.java b/media/java/android/media/MediaActionSound.java index ec56d614f2b5..ad1405aa2356 100644 --- a/media/java/android/media/MediaActionSound.java +++ b/media/java/android/media/MediaActionSound.java @@ -25,7 +25,8 @@ import android.util.Log; /** * <p>A class for producing sounds that match those produced by various actions - * taken by the media and camera APIs. </p> + * taken by the media and camera APIs. It is recommended to call methods in this class + * in a background thread since it relies on binder calls.</p> * * <p>This class is recommended for use with the {@link android.hardware.camera2} API, since the * camera2 API does not play any sounds on its own for any capture or video recording actions.</p> @@ -109,7 +110,7 @@ public class MediaActionSound { /** * <p>Returns true if the application must play the shutter sound in accordance - * to certain regional restrictions. </p> + * to certain regional restrictions.</p> * * <p>If this method returns true, applications are strongly recommended to use * MediaActionSound.play(SHUTTER_CLICK) or START_VIDEO_RECORDING whenever it captures diff --git a/packages/ConnectivityT/framework-t/Android.bp b/packages/ConnectivityT/framework-t/Android.bp index 66527802a0e4..217a1f67c336 100644 --- a/packages/ConnectivityT/framework-t/Android.bp +++ b/packages/ConnectivityT/framework-t/Android.bp @@ -154,17 +154,17 @@ filegroup { ], } +// TODO: remove this empty filegroup. filegroup { name: "framework-connectivity-tiramisu-sources", - srcs: [ - ":framework-connectivity-ethernet-sources", - ], + srcs: [], visibility: ["//frameworks/base"], } filegroup { name: "framework-connectivity-tiramisu-updatable-sources", srcs: [ + ":framework-connectivity-ethernet-sources", ":framework-connectivity-ipsec-sources", ":framework-connectivity-netstats-sources", ":framework-connectivity-nsd-sources", diff --git a/packages/ConnectivityT/framework-t/src/android/net/ConnectivityFrameworkInitializerTiramisu.java b/packages/ConnectivityT/framework-t/src/android/net/ConnectivityFrameworkInitializerTiramisu.java index 9bffbfb27a8d..61b34d0bcfe6 100644 --- a/packages/ConnectivityT/framework-t/src/android/net/ConnectivityFrameworkInitializerTiramisu.java +++ b/packages/ConnectivityT/framework-t/src/android/net/ConnectivityFrameworkInitializerTiramisu.java @@ -34,8 +34,9 @@ public final class ConnectivityFrameworkInitializerTiramisu { private ConnectivityFrameworkInitializerTiramisu() {} /** - * Called by {@link SystemServiceRegistry}'s static initializer and registers nsd services to - * {@link Context}, so that {@link Context#getSystemService} can return them. + * Called by {@link SystemServiceRegistry}'s static initializer and registers NetworkStats, nsd, + * ipsec and ethernet services to {@link Context}, so that {@link Context#getSystemService} can + * return them. * * @throws IllegalStateException if this is called anywhere besides * {@link SystemServiceRegistry}. @@ -68,5 +69,14 @@ public final class ConnectivityFrameworkInitializerTiramisu { return new NetworkStatsManager(context, service); } ); + + SystemServiceRegistry.registerContextAwareService( + Context.ETHERNET_SERVICE, + EthernetManager.class, + (context, serviceBinder) -> { + IEthernetManager service = IEthernetManager.Stub.asInterface(serviceBinder); + return new EthernetManager(context, service); + } + ); } } diff --git a/packages/ConnectivityT/framework-t/src/android/net/EthernetManager.java b/packages/ConnectivityT/framework-t/src/android/net/EthernetManager.java index eba51c11487e..793f28d5aa59 100644 --- a/packages/ConnectivityT/framework-t/src/android/net/EthernetManager.java +++ b/packages/ConnectivityT/framework-t/src/android/net/EthernetManager.java @@ -33,7 +33,7 @@ import android.os.Build; import android.os.RemoteException; import com.android.internal.annotations.GuardedBy; -import com.android.internal.os.BackgroundThread; +import com.android.modules.utils.BackgroundThread; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/packages/ConnectivityT/framework-t/src/android/net/EthernetNetworkUpdateRequest.java b/packages/ConnectivityT/framework-t/src/android/net/EthernetNetworkUpdateRequest.java index 43f4c40f2d27..1691942c3675 100644 --- a/packages/ConnectivityT/framework-t/src/android/net/EthernetNetworkUpdateRequest.java +++ b/packages/ConnectivityT/framework-t/src/android/net/EthernetNetworkUpdateRequest.java @@ -33,17 +33,20 @@ import java.util.Objects; */ @SystemApi public final class EthernetNetworkUpdateRequest implements Parcelable { - @NonNull + @Nullable private final IpConfiguration mIpConfig; @Nullable private final NetworkCapabilities mNetworkCapabilities; /** - * @return the new {@link IpConfiguration}. + * Setting the {@link IpConfiguration} is optional in {@link EthernetNetworkUpdateRequest}. + * When set to null, the existing IpConfiguration is not updated. + * + * @return the new {@link IpConfiguration} or null. */ - @NonNull + @Nullable public IpConfiguration getIpConfiguration() { - return new IpConfiguration(mIpConfig); + return mIpConfig == null ? null : new IpConfiguration(mIpConfig); } /** @@ -57,9 +60,8 @@ public final class EthernetNetworkUpdateRequest implements Parcelable { return mNetworkCapabilities == null ? null : new NetworkCapabilities(mNetworkCapabilities); } - private EthernetNetworkUpdateRequest(@NonNull final IpConfiguration ipConfig, + private EthernetNetworkUpdateRequest(@Nullable final IpConfiguration ipConfig, @Nullable final NetworkCapabilities networkCapabilities) { - Objects.requireNonNull(ipConfig); mIpConfig = ipConfig; mNetworkCapabilities = networkCapabilities; } @@ -90,7 +92,8 @@ public final class EthernetNetworkUpdateRequest implements Parcelable { */ public Builder(@NonNull final EthernetNetworkUpdateRequest request) { Objects.requireNonNull(request); - mBuilderIpConfig = new IpConfiguration(request.mIpConfig); + mBuilderIpConfig = null == request.mIpConfig + ? null : new IpConfiguration(request.mIpConfig); mBuilderNetworkCapabilities = null == request.mNetworkCapabilities ? null : new NetworkCapabilities(request.mNetworkCapabilities); } @@ -101,8 +104,8 @@ public final class EthernetNetworkUpdateRequest implements Parcelable { * @return The builder to facilitate chaining. */ @NonNull - public Builder setIpConfiguration(@NonNull final IpConfiguration ipConfig) { - mBuilderIpConfig = new IpConfiguration(ipConfig); + public Builder setIpConfiguration(@Nullable final IpConfiguration ipConfig) { + mBuilderIpConfig = ipConfig == null ? null : new IpConfiguration(ipConfig); return this; } @@ -119,9 +122,16 @@ public final class EthernetNetworkUpdateRequest implements Parcelable { /** * Build {@link EthernetNetworkUpdateRequest} return the current update request. + * + * @throws IllegalStateException when both mBuilderNetworkCapabilities and mBuilderIpConfig + * are null. */ @NonNull public EthernetNetworkUpdateRequest build() { + if (mBuilderIpConfig == null && mBuilderNetworkCapabilities == null) { + throw new IllegalStateException( + "Cannot construct an empty EthernetNetworkUpdateRequest"); + } return new EthernetNetworkUpdateRequest(mBuilderIpConfig, mBuilderNetworkCapabilities); } } diff --git a/packages/ConnectivityT/framework-t/src/android/net/netstats/provider/INetworkStatsProviderCallback.aidl b/packages/ConnectivityT/framework-t/src/android/net/netstats/provider/INetworkStatsProviderCallback.aidl index 7eaa01e262fe..01ff02dfc5b3 100644 --- a/packages/ConnectivityT/framework-t/src/android/net/netstats/provider/INetworkStatsProviderCallback.aidl +++ b/packages/ConnectivityT/framework-t/src/android/net/netstats/provider/INetworkStatsProviderCallback.aidl @@ -26,6 +26,7 @@ import android.net.NetworkStats; oneway interface INetworkStatsProviderCallback { void notifyStatsUpdated(int token, in NetworkStats ifaceStats, in NetworkStats uidStats); void notifyAlertReached(); - void notifyWarningOrLimitReached(); + void notifyWarningReached(); + void notifyLimitReached(); void unregister(); } diff --git a/packages/ConnectivityT/framework-t/src/android/net/netstats/provider/NetworkStatsProvider.java b/packages/ConnectivityT/framework-t/src/android/net/netstats/provider/NetworkStatsProvider.java index 23fc06927ef9..d37a53dbf1e9 100644 --- a/packages/ConnectivityT/framework-t/src/android/net/netstats/provider/NetworkStatsProvider.java +++ b/packages/ConnectivityT/framework-t/src/android/net/netstats/provider/NetworkStatsProvider.java @@ -152,19 +152,19 @@ public abstract class NetworkStatsProvider { try { // Reuse the code path to notify warning reached with limit reached // since framework handles them in the same way. - getProviderCallbackBinderOrThrow().notifyWarningOrLimitReached(); + getProviderCallbackBinderOrThrow().notifyWarningReached(); } catch (RemoteException e) { e.rethrowAsRuntimeException(); } } /** - * Notify system that the quota set by {@link #onSetLimit} or limit set by + * Notify system that the limit set by {@link #onSetLimit} or limit set by * {@link #onSetWarningAndLimit} has been reached. */ public void notifyLimitReached() { try { - getProviderCallbackBinderOrThrow().notifyWarningOrLimitReached(); + getProviderCallbackBinderOrThrow().notifyLimitReached(); } catch (RemoteException e) { e.rethrowAsRuntimeException(); } diff --git a/packages/ConnectivityT/service/Android.bp b/packages/ConnectivityT/service/Android.bp index 5100e7c5b9a4..4b799c599be9 100644 --- a/packages/ConnectivityT/service/Android.bp +++ b/packages/ConnectivityT/service/Android.bp @@ -102,17 +102,16 @@ filegroup { ], path: "src", visibility: [ - "//frameworks/opt/net/ethernet", + "//frameworks/opt/net/ethernet/tests", ], } // Connectivity-T common libraries. +// TODO: remove this empty filegroup. filegroup { name: "services.connectivity-tiramisu-sources", - srcs: [ - ":services.connectivity-ethernet-sources", - ], + srcs: [], path: "src", visibility: ["//frameworks/base/services/core"], } @@ -120,6 +119,7 @@ filegroup { filegroup { name: "services.connectivity-tiramisu-updatable-sources", srcs: [ + ":services.connectivity-ethernet-sources", ":services.connectivity-ipsec-sources", ":services.connectivity-netstats-sources", ":services.connectivity-nsd-sources", diff --git a/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java b/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java index 3db635b1d503..7db4b8c849d6 100644 --- a/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java +++ b/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java @@ -2393,10 +2393,17 @@ public class NetworkStatsService extends INetworkStatsService.Stub { } @Override - public void notifyWarningOrLimitReached() { - Log.d(TAG, mTag + ": notifyWarningOrLimitReached"); + public void notifyWarningReached() { + Log.d(TAG, mTag + ": notifyWarningReached"); BinderUtils.withCleanCallingIdentity(() -> - mNetworkPolicyManager.notifyStatsProviderWarningOrLimitReached()); + mNetworkPolicyManager.notifyStatsProviderWarningReached()); + } + + @Override + public void notifyLimitReached() { + Log.d(TAG, mTag + ": notifyLimitReached"); + BinderUtils.withCleanCallingIdentity(() -> + mNetworkPolicyManager.notifyStatsProviderLimitReached()); } @Override diff --git a/services/tests/servicestests/src/com/android/server/net/IpConfigStoreTest.java b/packages/ConnectivityT/tests/unit/java/com/android/server/net/IpConfigStoreTest.java index 2f771260ac1b..ad0be5862c5d 100644 --- a/services/tests/servicestests/src/com/android/server/net/IpConfigStoreTest.java +++ b/packages/ConnectivityT/tests/unit/java/com/android/server/net/IpConfigStoreTest.java @@ -48,10 +48,16 @@ import java.util.Arrays; */ @RunWith(AndroidJUnit4.class) public class IpConfigStoreTest { + private static final int KEY_CONFIG = 17; + private static final String IFACE_1 = "eth0"; + private static final String IFACE_2 = "eth1"; + private static final String IP_ADDR_1 = "192.168.1.10/24"; + private static final String IP_ADDR_2 = "192.168.1.20/24"; + private static final String DNS_IP_ADDR_1 = "1.2.3.4"; + private static final String DNS_IP_ADDR_2 = "5.6.7.8"; @Test public void backwardCompatibility2to3() throws IOException { - final int KEY_CONFIG = 17; ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); DataOutputStream outputStream = new DataOutputStream(byteStream); @@ -73,13 +79,6 @@ public class IpConfigStoreTest { @Test public void staticIpMultiNetworks() throws Exception { - final String IFACE_1 = "eth0"; - final String IFACE_2 = "eth1"; - final String IP_ADDR_1 = "192.168.1.10/24"; - final String IP_ADDR_2 = "192.168.1.20/24"; - final String DNS_IP_ADDR_1 = "1.2.3.4"; - final String DNS_IP_ADDR_2 = "5.6.7.8"; - final ArrayList<InetAddress> dnsServers = new ArrayList<>(); dnsServers.add(InetAddresses.parseNumericAddress(DNS_IP_ADDR_1)); dnsServers.add(InetAddresses.parseNumericAddress(DNS_IP_ADDR_2)); @@ -144,11 +143,11 @@ public class IpConfigStoreTest { /** Synchronously writes into given byte steam */ private static class MockedDelayedDiskWrite extends DelayedDiskWrite { - final ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); + final ByteArrayOutputStream mByteStream = new ByteArrayOutputStream(); @Override public void write(String filePath, Writer w) { - DataOutputStream outputStream = new DataOutputStream(byteStream); + DataOutputStream outputStream = new DataOutputStream(mByteStream); try { w.onWriteCalled(outputStream); diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml index a56c49088b67..534e41c42467 100644 --- a/packages/SettingsLib/res/values/strings.xml +++ b/packages/SettingsLib/res/values/strings.xml @@ -1038,23 +1038,6 @@ <!-- Developer settings: text for the WebView provider selection toast shown if an invalid provider was chosen (i.e. the setting list was stale). [CHAR LIMIT=NONE] --> <string name="select_webview_provider_toast_text">This choice is no longer valid. Try again.</string> - <!-- Developer settings screen, convert userdata to file encryption option name --> - <string name="convert_to_file_encryption">Convert to file encryption</string> - <!-- Developer settings screen, convert userdata to file encryption summary when option is available --> - <string name="convert_to_file_encryption_enabled">Convert\u2026</string> - <!-- Developer settings screen, convert userdata to file encryption summary when option is already done --> - <string name="convert_to_file_encryption_done">Already file encrypted</string> - <!-- Title used on dialog with final prompt for converting to file encryption --> - <string name="title_convert_fbe">Converting to file based encryption</string> - <!-- Warning displayed on dialog with final prompt for converting to file encryption --> - <string name="convert_to_fbe_warning"> - Convert data partition to file based encryption.\n - !!Warning!! This will erase all your data.\n - This feature is alpha, and may not work correctly.\n - Press \'Wipe and convert\u2026\' to continue.</string> - <!-- Button on dialog that triggers convertion to file encryption --> - <string name="button_convert_fbe">Wipe and convert\u2026</string> - <!-- Name of feature to change color setting for the display [CHAR LIMIT=60] --> <string name="picture_color_mode">Picture color mode</string> diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java index 981d8e403cd6..ca054c74c4d4 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java @@ -751,7 +751,10 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> ParcelUuid[] uuids = mDevice.getUuids(); if (uuids == null) return false; - ParcelUuid[] localUuids = mLocalAdapter.getUuids(); + List<ParcelUuid> uuidsList = mLocalAdapter.getUuidsList(); + ParcelUuid[] localUuids = new ParcelUuid[uuidsList.size()]; + uuidsList.toArray(localUuids); + if (localUuids == null) return false; /* @@ -1115,7 +1118,8 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> final boolean isOnCall = Utils.isAudioModeOngoingCall(mContext); if ((mIsActiveDeviceHearingAid) || (mIsActiveDeviceHeadset && isOnCall) - || (mIsActiveDeviceA2dp && !isOnCall)) { + || (mIsActiveDeviceA2dp && !isOnCall) + || mIsActiveDeviceLeAudio) { if (isTwsBatteryAvailable(leftBattery, rightBattery) && !shortSummary) { stringRes = R.string.bluetooth_active_battery_level_untethered; } else if (batteryLevelPercentageString != null && !shortSummary) { diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LeAudioProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LeAudioProfile.java index db6d41ef692d..c323c4ef9937 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LeAudioProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LeAudioProfile.java @@ -246,6 +246,13 @@ public class LeAudioProfile implements LocalBluetoothProfile { return R.drawable.ic_bt_le_audio; } + public int getAudioLocation(BluetoothDevice device) { + if (mService == null || device == null) { + return BluetoothLeAudio.AUDIO_LOCATION_INVALID; + } + return mService.getAudioLocation(device); + } + @RequiresApi(Build.VERSION_CODES.S) protected void finalize() { if (DEBUG) { diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java index 80b03a43b055..51ba9ad6ff56 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java @@ -124,7 +124,10 @@ public class LocalBluetoothAdapter { } public ParcelUuid[] getUuids() { - return mAdapter.getUuids(); + List<ParcelUuid> uuidsList = mAdapter.getUuidsList(); + ParcelUuid[] uuidsArray = new ParcelUuid[uuidsList.size()]; + uuidsList.toArray(uuidsArray); + return uuidsArray; } public boolean isDiscovering() { diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml index 8f2ac9f3e6b4..feee4a138a35 100644 --- a/packages/Shell/AndroidManifest.xml +++ b/packages/Shell/AndroidManifest.xml @@ -121,6 +121,8 @@ <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> + <!-- BLUETOOTH_PRIVILEGED is needed for testing purposes only. --> + <uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" /> <uses-permission android:name="android.permission.BLUETOOTH_SCAN" /> <uses-permission android:name="android.permission.LOCAL_MAC_ADDRESS" /> <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" /> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarMobileView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarMobileView.java index 68dcdd9ff49f..7de6a0e5e7cc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarMobileView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarMobileView.java @@ -186,7 +186,7 @@ public class StatusBarMobileView extends FrameLayout implements DarkReceiver, setContentDescription(state.contentDescription); int newVisibility = state.visible && !mForceHidden ? View.VISIBLE : View.GONE; - if (newVisibility != mMobileGroup.getVisibility()) { + if (newVisibility != mMobileGroup.getVisibility() && STATE_ICON == mVisibleState) { mMobileGroup.setVisibility(newVisibility); needsLayout = true; } diff --git a/proto/src/metrics_constants/metrics_constants.proto b/proto/src/metrics_constants/metrics_constants.proto index 3f712dd1492f..3801c2473c11 100644 --- a/proto/src/metrics_constants/metrics_constants.proto +++ b/proto/src/metrics_constants/metrics_constants.proto @@ -2260,10 +2260,12 @@ message MetricsEvent { ACCOUNTS_WORK_PROFILE_SETTINGS = 401; // Settings -> Dev options -> Convert to file encryption - CONVERT_FBE = 402; + // DEPRECATED: this setting was removed in Android T. + CONVERT_FBE = 402 [deprecated=true]; // Settings -> Dev options -> Convert to file encryption -> WIPE AND CONVERT... - CONVERT_FBE_CONFIRM = 403; + // DEPRECATED: this setting was removed in Android T. + CONVERT_FBE_CONFIRM = 403 [deprecated=true]; // Settings -> Dev options -> Running services RUNNING_SERVICES = 404; diff --git a/services/core/java/com/android/server/NetworkTimeUpdateService.java b/services/core/java/com/android/server/NetworkTimeUpdateService.java index 186ff6215c9c..2015dc929a59 100644 --- a/services/core/java/com/android/server/NetworkTimeUpdateService.java +++ b/services/core/java/com/android/server/NetworkTimeUpdateService.java @@ -196,13 +196,15 @@ public class NetworkTimeUpdateService extends Binder { * Overrides the NTP server config for tests. Passing {@code null} to a parameter clears the * test value, i.e. so the normal value will be used next time. */ - void setServerConfigForTests(@Nullable String hostname, @Nullable Duration timeout) { + void setServerConfigForTests( + @Nullable String hostname, @Nullable Integer port, @Nullable Duration timeout) { mContext.enforceCallingPermission( android.Manifest.permission.SET_TIME, "set NTP server config for tests"); mLocalLog.log("Setting server config for tests: hostname=" + hostname + + ", port=" + port + ", timeout=" + timeout); - mTime.setServerConfigForTests(hostname, timeout); + mTime.setServerConfigForTests(hostname, port, timeout); } private void onPollNetworkTime(int event) { diff --git a/services/core/java/com/android/server/NetworkTimeUpdateServiceShellCommand.java b/services/core/java/com/android/server/NetworkTimeUpdateServiceShellCommand.java index 464af01a009a..d7504ceb9d4d 100644 --- a/services/core/java/com/android/server/NetworkTimeUpdateServiceShellCommand.java +++ b/services/core/java/com/android/server/NetworkTimeUpdateServiceShellCommand.java @@ -46,6 +46,7 @@ class NetworkTimeUpdateServiceShellCommand extends ShellCommand { */ private static final String SHELL_COMMAND_SET_SERVER_CONFIG = "set_server_config"; private static final String SET_SERVER_CONFIG_HOSTNAME_ARG = "--hostname"; + private static final String SET_SERVER_CONFIG_PORT_ARG = "--port"; private static final String SET_SERVER_CONFIG_TIMEOUT_ARG = "--timeout_millis"; @NonNull @@ -87,6 +88,7 @@ class NetworkTimeUpdateServiceShellCommand extends ShellCommand { private int runSetServerConfig() { String hostname = null; + Integer port = null; Duration timeout = null; String opt; while ((opt = getNextArg()) != null) { @@ -95,6 +97,10 @@ class NetworkTimeUpdateServiceShellCommand extends ShellCommand { hostname = getNextArgRequired(); break; } + case SET_SERVER_CONFIG_PORT_ARG: { + port = Integer.parseInt(getNextArgRequired()); + break; + } case SET_SERVER_CONFIG_TIMEOUT_ARG: { timeout = Duration.ofMillis(Integer.parseInt(getNextArgRequired())); break; @@ -104,7 +110,7 @@ class NetworkTimeUpdateServiceShellCommand extends ShellCommand { } } } - mNetworkTimeUpdateService.setServerConfigForTests(hostname, timeout); + mNetworkTimeUpdateService.setServerConfigForTests(hostname, port, timeout); return 0; } @@ -120,8 +126,9 @@ class NetworkTimeUpdateServiceShellCommand extends ShellCommand { pw.printf(" Refreshes the latest time. Prints whether it was successful.\n"); pw.printf(" %s\n", SHELL_COMMAND_SET_SERVER_CONFIG); pw.printf(" Sets the NTP server config for tests. The config is not persisted.\n"); - pw.printf(" Options: [%s <hostname>] [%s <millis>]\n", - SET_SERVER_CONFIG_HOSTNAME_ARG, SET_SERVER_CONFIG_TIMEOUT_ARG); + pw.printf(" Options: [%s <hostname>] [%s <port>] [%s <millis>]\n", + SET_SERVER_CONFIG_HOSTNAME_ARG, SET_SERVER_CONFIG_PORT_ARG, + SET_SERVER_CONFIG_TIMEOUT_ARG); pw.printf(" Each key/value is optional and must be specified to override the\n"); pw.printf(" normal value, not specifying a key causes it to reset to the original.\n"); pw.println(); diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java index 9c8cb8c5267d..9f32888262ee 100644 --- a/services/core/java/com/android/server/StorageManagerService.java +++ b/services/core/java/com/android/server/StorageManagerService.java @@ -3072,23 +3072,6 @@ class StorageManagerService extends IStorageManager.Stub } /** - * Is userdata convertible to file based encryption? - * @return non zero for convertible - */ - @Override - public boolean isConvertibleToFBE() throws RemoteException { - mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER, - "no permission to access the crypt keeper"); - - try { - return mVold.isConvertibleToFbe(); - } catch (Exception e) { - Slog.wtf(TAG, e); - return false; - } - } - - /** * Check whether the device supports filesystem checkpointing. * * @return true if the device supports filesystem checkpointing, false otherwise. diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 811f2f5e5283..382359ab1da5 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -2009,10 +2009,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { return; } - ApnSetting apnSetting = preciseState.getApnSetting(); - synchronized (mRecords) { - if (validatePhoneId(phoneId)) { + if (validatePhoneId(phoneId) && preciseState.getApnSetting() != null) { Pair<Integer, ApnSetting> key = Pair.create(preciseState.getTransportType(), preciseState.getApnSetting()); PreciseDataConnectionState oldState = mPreciseDataConnectionStates.get(phoneId) diff --git a/services/core/java/com/android/server/VpnManagerService.java b/services/core/java/com/android/server/VpnManagerService.java index 7b8cce54c8a7..c1d8e7bf3dc0 100644 --- a/services/core/java/com/android/server/VpnManagerService.java +++ b/services/core/java/com/android/server/VpnManagerService.java @@ -37,6 +37,7 @@ import android.net.NetworkStack; import android.net.UnderlyingNetworkInfo; import android.net.Uri; import android.net.VpnManager; +import android.net.VpnProfileState; import android.net.VpnService; import android.net.util.NetdService; import android.os.Binder; @@ -374,6 +375,24 @@ public class VpnManagerService extends IVpnManager.Stub { } /** + * Retrieve the VpnProfileState for the profile provisioned by the given package. + * + * @return the VpnProfileState with current information, or null if there was no profile + * provisioned by the given package. + * @hide + */ + @Override + @Nullable + public VpnProfileState getProvisionedVpnProfileState(@NonNull String packageName) { + final int callingUid = Binder.getCallingUid(); + verifyCallingUidAndPackage(packageName, callingUid); + final int user = UserHandle.getUserId(callingUid); + synchronized (mVpns) { + return mVpns.get(user).getProvisionedVpnProfileState(packageName); + } + } + + /** * Start legacy VPN, controlling native daemons as needed. Creates a * secondary thread to perform connection work, returning quickly. * diff --git a/services/core/java/com/android/server/am/OomAdjuster.java b/services/core/java/com/android/server/am/OomAdjuster.java index 956f34ffbed8..96ea6db0c3f5 100644 --- a/services/core/java/com/android/server/am/OomAdjuster.java +++ b/services/core/java/com/android/server/am/OomAdjuster.java @@ -547,7 +547,6 @@ public class OomAdjuster { uids.clear(); uids.put(uidRec.getUid(), uidRec); updateUidsLSP(uids, SystemClock.elapsedRealtime()); - mProcessList.incrementProcStateSeqAndNotifyAppsLOSP(uids); } } @@ -1268,8 +1267,6 @@ public class OomAdjuster { } } - mProcessList.incrementProcStateSeqAndNotifyAppsLOSP(activeUids); - return mService.mAppProfiler.updateLowMemStateLSP(numCached, numEmpty, numTrimming); } @@ -1304,6 +1301,11 @@ public class OomAdjuster { @GuardedBy({"mService", "mProcLock"}) private void updateUidsLSP(ActiveUids activeUids, final long nowElapsed) { + // This compares previously set procstate to the current procstate in regards to whether + // or not the app's network access will be blocked. So, this needs to be called before + // we update the UidRecord's procstate by calling {@link UidRecord#setSetProcState}. + mProcessList.incrementProcStateSeqAndNotifyAppsLOSP(activeUids); + ArrayList<UidRecord> becameIdle = mTmpBecameIdle; becameIdle.clear(); diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index c0df095c3289..a6da4a6a4260 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -75,6 +75,7 @@ import android.net.RouteInfo; import android.net.UidRangeParcel; import android.net.UnderlyingNetworkInfo; import android.net.VpnManager; +import android.net.VpnProfileState; import android.net.VpnService; import android.net.VpnTransportInfo; import android.net.ipsec.ike.ChildSessionCallback; @@ -3438,6 +3439,45 @@ public class Vpn { } } + private @VpnProfileState.State int getStateFromLegacyState(int legacyState) { + switch (legacyState) { + case LegacyVpnInfo.STATE_CONNECTING: + return VpnProfileState.STATE_CONNECTING; + case LegacyVpnInfo.STATE_CONNECTED: + return VpnProfileState.STATE_CONNECTED; + case LegacyVpnInfo.STATE_DISCONNECTED: + return VpnProfileState.STATE_DISCONNECTED; + case LegacyVpnInfo.STATE_FAILED: + return VpnProfileState.STATE_FAILED; + default: + Log.wtf(TAG, "Unhandled state " + legacyState + + ", treat it as STATE_DISCONNECTED"); + return VpnProfileState.STATE_DISCONNECTED; + } + } + + private VpnProfileState makeVpnProfileState() { + // TODO: mSessionKey will be moved to Ikev2VpnRunner once aosp/2007077 is merged, so after + // merging aosp/2007077, here should check Ikev2VpnRunner is null or not. Session key will + // be null if Ikev2VpnRunner is null. + return new VpnProfileState(getStateFromLegacyState(mLegacyState), mSessionKey, mAlwaysOn, + mLockdown); + } + + /** + * Retrieve the VpnProfileState for the profile provisioned by the given package. + * + * @return the VpnProfileState with current information, or null if there was no profile + * provisioned by the given package. + */ + @Nullable + public synchronized VpnProfileState getProvisionedVpnProfileState( + @NonNull String packageName) { + requireNonNull(packageName, "No package name provided"); + enforceNotRestrictedUser(); + return isCurrentIkev2VpnLocked(packageName) ? makeVpnProfileState() : null; + } + /** * Proxy to allow testing * diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index b0997c0b2935..738e0b46d105 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -17845,14 +17845,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } else { preferenceBuilder.setPreference(PROFILE_NETWORK_PREFERENCE_DEFAULT); } - List<Integer> allowedUids = Arrays.stream( - preferentialNetworkServiceConfig.getIncludedUids()).boxed().collect( - Collectors.toList()); - List<Integer> excludedUids = Arrays.stream( - preferentialNetworkServiceConfig.getExcludedUids()).boxed().collect( - Collectors.toList()); - preferenceBuilder.setIncludedUids(allowedUids); - preferenceBuilder.setExcludedUids(excludedUids); + preferenceBuilder.setIncludedUids(preferentialNetworkServiceConfig.getIncludedUids()); + preferenceBuilder.setExcludedUids(preferentialNetworkServiceConfig.getExcludedUids()); preferenceBuilder.setPreferenceEnterpriseId( preferentialNetworkServiceConfig.getNetworkId()); diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 5ae8a5abd6eb..67b656bf2bfc 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -283,8 +283,6 @@ public final class SystemServer implements Dumpable { "com.android.server.wifi.p2p.WifiP2pService"; private static final String LOWPAN_SERVICE_CLASS = "com.android.server.lowpan.LowpanService"; - private static final String ETHERNET_SERVICE_CLASS = - "com.android.server.ethernet.EthernetService"; private static final String JOB_SCHEDULER_SERVICE_CLASS = "com.android.server.job.JobSchedulerService"; private static final String LOCK_SETTINGS_SERVICE_CLASS = @@ -1889,13 +1887,6 @@ public final class SystemServer implements Dumpable { t.traceEnd(); } - if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_ETHERNET) || - mPackageManager.hasSystemFeature(PackageManager.FEATURE_USB_HOST)) { - t.traceBegin("StartEthernet"); - mSystemServiceManager.startService(ETHERNET_SERVICE_CLASS); - t.traceEnd(); - } - t.traceBegin("StartPacProxyService"); try { pacProxyService = new PacProxyService(context); diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java index a67751d5b4bc..8225ae6071de 100644 --- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java @@ -4240,14 +4240,11 @@ public class DevicePolicyManagerTest extends DpmTestBase { dpm.setPreferentialNetworkServiceConfigs(List.of(preferentialNetworkServiceConfigEnabled)); assertThat(dpm.getPreferentialNetworkServiceConfigs().get(0) .isEnabled()).isTrue(); - List<Integer> includedList = new ArrayList<>(); - includedList.add(1); - includedList.add(2); ProfileNetworkPreference preferenceDetails = new ProfileNetworkPreference.Builder() .setPreference(PROFILE_NETWORK_PREFERENCE_ENTERPRISE_NO_FALLBACK) .setPreferenceEnterpriseId(NET_ENTERPRISE_ID_1) - .setIncludedUids(includedList) + .setIncludedUids(new int[]{1, 2}) .build(); List<ProfileNetworkPreference> preferences = new ArrayList<>(); preferences.add(preferenceDetails); @@ -4275,14 +4272,11 @@ public class DevicePolicyManagerTest extends DpmTestBase { dpm.setPreferentialNetworkServiceConfigs(List.of(preferentialNetworkServiceConfigEnabled)); assertThat(dpm.getPreferentialNetworkServiceConfigs().get(0) .isEnabled()).isTrue(); - List<Integer> excludedUids = new ArrayList<>(); - excludedUids.add(1); - excludedUids.add(2); ProfileNetworkPreference preferenceDetails = new ProfileNetworkPreference.Builder() .setPreference(PROFILE_NETWORK_PREFERENCE_ENTERPRISE_NO_FALLBACK) .setPreferenceEnterpriseId(NET_ENTERPRISE_ID_1) - .setExcludedUids(excludedUids) + .setExcludedUids(new int[]{1, 2}) .build(); List<ProfileNetworkPreference> preferences = new ArrayList<>(); preferences.clear(); diff --git a/telephony/java/android/telephony/PcoData.java b/telephony/java/android/telephony/PcoData.java index bcfbcf8bf5fa..39e4f2f799d8 100644 --- a/telephony/java/android/telephony/PcoData.java +++ b/telephony/java/android/telephony/PcoData.java @@ -19,6 +19,9 @@ package android.telephony; import android.os.Parcel; import android.os.Parcelable; +import java.util.Arrays; +import java.util.Objects; + /** * Contains Carrier-specific (and opaque) Protocol configuration Option * Data. In general this is only passed on to carrier-specific applications @@ -84,4 +87,22 @@ public class PcoData implements Parcelable { return "PcoData(" + cid + ", " + bearerProto + ", " + pcoId + ", contents[" + contents.length + "])"; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PcoData pcoData = (PcoData) o; + return cid == pcoData.cid + && pcoId == pcoData.pcoId + && Objects.equals(bearerProto, pcoData.bearerProto) + && Arrays.equals(contents, pcoData.contents); + } + + @Override + public int hashCode() { + int result = Objects.hash(cid, bearerProto, pcoId); + result = 31 * result + Arrays.hashCode(contents); + return result; + } } diff --git a/telephony/java/android/telephony/PhysicalChannelConfig.java b/telephony/java/android/telephony/PhysicalChannelConfig.java index 95448c7807cc..d91134e33ef3 100644 --- a/telephony/java/android/telephony/PhysicalChannelConfig.java +++ b/telephony/java/android/telephony/PhysicalChannelConfig.java @@ -23,12 +23,15 @@ import android.os.Parcel; import android.os.Parcelable; import android.telephony.Annotation.NetworkType; +import com.android.telephony.Rlog; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.Arrays; import java.util.Objects; public final class PhysicalChannelConfig implements Parcelable { + static final String TAG = "PhysicalChannelConfig"; // TODO(b/72993578) consolidate these enums in a central location. /** @hide */ @@ -568,19 +571,21 @@ public final class PhysicalChannelConfig implements Parcelable { public @NonNull Builder setNetworkType(@NetworkType int networkType) { if (!TelephonyManager.isNetworkTypeValid(networkType)) { - throw new IllegalArgumentException("Network type: " + networkType + " is invalid."); + Rlog.e(TAG, "Builder.setNetworkType: Network type " + networkType + " is invalid."); + } else { + mNetworkType = networkType; } - mNetworkType = networkType; return this; } public @NonNull Builder setFrequencyRange(int frequencyRange) { if (!ServiceState.isFrequencyRangeValid(frequencyRange) && frequencyRange != ServiceState.FREQUENCY_RANGE_UNKNOWN) { - throw new IllegalArgumentException("Frequency range: " + frequencyRange + - " is invalid."); + Rlog.e(TAG, "Builder.setFrequencyRange: Frequency range " + frequencyRange + + " is invalid."); + } else { + mFrequencyRange = frequencyRange; } - mFrequencyRange = frequencyRange; return this; } @@ -596,19 +601,21 @@ public final class PhysicalChannelConfig implements Parcelable { public @NonNull Builder setCellBandwidthDownlinkKhz(int cellBandwidthDownlinkKhz) { if (cellBandwidthDownlinkKhz < CELL_BANDWIDTH_UNKNOWN) { - throw new IllegalArgumentException("Cell downlink bandwidth(kHz): " + - cellBandwidthDownlinkKhz + " is invalid."); + Rlog.e(TAG, "Builder.setCellBandwidthDownlinkKhz: Cell downlink bandwidth(kHz) " + + cellBandwidthDownlinkKhz + " is invalid."); + } else { + mCellBandwidthDownlinkKhz = cellBandwidthDownlinkKhz; } - mCellBandwidthDownlinkKhz = cellBandwidthDownlinkKhz; return this; } public @NonNull Builder setCellBandwidthUplinkKhz(int cellBandwidthUplinkKhz) { if (cellBandwidthUplinkKhz < CELL_BANDWIDTH_UNKNOWN) { - throw new IllegalArgumentException("Cell uplink bandwidth(kHz): "+ - cellBandwidthUplinkKhz +" is invalid."); + Rlog.e(TAG, "Builder.setCellBandwidthUplinkKhz: Cell uplink bandwidth(kHz) " + + cellBandwidthUplinkKhz + " is invalid."); + } else { + mCellBandwidthUplinkKhz = cellBandwidthUplinkKhz; } - mCellBandwidthUplinkKhz = cellBandwidthUplinkKhz; return this; } @@ -625,19 +632,20 @@ public final class PhysicalChannelConfig implements Parcelable { public @NonNull Builder setPhysicalCellId(int physicalCellId) { if (physicalCellId > PHYSICAL_CELL_ID_MAXIMUM_VALUE) { - throw new IllegalArgumentException("Physical cell Id: " + physicalCellId + - " is over limit."); + Rlog.e(TAG, "Builder.setPhysicalCellId: Physical cell ID " + physicalCellId + + " is over limit."); + } else { + mPhysicalCellId = physicalCellId; } - mPhysicalCellId = physicalCellId; return this; } public @NonNull Builder setBand(int band) { if (band <= BAND_UNKNOWN) { - throw new IllegalArgumentException("Band: " + band + - " is invalid."); + Rlog.e(TAG, "Builder.setBand: Band " + band + " is invalid."); + } else { + mBand = band; } - mBand = band; return this; } } diff --git a/telephony/java/android/telephony/data/ApnSetting.java b/telephony/java/android/telephony/data/ApnSetting.java index cb112cf3b93a..f8540202b3bf 100644 --- a/telephony/java/android/telephony/data/ApnSetting.java +++ b/telephony/java/android/telephony/data/ApnSetting.java @@ -545,7 +545,6 @@ public class ApnSetting implements Parcelable { * Returns the profile id to which the APN saved in modem. * * @return the profile id of the APN - * @hide */ public int getProfileId() { return mProfileId; @@ -554,8 +553,7 @@ public class ApnSetting implements Parcelable { /** * Returns if the APN setting is persistent on the modem. * - * @return is the APN setting to be set in modem - * @hide + * @return {@code true} if the APN setting is persistent on the modem. */ public boolean isPersistent() { return mPersistent; diff --git a/telephony/java/android/telephony/data/DataServiceCallback.java b/telephony/java/android/telephony/data/DataServiceCallback.java index 13d8c7b9c915..ec734716f6e4 100644 --- a/telephony/java/android/telephony/data/DataServiceCallback.java +++ b/telephony/java/android/telephony/data/DataServiceCallback.java @@ -253,8 +253,10 @@ public class DataServiceCallback { return "RESULT_ERROR_BUSY"; case RESULT_ERROR_ILLEGAL_STATE: return "RESULT_ERROR_ILLEGAL_STATE"; + case RESULT_ERROR_TEMPORARILY_UNAVAILABLE: + return "RESULT_ERROR_TEMPORARILY_UNAVAILABLE"; default: - return "Missing case for result code=" + resultCode; + return "Unknown(" + resultCode + ")"; } } diff --git a/tests/BandwidthTests/src/com/android/tests/bandwidthenforcement/BandwidthEnforcementTestService.java b/tests/BandwidthTests/src/com/android/tests/bandwidthenforcement/BandwidthEnforcementTestService.java index 35f1e585931b..644d450a7a88 100644 --- a/tests/BandwidthTests/src/com/android/tests/bandwidthenforcement/BandwidthEnforcementTestService.java +++ b/tests/BandwidthTests/src/com/android/tests/bandwidthenforcement/BandwidthEnforcementTestService.java @@ -24,6 +24,8 @@ import android.net.SntpClient; import android.os.Environment; import android.util.Log; +import libcore.io.Streams; + import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; import java.io.File; @@ -37,8 +39,6 @@ import java.net.InetAddress; import java.net.URL; import java.util.Random; -import libcore.io.Streams; - /* * Test Service that tries to connect to the web via different methods and outputs the results to * the log and a output file. @@ -146,7 +146,7 @@ public class BandwidthEnforcementTestService extends IntentService { final ConnectivityManager mCM = context.getSystemService(ConnectivityManager.class); final Network network = mCM.getActiveNetwork(); - if (client.requestTime("0.pool.ntp.org", 10000, network)) { + if (client.requestTime("0.pool.ntp.org", SntpClient.STANDARD_NTP_PORT, 10000, network)) { return true; } return false; |