diff options
39 files changed, 615 insertions, 270 deletions
diff --git a/cmds/svc/src/com/android/commands/svc/BluetoothCommand.java b/cmds/svc/src/com/android/commands/svc/BluetoothCommand.java deleted file mode 100644 index b572ce24390c..000000000000 --- a/cmds/svc/src/com/android/commands/svc/BluetoothCommand.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2017 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.commands.svc; - -import android.bluetooth.BluetoothAdapter; -import android.os.RemoteException; - -public class BluetoothCommand extends Svc.Command { - - public BluetoothCommand() { - super("bluetooth"); - } - - @Override - public String shortHelp() { - return "Control Bluetooth service"; - } - - @Override - public String longHelp() { - return shortHelp() + "\n" - + "\n" - + "usage: svc bluetooth [enable|disable]\n" - + " Turn Bluetooth on or off.\n\n"; - } - - @Override - public void run(String[] args) { - BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); - - if (adapter == null) { - System.err.println("Got a null BluetoothAdapter, is the system running?"); - return; - } - - if (args.length == 2 && "enable".equals(args[1])) { - adapter.enable(); - } else if (args.length == 2 && "disable".equals(args[1])) { - adapter.disable(); - } else { - System.err.println(longHelp()); - } - } -} diff --git a/cmds/svc/src/com/android/commands/svc/Svc.java b/cmds/svc/src/com/android/commands/svc/Svc.java index 2ed2678bc877..bbad984746a1 100644 --- a/cmds/svc/src/com/android/commands/svc/Svc.java +++ b/cmds/svc/src/com/android/commands/svc/Svc.java @@ -96,7 +96,7 @@ public class Svc { // `svc wifi` has been migrated to WifiShellCommand new UsbCommand(), new NfcCommand(), - new BluetoothCommand(), + // `svc bluetooth` has been migrated to BluetoothShellCommand new SystemServerCommand(), }; } diff --git a/cmds/svc/svc b/cmds/svc/svc index 95265e817c1b..a2c9de32b3d0 100755 --- a/cmds/svc/svc +++ b/cmds/svc/svc @@ -33,6 +33,25 @@ if [ "x$1" == "xdata" ]; then exit 1 fi +# `svc bluetooth` has been migrated to BluetoothShellCommand, +# simply perform translation to `cmd bluetooth set-bluetooth-enabled` here. +if [ "x$1" == "xbluetooth" ]; then + # `cmd wifi` by convention uses enabled/disabled + # instead of enable/disable + if [ "x$2" == "xenable" ]; then + exec cmd bluetooth_manager enable + elif [ "x$2" == "xdisable" ]; then + exec cmd bluetooth_manager disable + else + echo "Control the Bluetooth manager" + echo "" + echo "usage: svc bluetooth [enable|disable]" + echo " Turn Bluetooth on or off." + echo "" + fi + exit 1 +fi + export CLASSPATH=/system/framework/svc.jar exec app_process /system/bin com.android.commands.svc.Svc "$@" diff --git a/core/api/current.txt b/core/api/current.txt index dbc2a519214e..15cf71d30040 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -41759,9 +41759,12 @@ package android.telephony { field public static final int DATA_DISCONNECTED = 0; // 0x0 field public static final int DATA_DISCONNECTING = 4; // 0x4 field public static final int DATA_ENABLED_REASON_CARRIER = 2; // 0x2 + field public static final int DATA_ENABLED_REASON_OVERRIDE = 4; // 0x4 field public static final int DATA_ENABLED_REASON_POLICY = 1; // 0x1 field public static final int DATA_ENABLED_REASON_THERMAL = 3; // 0x3 + field public static final int DATA_ENABLED_REASON_UNKNOWN = -1; // 0xffffffff field public static final int DATA_ENABLED_REASON_USER = 0; // 0x0 + field public static final int DATA_HANDOVER_IN_PROGRESS = 5; // 0x5 field public static final int DATA_SUSPENDED = 3; // 0x3 field public static final int DATA_UNKNOWN = -1; // 0xffffffff field public static final int ERI_FLASH = 2; // 0x2 @@ -42030,6 +42033,8 @@ package android.telephony.data { method public String getMmsProxyAddressAsString(); method public int getMmsProxyPort(); method public android.net.Uri getMmsc(); + method public int getMtuV4(); + method public int getMtuV6(); method public int getMvnoType(); method public int getNetworkTypeBitmask(); method public String getOperatorNumeric(); @@ -42062,6 +42067,7 @@ package android.telephony.data { field public static final int TYPE_DEFAULT = 17; // 0x11 field public static final int TYPE_DUN = 8; // 0x8 field public static final int TYPE_EMERGENCY = 512; // 0x200 + field public static final int TYPE_ENTERPRISE = 16384; // 0x4000 field public static final int TYPE_FOTA = 32; // 0x20 field public static final int TYPE_HIPRI = 16; // 0x10 field public static final int TYPE_IA = 256; // 0x100 @@ -42086,10 +42092,14 @@ package android.telephony.data { method @NonNull public android.telephony.data.ApnSetting.Builder setMmsProxyAddress(@Nullable String); method @NonNull public android.telephony.data.ApnSetting.Builder setMmsProxyPort(int); method @NonNull public android.telephony.data.ApnSetting.Builder setMmsc(@Nullable android.net.Uri); + method @NonNull public android.telephony.data.ApnSetting.Builder setMtuV4(int); + method @NonNull public android.telephony.data.ApnSetting.Builder setMtuV6(int); method @NonNull public android.telephony.data.ApnSetting.Builder setMvnoType(int); method @NonNull public android.telephony.data.ApnSetting.Builder setNetworkTypeBitmask(int); method @NonNull public android.telephony.data.ApnSetting.Builder setOperatorNumeric(@Nullable String); method @NonNull public android.telephony.data.ApnSetting.Builder setPassword(@Nullable String); + method @NonNull public android.telephony.data.ApnSetting.Builder setPersistent(boolean); + method @NonNull public android.telephony.data.ApnSetting.Builder setProfileId(int); method @NonNull public android.telephony.data.ApnSetting.Builder setProtocol(int); method @Deprecated public android.telephony.data.ApnSetting.Builder setProxyAddress(java.net.InetAddress); method @NonNull public android.telephony.data.ApnSetting.Builder setProxyAddress(@Nullable String); diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 80ee1a583aa9..bb9af143b4b4 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -7089,7 +7089,7 @@ package android.net { public final class EthernetNetworkUpdateRequest implements android.os.Parcelable { method public int describeContents(); method @NonNull public android.net.IpConfiguration getIpConfiguration(); - method @NonNull public android.net.NetworkCapabilities getNetworkCapabilities(); + 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; } @@ -7099,7 +7099,7 @@ package android.net { 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(@NonNull android.net.NetworkCapabilities); + method @NonNull public android.net.EthernetNetworkUpdateRequest.Builder setNetworkCapabilities(@Nullable android.net.NetworkCapabilities); } public final class MatchAllNetworkSpecifier extends android.net.NetworkSpecifier implements android.os.Parcelable { @@ -11999,6 +11999,7 @@ package android.telephony.data { field public static final String TYPE_DEFAULT_STRING = "default"; field public static final String TYPE_DUN_STRING = "dun"; field public static final String TYPE_EMERGENCY_STRING = "emergency"; + field public static final String TYPE_ENTERPRISE_STRING = "enterprise"; field public static final String TYPE_FOTA_STRING = "fota"; field public static final String TYPE_HIPRI_STRING = "hipri"; field public static final String TYPE_IA_STRING = "ia"; @@ -12070,21 +12071,23 @@ package android.telephony.data { public final class DataProfile implements android.os.Parcelable { method public int describeContents(); - method @NonNull public String getApn(); - method public int getAuthType(); - method public int getBearerBitmask(); + method @Deprecated @NonNull public String getApn(); + method @Nullable public android.telephony.data.ApnSetting getApnSetting(); + method @Deprecated public int getAuthType(); + method @Deprecated public int getBearerBitmask(); method @Deprecated public int getMtu(); - method public int getMtuV4(); - method public int getMtuV6(); - method @Nullable public String getPassword(); - method public int getProfileId(); - method public int getProtocolType(); - method public int getRoamingProtocolType(); - method public int getSupportedApnTypesBitmask(); + method @Deprecated public int getMtuV4(); + method @Deprecated public int getMtuV6(); + method @Deprecated @Nullable public String getPassword(); + method @Deprecated public int getProfileId(); + method @Deprecated public int getProtocolType(); + method @Deprecated public int getRoamingProtocolType(); + method @Deprecated public int getSupportedApnTypesBitmask(); + method @Nullable public android.telephony.data.TrafficDescriptor getTrafficDescriptor(); method public int getType(); - method @Nullable public String getUserName(); + method @Deprecated @Nullable public String getUserName(); method public boolean isEnabled(); - method public boolean isPersistent(); + method @Deprecated public boolean isPersistent(); method public boolean isPreferred(); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.telephony.data.DataProfile> CREATOR; @@ -12097,21 +12100,23 @@ package android.telephony.data { ctor public DataProfile.Builder(); method @NonNull public android.telephony.data.DataProfile build(); method @NonNull public android.telephony.data.DataProfile.Builder enable(boolean); - method @NonNull public android.telephony.data.DataProfile.Builder setApn(@NonNull String); - method @NonNull public android.telephony.data.DataProfile.Builder setAuthType(int); - method @NonNull public android.telephony.data.DataProfile.Builder setBearerBitmask(int); + method @Deprecated @NonNull public android.telephony.data.DataProfile.Builder setApn(@NonNull String); + method @NonNull public android.telephony.data.DataProfile.Builder setApnSetting(@NonNull android.telephony.data.ApnSetting); + method @Deprecated @NonNull public android.telephony.data.DataProfile.Builder setAuthType(int); + method @Deprecated @NonNull public android.telephony.data.DataProfile.Builder setBearerBitmask(int); method @Deprecated @NonNull public android.telephony.data.DataProfile.Builder setMtu(int); - method @NonNull public android.telephony.data.DataProfile.Builder setMtuV4(int); - method @NonNull public android.telephony.data.DataProfile.Builder setMtuV6(int); - method @NonNull public android.telephony.data.DataProfile.Builder setPassword(@NonNull String); - method @NonNull public android.telephony.data.DataProfile.Builder setPersistent(boolean); + method @Deprecated @NonNull public android.telephony.data.DataProfile.Builder setMtuV4(int); + method @Deprecated @NonNull public android.telephony.data.DataProfile.Builder setMtuV6(int); + method @Deprecated @NonNull public android.telephony.data.DataProfile.Builder setPassword(@NonNull String); + method @Deprecated @NonNull public android.telephony.data.DataProfile.Builder setPersistent(boolean); method @NonNull public android.telephony.data.DataProfile.Builder setPreferred(boolean); - method @NonNull public android.telephony.data.DataProfile.Builder setProfileId(int); - method @NonNull public android.telephony.data.DataProfile.Builder setProtocolType(int); - method @NonNull public android.telephony.data.DataProfile.Builder setRoamingProtocolType(int); - method @NonNull public android.telephony.data.DataProfile.Builder setSupportedApnTypesBitmask(int); + method @Deprecated @NonNull public android.telephony.data.DataProfile.Builder setProfileId(int); + method @Deprecated @NonNull public android.telephony.data.DataProfile.Builder setProtocolType(int); + method @Deprecated @NonNull public android.telephony.data.DataProfile.Builder setRoamingProtocolType(int); + method @Deprecated @NonNull public android.telephony.data.DataProfile.Builder setSupportedApnTypesBitmask(int); + method @NonNull public android.telephony.data.DataProfile.Builder setTrafficDescriptor(@NonNull android.telephony.data.TrafficDescriptor); method @NonNull public android.telephony.data.DataProfile.Builder setType(int); - method @NonNull public android.telephony.data.DataProfile.Builder setUserName(@NonNull String); + method @Deprecated @NonNull public android.telephony.data.DataProfile.Builder setUserName(@NonNull String); } public abstract class DataService extends android.app.Service { diff --git a/core/java/android/content/pm/IPackageInstallerSession.aidl b/core/java/android/content/pm/IPackageInstallerSession.aidl index f72288c670d9..9a7a949e3cd2 100644 --- a/core/java/android/content/pm/IPackageInstallerSession.aidl +++ b/core/java/android/content/pm/IPackageInstallerSession.aidl @@ -55,4 +55,5 @@ interface IPackageInstallerSession { int getParentSessionId(); boolean isStaged(); + int getInstallFlags(); } diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java index 3f8aedb31ea9..4030708d6a53 100644 --- a/core/java/android/content/pm/PackageInstaller.java +++ b/core/java/android/content/pm/PackageInstaller.java @@ -1432,6 +1432,18 @@ public class PackageInstaller { } /** + * @return Session's {@link SessionParams#installFlags}. + * @hide + */ + public int getInstallFlags() { + try { + return mSession.getInstallFlags(); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** * @return the session ID of the multi-package session that this belongs to or * {@link SessionInfo#INVALID_ID} if it does not belong to a multi-package session. */ diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index f54d9a76d02d..4ff26242dab2 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -1401,9 +1401,11 @@ public class PackageParser { } SigningDetails verified; if (skipVerify) { - // systemDir APKs are already trusted, save time by not verifying + // systemDir APKs are already trusted, save time by not verifying; since the signature + // is not verified and some system apps can have their V2+ signatures stripped allow + // pulling the certs from the jar signature. verified = ApkSignatureVerifier.unsafeGetCertsWithoutVerification( - apkPath, minSignatureScheme); + apkPath, SigningDetails.SignatureSchemeVersion.JAR); } else { verified = ApkSignatureVerifier.verify(apkPath, minSignatureScheme); } diff --git a/core/java/android/content/pm/parsing/ParsingPackageUtils.java b/core/java/android/content/pm/parsing/ParsingPackageUtils.java index e1d34dc3f622..dce242c9d87c 100644 --- a/core/java/android/content/pm/parsing/ParsingPackageUtils.java +++ b/core/java/android/content/pm/parsing/ParsingPackageUtils.java @@ -3038,9 +3038,11 @@ public class ParsingPackageUtils { SigningDetails verified; try { if (skipVerify) { - // systemDir APKs are already trusted, save time by not verifying + // systemDir APKs are already trusted, save time by not verifying; since the + // signature is not verified and some system apps can have their V2+ signatures + // stripped allow pulling the certs from the jar signature. verified = ApkSignatureVerifier.unsafeGetCertsWithoutVerification( - baseCodePath, minSignatureScheme); + baseCodePath, SigningDetails.SignatureSchemeVersion.JAR); } else { verified = ApkSignatureVerifier.verify(baseCodePath, minSignatureScheme); } diff --git a/core/java/android/nfc/INfcTag.aidl b/core/java/android/nfc/INfcTag.aidl index 539fd4adb0a0..e1ccc4fb740b 100644 --- a/core/java/android/nfc/INfcTag.aidl +++ b/core/java/android/nfc/INfcTag.aidl @@ -45,4 +45,7 @@ interface INfcTag boolean canMakeReadOnly(int ndefType); int getMaxTransceiveLength(int technology); boolean getExtendedLengthApdusSupported(); + + void setTagUpToDate(long cookie); + boolean isTagUpToDate(long cookie); } diff --git a/core/java/android/nfc/Tag.java b/core/java/android/nfc/Tag.java index 398ec63a931b..731d1ba78299 100644 --- a/core/java/android/nfc/Tag.java +++ b/core/java/android/nfc/Tag.java @@ -34,6 +34,7 @@ import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.os.RemoteException; +import android.os.SystemClock; import java.io.IOException; import java.util.Arrays; @@ -121,6 +122,7 @@ public final class Tag implements Parcelable { final INfcTag mTagService; // interface to NFC service, will be null if mock tag int mConnectedTechnology; + long mCookie; /** * Hidden constructor to be used by NFC service and internal classes. @@ -140,6 +142,17 @@ public final class Tag implements Parcelable { mTagService = tagService; mConnectedTechnology = -1; + mCookie = SystemClock.elapsedRealtime(); + + if (tagService == null) { + return; + } + + try { + tagService.setTagUpToDate(mCookie); + } catch (RemoteException e) { + throw e.rethrowAsRuntimeException(); + } } /** @@ -361,6 +374,22 @@ public final class Tag implements Parcelable { /** @hide */ @UnsupportedAppUsage public INfcTag getTagService() { + if (mTagService == null) { + return null; + } + + try { + if (!mTagService.isTagUpToDate(mCookie)) { + String id_str = ""; + for (int i = 0; i < mId.length; i++) { + id_str = id_str + String.format("%02X ", mId[i]); + } + String msg = "Permission Denial: Tag ( ID: " + id_str + ") is out of date"; + throw new SecurityException(msg); + } + } catch (RemoteException e) { + throw e.rethrowAsRuntimeException(); + } return mTagService; } diff --git a/core/java/android/os/IBinder.java b/core/java/android/os/IBinder.java index 010459d06e8d..9e47a708162d 100644 --- a/core/java/android/os/IBinder.java +++ b/core/java/android/os/IBinder.java @@ -293,7 +293,10 @@ public interface IBinder { * * @return Returns the result from {@link Binder#onTransact}. A successful call * generally returns true; false generally means the transaction code was not - * understood. + * understood. For a oneway call to a different process false should never be + * returned. If a oneway call is made to code in the same process (usually to + * a C++ or Rust implementation), then there are no oneway semantics, and + * false can still be returned. */ public boolean transact(int code, @NonNull Parcel data, @Nullable Parcel reply, int flags) throws RemoteException; diff --git a/core/java/android/service/dreams/OWNERS b/core/java/android/service/dreams/OWNERS index f8318054ddfc..489a5f62b49d 100644 --- a/core/java/android/service/dreams/OWNERS +++ b/core/java/android/service/dreams/OWNERS @@ -1,3 +1,8 @@ # Bug component: 78010 +brycelee@google.com dsandler@google.com +galinap@google.com +jjaggi@google.com +michaelwr@google.com +santoscordon@google.com diff --git a/core/java/android/telephony/PhoneStateListener.java b/core/java/android/telephony/PhoneStateListener.java index 5b9d69c2f9ff..e5c9adba46a9 100644 --- a/core/java/android/telephony/PhoneStateListener.java +++ b/core/java/android/telephony/PhoneStateListener.java @@ -743,6 +743,7 @@ public class PhoneStateListener { * @see TelephonyManager#DATA_CONNECTING * @see TelephonyManager#DATA_CONNECTED * @see TelephonyManager#DATA_SUSPENDED + * @see TelephonyManager#DATA_HANDOVER_IN_PROGRESS * @deprecated Use {@link TelephonyCallback.DataConnectionStateListener} instead. */ @Deprecated diff --git a/core/java/android/telephony/TelephonyCallback.java b/core/java/android/telephony/TelephonyCallback.java index 3028a6d8f97a..e8960b8e35cd 100644 --- a/core/java/android/telephony/TelephonyCallback.java +++ b/core/java/android/telephony/TelephonyCallback.java @@ -792,6 +792,7 @@ public class TelephonyCallback { * @see TelephonyManager#DATA_CONNECTING * @see TelephonyManager#DATA_CONNECTED * @see TelephonyManager#DATA_SUSPENDED + * @see TelephonyManager#DATA_HANDOVER_IN_PROGRESS */ void onDataConnectionStateChanged(@TelephonyManager.DataState int state, @Annotation.NetworkType int networkType); @@ -1408,10 +1409,11 @@ public class TelephonyCallback { * * @param enabled {@code true} if data is enabled, otherwise disabled. * @param reason Reason for data enabled/disabled. - * See {@link TelephonyManager.DataEnabledReason}. + * See {@link TelephonyManager.DataEnabledChangedReason}. */ @RequiresPermission(Manifest.permission.READ_PRECISE_PHONE_STATE) - void onDataEnabledChanged(boolean enabled, @TelephonyManager.DataEnabledReason int reason); + void onDataEnabledChanged(boolean enabled, + @TelephonyManager.DataEnabledChangedReason int reason); } /** diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 2c10d78ebd32..aa0f386c9375 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -2221,7 +2221,7 @@ <!-- Remote server that can provide NTP responses. --> <string translatable="false" name="config_ntpServer">time.android.com</string> <!-- Normal polling frequency in milliseconds --> - <integer name="config_ntpPollingInterval">86400000</integer> + <integer name="config_ntpPollingInterval">64800000</integer> <!-- Try-again polling interval in milliseconds, in case the network request failed --> <integer name="config_ntpPollingIntervalShorter">60000</integer> <!-- Number of times to try again with the shorter interval, before backing diff --git a/keystore/java/android/security/keystore2/AndroidKeyStoreProvider.java b/keystore/java/android/security/keystore2/AndroidKeyStoreProvider.java index 358104fffbf6..e5d127609b2e 100644 --- a/keystore/java/android/security/keystore2/AndroidKeyStoreProvider.java +++ b/keystore/java/android/security/keystore2/AndroidKeyStoreProvider.java @@ -83,16 +83,10 @@ public class AndroidKeyStoreProvider extends Provider { // java.security.KeyPairGenerator put("KeyPairGenerator.EC", PACKAGE_NAME + ".AndroidKeyStoreKeyPairGeneratorSpi$EC"); put("KeyPairGenerator.RSA", PACKAGE_NAME + ".AndroidKeyStoreKeyPairGeneratorSpi$RSA"); - put("KeyPairGenerator." + X25519_ALIAS, - PACKAGE_NAME + ".AndroidKeyStoreKeyPairGeneratorSpi$RSA"); - put("KeyPairGenerator." + ED25519_OID, - PACKAGE_NAME + ".AndroidKeyStoreKeyPairGeneratorSpi$RSA"); // java.security.KeyFactory putKeyFactoryImpl("EC"); putKeyFactoryImpl("RSA"); - putKeyFactoryImpl(X25519_ALIAS); - putKeyFactoryImpl(ED25519_OID); // javax.crypto.KeyGenerator put("KeyGenerator.AES", PACKAGE_NAME + ".AndroidKeyStoreKeyGeneratorSpi$AES"); diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index d9783e681a25..e69cf773d329 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -6831,7 +6831,8 @@ public class AudioManager { for (Integer format : formatsList) { int btSourceCodec = AudioSystem.audioFormatToBluetoothSourceCodec(format); if (btSourceCodec != BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID) { - codecConfigList.add(new BluetoothCodecConfig(btSourceCodec)); + codecConfigList.add( + new BluetoothCodecConfig.Builder().setCodecType(btSourceCodec).build()); } } return codecConfigList; diff --git a/packages/ConnectivityT/framework-t/src/android/net/EthernetNetworkUpdateRequest.java b/packages/ConnectivityT/framework-t/src/android/net/EthernetNetworkUpdateRequest.java index a6269711055a..43f4c40f2d27 100644 --- a/packages/ConnectivityT/framework-t/src/android/net/EthernetNetworkUpdateRequest.java +++ b/packages/ConnectivityT/framework-t/src/android/net/EthernetNetworkUpdateRequest.java @@ -24,36 +24,52 @@ import android.os.Parcelable; import java.util.Objects; -/** @hide */ +/** + * Represents a request to update an existing Ethernet interface. + * + * @see EthernetManager#updateConfiguration + * + * @hide + */ @SystemApi public final class EthernetNetworkUpdateRequest implements Parcelable { @NonNull private final IpConfiguration mIpConfig; - @NonNull + @Nullable private final NetworkCapabilities mNetworkCapabilities; + /** + * @return the new {@link IpConfiguration}. + */ @NonNull public IpConfiguration getIpConfiguration() { return new IpConfiguration(mIpConfig); } - @NonNull + /** + * Setting the {@link NetworkCapabilities} is optional in {@link EthernetNetworkUpdateRequest}. + * When set to null, the existing NetworkCapabilities are not updated. + * + * @return the new {@link NetworkCapabilities} or null. + */ + @Nullable public NetworkCapabilities getNetworkCapabilities() { - return new NetworkCapabilities(mNetworkCapabilities); + return mNetworkCapabilities == null ? null : new NetworkCapabilities(mNetworkCapabilities); } private EthernetNetworkUpdateRequest(@NonNull final IpConfiguration ipConfig, - @NonNull final NetworkCapabilities networkCapabilities) { + @Nullable final NetworkCapabilities networkCapabilities) { Objects.requireNonNull(ipConfig); - Objects.requireNonNull(networkCapabilities); - mIpConfig = new IpConfiguration(ipConfig); - mNetworkCapabilities = new NetworkCapabilities(networkCapabilities); + mIpConfig = ipConfig; + mNetworkCapabilities = networkCapabilities; } private EthernetNetworkUpdateRequest(@NonNull final Parcel source) { Objects.requireNonNull(source); - mIpConfig = IpConfiguration.CREATOR.createFromParcel(source); - mNetworkCapabilities = NetworkCapabilities.CREATOR.createFromParcel(source); + mIpConfig = source.readParcelable(IpConfiguration.class.getClassLoader(), + IpConfiguration.class); + mNetworkCapabilities = source.readParcelable(NetworkCapabilities.class.getClassLoader(), + NetworkCapabilities.class); } /** @@ -75,7 +91,8 @@ public final class EthernetNetworkUpdateRequest implements Parcelable { public Builder(@NonNull final EthernetNetworkUpdateRequest request) { Objects.requireNonNull(request); mBuilderIpConfig = new IpConfiguration(request.mIpConfig); - mBuilderNetworkCapabilities = new NetworkCapabilities(request.mNetworkCapabilities); + mBuilderNetworkCapabilities = null == request.mNetworkCapabilities + ? null : new NetworkCapabilities(request.mNetworkCapabilities); } /** @@ -85,7 +102,6 @@ public final class EthernetNetworkUpdateRequest implements Parcelable { */ @NonNull public Builder setIpConfiguration(@NonNull final IpConfiguration ipConfig) { - Objects.requireNonNull(ipConfig); mBuilderIpConfig = new IpConfiguration(ipConfig); return this; } @@ -96,9 +112,8 @@ public final class EthernetNetworkUpdateRequest implements Parcelable { * @return The builder to facilitate chaining. */ @NonNull - public Builder setNetworkCapabilities(@NonNull final NetworkCapabilities nc) { - Objects.requireNonNull(nc); - mBuilderNetworkCapabilities = new NetworkCapabilities(nc); + public Builder setNetworkCapabilities(@Nullable final NetworkCapabilities nc) { + mBuilderNetworkCapabilities = nc == null ? null : new NetworkCapabilities(nc); return this; } @@ -135,8 +150,8 @@ public final class EthernetNetworkUpdateRequest implements Parcelable { @Override public void writeToParcel(@NonNull Parcel dest, int flags) { - mIpConfig.writeToParcel(dest, flags); - mNetworkCapabilities.writeToParcel(dest, flags); + dest.writeParcelable(mIpConfig, flags); + dest.writeParcelable(mNetworkCapabilities, flags); } @Override diff --git a/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsFactory.java b/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsFactory.java index 151c90dd4155..3b93f1a1905f 100644 --- a/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsFactory.java +++ b/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsFactory.java @@ -25,9 +25,9 @@ import static android.net.NetworkStats.UID_ALL; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; -import android.net.ConnectivityManager; import android.net.NetworkStats; import android.net.UnderlyingNetworkInfo; +import android.os.ServiceSpecificException; import android.os.StrictMode; import android.os.SystemClock; @@ -35,6 +35,7 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ProcFileReader; import com.android.net.module.util.CollectionUtils; +import com.android.server.BpfNetMaps; import libcore.io.IoUtils; @@ -74,6 +75,8 @@ public class NetworkStatsFactory { private final Context mContext; + private final BpfNetMaps mBpfNetMaps; + /** * Guards persistent data access in this class * @@ -170,6 +173,7 @@ public class NetworkStatsFactory { mStatsXtIfaceFmt = new File(procRoot, "net/xt_qtaguid/iface_stat_fmt"); mStatsXtUid = new File(procRoot, "net/xt_qtaguid/stats"); mUseBpfStats = useBpfStats; + mBpfNetMaps = new BpfNetMaps(); synchronized (mPersistentDataLock) { mPersistSnapshot = new NetworkStats(SystemClock.elapsedRealtime(), -1); mTunAnd464xlatAdjustedStats = new NetworkStats(SystemClock.elapsedRealtime(), -1); @@ -297,12 +301,14 @@ public class NetworkStatsFactory { } @GuardedBy("mPersistentDataLock") - private void requestSwapActiveStatsMapLocked() { - // Do a active map stats swap. When the binder call successfully returns, - // the system server should be able to safely read and clean the inactive map - // without race problem. - final ConnectivityManager cm = mContext.getSystemService(ConnectivityManager.class); - cm.swapActiveStatsMap(); + private void requestSwapActiveStatsMapLocked() throws IOException { + try { + // Do a active map stats swap. Once the swap completes, this code + // can read and clean the inactive map without races. + mBpfNetMaps.swapActiveStatsMap(); + } catch (ServiceSpecificException e) { + throw new IOException(e); + } } /** @@ -328,11 +334,7 @@ public class NetworkStatsFactory { final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 0 /* initialSize */); if (mUseBpfStats) { - try { - requestSwapActiveStatsMapLocked(); - } catch (RuntimeException e) { - throw new IOException(e); - } + requestSwapActiveStatsMapLocked(); // Stats are always read from the inactive map, so they must be read after the // swap if (nativeReadNetworkStatsDetail(stats, mStatsXtUid.getAbsolutePath(), UID_ALL, 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 ef6f39a5c040..f8355817bf59 100644 --- a/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java +++ b/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java @@ -565,7 +565,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { return new BpfMap<U32, U8>(UID_COUNTERSET_MAP_PATH, BpfMap.BPF_F_RDWR, U32.class, U8.class); } catch (ErrnoException e) { - Log.wtf(TAG, "Cannot create uid counter set map: " + e); + Log.wtf(TAG, "Cannot open uid counter set map: " + e); return null; } } @@ -576,7 +576,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { return new BpfMap<CookieTagMapKey, CookieTagMapValue>(COOKIE_TAG_MAP_PATH, BpfMap.BPF_F_RDWR, CookieTagMapKey.class, CookieTagMapValue.class); } catch (ErrnoException e) { - Log.wtf(TAG, "Cannot create cookie tag map: " + e); + Log.wtf(TAG, "Cannot open cookie tag map: " + e); return null; } } @@ -587,7 +587,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { return new BpfMap<StatsMapKey, StatsMapValue>(STATS_MAP_A_PATH, BpfMap.BPF_F_RDWR, StatsMapKey.class, StatsMapValue.class); } catch (ErrnoException e) { - Log.wtf(TAG, "Cannot create stats map A: " + e); + Log.wtf(TAG, "Cannot open stats map A: " + e); return null; } } @@ -598,7 +598,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { return new BpfMap<StatsMapKey, StatsMapValue>(STATS_MAP_B_PATH, BpfMap.BPF_F_RDWR, StatsMapKey.class, StatsMapValue.class); } catch (ErrnoException e) { - Log.wtf(TAG, "Cannot create stats map B: " + e); + Log.wtf(TAG, "Cannot open stats map B: " + e); return null; } } @@ -609,7 +609,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { return new BpfMap<UidStatsMapKey, StatsMapValue>(APP_UID_STATS_MAP_PATH, BpfMap.BPF_F_RDWR, UidStatsMapKey.class, StatsMapValue.class); } catch (ErrnoException e) { - Log.wtf(TAG, "Cannot create app uid stats map: " + e); + Log.wtf(TAG, "Cannot open app uid stats map: " + e); return null; } } diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipSetCoordinatorProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipSetCoordinatorProfile.java index 6da249c2980e..c3f845ca8c0a 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipSetCoordinatorProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipSetCoordinatorProfile.java @@ -59,7 +59,7 @@ public class CsipSetCoordinatorProfile implements LocalBluetoothProfile { // These callbacks run on the main thread. private final class CoordinatedSetServiceListener implements BluetoothProfile.ServiceListener { - @RequiresApi(32) + @RequiresApi(33) public void onServiceConnected(int profile, BluetoothProfile proxy) { if (VDBG) { Log.d(TAG, "Bluetooth service connected"); @@ -233,7 +233,7 @@ public class CsipSetCoordinatorProfile implements LocalBluetoothProfile { return NAME; } - @RequiresApi(32) + @RequiresApi(33) protected void finalize() { if (VDBG) { Log.d(TAG, "finalize()"); diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index e1afd3fe6a30..4a7d7089d712 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -78,6 +78,18 @@ <!-- Checkbox label for USB device dialogs with warning text for USB device dialogs. [CHAR LIMIT=200]--> <string name="usb_device_permission_prompt_warn">Allow <xliff:g id="application" example= "Usb Mega Player">%1$s</xliff:g> to access <xliff:g id="usb_device" example="USB Headphones">%2$s</xliff:g>?\nThis app has not been granted record permission but could capture audio through this USB device.</string> + <!-- USB audio device permission dialog title. [CHAR LIMIT=200]--> + <string name="usb_audio_device_permission_prompt_title">Allow <xliff:g id="application" example= "Usb Mega Player">%1$s</xliff:g> to access <xliff:g id="usb_device" example="USB Headphones">%2$s</xliff:g>?</string> + + <!-- USB audio device confirm dialog title. [CHAR LIMIT=200]--> + <string name="usb_audio_device_confirm_prompt_title">Open <xliff:g id="application" example= "Usb Mega Player">%1$s</xliff:g> to handle <xliff:g id="usb_device" example="USB Headphones">%2$s</xliff:g>?</string> + + <!-- Checkbox label for USB audio device dialogs with warning text for USB audio device dialogs. [CHAR LIMIT=NONE]--> + <string name="usb_audio_device_prompt_warn">This app has not been granted record permission but could capture audio through this USB device. Using <xliff:g id="application" example= "Usb Mega Player">%1$s</xliff:g> with this device might prevent hearing calls, notifications and alarms.</string> + + <!-- Prompt for the USB audio device permission dialog [CHAR LIMIT=NONE] --> + <string name="usb_audio_device_prompt">Using <xliff:g id="application" example= "Usb Mega Player">%1$s</xliff:g> with this device might prevent hearing calls, notifications and alarms.</string> + <!-- Prompt for the USB accessory permission dialog [CHAR LIMIT=80] --> <string name="usb_accessory_permission_prompt">Allow <xliff:g id="application" example= "Usb Mega Player">%1$s</xliff:g> to access <xliff:g id="usb_accessory" example="USB Dock">%2$s</xliff:g>?</string> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt index 12258136c011..67985b95dda4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt @@ -21,7 +21,7 @@ import android.app.IActivityManager import android.app.IUidObserver import android.app.Notification import android.app.Notification.CallStyle.CALL_TYPE_ONGOING -import android.content.Intent +import android.app.PendingIntent import android.util.Log import android.view.View import androidx.annotation.VisibleForTesting @@ -98,7 +98,7 @@ class OngoingCallController @Inject constructor( val newOngoingCallInfo = CallNotificationInfo( entry.sbn.key, entry.sbn.notification.`when`, - entry.sbn.notification.contentIntent?.intent, + entry.sbn.notification.contentIntent, entry.sbn.uid, entry.sbn.notification.extras.getInt( Notification.EXTRA_CALL_TYPE, -1) == CALL_TYPE_ONGOING, @@ -230,7 +230,6 @@ class OngoingCallController @Inject constructor( logger.logChipClicked() activityStarter.postStartActivityDismissingKeyguard( intent, - 0, ActivityLaunchAnimator.Controller.fromView( backgroundView, InteractionJankMonitor.CUJ_STATUS_BAR_APP_LAUNCH_FROM_CALL_CHIP) @@ -351,7 +350,7 @@ class OngoingCallController @Inject constructor( private data class CallNotificationInfo( val key: String, val callStartTime: Long, - val intent: Intent?, + val intent: PendingIntent?, val uid: Int, /** True if the call is currently ongoing (as opposed to incoming, screening, etc.). */ val isOngoing: Boolean, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt index b385b7d62cff..45c6be936eb9 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt @@ -22,7 +22,6 @@ import android.app.IUidObserver import android.app.Notification import android.app.PendingIntent import android.app.Person -import android.content.Intent import android.service.notification.NotificationListenerService.REASON_USER_STOPPED import android.testing.AndroidTestingRunner import android.testing.TestableLooper @@ -429,6 +428,19 @@ class OngoingCallControllerTest : SysuiTestCase() { .isEqualTo(OngoingCallLogger.OngoingCallEvents.ONGOING_CALL_CLICKED.id) } + /** Regression test for b/212467440. */ + @Test + fun chipClicked_activityStarterTriggeredWithUnmodifiedIntent() { + val notifEntry = createOngoingCallNotifEntry() + val pendingIntent = notifEntry.sbn.notification.contentIntent + notifCollectionListener.onEntryUpdated(notifEntry) + + chipView.performClick() + + // Ensure that the sysui didn't modify the notification's intent -- see b/212467440. + verify(mockActivityStarter).postStartActivityDismissingKeyguard(eq(pendingIntent), any()) + } + @Test fun notifyChipVisibilityChanged_visibleEventLogged() { controller.notifyChipVisibilityChanged(true) @@ -570,7 +582,6 @@ class OngoingCallControllerTest : SysuiTestCase() { notificationEntryBuilder.modifyNotification(context).setContentIntent(null) } else { val contentIntent = mock(PendingIntent::class.java) - `when`(contentIntent.intent).thenReturn(mock(Intent::class.java)) notificationEntryBuilder.modifyNotification(context).setContentIntent(contentIntent) } diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java index b59cd4c0f212..1a39ffa393b3 100644 --- a/services/core/java/com/android/server/NetworkManagementService.java +++ b/services/core/java/com/android/server/NetworkManagementService.java @@ -1166,9 +1166,17 @@ public class NetworkManagementService extends INetworkManagementService.Stub { final ConnectivityManager cm = mContext.getSystemService(ConnectivityManager.class); try { if (allowlist) { - cm.updateMeteredNetworkAllowList(uid, enable); + if (enable) { + cm.addUidToMeteredNetworkAllowList(uid); + } else { + cm.removeUidFromMeteredNetworkAllowList(uid); + } } else { - cm.updateMeteredNetworkDenyList(uid, enable); + if (enable) { + cm.addUidToMeteredNetworkDenyList(uid); + } else { + cm.removeUidFromMeteredNetworkDenyList(uid); + } } synchronized (mRulesLock) { if (enable) { diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 9f59a5fc7253..3e0f26132d7e 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -13813,14 +13813,26 @@ public class ActivityManagerService extends IActivityManager.Stub return false; } - if (!Build.IS_DEBUGGABLE) { - int match = mContext.getPackageManager().checkSignatures( - ii.targetPackage, ii.packageName); - if (match < 0 && match != PackageManager.SIGNATURE_FIRST_NOT_SIGNED) { + int match = mContext.getPackageManager().checkSignatures( + ii.targetPackage, ii.packageName); + if (match < 0 && match != PackageManager.SIGNATURE_FIRST_NOT_SIGNED) { + if (Build.IS_DEBUGGABLE) { + String message = "Instrumentation test " + ii.packageName + + " doesn't have a signature matching the target " + + ii.targetPackage + + ", which would not be allowed on the production Android builds"; + if (callingUid != Process.ROOT_UID) { + Slog.e(TAG, message + + ". THIS WILL BE DISALLOWED ON FUTURE ANDROID VERSIONS" + + " unless from a rooted ADB shell."); + } else { + Slog.w(TAG, message); + } + } else { String msg = "Permission Denial: starting instrumentation " + className + " from pid=" + Binder.getCallingPid() - + ", uid=" + Binder.getCallingPid() + + ", uid=" + Binder.getCallingUid() + " not allowed because package " + ii.packageName + " does not have a signature matching the target " + ii.targetPackage; diff --git a/services/core/java/com/android/server/clipboard/EmulatorClipboardMonitor.java b/services/core/java/com/android/server/clipboard/EmulatorClipboardMonitor.java index 11c451e01d4c..28c7cad3b184 100644 --- a/services/core/java/com/android/server/clipboard/EmulatorClipboardMonitor.java +++ b/services/core/java/com/android/server/clipboard/EmulatorClipboardMonitor.java @@ -54,8 +54,8 @@ class EmulatorClipboardMonitor implements Consumer<ClipData> { return bits; } - private boolean isPipeOpened() { - return mPipe != null; + private synchronized FileDescriptor getPipeFD() { + return mPipe; } private synchronized boolean openPipe() { @@ -107,14 +107,16 @@ class EmulatorClipboardMonitor implements Consumer<ClipData> { return msg; } - private void sendMessage(final byte[] msg) throws ErrnoException, InterruptedIOException { + private static void sendMessage( + final FileDescriptor fd, + final byte[] msg) throws ErrnoException, InterruptedIOException { final byte[] lengthBits = new byte[4]; final ByteBuffer bb = ByteBuffer.wrap(lengthBits); bb.order(ByteOrder.LITTLE_ENDIAN); bb.putInt(msg.length); - Os.write(mPipe, lengthBits, 0, lengthBits.length); - Os.write(mPipe, msg, 0, msg.length); + Os.write(fd, lengthBits, 0, lengthBits.length); + Os.write(fd, msg, 0, msg.length); } EmulatorClipboardMonitor(final Consumer<ClipData> setAndroidClipboard) { @@ -162,17 +164,22 @@ class EmulatorClipboardMonitor implements Consumer<ClipData> { } private void setHostClipboardImpl(final String value) { - if (LOG_CLIBOARD_ACCESS) { - Slog.i(TAG, "Setting the host clipboard to '" + value + "'"); - } + final FileDescriptor pipeFD = getPipeFD(); - try { - if (isPipeOpened()) { - sendMessage(value.getBytes()); - } - } catch (ErrnoException | InterruptedIOException e) { - Slog.e(TAG, "Failed to set host clipboard " + e.getMessage()); - } catch (IllegalArgumentException e) { + if (pipeFD != null) { + Thread t = new Thread(() -> { + if (LOG_CLIBOARD_ACCESS) { + Slog.i(TAG, "Setting the host clipboard to '" + value + "'"); + } + + try { + sendMessage(pipeFD, value.getBytes()); + } catch (ErrnoException | InterruptedIOException e) { + Slog.e(TAG, "Failed to set host clipboard " + e.getMessage()); + } catch (IllegalArgumentException e) { + } + }); + t.start(); } } } diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java index d0e445749698..3ddcf17d0a47 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerSession.java +++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java @@ -126,6 +126,7 @@ import android.system.StructStat; import android.text.TextUtils; import android.util.ArrayMap; import android.util.ArraySet; +import android.util.EventLog; import android.util.ExceptionUtils; import android.util.MathUtils; import android.util.Slog; @@ -3097,6 +3098,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { if (mResolvedBaseFile == null) { mResolvedBaseFile = new File(appInfo.getBaseCodePath()); inheritFileLocked(mResolvedBaseFile); + } else if ((params.installFlags & PackageManager.INSTALL_DONT_KILL_APP) != 0) { + EventLog.writeEvent(0x534e4554, "219044664"); + + // Installing base.apk. Make sure the app is restarted. + params.setDontKillApp(false); } // Inherit splits if not overridden. @@ -3743,6 +3749,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { } @Override + public int getInstallFlags() { + return params.installFlags; + } + + @Override public DataLoaderParamsParcel getDataLoaderParams() { mContext.enforceCallingOrSelfPermission(Manifest.permission.USE_INSTALLER_V2, null); return params.dataLoaderParams != null ? params.dataLoaderParams.getData() : null; diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index a0f3d66aac6d..94dd4beeab9b 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -15176,15 +15176,17 @@ public class PackageManagerService extends IPackageManager.Stub } } - // Ensure the package is signed with at least the minimum signature scheme version - // required for its target SDK. - int minSignatureSchemeVersion = - ApkSignatureVerifier.getMinimumSignatureSchemeVersionForTargetSdk( - pkg.getTargetSdkVersion()); - if (pkg.getSigningDetails().signatureSchemeVersion < minSignatureSchemeVersion) { - throw new PackageManagerException(INSTALL_PARSE_FAILED_NO_CERTIFICATES, - "No signature found in package of version " + minSignatureSchemeVersion - + " or newer for package " + pkg.getPackageName()); + // If the package is not on a system partition ensure it is signed with at least the + // minimum signature scheme version required for its target SDK. + if ((parseFlags & ParsingPackageUtils.PARSE_IS_SYSTEM_DIR) == 0) { + int minSignatureSchemeVersion = + ApkSignatureVerifier.getMinimumSignatureSchemeVersionForTargetSdk( + pkg.getTargetSdkVersion()); + if (pkg.getSigningDetails().signatureSchemeVersion < minSignatureSchemeVersion) { + throw new PackageManagerException(INSTALL_PARSE_FAILED_NO_CERTIFICATES, + "No signature found in package of version " + minSignatureSchemeVersion + + " or newer for package " + pkg.getPackageName()); + } } } } diff --git a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java index 5b4084e9b229..265e6062f1d6 100644 --- a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java +++ b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java @@ -129,6 +129,7 @@ import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Set; import java.util.WeakHashMap; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; @@ -142,6 +143,10 @@ class PackageManagerShellCommand extends ShellCommand { private final static String ART_PROFILE_SNAPSHOT_DEBUG_LOCATION = "/data/misc/profman/"; private static final int DEFAULT_STAGED_READY_TIMEOUT_MS = 60 * 1000; private static final String TAG = "PackageManagerShellCommand"; + private static final Set<String> UNSUPPORTED_INSTALL_CMD_OPTS = Set.of( + "--multi-package" + ); + private static final Set<String> UNSUPPORTED_SESSION_CREATE_OPTS = Collections.emptySet(); final IPackageManager mInterface; final LegacyPermissionManagerInternal mLegacyPermissionManager; @@ -1282,7 +1287,7 @@ class PackageManagerShellCommand extends ShellCommand { } private int runStreamingInstall() throws RemoteException { - final InstallParams params = makeInstallParams(); + final InstallParams params = makeInstallParams(UNSUPPORTED_INSTALL_CMD_OPTS); if (params.sessionParams.dataLoaderParams == null) { params.sessionParams.setDataLoaderParams( PackageManagerShellCommandDataLoader.getStreamingDataLoaderParams(this)); @@ -1291,7 +1296,7 @@ class PackageManagerShellCommand extends ShellCommand { } private int runIncrementalInstall() throws RemoteException { - final InstallParams params = makeInstallParams(); + final InstallParams params = makeInstallParams(UNSUPPORTED_INSTALL_CMD_OPTS); if (params.sessionParams.dataLoaderParams == null) { params.sessionParams.setDataLoaderParams( PackageManagerShellCommandDataLoader.getIncrementalDataLoaderParams(this)); @@ -1300,7 +1305,7 @@ class PackageManagerShellCommand extends ShellCommand { } private int runInstall() throws RemoteException { - return doRunInstall(makeInstallParams()); + return doRunInstall(makeInstallParams(UNSUPPORTED_INSTALL_CMD_OPTS)); } private int doRunInstall(final InstallParams params) throws RemoteException { @@ -1452,7 +1457,7 @@ class PackageManagerShellCommand extends ShellCommand { private int runInstallCreate() throws RemoteException { final PrintWriter pw = getOutPrintWriter(); - final InstallParams installParams = makeInstallParams(); + final InstallParams installParams = makeInstallParams(UNSUPPORTED_SESSION_CREATE_OPTS); final int sessionId = doCreateSession(installParams.sessionParams, installParams.installerPackageName, installParams.userId); @@ -2764,7 +2769,7 @@ class PackageManagerShellCommand extends ShellCommand { long stagedReadyTimeoutMs = DEFAULT_STAGED_READY_TIMEOUT_MS; } - private InstallParams makeInstallParams() { + private InstallParams makeInstallParams(Set<String> unsupportedOptions) { final SessionParams sessionParams = new SessionParams(SessionParams.MODE_FULL_INSTALL); final InstallParams params = new InstallParams(); @@ -2776,6 +2781,9 @@ class PackageManagerShellCommand extends ShellCommand { boolean replaceExisting = true; boolean forceNonStaged = false; while ((opt = getNextOption()) != null) { + if (unsupportedOptions.contains(opt)) { + throw new IllegalArgumentException("Unsupported option " + opt); + } switch (opt) { case "-r": // ignore break; @@ -3674,7 +3682,7 @@ class PackageManagerShellCommand extends ShellCommand { pw.println(" [--user USER_ID] INTENT"); pw.println(" Prints all broadcast receivers that can handle the given INTENT."); pw.println(""); - pw.println(" install [-rtfdgw] [-i PACKAGE] [--user USER_ID|all|current]"); + pw.println(" install [-rtfdg] [-i PACKAGE] [--user USER_ID|all|current]"); pw.println(" [-p INHERIT_PACKAGE] [--install-location 0/1/2]"); pw.println(" [--install-reason 0/1/2/3/4] [--originating-uri URI]"); pw.println(" [--referrer URI] [--abi ABI_NAME] [--force-sdk]"); diff --git a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java index c5f990d52b82..66e840b5120b 100644 --- a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java +++ b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java @@ -112,7 +112,7 @@ public final class ProfcollectForwardingService extends SystemService { try { mIProfcollect.registerProviderStatusCallback(mProviderStatusCallback); } catch (RemoteException e) { - Log.e(LOG_TAG, e.getMessage()); + Log.e(LOG_TAG, "Failed to register provider status callback: " + e.getMessage()); } } @@ -123,7 +123,7 @@ public final class ProfcollectForwardingService extends SystemService { try { return !mIProfcollect.get_supported_provider().isEmpty(); } catch (RemoteException e) { - Log.e(LOG_TAG, e.getMessage()); + Log.e(LOG_TAG, "Failed to get supported provider: " + e.getMessage()); return false; } } @@ -219,7 +219,8 @@ public final class ProfcollectForwardingService extends SystemService { try { sSelfService.mIProfcollect.process(); } catch (RemoteException e) { - Log.e(LOG_TAG, e.getMessage()); + Log.e(LOG_TAG, "Failed to process profiles in background: " + + e.getMessage()); } }); return true; @@ -234,8 +235,11 @@ public final class ProfcollectForwardingService extends SystemService { // Event observers private void registerObservers() { - registerAppLaunchObserver(); - registerOTAObserver(); + BackgroundThread.get().getThreadHandler().post( + () -> { + registerAppLaunchObserver(); + registerOTAObserver(); + }); } private final AppLaunchObserver mAppLaunchObserver = new AppLaunchObserver(); @@ -264,7 +268,7 @@ public final class ProfcollectForwardingService extends SystemService { try { mIProfcollect.trace_once("applaunch"); } catch (RemoteException e) { - Log.e(LOG_TAG, e.getMessage()); + Log.e(LOG_TAG, "Failed to initiate trace: " + e.getMessage()); } }); } @@ -348,7 +352,7 @@ public final class ProfcollectForwardingService extends SystemService { .putExtra("filename", reportName); context.sendBroadcast(intent); } catch (RemoteException e) { - Log.e(LOG_TAG, e.getMessage()); + Log.e(LOG_TAG, "Failed to upload report: " + e.getMessage()); } }); } diff --git a/telephony/java/android/telephony/AccessNetworkConstants.java b/telephony/java/android/telephony/AccessNetworkConstants.java index 1d7a4761dec6..4469ffc14447 100644 --- a/telephony/java/android/telephony/AccessNetworkConstants.java +++ b/telephony/java/android/telephony/AccessNetworkConstants.java @@ -17,6 +17,7 @@ package android.telephony; import android.annotation.IntDef; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.hardware.radio.V1_5.AccessNetwork; @@ -28,6 +29,8 @@ import java.lang.annotation.RetentionPolicy; */ public final class AccessNetworkConstants { + private static final String TAG = AccessNetworkConstants.class.getSimpleName(); + /** * Wireless transportation type * @@ -108,6 +111,21 @@ public final class AccessNetworkConstants { default: return Integer.toString(type); } } + + /** @hide */ + public static @RadioAccessNetworkType int fromString(@NonNull String str) { + switch (str.toUpperCase()) { + case "GERAN" : return GERAN; + case "UTRAN" : return UTRAN; + case "EUTRAN" : return EUTRAN; + case "CDMA2000" : return CDMA2000; + case "IWLAN" : return IWLAN; + case "NGRAN" : return NGRAN; + default: + Rlog.e(TAG, "Invalid access network type " + str); + return UNKNOWN; + } + } } /** diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index 3fe34920d83b..b3a3a5348692 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -48,6 +48,7 @@ import android.telephony.ims.feature.RcsFeature; import com.android.internal.telephony.ICarrierConfigLoader; import com.android.telephony.Rlog; +import java.util.List; import java.util.concurrent.TimeUnit; /** @@ -559,9 +560,9 @@ public class CarrierConfigManager { KEY_DISABLE_CDMA_ACTIVATION_CODE_BOOL = "disable_cdma_activation_code_bool"; /** - * List of RIL radio technologies (See {@link ServiceState} {@code RIL_RADIO_TECHNOLOGY_*} - * constants) which support only a single data connection at a time. Some carriers do not - * support multiple pdp on UMTS. + * List of network type constants which support only a single data connection at a time. + * Some carriers do not support multiple PDP on UMTS. + * @see TelephonyManager NETWORK_TYPE_* */ public static final String KEY_ONLY_SINGLE_DC_ALLOWED_INT_ARRAY = "only_single_dc_allowed_int_array"; @@ -3669,11 +3670,19 @@ public class CarrierConfigManager { public static final String KEY_5G_WATCHDOG_TIME_MS_LONG = "5g_watchdog_time_ms_long"; /** - * Which NR types are unmetered. A string array containing the following keys: + * Which network types are unmetered. A string array that can contain network type names from + * {@link TelephonyManager#getNetworkTypeName(int)} in addition to the following NR keys: * NR_NSA - NR NSA is unmetered for sub-6 frequencies * NR_NSA_MMWAVE - NR NSA is unmetered for mmwave frequencies * NR_SA - NR SA is unmetered for sub-6 frequencies * NR_SA_MMWAVE - NR SA is unmetered for mmwave frequencies + * + * Note that this config only applies if an unmetered SubscriptionPlan is set via + * {@link SubscriptionManager#setSubscriptionPlans(int, List)} or an unmetered override is set + * via {@link SubscriptionManager#setSubscriptionOverrideUnmetered(int, boolean, int[], long)} + * or {@link SubscriptionManager#setSubscriptionOverrideUnmetered(int, boolean, long)}. + * If neither SubscriptionPlans nor an override are set, then no network types can be unmetered + * regardless of the value of this config. * TODO: remove other unmetered keys and replace with this * @hide */ @@ -3681,6 +3690,27 @@ public class CarrierConfigManager { "unmetered_network_types_string_array"; /** + * Which network types are unmetered when roaming. A string array that can contain network type + * names from {@link TelephonyManager#getNetworkTypeName(int)} in addition to the following + * NR keys: + * NR_NSA - NR NSA is unmetered when roaming for sub-6 frequencies + * NR_NSA_MMWAVE - NR NSA is unmetered when roaming for mmwave frequencies + * NR_SA - NR SA is unmetered when roaming for sub-6 frequencies + * NR_SA_MMWAVE - NR SA is unmetered when roaming for mmwave frequencies + * + * Note that this config only applies if an unmetered SubscriptionPlan is set via + * {@link SubscriptionManager#setSubscriptionPlans(int, List)} or an unmetered override is set + * via {@link SubscriptionManager#setSubscriptionOverrideUnmetered(int, boolean, int[], long)} + * or {@link SubscriptionManager#setSubscriptionOverrideUnmetered(int, boolean, long)}. + * If neither SubscriptionPlans nor an override are set, then no network types can be unmetered + * when roaming regardless of the value of this config. + * TODO: remove KEY_UNMETERED_NR_NSA_WHEN_ROAMING_BOOL and replace with this + * @hide + */ + public static final String KEY_ROAMING_UNMETERED_NETWORK_TYPES_STRING_ARRAY = + "roaming_unmetered_network_types_string_array"; + + /** * Whether NR (non-standalone) should be unmetered for all frequencies. * If either {@link #KEY_UNMETERED_NR_NSA_MMWAVE_BOOL} or * {@link #KEY_UNMETERED_NR_NSA_SUB6_BOOL} are true, then this value will be ignored. @@ -5512,7 +5542,7 @@ public class CarrierConfigManager { "telephony_network_capability_priorities_string_array"; /** - * Defines the rules for data retry. + * Defines the rules for data setup retry. * * The syntax of the retry rule: * 1. Retry based on {@link NetworkCapabilities}. Note that only APN-type network capabilities @@ -5544,8 +5574,34 @@ public class CarrierConfigManager { * // TODO: remove KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS * @hide */ - public static final String KEY_TELEPHONY_DATA_RETRY_RULES_STRING_ARRAY = - "telephony_data_retry_rules_string_array"; + public static final String KEY_TELEPHONY_DATA_SETUP_RETRY_RULES_STRING_ARRAY = + "telephony_data_setup_retry_rules_string_array"; + + /** + * Defines the rules for data handover retry. + * + * The syntax of the retry rule: + * 1. Retry when handover fails. + * "retry_interval=[n1|n2|n3|...], [maximum_retries=n]" + * + * For example, + * "retry_interval=1000|3000|5000, maximum_retries=10" means handover retry will happen in 1s, + * 3s, 5s, 5s, 5s....up to 10 times. + * + * 2. Retry when handover fails with certain fail causes. + * "retry_interval=[n1|n2|n3|...], fail_causes=[cause1|cause2|cause3|...], [maximum_retries=n] + * + * For example, + * "retry_interval=1000, maximum_retries=3, fail_causes=5" means handover retry every 1 second + * for up to 3 times when handover fails with the cause 5. + * + * "maximum_retries=0, fail_causes=6|10|67" means handover retry should not happen for those + * causes. + * + * @hide + */ + public static final String KEY_TELEPHONY_DATA_HANDOVER_RETRY_RULES_STRING_ARRAY = + "telephony_data_handover_retry_rules_string_array"; /** * The patterns of missed incoming call sms. This is the regular expression used for @@ -5730,6 +5786,34 @@ public class CarrierConfigManager { public static final String KEY_UNTHROTTLE_DATA_RETRY_WHEN_TAC_CHANGES_BOOL = "unthrottle_data_retry_when_tac_changes_bool"; + /** + * IWLAN handover rules that determine whether handover is allowed or disallowed between + * cellular and IWLAN. + * + * The handover rules will be matched in the order. Here are some sample rules. + * <string-array name="iwlan_handover_rules" num="5"> + * <!-- Handover from IWLAN to 2G/3G is not allowed --> + * <item value="source=IWLAN, target=GERAN|UTRAN, type=disallowed"/> + * <!-- Handover from 2G/3G to IWLAN is not allowed --> + * <item value="source=GERAN|UTRAN, target:IWLAN, type=disallowed"/> + * <!-- Handover from IWLAN to 3G/4G/5G is not allowed if the device is roaming. --> + * <item value="source=IWLAN, target=UTRAN|EUTRAN|NGRAN, roaming=true, type=disallowed"/> + * <!-- Handover from 4G to IWLAN is not allowed --> + * <item value="source=EUTRAN, target=IWLAN, type=disallowed"/> + * <!-- Handover is always allowed in any condition. --> + * <item value="source=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN, + * target=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN, type=allowed"/> + * </string-array> + * + * When handover is not allowed, frameworks will tear down the data network on source transport, + * and then setup a new one on the target transport when Qualified Network Service changes the + * preferred access networks for particular APN types. + * + * @hide + */ + public static final String KEY_IWLAN_HANDOVER_POLICY_STRING_ARRAY = + "iwlan_handover_policy_string_array"; + /** The default value for every variable. */ private final static PersistableBundle sDefaults; @@ -5878,7 +5962,7 @@ public class CarrierConfigManager { "others:max_retries=3, 5000, 5000, 5000"}); sDefaults.putLong(KEY_CARRIER_DATA_CALL_APN_DELAY_DEFAULT_LONG, 20000); sDefaults.putLong(KEY_CARRIER_DATA_CALL_APN_DELAY_FASTER_LONG, 3000); - sDefaults.putLong(KEY_CARRIER_DATA_CALL_APN_RETRY_AFTER_DISCONNECT_LONG, 10000); + sDefaults.putLong(KEY_CARRIER_DATA_CALL_APN_RETRY_AFTER_DISCONNECT_LONG, 3000); sDefaults.putInt(KEY_CARRIER_DATA_CALL_RETRY_NETWORK_REQUESTED_MAX_COUNT_INT, 3); sDefaults.putString(KEY_CARRIER_ERI_FILE_NAME_STRING, "eri.xml"); sDefaults.putInt(KEY_DURATION_BLOCKING_DISABLED_AFTER_EMERGENCY_INT, 7200); @@ -5891,14 +5975,9 @@ public class CarrierConfigManager { sDefaults.putStringArray(KEY_CARRIER_WLAN_DISALLOWED_APN_TYPES_STRING_ARRAY, new String[]{""}); sDefaults.putIntArray(KEY_ONLY_SINGLE_DC_ALLOWED_INT_ARRAY, - new int[]{ - 4, /* IS95A */ - 5, /* IS95B */ - 6, /* 1xRTT */ - 7, /* EVDO_0 */ - 8, /* EVDO_A */ - 12 /* EVDO_B */ - }); + new int[] {TelephonyManager.NETWORK_TYPE_CDMA, TelephonyManager.NETWORK_TYPE_1xRTT, + TelephonyManager.NETWORK_TYPE_EVDO_0, TelephonyManager.NETWORK_TYPE_EVDO_A, + TelephonyManager.NETWORK_TYPE_EVDO_B}); sDefaults.putStringArray(KEY_GSM_ROAMING_NETWORKS_STRING_ARRAY, null); sDefaults.putStringArray(KEY_GSM_NONROAMING_NETWORKS_STRING_ARRAY, null); sDefaults.putString(KEY_CONFIG_IMS_PACKAGE_OVERRIDE_STRING, null); @@ -6241,7 +6320,9 @@ public class CarrierConfigManager { sDefaults.putInt(KEY_NR_ADVANCED_CAPABLE_PCO_ID_INT, 0); sDefaults.putBoolean(KEY_ENABLE_NR_ADVANCED_WHILE_ROAMING_BOOL, true); sDefaults.putBoolean(KEY_LTE_ENDC_USING_USER_DATA_FOR_RRC_DETECTION_BOOL, false); - sDefaults.putStringArray(KEY_UNMETERED_NETWORK_TYPES_STRING_ARRAY, new String[0]); + sDefaults.putStringArray(KEY_UNMETERED_NETWORK_TYPES_STRING_ARRAY, new String[] { + "NR_NSA", "NR_NSA_MMWAVE", "NR_SA", "NR_SA_MMWAVE"}); + sDefaults.putStringArray(KEY_ROAMING_UNMETERED_NETWORK_TYPES_STRING_ARRAY, new String[0]); sDefaults.putBoolean(KEY_UNMETERED_NR_NSA_BOOL, false); sDefaults.putBoolean(KEY_UNMETERED_NR_NSA_MMWAVE_BOOL, false); sDefaults.putBoolean(KEY_UNMETERED_NR_NSA_SUB6_BOOL, false); @@ -6349,15 +6430,19 @@ public class CarrierConfigManager { "ims:40", "dun:30", "enterprise:20", "internet:20" }); sDefaults.putStringArray( - KEY_TELEPHONY_DATA_RETRY_RULES_STRING_ARRAY, new String[] { + KEY_TELEPHONY_DATA_SETUP_RETRY_RULES_STRING_ARRAY, new String[] { "capabilities=eims, retry_interval=1000, maximum_retries=20", - "fail_causes=8|27|28|29|30|32|33|35|50|51|111|-5|-6|65537|65538|-3|2253|" - + "2254, maximum_retries=0", // No retry for those causes + "fail_causes=8|27|28|29|30|32|33|35|50|51|111|-5|-6|65537|65538|-3|2252|" + + "2253|2254, maximum_retries=0", // No retry for those causes "capabilities=mms|supl|cbs, retry_interval=2000", "capabilities=internet|enterprise|dun|ims|fota, retry_interval=2500|3000|" + "5000|10000|15000|20000|40000|60000|120000|240000|" + "600000|1200000|1800000, maximum_retries=20" }); + sDefaults.putStringArray( + KEY_TELEPHONY_DATA_HANDOVER_RETRY_RULES_STRING_ARRAY, new String[] { + "retry_interval=1000|2000|4000|8000|16000, maximum_retries=5" + }); sDefaults.putStringArray(KEY_MISSED_INCOMING_CALL_SMS_PATTERN_STRING_ARRAY, new String[0]); sDefaults.putBoolean(KEY_DISABLE_DUN_APN_WHILE_ROAMING_WITH_PRESET_APN_BOOL, false); sDefaults.putString(KEY_DEFAULT_PREFERRED_APN_NAME_STRING, ""); @@ -6378,6 +6463,9 @@ public class CarrierConfigManager { sDefaults.putBoolean(KEY_UNTHROTTLE_DATA_RETRY_WHEN_TAC_CHANGES_BOOL, false); sDefaults.putBoolean(KEY_VONR_SETTING_VISIBILITY_BOOL, true); sDefaults.putBoolean(KEY_VONR_ENABLED_BOOL, false); + sDefaults.putStringArray(KEY_IWLAN_HANDOVER_POLICY_STRING_ARRAY, new String[]{ + "source=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN, " + + "target=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN, type=allowed"}); } /** diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 390ffc751498..63ff2324d385 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -5985,6 +5985,7 @@ public class TelephonyManager { DATA_CONNECTED, DATA_SUSPENDED, DATA_DISCONNECTING, + DATA_HANDOVER_IN_PROGRESS, }) @Retention(RetentionPolicy.SOURCE) public @interface DataState{} @@ -6009,6 +6010,12 @@ public class TelephonyManager { public static final int DATA_DISCONNECTING = 4; /** + * Data connection state: Handover in progress. The connection is being transited from cellular + * network to IWLAN, or from IWLAN to cellular network. + */ + public static final int DATA_HANDOVER_IN_PROGRESS = 5; + + /** * Used for checking if the SDK version for {@link TelephonyManager#getDataState} is above Q. */ @ChangeId @@ -6024,6 +6031,7 @@ public class TelephonyManager { * @see #DATA_CONNECTED * @see #DATA_SUSPENDED * @see #DATA_DISCONNECTING + * @see #DATA_HANDOVER_IN_PROGRESS */ public int getDataState() { try { @@ -12534,6 +12542,25 @@ public class TelephonyManager { @Retention(RetentionPolicy.SOURCE) public @interface DataEnabledReason{} + /** @hide */ + @IntDef({ + DATA_ENABLED_REASON_UNKNOWN, + DATA_ENABLED_REASON_USER, + DATA_ENABLED_REASON_POLICY, + DATA_ENABLED_REASON_CARRIER, + DATA_ENABLED_REASON_THERMAL, + DATA_ENABLED_REASON_OVERRIDE + }) + @Retention(RetentionPolicy.SOURCE) + public @interface DataEnabledChangedReason{} + + /** + * To indicate that data was enabled or disabled due to an unknown reason. + * Note that this is not a valid reason for {@link #setDataEnabledForReason(int, boolean)} and + * is only used to indicate that data enabled was changed. + */ + public static final int DATA_ENABLED_REASON_UNKNOWN = -1; + /** * To indicate that user enabled or disabled data. */ @@ -12561,6 +12588,13 @@ public class TelephonyManager { public static final int DATA_ENABLED_REASON_THERMAL = 3; /** + * To indicate data was enabled or disabled due to {@link MobileDataPolicy} overrides. + * Note that this is not a valid reason for {@link #setDataEnabledForReason(int, boolean)} and + * is only used to indicate that data enabled was changed due to an override. + */ + public static final int DATA_ENABLED_REASON_OVERRIDE = 4; + + /** * Control of data connection and provide the reason triggering the data connection control. * This can be called for following reasons * <ol> diff --git a/telephony/java/android/telephony/data/ApnSetting.java b/telephony/java/android/telephony/data/ApnSetting.java index 8c02ffe12363..cb112cf3b93a 100644 --- a/telephony/java/android/telephony/data/ApnSetting.java +++ b/telephony/java/android/telephony/data/ApnSetting.java @@ -118,11 +118,9 @@ public class ApnSetting implements Parcelable { public static final int TYPE_VSIM = 1 << 12; // TODO: Refer to ApnTypes.VSIM /** APN type for BIP. */ public static final int TYPE_BIP = 1 << 13; // TODO: Refer to ApnTypes.BIP - /** - * APN type for ENTERPRISE. - * @hide - */ - public static final int TYPE_ENTERPRISE = TYPE_BIP << 1; + /** APN type for ENTERPRISE. */ + public static final int TYPE_ENTERPRISE = 1 << 14; //TODO: In future should be referenced from + // hardware.interfaces.radio.data.ApnTypes /** @hide */ @IntDef(flag = true, prefix = {"TYPE_"}, value = { @@ -355,6 +353,7 @@ public class ApnSetting implements Parcelable { * modem components or carriers. Non-system apps should use the integer variants instead. * @hide */ + @SystemApi public static final String TYPE_ENTERPRISE_STRING = "enterprise"; @@ -521,11 +520,11 @@ public class ApnSetting implements Parcelable { private final boolean mAlwaysOn; /** - * Returns the MTU size of the IPv4 mobile interface to which the APN connected. Note this value - * is used only if MTU size is not provided in {@link DataCallResponse}. + * Returns the default MTU (Maximum Transmission Unit) size in bytes of the IPv4 routes brought + * up by this APN setting. Note this value will only be used when MTU size is not provided + * in {@link DataCallResponse#getMtuV4()} during network bring up. * - * @return the MTU size of the APN - * @hide + * @return the MTU size in bytes of the route. */ public int getMtuV4() { return mMtuV4; @@ -533,10 +532,10 @@ public class ApnSetting implements Parcelable { /** * Returns the MTU size of the IPv6 mobile interface to which the APN connected. Note this value - * is used only if MTU size is not provided in {@link DataCallResponse}. + * will only be used when MTU size is not provided in {@link DataCallResponse#getMtuV6()} + * during network bring up. * - * @return the MTU size of the APN - * @hide + * @return the MTU size in bytes of the route. */ public int getMtuV6() { return mMtuV6; @@ -1753,25 +1752,25 @@ public class ApnSetting implements Parcelable { } /** - * Set the MTU size of the IPv4 mobile interface to which the APN connected. Note this value - * is used only if MTU size is not provided in {@link DataCallResponse}. + * Set the default MTU (Maximum Transmission Unit) size in bytes of the IPv4 routes brought + * up by this APN setting. Note this value will only be used when MTU size is not provided + * in {@link DataCallResponse#getMtuV4()} during network bring up. * - * @param mtuV4 the MTU size to set for the APN - * @hide + * @param mtuV4 the MTU size in bytes of the route. */ - public Builder setMtuV4(int mtuV4) { + public @NonNull Builder setMtuV4(int mtuV4) { this.mMtuV4 = mtuV4; return this; } /** - * Set the MTU size of the IPv6 mobile interface to which the APN connected. Note this value - * is used only if MTU size is not provided in {@link DataCallResponse}. + * Set the default MTU (Maximum Transmission Unit) size in bytes of the IPv6 routes brought + * up by this APN setting. Note this value will only be used when MTU size is not provided + * in {@link DataCallResponse#getMtuV6()} during network bring up. * - * @param mtuV6 the MTU size to set for the APN - * @hide + * @param mtuV6 the MTU size in bytes of the route. */ - public Builder setMtuV6(int mtuV6) { + public @NonNull Builder setMtuV6(int mtuV6) { this.mMtuV6 = mtuV6; return this; } @@ -1779,15 +1778,25 @@ public class ApnSetting implements Parcelable { /** * Sets the profile id to which the APN saved in modem. * - * @param profileId the profile id to set for the APN - * @hide + * @param profileId the profile id to set for the APN. */ - public Builder setProfileId(int profileId) { + public @NonNull Builder setProfileId(int profileId) { this.mProfileId = profileId; return this; } /** + * Set if the APN setting should be persistent/non-persistent in modem. + * + * @param isPersistent {@code true} if this APN setting should be persistent/non-persistent + * in modem. + * @return The same instance of the builder. + */ + public @NonNull Builder setPersistent(boolean isPersistent) { + return setModemCognitive(isPersistent); + } + + /** * Sets if the APN setting is to be set in modem. * * @param modemCognitive if the APN setting is to be set in modem diff --git a/telephony/java/android/telephony/data/DataProfile.java b/telephony/java/android/telephony/data/DataProfile.java index c1d16a9aaea7..ec04c1ae9522 100644 --- a/telephony/java/android/telephony/data/DataProfile.java +++ b/telephony/java/android/telephony/data/DataProfile.java @@ -38,8 +38,10 @@ import java.lang.annotation.RetentionPolicy; import java.util.Objects; /** - * Description of a mobile data profile used for establishing - * data connections. + * Description of a mobile data profile used for establishing data networks. The data profile + * consist an {@link ApnSetting} which is needed for 2G/3G/4G networks bring up, and a + * {@link TrafficDescriptor} contains additional information that can be used for 5G standalone + * network bring up. * * @hide */ @@ -113,7 +115,9 @@ public final class DataProfile implements Parcelable { /** * @return Id of the data profile. + * @deprecated Use {@link #getApnSetting()} and {@link ApnSetting#getProfileId()} instead. */ + @Deprecated public int getProfileId() { if (mApnSetting != null) { return mApnSetting.getProfileId(); @@ -124,9 +128,10 @@ public final class DataProfile implements Parcelable { /** * @return The APN (Access Point Name) to establish data connection. This is a string * specifically defined by the carrier. + * @deprecated Use {@link #getApnSetting()} and {@link ApnSetting#getApnName()} instead. */ - @NonNull - public String getApn() { + @Deprecated + public @NonNull String getApn() { if (mApnSetting != null) { return TextUtils.emptyIfNull(mApnSetting.getApnName()); } @@ -135,7 +140,9 @@ public final class DataProfile implements Parcelable { /** * @return The connection protocol defined in 3GPP TS 27.007 section 10.1.1. + * @deprecated Use {@link #getApnSetting()} and {@link ApnSetting#getProtocol()} instead. */ + @Deprecated public @ProtocolType int getProtocolType() { if (mApnSetting != null) { return mApnSetting.getProtocol(); @@ -145,7 +152,9 @@ public final class DataProfile implements Parcelable { /** * @return The authentication protocol used for this PDP context. + * @deprecated Use {@link #getApnSetting()} and {@link ApnSetting#getAuthType()} instead. */ + @Deprecated public @AuthType int getAuthType() { if (mApnSetting != null) { return mApnSetting.getAuthType(); @@ -154,10 +163,11 @@ public final class DataProfile implements Parcelable { } /** - * @return The username for APN. Can be null. + * @return The username for APN. + * @deprecated Use {@link #getApnSetting()} and {@link ApnSetting#getUser()} instead. */ - @Nullable - public String getUserName() { + @Deprecated + public @Nullable String getUserName() { if (mApnSetting != null) { return mApnSetting.getUser(); } @@ -165,10 +175,11 @@ public final class DataProfile implements Parcelable { } /** - * @return The password for APN. Can be null. + * @return The password for APN. + * @deprecated Use {@link #getApnSetting()} and {@link ApnSetting#getPassword()} instead. */ - @Nullable - public String getPassword() { + @Deprecated + public @Nullable String getPassword() { if (mApnSetting != null) { return mApnSetting.getPassword(); } @@ -232,7 +243,9 @@ public final class DataProfile implements Parcelable { /** * @return The supported APN types bitmask. + * @deprecated Use {@link #getApnSetting()} and {@link ApnSetting#getApnTypeBitmask()} instead. */ + @Deprecated public @ApnType int getSupportedApnTypesBitmask() { if (mApnSetting != null) { return mApnSetting.getApnTypeBitmask(); @@ -242,7 +255,9 @@ public final class DataProfile implements Parcelable { /** * @return The connection protocol on roaming network defined in 3GPP TS 27.007 section 10.1.1. + * @deprecated Use {@link #getApnSetting()} and {@link ApnSetting#getRoamingProtocol()} instead. */ + @Deprecated public @ProtocolType int getRoamingProtocolType() { if (mApnSetting != null) { return mApnSetting.getRoamingProtocol(); @@ -252,7 +267,10 @@ public final class DataProfile implements Parcelable { /** * @return The bearer bitmask indicating the applicable networks for this data profile. + * @deprecated use {@link #getApnSetting()} and {@link ApnSetting#getNetworkTypeBitmask()} + * instead. */ + @Deprecated public @NetworkTypeBitMask int getBearerBitmask() { if (mApnSetting != null) { return mApnSetting.getNetworkTypeBitmask(); @@ -262,7 +280,8 @@ public final class DataProfile implements Parcelable { /** * @return The maximum transmission unit (MTU) size in bytes. - * @deprecated use {@link #getMtuV4} or {@link #getMtuV6} instead. + * @deprecated use {@link #getApnSetting()} and {@link ApnSetting#getMtuV4()}/ + * {@link ApnSetting#getMtuV6()} instead. */ @Deprecated public int getMtu() { @@ -272,7 +291,9 @@ public final class DataProfile implements Parcelable { /** * This replaces the deprecated method getMtu. * @return The maximum transmission unit (MTU) size in bytes, for IPv4. + * @deprecated use {@link #getApnSetting()} and {@link ApnSetting#getMtuV4()} instead. */ + @Deprecated public int getMtuV4() { if (mApnSetting != null) { return mApnSetting.getMtuV4(); @@ -282,7 +303,9 @@ public final class DataProfile implements Parcelable { /** * @return The maximum transmission unit (MTU) size in bytes, for IPv6. + * @deprecated use {@link #getApnSetting()} and {@link ApnSetting#getMtuV6()} instead. */ + @Deprecated public int getMtuV6() { if (mApnSetting != null) { return mApnSetting.getMtuV6(); @@ -292,7 +315,9 @@ public final class DataProfile implements Parcelable { /** * @return {@code true} if modem must persist this data profile. + * @deprecated Use {@link #getApnSetting()} and {@link ApnSetting#isPersistent()} instead. */ + @Deprecated public boolean isPersistent() { if (mApnSetting != null) { return mApnSetting.isPersistent(); @@ -320,16 +345,16 @@ public final class DataProfile implements Parcelable { } /** - * @return The APN setting - * @hide TODO: Remove before T is released. + * @return The APN setting {@link ApnSetting}, which is used to establish data network on + * 2G/3G/4G. */ public @Nullable ApnSetting getApnSetting() { return mApnSetting; } /** - * @return The traffic descriptor - * @hide TODO: Remove before T is released. + * @return The traffic descriptor {@link TrafficDescriptor}, which can be used to establish + * data network on 5G. */ public @Nullable TrafficDescriptor getTrafficDescriptor() { return mTrafficDescriptor; @@ -539,7 +564,10 @@ public final class DataProfile implements Parcelable { * * @param profileId Network domain. * @return The same instance of the builder. + * @deprecated use {@link #setApnSetting(ApnSetting)} and + * {@link ApnSetting.Builder#setProfileId(int)} instead. */ + @Deprecated public @NonNull Builder setProfileId(int profileId) { mProfileId = profileId; return this; @@ -551,7 +579,10 @@ public final class DataProfile implements Parcelable { * * @param apn Access point name * @return The same instance of the builder. + * @deprecated use {@link #setApnSetting(ApnSetting)} and + * {@link ApnSetting.Builder#setApnName(String)} instead. */ + @Deprecated public @NonNull Builder setApn(@NonNull String apn) { mApn = apn; return this; @@ -562,7 +593,10 @@ public final class DataProfile implements Parcelable { * * @param protocolType The connection protocol defined in 3GPP TS 27.007 section 10.1.1. * @return The same instance of the builder. + * @deprecated use {@link #setApnSetting(ApnSetting)} and + * {@link ApnSetting.Builder#setProtocol(int)} instead. */ + @Deprecated public @NonNull Builder setProtocolType(@ProtocolType int protocolType) { mProtocolType = protocolType; return this; @@ -573,7 +607,10 @@ public final class DataProfile implements Parcelable { * * @param authType The authentication type * @return The same instance of the builder. + * @deprecated use {@link #setApnSetting(ApnSetting)} and + * {@link ApnSetting.Builder#setAuthType(int)} instead. */ + @Deprecated public @NonNull Builder setAuthType(@AuthType int authType) { mAuthType = authType; return this; @@ -584,7 +621,10 @@ public final class DataProfile implements Parcelable { * * @param userName The user name * @return The same instance of the builder. + * @deprecated use {@link #setApnSetting(ApnSetting)} and + * {@link ApnSetting.Builder#setUser(String)} instead. */ + @Deprecated public @NonNull Builder setUserName(@NonNull String userName) { mUserName = userName; return this; @@ -595,7 +635,10 @@ public final class DataProfile implements Parcelable { * * @param password The password * @return The same instance of the builder. + * @deprecated use {@link #setApnSetting(ApnSetting)} and + * {@link ApnSetting.Builder#setPassword(String)} (int)} instead. */ + @Deprecated public @NonNull Builder setPassword(@NonNull String password) { mPassword = password; return this; @@ -628,7 +671,10 @@ public final class DataProfile implements Parcelable { * * @param supportedApnTypesBitmask The supported APN types bitmask. * @return The same instance of the builder. + * @deprecated use {@link #setApnSetting(ApnSetting)} and + * {@link ApnSetting.Builder#setApnTypeBitmask(int)} instead. */ + @Deprecated public @NonNull Builder setSupportedApnTypesBitmask(@ApnType int supportedApnTypesBitmask) { mSupportedApnTypesBitmask = supportedApnTypesBitmask; return this; @@ -639,7 +685,10 @@ public final class DataProfile implements Parcelable { * * @param protocolType The connection protocol defined in 3GPP TS 27.007 section 10.1.1. * @return The same instance of the builder. + * @deprecated use {@link #setApnSetting(ApnSetting)} and + * {@link ApnSetting.Builder#setRoamingProtocol(int)} instead. */ + @Deprecated public @NonNull Builder setRoamingProtocolType(@ProtocolType int protocolType) { mRoamingProtocolType = protocolType; return this; @@ -651,7 +700,10 @@ public final class DataProfile implements Parcelable { * @param bearerBitmask The bearer bitmask indicating the applicable networks for this data * profile. * @return The same instance of the builder. + * @deprecated use {@link #setApnSetting(ApnSetting)} and + * {@link ApnSetting.Builder#setNetworkTypeBitmask(int)} instead. */ + @Deprecated public @NonNull Builder setBearerBitmask(@NetworkTypeBitMask int bearerBitmask) { mBearerBitmask = bearerBitmask; return this; @@ -662,7 +714,9 @@ public final class DataProfile implements Parcelable { * * @param mtu The maximum transmission unit (MTU) size in bytes. * @return The same instance of the builder. - * @deprecated use {@link #setApnSetting(ApnSetting)} instead. + * @deprecated use {@link #setApnSetting(ApnSetting)} and + * {@link ApnSetting.Builder#setMtuV4(int)}/{@link ApnSetting.Builder#setMtuV6(int)} + * instead. */ @Deprecated public @NonNull Builder setMtu(int mtu) { @@ -672,11 +726,13 @@ public final class DataProfile implements Parcelable { /** * Set the maximum transmission unit (MTU) size in bytes, for IPv4. - * This replaces the deprecated method setMtu. * * @param mtu The maximum transmission unit (MTU) size in bytes. * @return The same instance of the builder. + * @deprecated Use {{@link #setApnSetting(ApnSetting)}} and + * {@link ApnSetting.Builder#setMtuV4(int)} instead. */ + @Deprecated public @NonNull Builder setMtuV4(int mtu) { mMtuV4 = mtu; return this; @@ -687,7 +743,10 @@ public final class DataProfile implements Parcelable { * * @param mtu The maximum transmission unit (MTU) size in bytes. * @return The same instance of the builder. + * @deprecated Use {{@link #setApnSetting(ApnSetting)}} and + * {@link ApnSetting.Builder#setMtuV6(int)} instead. */ + @Deprecated public @NonNull Builder setMtuV6(int mtu) { mMtuV6 = mtu; return this; @@ -712,19 +771,23 @@ public final class DataProfile implements Parcelable { * @param isPersistent {@code true} if this data profile was used to bring up the last * default (i.e internet) data connection successfully. * @return The same instance of the builder. + * @deprecated Use {{@link #setApnSetting(ApnSetting)}} and + * {@link ApnSetting.Builder#setPersistent(boolean)} instead. */ + @Deprecated public @NonNull Builder setPersistent(boolean isPersistent) { mPersistent = isPersistent; return this; } /** - * Set APN setting. + * Set the APN setting. Note that if an APN setting is not set here, then either + * {@link #setApn(String)} or {@link #setTrafficDescriptor(TrafficDescriptor)} must be + * called. Otherwise {@link IllegalArgumentException} will be thrown when {@link #build()} + * the data profile. * - * @param apnSetting APN setting - * @return The same instance of the builder - * - * @hide // TODO: Remove before T is released. + * @param apnSetting The APN setting. + * @return The same instance of the builder. */ public @NonNull Builder setApnSetting(@NonNull ApnSetting apnSetting) { mApnSetting = apnSetting; @@ -732,12 +795,13 @@ public final class DataProfile implements Parcelable { } /** - * Set traffic descriptor. - * - * @param trafficDescriptor Traffic descriptor - * @return The same instance of the builder + * Set the traffic descriptor. Note that if a traffic descriptor is not set here, then + * either {@link #setApnSetting(ApnSetting)} or {@link #setApn(String)} must be called. + * Otherwise {@link IllegalArgumentException} will be thrown when {@link #build()} the data + * profile. * - * @hide // TODO: Remove before T is released. + * @param trafficDescriptor The traffic descriptor. + * @return The same instance of the builder. */ public @NonNull Builder setTrafficDescriptor(@NonNull TrafficDescriptor trafficDescriptor) { mTrafficDescriptor = trafficDescriptor; @@ -745,9 +809,9 @@ public final class DataProfile implements Parcelable { } /** - * Build the DataProfile object + * Build the DataProfile object. * - * @return The data profile object + * @return The data profile object. */ public @NonNull DataProfile build() { if (mApnSetting == null && mApn != null) { diff --git a/telephony/java/android/telephony/ims/aidl/SipDelegateAidlWrapper.java b/telephony/java/android/telephony/ims/aidl/SipDelegateAidlWrapper.java index f0048248a5cc..b154a999c25f 100644 --- a/telephony/java/android/telephony/ims/aidl/SipDelegateAidlWrapper.java +++ b/telephony/java/android/telephony/ims/aidl/SipDelegateAidlWrapper.java @@ -47,6 +47,9 @@ public class SipDelegateAidlWrapper implements DelegateStateCallback, DelegateMe @Override public void sendMessage(SipMessage sipMessage, long configVersion) { SipDelegate d = mDelegate; + if (d == null) { + return; + } final long token = Binder.clearCallingIdentity(); try { mExecutor.execute(() -> d.sendMessage(sipMessage, configVersion)); @@ -58,6 +61,9 @@ public class SipDelegateAidlWrapper implements DelegateStateCallback, DelegateMe @Override public void notifyMessageReceived(String viaTransactionId) { SipDelegate d = mDelegate; + if (d == null) { + return; + } final long token = Binder.clearCallingIdentity(); try { mExecutor.execute(() -> d.notifyMessageReceived(viaTransactionId)); @@ -70,6 +76,9 @@ public class SipDelegateAidlWrapper implements DelegateStateCallback, DelegateMe @Override public void notifyMessageReceiveError(String viaTransactionId, int reason) { SipDelegate d = mDelegate; + if (d == null) { + return; + } final long token = Binder.clearCallingIdentity(); try { mExecutor.execute(() -> d.notifyMessageReceiveError(viaTransactionId, reason)); @@ -82,6 +91,9 @@ public class SipDelegateAidlWrapper implements DelegateStateCallback, DelegateMe @Override public void cleanupSession(String callId) { SipDelegate d = mDelegate; + if (d == null) { + return; + } final long token = Binder.clearCallingIdentity(); try { mExecutor.execute(() -> d.cleanupSession(callId)); diff --git a/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt b/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt index 1aec9b812e61..2e60f64b21e8 100644 --- a/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt +++ b/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt @@ -21,8 +21,6 @@ import com.android.codegen.BASE_BUILDER_CLASS import com.android.codegen.CANONICAL_BUILDER_CLASS import com.android.codegen.CODEGEN_NAME import com.android.codegen.CODEGEN_VERSION -import com.sun.tools.javac.code.Symbol -import com.sun.tools.javac.code.Type import java.io.File import java.io.FileNotFoundException import javax.annotation.processing.AbstractProcessor @@ -33,6 +31,7 @@ import javax.lang.model.element.AnnotationMirror import javax.lang.model.element.Element import javax.lang.model.element.ElementKind import javax.lang.model.element.TypeElement +import javax.lang.model.type.ExecutableType import javax.tools.Diagnostic private const val STALE_FILE_THRESHOLD_MS = 1000 @@ -102,14 +101,13 @@ class StaleDataclassProcessor: AbstractProcessor() { append(" ") append(elem.annotationMirrors.joinToString(" ", transform = { annotationToString(it) })) append(" ") - if (elem is Symbol) { - if (elem.type is Type.MethodType) { - append((elem.type as Type.MethodType).returnType) - } else { - append(elem.type) - } - append(" ") + val type = elem.asType() + if (type is ExecutableType) { + append(type.returnType) + } else { + append(type) } + append(" ") append(elem) } } @@ -234,4 +232,4 @@ class StaleDataclassProcessor: AbstractProcessor() { override fun getSupportedSourceVersion(): SourceVersion { return SourceVersion.latest() } -}
\ No newline at end of file +} |