diff options
113 files changed, 1900 insertions, 502 deletions
diff --git a/api/Android.bp b/api/Android.bp index 3c92cb26b0fe..c7c56861894d 100644 --- a/api/Android.bp +++ b/api/Android.bp @@ -73,6 +73,7 @@ combined_apis {          "framework-bluetooth",          "framework-configinfrastructure",          "framework-connectivity", +        "framework-connectivity-b",          "framework-connectivity-t",          "framework-devicelock",          "framework-graphics", @@ -124,27 +125,54 @@ combined_apis {      }),  } +// Create a single file containing the latest released version of the whole +// Android public API. +java_genrule { +    name: "android.api.merged.public.latest", +    srcs: [ +        ":android.api.combined.public.latest", +    ], +    out: ["public-latest.txt"], +    tools: ["metalava"], +    cmd: metalava_cmd + " merge-signatures --format=2.0 $(in) --out $(out)", +} + +// Make sure that the Android public API is compatible with the +// previously released public API.  java_genrule {      name: "frameworks-base-api-current-compat",      srcs: [ -        ":android.api.public.latest", +        ":android.api.merged.public.latest",          ":android-incompatibilities.api.public.latest",          ":frameworks-base-api-current.txt",      ],      out: ["updated-baseline.txt"],      tools: ["metalava"],      cmd: metalava_cmd + -        "--check-compatibility:api:released $(location :android.api.public.latest) " + +        "--check-compatibility:api:released $(location :android.api.merged.public.latest) " +          "--baseline:compatibility:released $(location :android-incompatibilities.api.public.latest) " +          "--update-baseline:compatibility:released $(genDir)/updated-baseline.txt " +          "$(location :frameworks-base-api-current.txt)",  } +// Create a single file containing the latest released version of the whole +// Android system API. +java_genrule { +    name: "android.api.merged.system.latest", +    srcs: [ +        ":android.api.combined.system.latest", +    ], +    out: ["system-latest.txt"], +    tools: ["metalava"], +    cmd: metalava_cmd + " merge-signatures --format=2.0 $(in) --out $(out)", +} + +// Make sure that the Android system API is compatible with the +// previously released system API.  java_genrule {      name: "frameworks-base-api-system-current-compat",      srcs: [ -        ":android.api.public.latest", -        ":android.api.system.latest", +        ":android.api.merged.system.latest",          ":android-incompatibilities.api.system.latest",          ":frameworks-base-api-current.txt",          ":frameworks-base-api-system-current.txt", @@ -152,20 +180,31 @@ java_genrule {      out: ["updated-baseline.txt"],      tools: ["metalava"],      cmd: metalava_cmd + -        "--check-compatibility:api:released $(location :android.api.public.latest) " + -        "--check-compatibility:api:released $(location :android.api.system.latest) " + +        "--check-compatibility:api:released $(location :android.api.merged.system.latest) " +          "--baseline:compatibility:released $(location :android-incompatibilities.api.system.latest) " +          "--update-baseline:compatibility:released $(genDir)/updated-baseline.txt " +          "$(location :frameworks-base-api-current.txt) " +          "$(location :frameworks-base-api-system-current.txt)",  } +// Create a single file containing the latest released version of the whole +// Android module-lib API. +java_genrule { +    name: "android.api.merged.module-lib.latest", +    srcs: [ +        ":android.api.combined.module-lib.latest", +    ], +    out: ["module-lib-latest.txt"], +    tools: ["metalava"], +    cmd: metalava_cmd + " merge-signatures --format=2.0 $(in) --out $(out)", +} + +// Make sure that the Android module-lib API is compatible with the +// previously released module-lib API.  java_genrule {      name: "frameworks-base-api-module-lib-current-compat",      srcs: [ -        ":android.api.public.latest", -        ":android.api.system.latest", -        ":android.api.module-lib.latest", +        ":android.api.merged.module-lib.latest",          ":android-incompatibilities.api.module-lib.latest",          ":frameworks-base-api-current.txt",          ":frameworks-base-api-system-current.txt", @@ -174,9 +213,7 @@ java_genrule {      out: ["updated-baseline.txt"],      tools: ["metalava"],      cmd: metalava_cmd + -        "--check-compatibility:api:released $(location :android.api.public.latest) " + -        "--check-compatibility:api:released $(location :android.api.system.latest) " + -        "--check-compatibility:api:released $(location :android.api.module-lib.latest) " + +        "--check-compatibility:api:released $(location :android.api.merged.module-lib.latest) " +          "--baseline:compatibility:released $(location :android-incompatibilities.api.module-lib.latest) " +          "--update-baseline:compatibility:released $(genDir)/updated-baseline.txt " +          "$(location :frameworks-base-api-current.txt) " + @@ -191,7 +228,7 @@ java_genrule {      cmd: "$(location merge_zips) $(out) $(in)",      srcs: [          ":api-stubs-docs-non-updatable{.exportable}", -        ":all-modules-public-stubs-source", +        ":all-modules-public-stubs-source-exportable",      ],      visibility: ["//visibility:private"], // Used by make module in //development, mind  } diff --git a/api/ApiDocs.bp b/api/ApiDocs.bp index e8fcf4b2b32d..1ebe0cdfabd7 100644 --- a/api/ApiDocs.bp +++ b/api/ApiDocs.bp @@ -129,7 +129,7 @@ droidstubs {  droidstubs {      name: "framework-doc-stubs",      defaults: ["android-non-updatable-doc-stubs-defaults"], -    srcs: [":all-modules-public-stubs-source"], +    srcs: [":all-modules-public-stubs-source-exportable"],      api_levels_module: "api_versions_public",      aidl: {          include_dirs: [ diff --git a/api/api.go b/api/api.go index 29083dfc8968..aa89c2450288 100644 --- a/api/api.go +++ b/api/api.go @@ -428,8 +428,9 @@ func createMergedFrameworkSystemServerExportableStubs(ctx android.LoadHookContex  func createPublicStubsSourceFilegroup(ctx android.LoadHookContext, modules proptools.Configurable[[]string]) {  	props := fgProps{} -	props.Name = proptools.StringPtr("all-modules-public-stubs-source") -	props.Device_common_srcs = createSrcs(modules, "{.public.stubs.source}") +	props.Name = proptools.StringPtr("all-modules-public-stubs-source-exportable") +	transformConfigurableArray(modules, "", ".stubs.source") +	props.Device_common_srcs = createSrcs(modules, "{.exportable}")  	props.Visibility = []string{"//frameworks/base"}  	ctx.CreateModule(android.FileGroupFactory, &props)  } diff --git a/config/preloaded-classes-denylist b/config/preloaded-classes-denylist index a413bbd68f60..16f069394639 100644 --- a/config/preloaded-classes-denylist +++ b/config/preloaded-classes-denylist @@ -1,13 +1,16 @@  android.content.AsyncTaskLoader$LoadTask +android.media.MediaCodecInfo$CodecCapabilities$FeatureList  android.net.ConnectivityThread$Singleton  android.os.FileObserver  android.os.NullVibrator +android.permission.PermissionManager +android.provider.MediaStore  android.speech.tts.TextToSpeech$Connection$SetupConnectionAsyncTask +android.view.HdrRenderState  android.widget.Magnifier +com.android.internal.jank.InteractionJankMonitor$InstanceHolder +com.android.internal.util.LatencyTracker$SLatencyTrackerHolder  gov.nist.core.net.DefaultNetworkLayer -android.net.rtp.AudioGroup -android.net.rtp.AudioStream -android.net.rtp.RtpStream  java.util.concurrent.ThreadLocalRandom  java.util.ImmutableCollections -com.android.internal.jank.InteractionJankMonitor$InstanceHolder +sun.nio.fs.UnixChannelFactory diff --git a/core/api/current.txt b/core/api/current.txt index 6d9fe4494220..9a5e0de1f9b0 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -23754,6 +23754,7 @@ package android.media {      field public static final String KEY_MPEGH_COMPATIBLE_SETS = "mpegh-compatible-sets";      field public static final String KEY_MPEGH_PROFILE_LEVEL_INDICATION = "mpegh-profile-level-indication";      field public static final String KEY_MPEGH_REFERENCE_CHANNEL_LAYOUT = "mpegh-reference-channel-layout"; +    field @FlaggedApi("android.media.codec.num_input_slots") public static final String KEY_NUM_SLOTS = "num-slots";      field public static final String KEY_OPERATING_RATE = "operating-rate";      field public static final String KEY_OUTPUT_REORDER_DEPTH = "output-reorder-depth";      field public static final String KEY_PCM_ENCODING = "pcm-encoding"; @@ -40010,7 +40011,7 @@ package android.security.keystore {      method @NonNull public android.security.keystore.KeyProtection.Builder setUserPresenceRequired(boolean);    } -  @FlaggedApi("android.security.keystore_grant_api") public class KeyStoreManager { +  @FlaggedApi("android.security.keystore_grant_api") public final class KeyStoreManager {      method @NonNull public java.util.List<java.security.cert.X509Certificate> getGrantedCertificateChainFromId(long) throws android.security.keystore.KeyPermanentlyInvalidatedException, java.security.UnrecoverableKeyException;      method @NonNull public java.security.Key getGrantedKeyFromId(long) throws android.security.keystore.KeyPermanentlyInvalidatedException, java.security.UnrecoverableKeyException;      method @NonNull public java.security.KeyPair getGrantedKeyPairFromId(long) throws android.security.keystore.KeyPermanentlyInvalidatedException, java.security.UnrecoverableKeyException; diff --git a/core/java/Android.bp b/core/java/Android.bp index 7e8a3091ff2a..3f6e65b95c93 100644 --- a/core/java/Android.bp +++ b/core/java/Android.bp @@ -649,16 +649,31 @@ gen_readonly_feature_apis = select(release_flag("RELEASE_USE_SYSTEM_FEATURE_BUIL  // Generates com.android.internal.pm.RoSystemFeatures, optionally compiling in  // details about fixed system features defined by build flags. When disabled,  // the APIs are simply passthrough stubs with no meaningful side effects. +// TODO(b/203143243): Implement the `--feature=` aggregation  directly with a native soong module.  genrule {      name: "systemfeatures-gen-srcs",      cmd: "$(location systemfeatures-gen-tool) com.android.internal.pm.RoSystemFeatures " +          // --readonly=false (default) makes the codegen an effective no-op passthrough API.          " --readonly=" + gen_readonly_feature_apis + -        // For now, only export "android.hardware.type.*" system features APIs. -        // TODO(b/203143243): Use an intermediate soong var that aggregates all declared -        // RELEASE_SYSTEM_FEATURE_* declarations into a single arg. -        " --feature-apis=AUTOMOTIVE,WATCH,TELEVISION,EMBEDDED,PC" + -        " > $(out)", +        " --feature=AUTOMOTIVE:" + select(release_flag("RELEASE_SYSTEM_FEATURE_AUTOMOTIVE"), { +            any @ value: value, +            default: "", +        }) + " --feature=EMBEDDED:" + select(release_flag("RELEASE_SYSTEM_FEATURE_EMBEDDED"), { +            any @ value: value, +            default: "", +        }) + " --feature=LEANBACK:" + select(release_flag("RELEASE_SYSTEM_FEATURE_LEANBACK"), { +            any @ value: value, +            default: "", +        }) + " --feature=PC:" + select(release_flag("RELEASE_SYSTEM_FEATURE_PC"), { +            any @ value: value, +            default: "", +        }) + " --feature=TELEVISION:" + select(release_flag("RELEASE_SYSTEM_FEATURE_TELEVISION"), { +            any @ value: value, +            default: "", +        }) + " --feature=WATCH:" + select(release_flag("RELEASE_SYSTEM_FEATURE_WATCH"), { +            any @ value: value, +            default: "", +        }) + " > $(out)",      out: [          "RoSystemFeatures.java",      ], diff --git a/core/java/android/database/CursorWindow.java b/core/java/android/database/CursorWindow.java index ef59e0af3a27..93ef5c365730 100644 --- a/core/java/android/database/CursorWindow.java +++ b/core/java/android/database/CursorWindow.java @@ -45,7 +45,7 @@ import dalvik.system.CloseGuard;   * </p>   */  @RavenwoodKeepWholeClass -@RavenwoodRedirectionClass("CursorWindow_host") +@RavenwoodRedirectionClass("CursorWindow_ravenwood")  public class CursorWindow extends SQLiteClosable implements Parcelable {      private static final String STATS_TAG = "CursorWindowStats"; diff --git a/ravenwood/runtime-helper-src/framework/android/database/CursorWindow_host.java b/core/java/android/database/CursorWindow_ravenwood.java index e21a9cd71a2d..990ec5e9d59e 100644 --- a/ravenwood/runtime-helper-src/framework/android/database/CursorWindow_host.java +++ b/core/java/android/database/CursorWindow_ravenwood.java @@ -17,6 +17,7 @@ package android.database;  import android.database.sqlite.SQLiteException;  import android.os.Parcel; +import android.ravenwood.annotation.RavenwoodKeepWholeClass;  import android.util.Base64;  import java.text.DecimalFormat; @@ -26,9 +27,10 @@ import java.util.Arrays;  import java.util.HashMap;  import java.util.List; -public class CursorWindow_host { +@RavenwoodKeepWholeClass +class CursorWindow_ravenwood { -    private static final HashMap<Long, CursorWindow_host> sInstances = new HashMap<>(); +    private static final HashMap<Long, CursorWindow_ravenwood> sInstances = new HashMap<>();      private static long sNextId = 1;      private String mName; @@ -41,7 +43,7 @@ public class CursorWindow_host {      private final List<Row> mRows = new ArrayList<>();      public static long nativeCreate(String name, int cursorWindowSize) { -        CursorWindow_host instance = new CursorWindow_host(); +        CursorWindow_ravenwood instance = new CursorWindow_ravenwood();          instance.mName = name;          long instanceId = sNextId++;          sInstances.put(instanceId, instance); @@ -66,7 +68,7 @@ public class CursorWindow_host {      }      public static boolean nativeAllocRow(long windowPtr) { -        CursorWindow_host instance = sInstances.get(windowPtr); +        CursorWindow_ravenwood instance = sInstances.get(windowPtr);          Row row = new Row();          row.mFields = new String[instance.mColumnNum];          row.mTypes = new int[instance.mColumnNum]; @@ -76,7 +78,7 @@ public class CursorWindow_host {      }      private static boolean put(long windowPtr, String value, int type, int row, int column) { -        CursorWindow_host instance = sInstances.get(windowPtr); +        CursorWindow_ravenwood instance = sInstances.get(windowPtr);          if (row >= instance.mRows.size() || column >= instance.mColumnNum) {              return false;          } @@ -87,7 +89,7 @@ public class CursorWindow_host {      }      public static int nativeGetType(long windowPtr, int row, int column) { -        CursorWindow_host instance = sInstances.get(windowPtr); +        CursorWindow_ravenwood instance = sInstances.get(windowPtr);          if (row >= instance.mRows.size() || column >= instance.mColumnNum) {              return Cursor.FIELD_TYPE_NULL;          } @@ -101,7 +103,7 @@ public class CursorWindow_host {      }      public static String nativeGetString(long windowPtr, int row, int column) { -        CursorWindow_host instance = sInstances.get(windowPtr); +        CursorWindow_ravenwood instance = sInstances.get(windowPtr);          if (row >= instance.mRows.size() || column >= instance.mColumnNum) {              return null;          } @@ -164,7 +166,7 @@ public class CursorWindow_host {      }      public static void nativeWriteToParcel(long windowPtr, Parcel parcel) { -        CursorWindow_host window = sInstances.get(windowPtr); +        CursorWindow_ravenwood window = sInstances.get(windowPtr);          parcel.writeString(window.mName);          parcel.writeInt(window.mColumnNum);          parcel.writeInt(window.mRows.size()); @@ -176,7 +178,7 @@ public class CursorWindow_host {      public static long nativeCreateFromParcel(Parcel parcel) {          long windowPtr = nativeCreate(null, 0); -        CursorWindow_host window = sInstances.get(windowPtr); +        CursorWindow_ravenwood window = sInstances.get(windowPtr);          window.mName = parcel.readString();          window.mColumnNum = parcel.readInt();          int rowCount = parcel.readInt(); diff --git a/core/java/android/database/sqlite/flags.aconfig b/core/java/android/database/sqlite/flags.aconfig index 1b8471dfef4c..c2cc9d18e457 100644 --- a/core/java/android/database/sqlite/flags.aconfig +++ b/core/java/android/database/sqlite/flags.aconfig @@ -2,13 +2,6 @@ package: "android.database.sqlite"  container: "system"  flag { -     name: "oneway_finalizer_close" -     namespace: "system_performance" -     description: "Make BuildCursorNative.close oneway if in the the finalizer" -     bug: "368221351" -} - -flag {       name: "oneway_finalizer_close_fixed"       namespace: "system_performance"       is_fixed_read_only: true diff --git a/core/java/android/hardware/location/OWNERS b/core/java/android/hardware/location/OWNERS index 747f90947b9c..340d6f2eb08c 100644 --- a/core/java/android/hardware/location/OWNERS +++ b/core/java/android/hardware/location/OWNERS @@ -9,4 +9,4 @@ wyattriley@google.com  yuhany@google.com  # ContextHub team -per-file *ContextHub*,*NanoApp* = file:platform/system/chre:/OWNERS +per-file Android.bp,*Hub*,*NanoApp* = file:platform/system/chre:/OWNERS diff --git a/core/java/android/net/vcn/flags.aconfig b/core/java/android/net/vcn/flags.aconfig index 1adefe5a0b86..1b2c575917b2 100644 --- a/core/java/android/net/vcn/flags.aconfig +++ b/core/java/android/net/vcn/flags.aconfig @@ -18,13 +18,6 @@ flag {  }  flag { -    name: "safe_mode_timeout_config" -    namespace: "vcn" -    description: "Feature flag for adjustable safe mode timeout" -    bug: "317406085" -} - -flag {      name: "fix_config_garbage_collection"      namespace: "vcn"      description: "Handle race condition in subscription change" diff --git a/core/java/android/os/MessageQueue.java b/core/java/android/os/MessageQueue.java index 53da4a9c03d0..5a7650bc76ca 100644 --- a/core/java/android/os/MessageQueue.java +++ b/core/java/android/os/MessageQueue.java @@ -40,7 +40,7 @@ import java.util.ArrayList;   * {@link Looper#myQueue() Looper.myQueue()}.   */  @android.ravenwood.annotation.RavenwoodKeepWholeClass -@android.ravenwood.annotation.RavenwoodRedirectionClass("MessageQueue_host") +@android.ravenwood.annotation.RavenwoodRedirectionClass("MessageQueue_ravenwood")  public final class MessageQueue {      private static final String TAG = "MessageQueue";      private static final boolean DEBUG = false; diff --git a/ravenwood/runtime-helper-src/framework/android/os/MessageQueue_host.java b/core/java/android/os/MessageQueue_ravenwood.java index 1b63adc4319f..4033707c3253 100644 --- a/ravenwood/runtime-helper-src/framework/android/os/MessageQueue_host.java +++ b/core/java/android/os/MessageQueue_ravenwood.java @@ -16,13 +16,16 @@  package android.os; +import android.ravenwood.annotation.RavenwoodKeepWholeClass; +  import java.util.Map;  import java.util.concurrent.ConcurrentHashMap;  import java.util.concurrent.atomic.AtomicLong; -public class MessageQueue_host { +@RavenwoodKeepWholeClass +class MessageQueue_ravenwood {      private static final AtomicLong sNextId = new AtomicLong(1); -    private static final Map<Long, MessageQueue_host> sInstances = new ConcurrentHashMap<>(); +    private static final Map<Long, MessageQueue_ravenwood> sInstances = new ConcurrentHashMap<>();      private boolean mDeleted = false; @@ -37,8 +40,8 @@ public class MessageQueue_host {          }      } -    private static MessageQueue_host getInstance(long id) { -        MessageQueue_host q = sInstances.get(id); +    private static MessageQueue_ravenwood getInstance(long id) { +        MessageQueue_ravenwood q = sInstances.get(id);          if (q == null) {              throw new RuntimeException("MessageQueue doesn't exist with id=" + id);          } @@ -48,7 +51,7 @@ public class MessageQueue_host {      public static long nativeInit() {          final long id = sNextId.getAndIncrement(); -        final MessageQueue_host q = new MessageQueue_host(); +        final MessageQueue_ravenwood q = new MessageQueue_ravenwood();          sInstances.put(id, q);          return id;      } diff --git a/core/java/android/print/OWNERS b/core/java/android/print/OWNERS index 0809de25b45c..ce79f5d0c669 100644 --- a/core/java/android/print/OWNERS +++ b/core/java/android/print/OWNERS @@ -2,3 +2,4 @@  anothermark@google.com  kumarashishg@google.com +bmgordon@google.com diff --git a/core/java/android/printservice/OWNERS b/core/java/android/printservice/OWNERS index 0809de25b45c..ce79f5d0c669 100644 --- a/core/java/android/printservice/OWNERS +++ b/core/java/android/printservice/OWNERS @@ -2,3 +2,4 @@  anothermark@google.com  kumarashishg@google.com +bmgordon@google.com diff --git a/core/java/android/util/Log.java b/core/java/android/util/Log.java index 8358b9a51adb..1dd9d46fdfb7 100644 --- a/core/java/android/util/Log.java +++ b/core/java/android/util/Log.java @@ -75,8 +75,7 @@ import java.net.UnknownHostException;  @android.ravenwood.annotation.RavenwoodClassLoadHook(          "com.android.platform.test.ravenwood.runtimehelper.ClassLoadHook.onClassLoaded")  // Uncomment the following annotation to switch to the Java substitution version. -//@android.ravenwood.annotation.RavenwoodNativeSubstitutionClass( -//        "com.android.platform.test.ravenwood.nativesubstitution.Log_host") +@android.ravenwood.annotation.RavenwoodRedirectionClass("Log_host")  public final class Log {      /** @hide */      @IntDef({ASSERT, ERROR, WARN, INFO, DEBUG, VERBOSE}) @@ -250,6 +249,7 @@ public final class Log {       *         tag limit of concern after this API level.       */      @FastNative +    @android.ravenwood.annotation.RavenwoodRedirect      public static native boolean isLoggable(@Nullable String tag, @Level int level);      /** @@ -425,6 +425,7 @@ public final class Log {       * @hide       */      @UnsupportedAppUsage +    @android.ravenwood.annotation.RavenwoodRedirect      public static native int println_native(int bufID, int priority, String tag, String msg);      /** @@ -452,6 +453,7 @@ public final class Log {       * Return the maximum payload the log daemon accepts without truncation.       * @return LOGGER_ENTRY_MAX_PAYLOAD.       */ +    @android.ravenwood.annotation.RavenwoodRedirect      private static native int logger_entry_max_payload_native();      /** diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index 505a82a1518f..884a66c477b4 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -2917,12 +2917,12 @@ public final class SurfaceControl implements Parcelable {          private void apply(boolean sync, boolean oneWay) {              applyResizedSurfaces();              notifyReparentedSurfaces(); -            nativeApplyTransaction(mNativeObject, sync, oneWay);              if (SurfaceControlRegistry.sCallStackDebuggingEnabled) {                  SurfaceControlRegistry.getProcessInstance().checkCallStackDebugging(                          "apply", this, null, null);              } +            nativeApplyTransaction(mNativeObject, sync, oneWay);          }          /** diff --git a/core/java/com/android/internal/os/LongArrayMultiStateCounter.java b/core/java/com/android/internal/os/LongArrayMultiStateCounter.java index dfb2884044f5..1f9a39d4ad97 100644 --- a/core/java/com/android/internal/os/LongArrayMultiStateCounter.java +++ b/core/java/com/android/internal/os/LongArrayMultiStateCounter.java @@ -60,14 +60,14 @@ import java.util.concurrent.atomic.AtomicReference;   * @hide   */  @RavenwoodKeepWholeClass -@RavenwoodRedirectionClass("LongArrayMultiStateCounter_host") +@RavenwoodRedirectionClass("LongArrayMultiStateCounter_ravenwood")  public final class LongArrayMultiStateCounter implements Parcelable {      /**       * Container for a native equivalent of a long[].       */      @RavenwoodKeepWholeClass -    @RavenwoodRedirectionClass("LongArrayContainer_host") +    @RavenwoodRedirectionClass("LongArrayMultiStateCounter_ravenwood$LongArrayContainer")      public static class LongArrayContainer {          private static NativeAllocationRegistry sRegistry; diff --git a/ravenwood/runtime-helper-src/framework/com/android/internal/os/LongArrayMultiStateCounter_host.java b/core/java/com/android/internal/os/LongArrayMultiStateCounter_ravenwood.java index 9ce8ea8e16ef..e5caa6a54390 100644 --- a/ravenwood/runtime-helper-src/framework/com/android/internal/os/LongArrayMultiStateCounter_host.java +++ b/core/java/com/android/internal/os/LongArrayMultiStateCounter_ravenwood.java @@ -18,6 +18,7 @@ package com.android.internal.os;  import android.os.BadParcelableException;  import android.os.Parcel; +import android.ravenwood.annotation.RavenwoodKeepWholeClass;  import java.util.Arrays;  import java.util.HashMap; @@ -25,7 +26,52 @@ import java.util.HashMap;  /**   * Native implementation substitutions for the LongArrayMultiStateCounter class.   */ -public class LongArrayMultiStateCounter_host { +@RavenwoodKeepWholeClass +class LongArrayMultiStateCounter_ravenwood { + +    static class LongArrayContainer { +        private static final HashMap<Long, long[]> sInstances = new HashMap<>(); +        private static long sNextId = 1; + +        public static long native_init(int arrayLength) { +            long[] array = new long[arrayLength]; +            long instanceId = sNextId++; +            sInstances.put(instanceId, array); +            return instanceId; +        } + +        static long[] getInstance(long instanceId) { +            return sInstances.get(instanceId); +        } + +        public static void native_setValues(long instanceId, long[] values) { +            System.arraycopy(values, 0, getInstance(instanceId), 0, values.length); +        } + +        public static void native_getValues(long instanceId, long[] values) { +            System.arraycopy(getInstance(instanceId), 0, values, 0, values.length); +        } + +        public static boolean native_combineValues(long instanceId, long[] array, int[] indexMap) { +            long[] values = getInstance(instanceId); + +            boolean nonZero = false; +            Arrays.fill(array, 0); + +            for (int i = 0; i < values.length; i++) { +                int index = indexMap[i]; +                if (index < 0 || index >= array.length) { +                    throw new IndexOutOfBoundsException("Index " + index + " is out of bounds: [0, " +                            + (array.length - 1) + "]"); +                } +                if (values[i] != 0) { +                    array[index] += values[i]; +                    nonZero = true; +                } +            } +            return nonZero; +        } +    }      /**       * A reimplementation of {@link LongArrayMultiStateCounter}, only in @@ -288,13 +334,13 @@ public class LongArrayMultiStateCounter_host {      public static void native_setValues(long instanceId, int state, long containerInstanceId) {          getInstance(instanceId).setValue(state, -                LongArrayContainer_host.getInstance(containerInstanceId)); +                LongArrayContainer.getInstance(containerInstanceId));      }      public static void native_updateValues(long instanceId, long containerInstanceId,              long timestampMs) {          getInstance(instanceId).updateValue( -                LongArrayContainer_host.getInstance(containerInstanceId), timestampMs); +                LongArrayContainer.getInstance(containerInstanceId), timestampMs);      }      public static void native_setState(long instanceId, int state, long timestampMs) { @@ -308,15 +354,15 @@ public class LongArrayMultiStateCounter_host {      public static void native_incrementValues(long instanceId, long containerInstanceId,              long timestampMs) {          getInstance(instanceId).incrementValues( -                LongArrayContainer_host.getInstance(containerInstanceId), timestampMs); +                LongArrayContainer.getInstance(containerInstanceId), timestampMs);      }      public static void native_addCounts(long instanceId, long containerInstanceId) { -        getInstance(instanceId).addCounts(LongArrayContainer_host.getInstance(containerInstanceId)); +        getInstance(instanceId).addCounts(LongArrayContainer.getInstance(containerInstanceId));      }      public static void native_getCounts(long instanceId, long containerInstanceId, int state) { -        getInstance(instanceId).getValues(LongArrayContainer_host.getInstance(containerInstanceId), +        getInstance(instanceId).getValues(LongArrayContainer.getInstance(containerInstanceId),                  state);      } diff --git a/core/java/com/android/internal/os/LongMultiStateCounter.java b/core/java/com/android/internal/os/LongMultiStateCounter.java index c386a86f5906..ee855d58c874 100644 --- a/core/java/com/android/internal/os/LongMultiStateCounter.java +++ b/core/java/com/android/internal/os/LongMultiStateCounter.java @@ -60,7 +60,7 @@ import libcore.util.NativeAllocationRegistry;   * @hide   */  @RavenwoodKeepWholeClass -@RavenwoodRedirectionClass("LongMultiStateCounter_host") +@RavenwoodRedirectionClass("LongMultiStateCounter_ravenwood")  public final class LongMultiStateCounter implements Parcelable {      private static NativeAllocationRegistry sRegistry; diff --git a/ravenwood/runtime-helper-src/framework/com/android/internal/os/LongMultiStateCounter_host.java b/core/java/com/android/internal/os/LongMultiStateCounter_ravenwood.java index 1d95aa143549..42db37f1f82f 100644 --- a/ravenwood/runtime-helper-src/framework/com/android/internal/os/LongMultiStateCounter_host.java +++ b/core/java/com/android/internal/os/LongMultiStateCounter_ravenwood.java @@ -18,13 +18,15 @@ package com.android.internal.os;  import android.os.BadParcelableException;  import android.os.Parcel; +import android.ravenwood.annotation.RavenwoodKeepWholeClass;  import java.util.HashMap;  /**   * Native implementation substitutions for the LongMultiStateCounter class.   */ -public class LongMultiStateCounter_host { +@RavenwoodKeepWholeClass +class LongMultiStateCounter_ravenwood {      /**       * A reimplementation of {@link com.android.internal.os.LongMultiStateCounter}, only in diff --git a/keystore/java/android/security/keystore/KeyStoreManager.java b/keystore/java/android/security/keystore/KeyStoreManager.java index 197aaba4bcb5..e6091c1da8a5 100644 --- a/keystore/java/android/security/keystore/KeyStoreManager.java +++ b/keystore/java/android/security/keystore/KeyStoreManager.java @@ -49,7 +49,7 @@ import java.util.List;   */  @FlaggedApi(android.security.Flags.FLAG_KEYSTORE_GRANT_API)  @SystemService(Context.KEYSTORE_SERVICE) -public class KeyStoreManager { +public final class KeyStoreManager {      private static final String TAG = "KeyStoreManager";      private static final Object sInstanceLock = new Object(); diff --git a/media/java/android/media/MediaFormat.java b/media/java/android/media/MediaFormat.java index b08a86ee8f46..bd65b2ecb76a 100644 --- a/media/java/android/media/MediaFormat.java +++ b/media/java/android/media/MediaFormat.java @@ -17,6 +17,7 @@  package android.media;  import static android.media.codec.Flags.FLAG_IN_PROCESS_SW_AUDIO_CODEC; +import static android.media.codec.Flags.FLAG_NUM_INPUT_SLOTS;  import static android.media.codec.Flags.FLAG_REGION_OF_INTEREST;  import static android.media.codec.Flags.FLAG_APV_SUPPORT; @@ -1777,6 +1778,17 @@ public final class MediaFormat {      public static final String KEY_SECURITY_MODEL = "security-model";      /** +     * A key describing the number of slots used in the codec. When present in input format, +     * the associated value indicates the number of input slots. The entry is set by the codec +     * if configured with (@link MediaCodec#CONFIGURE_FLAG_BLOCK_MODEL), and will be ignored if set +     * by the application. +     * <p> +     * The associated value is an integer. +     */ +    @FlaggedApi(FLAG_NUM_INPUT_SLOTS) +    public static final String KEY_NUM_SLOTS = "num-slots"; + +    /**       * QpOffsetRect constitutes the metadata required for encoding a region of interest in an       * image or a video frame. The region of interest is represented by a rectangle. The four       * integer coordinates of the rectangle are stored in fields left, top, right, bottom. diff --git a/nfc/api/system-current.txt b/nfc/api/system-current.txt index 6aa8a2b73f2c..a23845fa17e9 100644 --- a/nfc/api/system-current.txt +++ b/nfc/api/system-current.txt @@ -59,6 +59,7 @@ package android.nfc {      method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void clearPreference();      method @FlaggedApi("android.nfc.nfc_oem_extension") @NonNull public java.util.List<java.lang.String> getActiveNfceeList();      method @FlaggedApi("android.nfc.nfc_oem_extension") @NonNull @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public android.nfc.RoutingStatus getRoutingStatus(); +    method @FlaggedApi("android.nfc.nfc_oem_extension") @NonNull @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public java.util.List<android.nfc.NfcRoutingTableEntry> getRoutingTable();      method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean hasUserEnabledNfc();      method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean isAutoChangeEnabled();      method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean isTagPresent(); @@ -99,6 +100,7 @@ package android.nfc {      method public void onHceEventReceived(int);      method public void onLaunchHceAppChooserActivity(@NonNull String, @NonNull java.util.List<android.nfc.cardemulation.ApduServiceInfo>, @NonNull android.content.ComponentName, @NonNull String);      method public void onLaunchHceTapAgainDialog(@NonNull android.nfc.cardemulation.ApduServiceInfo, @NonNull String); +    method public void onLogEventNotified(@NonNull android.nfc.OemLogItems);      method public void onNdefMessage(@NonNull android.nfc.Tag, @NonNull android.nfc.NdefMessage, @NonNull java.util.function.Consumer<java.lang.Boolean>);      method public void onNdefRead(@NonNull java.util.function.Consumer<java.lang.Boolean>);      method public void onReaderOptionChanged(boolean); @@ -110,12 +112,67 @@ package android.nfc {      method public void onTagDispatch(@NonNull java.util.function.Consumer<java.lang.Boolean>);    } +  @FlaggedApi("android.nfc.nfc_oem_extension") public abstract class NfcRoutingTableEntry { +    method public int getNfceeId(); +  } + +  @FlaggedApi("android.nfc.nfc_oem_extension") public final class OemLogItems implements android.os.Parcelable { +    method public int describeContents(); +    method public int getAction(); +    method public int getCallingPid(); +    method @Nullable public byte[] getCommandApdu(); +    method public int getEvent(); +    method @Nullable public byte[] getResponseApdu(); +    method @Nullable public java.time.Instant getRfFieldEventTimeMillis(); +    method @Nullable public android.nfc.Tag getTag(); +    method public void writeToParcel(@NonNull android.os.Parcel, int); +    field @NonNull public static final android.os.Parcelable.Creator<android.nfc.OemLogItems> CREATOR; +    field public static final int EVENT_DISABLE = 2; // 0x2 +    field public static final int EVENT_ENABLE = 1; // 0x1 +    field public static final int EVENT_UNSET = 0; // 0x0 +    field public static final int LOG_ACTION_HCE_DATA = 516; // 0x204 +    field public static final int LOG_ACTION_NFC_TOGGLE = 513; // 0x201 +    field public static final int LOG_ACTION_RF_FIELD_STATE_CHANGED = 1; // 0x1 +    field public static final int LOG_ACTION_SCREEN_STATE_CHANGED = 518; // 0x206 +    field public static final int LOG_ACTION_TAG_DETECTED = 3; // 0x3 +  } +    @FlaggedApi("android.nfc.nfc_oem_extension") public class RoutingStatus {      method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public int getDefaultIsoDepRoute();      method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public int getDefaultOffHostRoute();      method @FlaggedApi("android.nfc.nfc_oem_extension") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public int getDefaultRoute();    } +  @FlaggedApi("android.nfc.nfc_oem_extension") public class RoutingTableAidEntry extends android.nfc.NfcRoutingTableEntry { +    method @FlaggedApi("android.nfc.nfc_oem_extension") @NonNull public String getAid(); +  } + +  @FlaggedApi("android.nfc.nfc_oem_extension") public class RoutingTableProtocolEntry extends android.nfc.NfcRoutingTableEntry { +    method @FlaggedApi("android.nfc.nfc_oem_extension") public int getProtocol(); +    field @FlaggedApi("android.nfc.nfc_oem_extension") public static final int PROTOCOL_ISO_DEP = 4; // 0x4 +    field @FlaggedApi("android.nfc.nfc_oem_extension") public static final int PROTOCOL_NDEF = 7; // 0x7 +    field @FlaggedApi("android.nfc.nfc_oem_extension") public static final int PROTOCOL_NFC_DEP = 5; // 0x5 +    field @FlaggedApi("android.nfc.nfc_oem_extension") public static final int PROTOCOL_T1T = 1; // 0x1 +    field @FlaggedApi("android.nfc.nfc_oem_extension") public static final int PROTOCOL_T2T = 2; // 0x2 +    field @FlaggedApi("android.nfc.nfc_oem_extension") public static final int PROTOCOL_T3T = 3; // 0x3 +    field @FlaggedApi("android.nfc.nfc_oem_extension") public static final int PROTOCOL_T5T = 6; // 0x6 +    field @FlaggedApi("android.nfc.nfc_oem_extension") public static final int PROTOCOL_UNDETERMINED = 0; // 0x0 +    field @FlaggedApi("android.nfc.nfc_oem_extension") public static final int PROTOCOL_UNSUPPORTED = -1; // 0xffffffff +  } + +  @FlaggedApi("android.nfc.nfc_oem_extension") public class RoutingTableSystemCodeEntry extends android.nfc.NfcRoutingTableEntry { +    method @FlaggedApi("android.nfc.nfc_oem_extension") @NonNull public byte[] getSystemCode(); +  } + +  @FlaggedApi("android.nfc.nfc_oem_extension") public class RoutingTableTechnologyEntry extends android.nfc.NfcRoutingTableEntry { +    method @FlaggedApi("android.nfc.nfc_oem_extension") public int getTechnology(); +    field @FlaggedApi("android.nfc.nfc_oem_extension") public static final int TECHNOLOGY_A = 0; // 0x0 +    field @FlaggedApi("android.nfc.nfc_oem_extension") public static final int TECHNOLOGY_B = 1; // 0x1 +    field @FlaggedApi("android.nfc.nfc_oem_extension") public static final int TECHNOLOGY_F = 2; // 0x2 +    field @FlaggedApi("android.nfc.nfc_oem_extension") public static final int TECHNOLOGY_UNSUPPORTED = -1; // 0xffffffff +    field @FlaggedApi("android.nfc.nfc_oem_extension") public static final int TECHNOLOGY_V = 3; // 0x3 +  } +  }  package android.nfc.cardemulation { diff --git a/nfc/java/android/nfc/Entry.aidl b/nfc/java/android/nfc/Entry.aidl new file mode 100644 index 000000000000..148c4ec86845 --- /dev/null +++ b/nfc/java/android/nfc/Entry.aidl @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2024 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.nfc; + +parcelable Entry;
\ No newline at end of file diff --git a/nfc/java/android/nfc/Entry.java b/nfc/java/android/nfc/Entry.java new file mode 100644 index 000000000000..49d0f10dbfce --- /dev/null +++ b/nfc/java/android/nfc/Entry.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2024 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.nfc; + +import android.annotation.NonNull; +import android.os.Parcel; +import android.os.Parcelable; + + +/** @hide */ +public final class Entry implements Parcelable { +    private final byte mType; +    private final byte mNfceeId; +    private final String mEntry; + +    public Entry(String entry, byte type, byte nfceeId) { +        mEntry = entry; +        mType = type; +        mNfceeId = nfceeId; +    } + +    public byte getType() { +        return mType; +    } + +    public byte getNfceeId() { +        return mNfceeId; +    } + +    public String getEntry() { +        return mEntry; +    } + +    @Override +    public int describeContents() { +        return 0; +    } + +    private Entry(Parcel in) { +        this.mEntry = in.readString(); +        this.mNfceeId = in.readByte(); +        this.mType = in.readByte(); +    } + +    public static final @NonNull Parcelable.Creator<Entry> CREATOR = +            new Parcelable.Creator<Entry>() { +                @Override +                public Entry createFromParcel(Parcel in) { +                    return new Entry(in); +                } + +                @Override +                public Entry[] newArray(int size) { +                    return new Entry[size]; +                } +            }; + +    @Override +    public void writeToParcel(@NonNull Parcel dest, int flags) { +        dest.writeString(mEntry); +        dest.writeByte(mNfceeId); +        dest.writeByte(mType); +    } +} diff --git a/nfc/java/android/nfc/INfcAdapter.aidl b/nfc/java/android/nfc/INfcAdapter.aidl index a166b283f55b..40fd0683f465 100644 --- a/nfc/java/android/nfc/INfcAdapter.aidl +++ b/nfc/java/android/nfc/INfcAdapter.aidl @@ -18,6 +18,7 @@ package android.nfc;  import android.app.PendingIntent;  import android.content.IntentFilter; +import android.nfc.Entry;  import android.nfc.NdefMessage;  import android.nfc.Tag;  import android.nfc.TechListParcel; @@ -117,4 +118,6 @@ interface INfcAdapter      void triggerInitialization();      boolean getSettingStatus();      boolean isTagPresent(); +    List<Entry> getRoutingTableEntryList(); +    void indicateDataMigration(boolean inProgress, String pkg);  } diff --git a/nfc/java/android/nfc/INfcOemExtensionCallback.aidl b/nfc/java/android/nfc/INfcOemExtensionCallback.aidl index 7f1fd15fe68a..b102e873d737 100644 --- a/nfc/java/android/nfc/INfcOemExtensionCallback.aidl +++ b/nfc/java/android/nfc/INfcOemExtensionCallback.aidl @@ -18,6 +18,7 @@ package android.nfc;  import android.content.ComponentName;  import android.nfc.cardemulation.ApduServiceInfo;  import android.nfc.NdefMessage; +import android.nfc.OemLogItems;  import android.nfc.Tag;  import android.os.ResultReceiver; @@ -51,4 +52,5 @@ interface INfcOemExtensionCallback {     void onNdefMessage(in Tag tag, in NdefMessage message, in ResultReceiver hasOemExecutableContent);     void onLaunchHceAppChooserActivity(in String selectedAid, in List<ApduServiceInfo> services, in ComponentName failedComponent, in String category);     void onLaunchHceTapAgainActivity(in ApduServiceInfo service, in String category); +   void onLogEventNotified(in OemLogItems item);  } diff --git a/nfc/java/android/nfc/NfcAdapter.java b/nfc/java/android/nfc/NfcAdapter.java index d9fd42fd4f7a..c5d8191b22e6 100644 --- a/nfc/java/android/nfc/NfcAdapter.java +++ b/nfc/java/android/nfc/NfcAdapter.java @@ -2795,11 +2795,8 @@ public final class NfcAdapter {              @IntRange(from = 0, to = 15) int gid, @IntRange(from = 0) int oid,              @NonNull byte[] payload) {          Objects.requireNonNull(payload, "Payload must not be null"); -        try { -            return sService.sendVendorNciMessage(mt, gid, oid, payload); -        } catch (RemoteException e) { -            throw e.rethrowFromSystemServer(); -        } +        return callServiceReturn(() ->  sService.sendVendorNciMessage(mt, gid, oid, payload), +                SEND_VENDOR_NCI_STATUS_FAILED);      }      /** @@ -2873,6 +2870,18 @@ public final class NfcAdapter {      }      /** +     * Used by data migration to indicate data migration is in progrerss or not. +     * +     * Note: This is @hide intentionally since the client is inside the NFC apex. +     * @param inProgress true if migration is in progress, false once done. +     * @hide +     */ +    @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) +    public void indicateDataMigration(boolean inProgress) { +        callService(() -> sService.indicateDataMigration(inProgress, mContext.getPackageName())); +    } + +    /**       * Returns an instance of {@link NfcOemExtension} associated with {@link NfcAdapter} instance.       * @hide       */ diff --git a/nfc/java/android/nfc/NfcOemExtension.java b/nfc/java/android/nfc/NfcOemExtension.java index 1d2085c88213..abd99bc02f55 100644 --- a/nfc/java/android/nfc/NfcOemExtension.java +++ b/nfc/java/android/nfc/NfcOemExtension.java @@ -43,6 +43,7 @@ import android.util.Log;  import java.lang.annotation.Retention;  import java.lang.annotation.RetentionPolicy; +import java.nio.charset.StandardCharsets;  import java.util.ArrayList;  import java.util.HashMap;  import java.util.List; @@ -71,6 +72,11 @@ import java.util.function.Supplier;  public final class NfcOemExtension {      private static final String TAG = "NfcOemExtension";      private static final int OEM_EXTENSION_RESPONSE_THRESHOLD_MS = 2000; +    private static final int TYPE_TECHNOLOGY = 0; +    private static final int TYPE_PROTOCOL = 1; +    private static final int TYPE_AID = 2; +    private static final int TYPE_SYSTEMCODE = 3; +      private final NfcAdapter mAdapter;      private final NfcOemExtensionCallback mOemNfcExtensionCallback;      private boolean mIsRegistered = false; @@ -386,6 +392,12 @@ public final class NfcOemExtension {           * @param category the category of the service           */          void onLaunchHceTapAgainDialog(@NonNull ApduServiceInfo service, @NonNull String category); + +        /** +         * Callback when OEM specified log event are notified. +         * @param item the log items that contains log information of NFC event. +         */ +        void onLogEventNotified(@NonNull OemLogItems item);      } @@ -689,6 +701,39 @@ public final class NfcOemExtension {                  ));      } +    /** +     * Gets current routing table entries. +     * @return List of {@link NfcRoutingTableEntry} representing current routing table +     */ +    @NonNull +    @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS) +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public List<NfcRoutingTableEntry> getRoutingTable() { +        List<Entry> entryList = NfcAdapter.callServiceReturn(() -> +                NfcAdapter.sService.getRoutingTableEntryList(), null); +        List<NfcRoutingTableEntry> result = new ArrayList<>(); +        for (Entry entry : entryList) { +            switch (entry.getType()) { +                case TYPE_TECHNOLOGY -> result.add( +                        new RoutingTableTechnologyEntry(entry.getNfceeId(), +                                RoutingTableTechnologyEntry.techStringToInt(entry.getEntry())) +                ); +                case TYPE_PROTOCOL -> result.add( +                        new RoutingTableProtocolEntry(entry.getNfceeId(), +                                RoutingTableProtocolEntry.protocolStringToInt(entry.getEntry())) +                ); +                case TYPE_AID -> result.add( +                        new RoutingTableAidEntry(entry.getNfceeId(), entry.getEntry()) +                ); +                case TYPE_SYSTEMCODE -> result.add( +                        new RoutingTableSystemCodeEntry(entry.getNfceeId(), +                                entry.getEntry().getBytes(StandardCharsets.UTF_8)) +                ); +            } +        } +        return result; +    } +      private final class NfcOemExtensionCallback extends INfcOemExtensionCallback.Stub {          @Override @@ -861,6 +906,12 @@ public final class NfcOemExtension {                      handleVoid2ArgCallback(service, category, cb::onLaunchHceTapAgainDialog, ex));          } +        @Override +        public void onLogEventNotified(OemLogItems item) throws RemoteException  { +            mCallbackMap.forEach((cb, ex) -> +                    handleVoidCallback(item, cb::onLogEventNotified, ex)); +        } +          private <T> void handleVoidCallback(                  T input, Consumer<T> callbackMethod, Executor executor) {              synchronized (mLock) { diff --git a/nfc/java/android/nfc/NfcRoutingTableEntry.java b/nfc/java/android/nfc/NfcRoutingTableEntry.java new file mode 100644 index 000000000000..4e913776a030 --- /dev/null +++ b/nfc/java/android/nfc/NfcRoutingTableEntry.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2024 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.nfc; + + +import android.annotation.FlaggedApi; +import android.annotation.SystemApi; + +/** + * Class to represent an entry of routing table. This class is abstract and extended by + * {@link RoutingTableTechnologyEntry}, {@link RoutingTableProtocolEntry}, + * {@link RoutingTableAidEntry} and {@link RoutingTableSystemCodeEntry}. + * + * @hide + */ +@FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +@SystemApi +public abstract class NfcRoutingTableEntry { +    private final int mNfceeId; + +    /** @hide */ +    protected NfcRoutingTableEntry(int nfceeId) { +        mNfceeId = nfceeId; +    } + +    /** +     * Gets the NFCEE Id of this entry. +     * @return an integer of NFCEE Id. +     */ +    public int getNfceeId() { +        return mNfceeId; +    } +} diff --git a/nfc/java/android/nfc/OemLogItems.aidl b/nfc/java/android/nfc/OemLogItems.aidl new file mode 100644 index 000000000000..3bcb445fc7d2 --- /dev/null +++ b/nfc/java/android/nfc/OemLogItems.aidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2024 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.nfc; + +parcelable OemLogItems;
\ No newline at end of file diff --git a/nfc/java/android/nfc/OemLogItems.java b/nfc/java/android/nfc/OemLogItems.java new file mode 100644 index 000000000000..6671941c1cc9 --- /dev/null +++ b/nfc/java/android/nfc/OemLogItems.java @@ -0,0 +1,325 @@ +/*
 + * Copyright 2024 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.nfc;
 +
 +import android.annotation.FlaggedApi;
 +import android.annotation.IntDef;
 +import android.annotation.NonNull;
 +import android.annotation.Nullable;
 +import android.annotation.SystemApi;
 +import android.os.Parcel;
 +import android.os.Parcelable;
 +
 +import java.lang.annotation.Retention;
 +import java.lang.annotation.RetentionPolicy;
 +import java.time.Instant;
 +
 +/**
 + * A log class for OEMs to get log information of NFC events.
 + * @hide
 + */
 +@FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION)
 +@SystemApi
 +public final class OemLogItems implements Parcelable {
 +    /**
 +     * Used when RF field state is changed.
 +     */
 +    public static final int LOG_ACTION_RF_FIELD_STATE_CHANGED = 0X01;
 +    /**
 +     * Used when NFC is toggled. Event should be set to {@link LogEvent#EVENT_ENABLE} or
 +     * {@link LogEvent#EVENT_DISABLE} if this action is used.
 +     */
 +    public static final int LOG_ACTION_NFC_TOGGLE = 0x0201;
 +    /**
 +     * Used when sending host routing status.
 +     */
 +    public static final int LOG_ACTION_HCE_DATA = 0x0204;
 +    /**
 +     * Used when screen state is changed.
 +     */
 +    public static final int LOG_ACTION_SCREEN_STATE_CHANGED = 0x0206;
 +    /**
 +     * Used when tag is detected.
 +     */
 +    public static final int LOG_ACTION_TAG_DETECTED = 0x03;
 +
 +    /**
 +     * @hide
 +     */
 +    @IntDef(prefix = { "LOG_ACTION_" }, value = {
 +            LOG_ACTION_RF_FIELD_STATE_CHANGED,
 +            LOG_ACTION_NFC_TOGGLE,
 +            LOG_ACTION_HCE_DATA,
 +            LOG_ACTION_SCREEN_STATE_CHANGED,
 +            LOG_ACTION_TAG_DETECTED,
 +    })
 +    @Retention(RetentionPolicy.SOURCE)
 +    public @interface LogAction {}
 +
 +    /**
 +     * Represents the event is not set.
 +     */
 +    public static final int EVENT_UNSET = 0;
 +    /**
 +     * Represents nfc enable is called.
 +     */
 +    public static final int EVENT_ENABLE = 1;
 +    /**
 +     * Represents nfc disable is called.
 +     */
 +    public static final int EVENT_DISABLE = 2;
 +    /** @hide */
 +    @IntDef(prefix = { "EVENT_" }, value = {
 +            EVENT_UNSET,
 +            EVENT_ENABLE,
 +            EVENT_DISABLE,
 +    })
 +    @Retention(RetentionPolicy.SOURCE)
 +    public @interface LogEvent {}
 +    private int mAction;
 +    private int mEvent;
 +    private int mCallingPid;
 +    private byte[] mCommandApdus;
 +    private byte[] mResponseApdus;
 +    private Instant mRfFieldOnTime;
 +    private Tag mTag;
 +
 +    /** @hide */
 +    public OemLogItems(@LogAction int action, @LogEvent int event, int callingPid,
 +            byte[] commandApdus, byte[] responseApdus, Instant rfFieldOnTime,
 +            Tag tag) {
 +        mAction = action;
 +        mEvent = event;
 +        mTag = tag;
 +        mCallingPid = callingPid;
 +        mCommandApdus = commandApdus;
 +        mResponseApdus = responseApdus;
 +        mRfFieldOnTime = rfFieldOnTime;
 +    }
 +
 +    /**
 +     * Describe the kinds of special objects contained in this Parcelable
 +     * instance's marshaled representation. For example, if the object will
 +     * include a file descriptor in the output of {@link #writeToParcel(Parcel, int)},
 +     * the return value of this method must include the
 +     * {@link #CONTENTS_FILE_DESCRIPTOR} bit.
 +     *
 +     * @return a bitmask indicating the set of special object types marshaled
 +     * by this Parcelable object instance.
 +     */
 +    @Override
 +    public int describeContents() {
 +        return 0;
 +    }
 +
 +    /**
 +     * Flatten this object in to a Parcel.
 +     *
 +     * @param dest  The Parcel in which the object should be written.
 +     * @param flags Additional flags about how the object should be written.
 +     *              May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}.
 +     */
 +    @Override
 +    public void writeToParcel(@NonNull Parcel dest, int flags) {
 +        dest.writeInt(mAction);
 +        dest.writeInt(mEvent);
 +        dest.writeInt(mCallingPid);
 +        dest.writeInt(mCommandApdus.length);
 +        dest.writeByteArray(mCommandApdus);
 +        dest.writeInt(mResponseApdus.length);
 +        dest.writeByteArray(mResponseApdus);
 +        dest.writeLong(mRfFieldOnTime.getEpochSecond());
 +        dest.writeInt(mRfFieldOnTime.getNano());
 +        dest.writeParcelable(mTag, 0);
 +    }
 +
 +    /** @hide */
 +    public static class Builder {
 +        private final OemLogItems mItem;
 +
 +        public Builder(@LogAction int type) {
 +            mItem = new OemLogItems(type, EVENT_UNSET, 0, new byte[0], new byte[0], null, null);
 +        }
 +
 +        /** Setter of the log action. */
 +        public OemLogItems.Builder setAction(@LogAction int action) {
 +            mItem.mAction = action;
 +            return this;
 +        }
 +
 +        /** Setter of the log calling event. */
 +        public OemLogItems.Builder setCallingEvent(@LogEvent int event) {
 +            mItem.mEvent = event;
 +            return this;
 +        }
 +
 +        /** Setter of the log calling Pid. */
 +        public OemLogItems.Builder setCallingPid(int pid) {
 +            mItem.mCallingPid = pid;
 +            return this;
 +        }
 +
 +        /** Setter of APDU command. */
 +        public OemLogItems.Builder setApduCommand(byte[] apdus) {
 +            mItem.mCommandApdus = apdus;
 +            return this;
 +        }
 +
 +        /** Setter of RF field on time. */
 +        public OemLogItems.Builder setRfFieldOnTime(Instant time) {
 +            mItem.mRfFieldOnTime = time;
 +            return this;
 +        }
 +
 +        /** Setter of APDU response. */
 +        public OemLogItems.Builder setApduResponse(byte[] apdus) {
 +            mItem.mResponseApdus = apdus;
 +            return this;
 +        }
 +
 +        /** Setter of dispatched tag. */
 +        public OemLogItems.Builder setTag(Tag tag) {
 +            mItem.mTag = tag;
 +            return this;
 +        }
 +
 +        /** Builds an {@link OemLogItems} instance. */
 +        public OemLogItems build() {
 +            return mItem;
 +        }
 +    }
 +
 +    /**
 +     * Gets the action of this log.
 +     * @return one of {@link LogAction}
 +     */
 +    @LogAction
 +    public int getAction() {
 +        return mAction;
 +    }
 +
 +    /**
 +     * Gets the event of this log. This will be set to {@link LogEvent#EVENT_ENABLE} or
 +     * {@link LogEvent#EVENT_DISABLE} only when action is set to
 +     * {@link LogAction#LOG_ACTION_NFC_TOGGLE}
 +     * @return one of {@link LogEvent}
 +     */
 +    @LogEvent
 +    public int getEvent() {
 +        return mEvent;
 +    }
 +
 +    /**
 +     * Gets the calling Pid of this log. This field will be set only when action is set to
 +     * {@link LogAction#LOG_ACTION_NFC_TOGGLE}
 +     * @return calling Pid
 +     */
 +    public int getCallingPid() {
 +        return mCallingPid;
 +    }
 +
 +    /**
 +     * Gets the command APDUs of this log. This field will be set only when action is set to
 +     * {@link LogAction#LOG_ACTION_HCE_DATA}
 +     * @return a byte array of command APDUs with the same format as
 +     * {@link android.nfc.cardemulation.HostApduService#sendResponseApdu(byte[])}
 +     */
 +    @Nullable
 +    public byte[] getCommandApdu() {
 +        return mCommandApdus;
 +    }
 +
 +    /**
 +     * Gets the response APDUs of this log. This field will be set only when action is set to
 +     * {@link LogAction#LOG_ACTION_HCE_DATA}
 +     * @return a byte array of response APDUs with the same format as
 +     * {@link android.nfc.cardemulation.HostApduService#sendResponseApdu(byte[])}
 +     */
 +    @Nullable
 +    public byte[] getResponseApdu() {
 +        return mResponseApdus;
 +    }
 +
 +    /**
 +     * Gets the RF field event time in this log in millisecond. This field will be set only when
 +     * action is set to {@link LogAction#LOG_ACTION_RF_FIELD_STATE_CHANGED}
 +     * @return an {@link Instant} of RF field event time.
 +     */
 +    @Nullable
 +    public Instant getRfFieldEventTimeMillis() {
 +        return mRfFieldOnTime;
 +    }
 +
 +    /**
 +     * Gets the tag of this log. This field will be set only when action is set to
 +     * {@link LogAction#LOG_ACTION_TAG_DETECTED}
 +     * @return a detected {@link Tag} in {@link #LOG_ACTION_TAG_DETECTED} case. Return
 +     * null otherwise.
 +     */
 +    @Nullable
 +    public Tag getTag() {
 +        return mTag;
 +    }
 +
 +    private String byteToHex(byte[] bytes) {
 +        char[] HexArray = "0123456789ABCDEF".toCharArray();
 +        char[] hexChars = new char[bytes.length * 2];
 +        for (int j = 0; j < bytes.length; j++) {
 +            int v = bytes[j] & 0xFF;
 +            hexChars[j * 2] = HexArray[v >>> 4];
 +            hexChars[j * 2 + 1] = HexArray[v & 0x0F];
 +        }
 +        return new String(hexChars);
 +    }
 +
 +    @Override
 +    public String toString() {
 +        return "[mCommandApdus: "
 +                + ((mCommandApdus != null) ? byteToHex(mCommandApdus) : "null")
 +                + "[mResponseApdus: "
 +                + ((mResponseApdus != null) ? byteToHex(mResponseApdus) : "null")
 +                + ", mCallingApi= " + mEvent
 +                + ", mAction= " + mAction
 +                + ", mCallingPId = " + mCallingPid
 +                + ", mRfFieldOnTime= " + mRfFieldOnTime;
 +    }
 +    private OemLogItems(Parcel in) {
 +        this.mAction = in.readInt();
 +        this.mEvent = in.readInt();
 +        this.mCallingPid = in.readInt();
 +        this.mCommandApdus = new byte[in.readInt()];
 +        in.readByteArray(this.mCommandApdus);
 +        this.mResponseApdus = new byte[in.readInt()];
 +        in.readByteArray(this.mResponseApdus);
 +        this.mRfFieldOnTime = Instant.ofEpochSecond(in.readLong(), in.readInt());
 +        this.mTag = in.readParcelable(Tag.class.getClassLoader(), Tag.class);
 +    }
 +
 +    public static final @NonNull Parcelable.Creator<OemLogItems> CREATOR =
 +            new Parcelable.Creator<OemLogItems>() {
 +                @Override
 +                public OemLogItems createFromParcel(Parcel in) {
 +                    return new OemLogItems(in);
 +                }
 +
 +                @Override
 +                public OemLogItems[] newArray(int size) {
 +                    return new OemLogItems[size];
 +                }
 +            };
 +
 +}
 diff --git a/nfc/java/android/nfc/RoutingTableAidEntry.java b/nfc/java/android/nfc/RoutingTableAidEntry.java new file mode 100644 index 000000000000..7634fe342ab9 --- /dev/null +++ b/nfc/java/android/nfc/RoutingTableAidEntry.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2024 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.nfc; + +import android.annotation.FlaggedApi; +import android.annotation.NonNull; +import android.annotation.SystemApi; + +/** + * Represents an AID entry in current routing table. + * @hide + */ +@FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +@SystemApi +public class RoutingTableAidEntry extends NfcRoutingTableEntry { +    private final String mValue; + +    /** @hide */ +    public RoutingTableAidEntry(int nfceeId, String value) { +        super(nfceeId); +        this.mValue = value; +    } + +    /** +     * Gets AID value. +     * @return String of AID +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    @NonNull +    public String getAid() { +        return mValue; +    } +} diff --git a/nfc/java/android/nfc/RoutingTableProtocolEntry.java b/nfc/java/android/nfc/RoutingTableProtocolEntry.java new file mode 100644 index 000000000000..0c5be7dd9d97 --- /dev/null +++ b/nfc/java/android/nfc/RoutingTableProtocolEntry.java @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2024 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.nfc; + +import android.annotation.FlaggedApi; +import android.annotation.IntDef; +import android.annotation.SystemApi; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Represents a protocol entry in current routing table. + * @hide + */ +@FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +@SystemApi +public class RoutingTableProtocolEntry extends NfcRoutingTableEntry { +    /** +     * Protocol undetermined. +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public static final int PROTOCOL_UNDETERMINED = 0; +    /** +     * T1T Protocol +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public static final int PROTOCOL_T1T = 1; +    /** +     * T2T Protocol +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public static final int PROTOCOL_T2T = 2; +    /** +     * T3T Protocol +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public static final int PROTOCOL_T3T = 3; +    /** +     * ISO-DEP Protocol +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public static final int PROTOCOL_ISO_DEP = 4; +    /** +     * DEP Protocol +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public static final int PROTOCOL_NFC_DEP = 5; +    /** +     * T5T Protocol +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public static final int PROTOCOL_T5T = 6; +    /** +     * NDEF Protocol +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public static final int PROTOCOL_NDEF = 7; +    /** +     * Unsupported Protocol +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public static final int PROTOCOL_UNSUPPORTED = -1; + +    /** +     * +     * @hide +     */ +    @IntDef(prefix = { "PROTOCOL_" }, value = { +            PROTOCOL_UNDETERMINED, +            PROTOCOL_T1T, +            PROTOCOL_T2T, +            PROTOCOL_T3T, +            PROTOCOL_ISO_DEP, +            PROTOCOL_NFC_DEP, +            PROTOCOL_T5T, +            PROTOCOL_NDEF, +            PROTOCOL_UNSUPPORTED +    }) +    @Retention(RetentionPolicy.SOURCE) +    public @interface ProtocolValue {} + +    private final @ProtocolValue int mValue; + +    /** @hide */ +    public RoutingTableProtocolEntry(int nfceeId, @ProtocolValue int value) { +        super(nfceeId); +        this.mValue = value; +    } + +    /** +     * Gets Protocol value. +     * @return Protocol defined in {@link ProtocolValue} +     */ +    @ProtocolValue +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public int getProtocol() { +        return mValue; +    } + +    /** @hide */ +    @ProtocolValue +    public static int protocolStringToInt(String protocolString) { +        return switch (protocolString) { +            case "PROTOCOL_T1T" -> PROTOCOL_T1T; +            case "PROTOCOL_T2T" -> PROTOCOL_T2T; +            case "PROTOCOL_T3T" -> PROTOCOL_T3T; +            case "PROTOCOL_ISO_DEP" -> PROTOCOL_ISO_DEP; +            case "PROTOCOL_NFC_DEP" -> PROTOCOL_NFC_DEP; +            case "PROTOCOL_T5T" -> PROTOCOL_T5T; +            case "PROTOCOL_NDEF" -> PROTOCOL_NDEF; +            case "PROTOCOL_UNDETERMINED" -> PROTOCOL_UNDETERMINED; +            default -> PROTOCOL_UNSUPPORTED; +        }; +    } +} diff --git a/nfc/java/android/nfc/RoutingTableSystemCodeEntry.java b/nfc/java/android/nfc/RoutingTableSystemCodeEntry.java new file mode 100644 index 000000000000..f87ad5f95195 --- /dev/null +++ b/nfc/java/android/nfc/RoutingTableSystemCodeEntry.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2024 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.nfc; + +import android.annotation.FlaggedApi; +import android.annotation.NonNull; +import android.annotation.SystemApi; + +/** + * Represents a system code entry in current routing table. + * @hide + */ +@FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +@SystemApi +public class RoutingTableSystemCodeEntry extends NfcRoutingTableEntry { +    private final byte[] mValue; + +    /** @hide */ +    public RoutingTableSystemCodeEntry(int nfceeId, byte[] value) { +        super(nfceeId); +        this.mValue = value; +    } + +    /** +     * Gets system code value. +     * @return Byte array of system code +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    @NonNull +    public byte[] getSystemCode() { +        return mValue; +    } +} diff --git a/nfc/java/android/nfc/RoutingTableTechnologyEntry.java b/nfc/java/android/nfc/RoutingTableTechnologyEntry.java new file mode 100644 index 000000000000..f51a5299be11 --- /dev/null +++ b/nfc/java/android/nfc/RoutingTableTechnologyEntry.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2024 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.nfc; + +import android.annotation.FlaggedApi; +import android.annotation.IntDef; +import android.annotation.SystemApi; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Represents a technology entry in current routing table. + * @hide + */ +@FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +@SystemApi +public class RoutingTableTechnologyEntry extends NfcRoutingTableEntry { +    /** +     * Technology-A +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public static final int TECHNOLOGY_A = 0; +    /** +     * Technology-B +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public static final int TECHNOLOGY_B = 1; +    /** +     * Technology-F +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public static final int TECHNOLOGY_F = 2; +    /** +     * Technology-V +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public static final int TECHNOLOGY_V = 3; +    /** +     * Unsupported technology +     */ +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public static final int TECHNOLOGY_UNSUPPORTED = -1; + +    /** +     * +     * @hide +     */ +    @IntDef(prefix = { "TECHNOLOGY_" }, value = { +            TECHNOLOGY_A, +            TECHNOLOGY_B, +            TECHNOLOGY_F, +            TECHNOLOGY_V, +            TECHNOLOGY_UNSUPPORTED +    }) +    @Retention(RetentionPolicy.SOURCE) +    public @interface TechnologyValue{} + +    private final @TechnologyValue int mValue; + +    /** @hide */ +    public RoutingTableTechnologyEntry(int nfceeId, @TechnologyValue int value) { +        super(nfceeId); +        this.mValue = value; +    } + +    /** +     * Gets technology value. +     * @return technology value +     */ +    @TechnologyValue +    @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION) +    public int getTechnology() { +        return mValue; +    } + +    /** @hide */ +    @TechnologyValue +    public static int techStringToInt(String tech) { +        return switch (tech) { +            case "TECHNOLOGY_A" -> TECHNOLOGY_A; +            case "TECHNOLOGY_B" -> TECHNOLOGY_B; +            case "TECHNOLOGY_F" -> TECHNOLOGY_F; +            case "TECHNOLOGY_V" -> TECHNOLOGY_V; +            default -> TECHNOLOGY_UNSUPPORTED; +        }; +    } +} diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/OWNERS b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/OWNERS new file mode 100644 index 000000000000..a2001e66e55b --- /dev/null +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/OWNERS @@ -0,0 +1 @@ +include /core/java/android/view/accessibility/OWNERS
\ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/CustomizationProvider.kt b/packages/SystemUI/src/com/android/systemui/keyguard/CustomizationProvider.kt index 342325ffee91..ca358e180b0b 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/CustomizationProvider.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/CustomizationProvider.kt @@ -30,7 +30,7 @@ import android.net.Uri  import android.os.Binder  import android.os.Bundle  import android.util.Log -import com.android.app.tracing.coroutines.runBlocking +import com.android.app.tracing.coroutines.runBlockingTraced as runBlocking  import com.android.systemui.SystemUIAppComponentFactoryBase  import com.android.systemui.SystemUIAppComponentFactoryBase.ContextAvailableCallback  import com.android.systemui.dagger.qualifiers.Main diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt index 1b201ceda310..ac797feca550 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt @@ -23,7 +23,7 @@ import android.annotation.FloatRange  import android.annotation.SuppressLint  import android.os.Trace  import android.util.Log -import com.android.app.tracing.coroutines.withContext +import com.android.app.tracing.coroutines.withContextTraced as withContext  import com.android.systemui.dagger.SysUISingleton  import com.android.systemui.dagger.qualifiers.Main  import com.android.systemui.keyguard.shared.model.KeyguardState diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromAodTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromAodTransitionInteractor.kt index 2a9ee9fb8779..1e228eb5205d 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromAodTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromAodTransitionInteractor.kt @@ -18,7 +18,7 @@ package com.android.systemui.keyguard.domain.interactor  import android.animation.ValueAnimator  import com.android.app.animation.Interpolators -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.dagger.SysUISingleton  import com.android.systemui.dagger.qualifiers.Background  import com.android.systemui.dagger.qualifiers.Main diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromDreamingTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromDreamingTransitionInteractor.kt index 7fa197c11e57..ab8075c7bcbf 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromDreamingTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromDreamingTransitionInteractor.kt @@ -18,7 +18,7 @@ package com.android.systemui.keyguard.domain.interactor  import android.animation.ValueAnimator  import com.android.app.animation.Interpolators -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.Flags.communalHub  import com.android.systemui.dagger.SysUISingleton  import com.android.systemui.dagger.qualifiers.Background diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGlanceableHubTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGlanceableHubTransitionInteractor.kt index e516fa3c44bb..26d1c25b6634 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGlanceableHubTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGlanceableHubTransitionInteractor.kt @@ -18,7 +18,7 @@ package com.android.systemui.keyguard.domain.interactor  import android.animation.ValueAnimator  import com.android.app.animation.Interpolators -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.Flags  import com.android.systemui.dagger.SysUISingleton  import com.android.systemui.dagger.qualifiers.Background diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractor.kt index f5b12a2ecfcf..a5b8ff034603 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractor.kt @@ -18,7 +18,7 @@ package com.android.systemui.keyguard.domain.interactor  import android.animation.ValueAnimator  import com.android.app.animation.Interpolators -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.communal.domain.interactor.CommunalInteractor  import com.android.systemui.dagger.SysUISingleton  import com.android.systemui.dagger.qualifiers.Background diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromLockscreenTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromLockscreenTransitionInteractor.kt index f30eef080ede..a2c9da0d70e5 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromLockscreenTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromLockscreenTransitionInteractor.kt @@ -19,7 +19,7 @@ package com.android.systemui.keyguard.domain.interactor  import android.animation.ValueAnimator  import android.util.MathUtils  import com.android.app.animation.Interpolators -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.Flags  import com.android.systemui.dagger.SysUISingleton  import com.android.systemui.dagger.qualifiers.Background diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt index ccce3bf1397c..a01a0e467f34 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt @@ -22,7 +22,7 @@ import android.app.admin.DevicePolicyManager  import android.content.Context  import android.content.Intent  import android.util.Log -import com.android.app.tracing.coroutines.withContext +import com.android.app.tracing.coroutines.withContextTraced as withContext  import com.android.compose.animation.scene.ObservableTransitionState  import com.android.internal.widget.LockPatternUtils  import com.android.systemui.animation.DialogTransitionAnimator diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerMessageAreaViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerMessageAreaViewBinder.kt index fe5f632c0b6a..23b7b664d4f1 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerMessageAreaViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerMessageAreaViewBinder.kt @@ -18,7 +18,7 @@ package com.android.systemui.keyguard.ui.binder  import androidx.lifecycle.Lifecycle  import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.keyguard.AuthKeyguardMessageArea  import com.android.systemui.keyguard.ui.viewmodel.AlternateBouncerMessageAreaViewModel  import com.android.systemui.lifecycle.repeatWhenAttached diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerUdfpsViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerUdfpsViewBinder.kt index 9dc77d3dc9d3..53eefa7408c7 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerUdfpsViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerUdfpsViewBinder.kt @@ -21,7 +21,7 @@ import android.content.res.ColorStateList  import android.view.View  import androidx.lifecycle.Lifecycle  import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor  import com.android.systemui.keyguard.ui.view.DeviceEntryIconView  import com.android.systemui.keyguard.ui.viewmodel.AlternateBouncerUdfpsIconViewModel diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerViewBinder.kt index f8063c92124d..e7e4ed50bf7a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/AlternateBouncerViewBinder.kt @@ -29,7 +29,7 @@ import androidx.constraintlayout.widget.ConstraintLayout  import androidx.constraintlayout.widget.ConstraintSet  import androidx.lifecycle.Lifecycle  import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.CoreStartable  import com.android.systemui.dagger.SysUISingleton  import com.android.systemui.dagger.qualifiers.Application diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt index b45eae7301b4..646f0fde8cc0 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt @@ -27,7 +27,7 @@ import androidx.compose.ui.graphics.toArgb  import androidx.core.view.isInvisible  import androidx.lifecycle.Lifecycle  import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.common.ui.view.LongPressHandlingView  import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor  import com.android.systemui.keyguard.ui.view.DeviceEntryIconView diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBlueprintViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBlueprintViewBinder.kt index bec8f3da9999..b684d196619a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBlueprintViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBlueprintViewBinder.kt @@ -22,7 +22,7 @@ import androidx.constraintlayout.widget.ConstraintLayout  import androidx.constraintlayout.widget.ConstraintSet  import androidx.lifecycle.Lifecycle  import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.keyguard.KeyguardBottomAreaRefactor  import com.android.systemui.keyguard.shared.model.KeyguardBlueprint  import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.BaseBlueprintTransition diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt index 660a650fb916..3bdf7dac75b3 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt @@ -36,7 +36,7 @@ import androidx.core.view.updateLayoutParams  import androidx.lifecycle.Lifecycle  import androidx.lifecycle.repeatOnLifecycle  import com.android.app.animation.Interpolators -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.settingslib.Utils  import com.android.systemui.animation.ActivityTransitionAnimator  import com.android.systemui.animation.Expandable diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt index 23c2491813f7..93499027140b 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardIndicationAreaBinder.kt @@ -22,7 +22,7 @@ import android.view.ViewGroup  import android.widget.TextView  import androidx.lifecycle.Lifecycle  import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.keyguard.KeyguardBottomAreaRefactor  import com.android.systemui.keyguard.MigrateClocksToBlueprint  import com.android.systemui.keyguard.ui.viewmodel.KeyguardIndicationAreaViewModel diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardLongPressViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardLongPressViewBinder.kt index 09fe067f7724..762760e3a1e3 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardLongPressViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardLongPressViewBinder.kt @@ -20,7 +20,7 @@ package com.android.systemui.keyguard.ui.binder  import android.view.View  import androidx.lifecycle.Lifecycle  import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.common.ui.view.LongPressHandlingView  import com.android.systemui.keyguard.ui.viewmodel.KeyguardLongPressViewModel  import com.android.systemui.lifecycle.repeatWhenAttached diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockViewBinder.kt index 8386628f4c83..86dae0cbc6aa 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockViewBinder.kt @@ -33,7 +33,7 @@ import androidx.constraintlayout.widget.ConstraintSet.TOP  import androidx.core.view.isVisible  import androidx.lifecycle.Lifecycle  import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.internal.policy.SystemBarUtils  import com.android.systemui.customization.R as customizationR  import com.android.systemui.keyguard.shared.model.ClockSizeSetting diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewSmartspaceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewSmartspaceViewBinder.kt index 4b75b804e52b..baa681282a0b 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewSmartspaceViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewSmartspaceViewBinder.kt @@ -22,7 +22,7 @@ import android.view.View  import androidx.core.view.isInvisible  import androidx.lifecycle.Lifecycle  import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.keyguard.shared.model.ClockSizeSetting  import com.android.systemui.keyguard.ui.viewmodel.KeyguardPreviewSmartspaceViewModel  import com.android.systemui.lifecycle.repeatWhenAttached diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSettingsViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSettingsViewBinder.kt index fa5756522a6a..8df67d38d0f2 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSettingsViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSettingsViewBinder.kt @@ -22,7 +22,7 @@ import android.view.View  import androidx.core.view.isVisible  import androidx.lifecycle.Lifecycle  import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.animation.ActivityTransitionAnimator  import com.android.systemui.common.ui.binder.IconViewBinder  import com.android.systemui.common.ui.binder.TextViewBinder diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt index 191056c5578a..7a13d657973c 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt @@ -21,7 +21,7 @@ import androidx.constraintlayout.helper.widget.Layer  import androidx.constraintlayout.widget.ConstraintLayout  import androidx.lifecycle.Lifecycle  import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.keyguard.MigrateClocksToBlueprint  import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor  import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransition.Config diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSurfaceBehindViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSurfaceBehindViewBinder.kt index fd27dc39299b..3934917d13c4 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSurfaceBehindViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSurfaceBehindViewBinder.kt @@ -16,7 +16,7 @@  package com.android.systemui.keyguard.ui.binder -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.keyguard.WindowManagerLockscreenVisibilityManager  import com.android.systemui.keyguard.ui.viewmodel.KeyguardSurfaceBehindViewModel  import kotlinx.coroutines.CoroutineScope diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/LightRevealScrimViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/LightRevealScrimViewBinder.kt index b2ee68967878..2df17c39d90d 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/LightRevealScrimViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/LightRevealScrimViewBinder.kt @@ -18,7 +18,7 @@ package com.android.systemui.keyguard.ui.binder  import androidx.lifecycle.Lifecycle  import androidx.lifecycle.repeatOnLifecycle -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.keyguard.ui.viewmodel.LightRevealScrimViewModel  import com.android.systemui.lifecycle.repeatWhenAttached  import com.android.systemui.statusbar.LightRevealScrim diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/WindowManagerLockscreenVisibilityViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/WindowManagerLockscreenVisibilityViewBinder.kt index ae46dd3a6ef3..b1ce47ee79e6 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/WindowManagerLockscreenVisibilityViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/WindowManagerLockscreenVisibilityViewBinder.kt @@ -16,7 +16,7 @@  package com.android.systemui.keyguard.ui.binder -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.keyguard.WindowManagerLockscreenVisibilityManager  import com.android.systemui.keyguard.ui.viewmodel.WindowManagerLockscreenVisibilityViewModel  import kotlinx.coroutines.CoroutineScope diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt index aefff7d0f79b..edd7ae0733b3 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt @@ -20,7 +20,7 @@ package com.android.systemui.keyguard.ui.viewmodel  import android.graphics.Point  import android.util.MathUtils  import android.view.View.VISIBLE -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.Flags.newAodTransition  import com.android.systemui.common.shared.model.NotificationContainerBounds  import com.android.systemui.communal.domain.interactor.CommunalInteractor diff --git a/packages/SystemUI/src/com/android/systemui/lifecycle/RepeatWhenAttached.kt b/packages/SystemUI/src/com/android/systemui/lifecycle/RepeatWhenAttached.kt index bf80e1870f1b..be32d108f676 100644 --- a/packages/SystemUI/src/com/android/systemui/lifecycle/RepeatWhenAttached.kt +++ b/packages/SystemUI/src/com/android/systemui/lifecycle/RepeatWhenAttached.kt @@ -26,7 +26,7 @@ import androidx.lifecycle.LifecycleOwner  import androidx.lifecycle.LifecycleRegistry  import androidx.lifecycle.lifecycleScope  import com.android.app.tracing.coroutines.createCoroutineTracingContext -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.Flags.coroutineTracing  import com.android.systemui.util.Assert  import com.android.systemui.util.Compile diff --git a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt index 3aa9daac4866..d0f6f7961889 100644 --- a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt +++ b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt @@ -37,7 +37,7 @@ import android.os.UserManager  import android.provider.Settings  import android.widget.Toast  import androidx.annotation.VisibleForTesting -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.dagger.SysUISingleton  import com.android.systemui.dagger.qualifiers.Application  import com.android.systemui.dagger.qualifiers.Background diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ActionExecutor.kt b/packages/SystemUI/src/com/android/systemui/screenshot/ActionExecutor.kt index 1868b4a29f20..a7b6ec7bb713 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ActionExecutor.kt +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ActionExecutor.kt @@ -26,7 +26,7 @@ import android.os.UserHandle  import android.util.Log  import android.util.Pair  import android.view.Window -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.internal.app.ChooserActivity  import com.android.systemui.dagger.qualifiers.Application  import dagger.assisted.Assisted diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ActionIntentExecutor.kt b/packages/SystemUI/src/com/android/systemui/screenshot/ActionIntentExecutor.kt index 9e622801a01b..7b01c36489fb 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ActionIntentExecutor.kt +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ActionIntentExecutor.kt @@ -31,7 +31,7 @@ import android.view.RemoteAnimationAdapter  import android.view.RemoteAnimationTarget  import android.view.WindowManager  import android.view.WindowManagerGlobal -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.internal.infra.ServiceConnector  import com.android.systemui.Flags  import com.android.systemui.dagger.SysUISingleton diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotProxyService.kt b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotProxyService.kt index c8067df114fc..6df22f036273 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotProxyService.kt +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotProxyService.kt @@ -21,7 +21,7 @@ import android.os.RemoteException  import android.util.Log  import androidx.lifecycle.LifecycleService  import androidx.lifecycle.lifecycleScope -import com.android.app.tracing.coroutines.launch +import com.android.app.tracing.coroutines.launchTraced as launch  import com.android.systemui.dagger.qualifiers.Main  import com.android.systemui.plugins.ActivityStarter  import com.android.systemui.shade.ShadeExpansionStateManager diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotSoundController.kt b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotSoundController.kt index d3a7fc4a3e4a..7aeec47241cb 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotSoundController.kt +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotSoundController.kt @@ -18,7 +18,7 @@ package com.android.systemui.screenshot  import android.media.MediaPlayer  import android.util.Log -import com.android.app.tracing.coroutines.async +import com.android.app.tracing.coroutines.asyncTraced as async  import com.android.systemui.dagger.qualifiers.Application  import com.android.systemui.dagger.qualifiers.Background  import javax.inject.Inject diff --git a/packages/Vcn/framework-b/Android.bp b/packages/Vcn/framework-b/Android.bp new file mode 100644 index 000000000000..be64bb1ae404 --- /dev/null +++ b/packages/Vcn/framework-b/Android.bp @@ -0,0 +1,44 @@ +// +// Copyright (C) 2024 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 { +    default_team: "trendy_team_enigma", +    default_applicable_licenses: ["Android-Apache-2.0"], +} + +java_defaults { +    name: "framework-connectivity-b-defaults", +    sdk_version: "module_current", +    min_sdk_version: "35", // TODO: Make it Android 25Q2 when this is included in mainline +    defaults: ["framework-module-defaults"], // This is a boot jar + +    srcs: [ +        "src/**/*.java", +    ], +} + +java_sdk_library { +    name: "framework-connectivity-b", +    defaults: [ +        "framework-connectivity-b-defaults", +    ], + +    permitted_packages: [ +        "android.net.vcn", +    ], + +    // TODO: b/375213246 Expose this library to Tethering module +} diff --git a/packages/Vcn/framework-b/api/current.txt b/packages/Vcn/framework-b/api/current.txt new file mode 100644 index 000000000000..d802177e249b --- /dev/null +++ b/packages/Vcn/framework-b/api/current.txt @@ -0,0 +1 @@ +// Signature format: 2.0 diff --git a/packages/Vcn/framework-b/api/module-lib-current.txt b/packages/Vcn/framework-b/api/module-lib-current.txt new file mode 100644 index 000000000000..d802177e249b --- /dev/null +++ b/packages/Vcn/framework-b/api/module-lib-current.txt @@ -0,0 +1 @@ +// Signature format: 2.0 diff --git a/packages/Vcn/framework-b/api/module-lib-removed.txt b/packages/Vcn/framework-b/api/module-lib-removed.txt new file mode 100644 index 000000000000..d802177e249b --- /dev/null +++ b/packages/Vcn/framework-b/api/module-lib-removed.txt @@ -0,0 +1 @@ +// Signature format: 2.0 diff --git a/packages/Vcn/framework-b/api/removed.txt b/packages/Vcn/framework-b/api/removed.txt new file mode 100644 index 000000000000..d802177e249b --- /dev/null +++ b/packages/Vcn/framework-b/api/removed.txt @@ -0,0 +1 @@ +// Signature format: 2.0 diff --git a/packages/Vcn/framework-b/api/system-current.txt b/packages/Vcn/framework-b/api/system-current.txt new file mode 100644 index 000000000000..d802177e249b --- /dev/null +++ b/packages/Vcn/framework-b/api/system-current.txt @@ -0,0 +1 @@ +// Signature format: 2.0 diff --git a/packages/Vcn/framework-b/api/system-removed.txt b/packages/Vcn/framework-b/api/system-removed.txt new file mode 100644 index 000000000000..d802177e249b --- /dev/null +++ b/packages/Vcn/framework-b/api/system-removed.txt @@ -0,0 +1 @@ +// Signature format: 2.0 diff --git a/packages/Vcn/framework-b/src/android/net/vcn/Placeholder.java b/packages/Vcn/framework-b/src/android/net/vcn/Placeholder.java new file mode 100644 index 000000000000..fb5e15386cc7 --- /dev/null +++ b/packages/Vcn/framework-b/src/android/net/vcn/Placeholder.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 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.vcn; + +/** + * Placeholder class so new framework-vcn isn't empty + * + * @hide + */ +// This class will be removed once source code is migrated +public class Placeholder {} diff --git a/packages/Vcn/service-b/Android.bp b/packages/Vcn/service-b/Android.bp new file mode 100644 index 000000000000..a462297c07af --- /dev/null +++ b/packages/Vcn/service-b/Android.bp @@ -0,0 +1,36 @@ +// +// Copyright (C) 2024 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 { +    default_team: "trendy_team_enigma", +    default_applicable_licenses: ["Android-Apache-2.0"], +} + +java_library { +    name: "service-connectivity-b-pre-jarjar", +    sdk_version: "system_server_current", +    min_sdk_version: "35", // TODO: Make it Android 25Q2 when this is included in mainline +    defaults: ["framework-system-server-module-defaults"], // This is a system server jar + +    srcs: [ +        "src/**/*.java", +    ], + +    // TODO: b/375213246 Expose this library to Tethering module +    visibility: [ +        "//frameworks/base/services", +    ], +} diff --git a/packages/Vcn/service-b/src/com/android/server/vcn/Placeholder.java b/packages/Vcn/service-b/src/com/android/server/vcn/Placeholder.java new file mode 100644 index 000000000000..e79914531c38 --- /dev/null +++ b/packages/Vcn/service-b/src/com/android/server/vcn/Placeholder.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + *      http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.vcn; + +/** + * Placeholder class so new service-vcn isn't empty + * + * @hide + */ +// This class will be removed once source code is migrated +public class Placeholder {} diff --git a/packages/overlays/Android.bp b/packages/overlays/Android.bp index 5075f6322d1b..44abb9ffb34f 100644 --- a/packages/overlays/Android.bp +++ b/packages/overlays/Android.bp @@ -21,6 +21,7 @@ package {  phony {      name: "frameworks-base-overlays", +    product_specific: true,      required: [          "DisplayCutoutEmulationCornerOverlay",          "DisplayCutoutEmulationDoubleOverlay", diff --git a/ravenwood/Android.bp b/ravenwood/Android.bp index b3f78ab30021..0c2ce8dcb698 100644 --- a/ravenwood/Android.bp +++ b/ravenwood/Android.bp @@ -279,6 +279,15 @@ cc_defaults {      shared_libs: [          "liblog",      ], +    visibility: ["//visibility:private"], +} + +cc_library_host_shared { +    name: "libravenwood_initializer", +    defaults: ["ravenwood_jni_defaults"], +    srcs: [ +        "runtime-jni/ravenwood_initializer.cpp", +    ],  }  // We need this as a separate library because we need to overload the @@ -301,7 +310,6 @@ cc_library_host_shared {          "libutils",          "libcutils",      ], -    visibility: ["//frameworks/base"],  }  // For collecting the *stats.csv files in a known directory under out/host/linux-x86/testcases/. @@ -368,6 +376,7 @@ filegroup {          ":ravenwood-empty-res",          ":framework-platform-compat-config",          ":services-platform-compat-config", +        "texts/ravenwood-build.prop",      ],      device_first_srcs: [          ":apex_icu.dat", @@ -659,6 +668,7 @@ android_ravenwood_libgroup {      ],      jni_libs: [          // Libraries has to be loaded in the following order +        "libravenwood_initializer",          "libravenwood_sysprop",          "libravenwood_runtime",          "libandroid_runtime", diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodNativeLoader.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodNativeLoader.java index d29b93c0c171..a208d6dce2ce 100644 --- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodNativeLoader.java +++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodNativeLoader.java @@ -40,7 +40,7 @@ public final class RavenwoodNativeLoader {       * See frameworks/base/core/jni/platform/host/HostRuntime.cpp       */      private static final Class<?>[] sLibandroidClasses = { -            android.util.Log.class, +//            android.util.Log.class, // Not using native log: b/377377826              android.os.Parcel.class,              android.os.Binder.class,              android.os.SystemProperties.class, diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java index 28c262d53ff1..c5a9c7b28ad3 100644 --- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java +++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java @@ -22,7 +22,6 @@ import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_INST_R  import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_RESOURCE_APK;  import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_VERBOSE_LOGGING;  import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_VERSION_JAVA_SYSPROP; -import static com.android.ravenwood.common.RavenwoodCommonUtils.getRavenwoodRuntimePath;  import static org.junit.Assert.assertThrows;  import static org.mockito.ArgumentMatchers.any; @@ -51,6 +50,7 @@ import android.util.Log;  import androidx.test.platform.app.InstrumentationRegistry;  import com.android.hoststubgen.hosthelper.HostTestUtils; +import com.android.internal.annotations.GuardedBy;  import com.android.internal.os.RuntimeInit;  import com.android.ravenwood.RavenwoodRuntimeNative;  import com.android.ravenwood.RavenwoodRuntimeState; @@ -86,10 +86,9 @@ public class RavenwoodRuntimeEnvironmentController {      }      private static final String MAIN_THREAD_NAME = "RavenwoodMain"; +    private static final String LIBRAVENWOOD_INITIALIZER_NAME = "ravenwood_initializer";      private static final String RAVENWOOD_NATIVE_SYSPROP_NAME = "ravenwood_sysprop";      private static final String RAVENWOOD_NATIVE_RUNTIME_NAME = "ravenwood_runtime"; -    private static final String RAVENWOOD_BUILD_PROP = -            getRavenwoodRuntimePath() + "ravenwood-data/build.prop";      /**       * When enabled, attempt to dump all thread stacks just before we hit the @@ -139,23 +138,61 @@ public class RavenwoodRuntimeEnvironmentController {          return res;      } +    private static final Object sInitializationLock = new Object(); + +    @GuardedBy("sInitializationLock") +    private static boolean sInitialized = false; + +    @GuardedBy("sInitializationLock") +    private static Throwable sExceptionFromGlobalInit; +      private static RavenwoodAwareTestRunner sRunner;      private static RavenwoodSystemProperties sProps; -    private static boolean sInitialized = false;      /**       * Initialize the global environment.       */      public static void globalInitOnce() { -        if (sInitialized) { -            return; +        synchronized (sInitializationLock) { +            if (!sInitialized) { +                // globalInitOnce() is called from class initializer, which cause +                // this method to be called recursively, +                sInitialized = true; + +                // This is the first call. +                try { +                    globalInitInner(); +                } catch (Throwable th) { +                    Log.e(TAG, "globalInit() failed", th); + +                    sExceptionFromGlobalInit = th; +                    throw th; +                } +            } else { +                // Subsequent calls. If the first call threw, just throw the same error, to prevent +                // the test from running. +                if (sExceptionFromGlobalInit != null) { +                    Log.e(TAG, "globalInit() failed re-throwing the same exception", +                            sExceptionFromGlobalInit); + +                    SneakyThrow.sneakyThrow(sExceptionFromGlobalInit); +                } +            } +        } +    } + +    private static void globalInitInner() { +        if (RAVENWOOD_VERBOSE_LOGGING) { +            Log.v(TAG, "globalInit() called here...", new RuntimeException("NOT A CRASH"));          } -        sInitialized = true; + +        // Some process-wide initialization. (maybe redirect stdout/stderr) +        RavenwoodCommonUtils.loadJniLibrary(LIBRAVENWOOD_INITIALIZER_NAME);          // We haven't initialized liblog yet, so directly write to System.out here. -        RavenwoodCommonUtils.log(TAG, "globalInit()"); +        RavenwoodCommonUtils.log(TAG, "globalInitInner()"); -        // Load libravenwood_sysprop first +        // Load libravenwood_sysprop before other libraries that may use SystemProperties.          var libProp = RavenwoodCommonUtils.getJniLibraryPath(RAVENWOOD_NATIVE_SYSPROP_NAME);          System.load(libProp);          RavenwoodRuntimeNative.reloadNativeLibrary(libProp); @@ -164,7 +201,7 @@ public class RavenwoodRuntimeEnvironmentController {          System.load(RavenwoodCommonUtils.getJniLibraryPath(RAVENWOOD_NATIVE_RUNTIME_NAME));          // Do the basic set up for the android sysprops. -        RavenwoodSystemProperties.initialize(RAVENWOOD_BUILD_PROP); +        RavenwoodSystemProperties.initialize();          setSystemProperties(null);          // Do this after loading RAVENWOOD_NATIVE_RUNTIME_NAME (which backs Os.setenv()), diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodConfig.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodConfig.java index d8f2b705d539..3ed8b0a748e1 100644 --- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodConfig.java +++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodConfig.java @@ -16,7 +16,6 @@  package android.platform.test.ravenwood;  import static android.os.Process.FIRST_APPLICATION_UID; -import static android.os.Process.SYSTEM_UID;  import static android.os.UserHandle.SYSTEM;  import android.annotation.NonNull; @@ -61,17 +60,14 @@ public final class RavenwoodConfig {       * Unless the test author requests differently, run as "nobody", and give each collection of       * tests its own unique PID.       */ -    int mUid = NOBODY_UID; +    int mUid = FIRST_APPLICATION_UID;      int mPid = sNextPid.getAndIncrement();      String mTestPackageName;      String mTargetPackageName; -    int mMinSdkLevel;      int mTargetSdkLevel = Build.VERSION_CODES.CUR_DEVELOPMENT; -    boolean mProvideMainThread = false; -      final RavenwoodSystemProperties mSystemProperties = new RavenwoodSystemProperties();      final List<Class<?>> mServicesRequired = new ArrayList<>(); @@ -108,20 +104,18 @@ public final class RavenwoodConfig {          }          /** -         * Configure the identity of this process to be the system UID for the duration of the -         * test. Has no effect on non-Ravenwood environments. +         * @deprecated no longer used. We always use an app UID.           */ +        @Deprecated          public Builder setProcessSystem() { -            mConfig.mUid = SYSTEM_UID;              return this;          }          /** -         * Configure the identity of this process to be an app UID for the duration of the -         * test. Has no effect on non-Ravenwood environments. +         * @deprecated no longer used. We always use an app UID.           */ +        @Deprecated          public Builder setProcessApp() { -            mConfig.mUid = FIRST_APPLICATION_UID;              return this;          } @@ -144,14 +138,6 @@ public final class RavenwoodConfig {          }          /** -         * Configure the min SDK level of the test. -         */ -        public Builder setMinSdkLevel(int sdkLevel) { -            mConfig.mMinSdkLevel = sdkLevel; -            return this; -        } - -        /**           * Configure the target SDK level of the test.           */          public Builder setTargetSdkLevel(int sdkLevel) { @@ -160,14 +146,10 @@ public final class RavenwoodConfig {          }          /** -         * Configure a "main" thread to be available for the duration of the test, as defined -         * by {@code Looper.getMainLooper()}. Has no effect on non-Ravenwood environments. -         * -         * @deprecated +         * @deprecated no longer used. Main thread is always available.           */          @Deprecated          public Builder setProvideMainThread(boolean provideMainThread) { -            mConfig.mProvideMainThread = provideMainThread;              return this;          } diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java index 3d6ac0f37050..bfa3802ce583 100644 --- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java +++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java @@ -112,20 +112,18 @@ public final class RavenwoodRule implements TestRule {          }          /** -         * Configure the identity of this process to be the system UID for the duration of the -         * test. Has no effect on non-Ravenwood environments. +         * @deprecated no longer used. We always use an app UID.           */ +        @Deprecated          public Builder setProcessSystem() { -            mBuilder.setProcessSystem();              return this;          }          /** -         * Configure the identity of this process to be an app UID for the duration of the -         * test. Has no effect on non-Ravenwood environments. +         * @deprecated no longer used. We always use an app UID.           */ +        @Deprecated          public Builder setProcessApp() { -            mBuilder.setProcessApp();              return this;          } @@ -139,14 +137,10 @@ public final class RavenwoodRule implements TestRule {          }          /** -         * Configure a "main" thread to be available for the duration of the test, as defined -         * by {@code Looper.getMainLooper()}. Has no effect on non-Ravenwood environments. -         * -         * @deprecated +         * @deprecated no longer used. Main thread is always available.           */          @Deprecated          public Builder setProvideMainThread(boolean provideMainThread) { -            mBuilder.setProvideMainThread(provideMainThread);              return this;          } diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodSystemProperties.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodSystemProperties.java index 9bc45bee1775..3e4619f55c6d 100644 --- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodSystemProperties.java +++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodSystemProperties.java @@ -16,21 +16,30 @@  package android.platform.test.ravenwood; -import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_SYSPROP; +import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_VERBOSE_LOGGING; +import static com.android.ravenwood.common.RavenwoodCommonUtils.getRavenwoodRuntimePath; -import com.android.ravenwood.common.RavenwoodCommonUtils; +import android.util.Log;  import java.io.IOException;  import java.nio.file.Files;  import java.nio.file.Path;  import java.util.HashMap;  import java.util.HashSet; +import java.util.LinkedHashMap;  import java.util.Map;  import java.util.Set;  public class RavenwoodSystemProperties {      private static final String TAG = "RavenwoodSystemProperties"; +    /** We pull in propeties from this file. */ +    private static final String RAVENWOOD_BUILD_PROP = "ravenwood-data/ravenwood-build.prop"; + +    /** This is the actual build.prop we use to build the device (contents depends on lunch). */ +    private static final String DEVICE_BUILD_PROP = "ravenwood-data/build.prop"; + +    /** The default values. */      private static final Map<String, String> sDefaultValues = new HashMap<>();      private static final String[] PARTITIONS = { @@ -43,52 +52,54 @@ public class RavenwoodSystemProperties {              "vendor_dlkm",      }; -    /** -     * More info about property file loading: system/core/init/property_service.cpp -     * In the following logic, the only partition we would need to consider is "system", -     * since we only read from system-build.prop -     */ -    static void initialize(String propFile) { -        // Load all properties from build.prop +    private static Map<String, String> readProperties(String propFile) { +        // Use an ordered map just for cleaner dump log. +        final Map<String, String> ret = new LinkedHashMap<>();          try {              Files.readAllLines(Path.of(propFile)).stream()                      .map(String::trim)                      .filter(s -> !s.startsWith("#"))                      .map(s -> s.split("\\s*=\\s*", 2))                      .filter(a -> a.length == 2) -                    .forEach(a -> sDefaultValues.put(a[0], a[1])); +                    .forEach(a -> ret.put(a[0], a[1]));          } catch (IOException e) {              throw new RuntimeException(e);          } +        return ret; +    } -        // If ro.product.${name} is not set, derive from ro.product.${partition}.${name} -        // If ro.product.cpu.abilist* is not set, derive from ro.${partition}.product.cpu.abilist* -        for (var entry : Set.copyOf(sDefaultValues.entrySet())) { -            final String key; -            if (entry.getKey().startsWith("ro.product.system.")) { -                var name = entry.getKey().substring(18); -                key = "ro.product." + name; - -            } else if (entry.getKey().startsWith("ro.system.product.cpu.abilist")) { -                var name = entry.getKey().substring(22); -                key = "ro.product.cpu." + name; +    /** +     * Load default sysprops from {@link #RAVENWOOD_BUILD_PROP}. We also pull in +     * certain properties from the acutual device's build.prop {@link #DEVICE_BUILD_PROP} too. +     * +     * More info about property file loading: system/core/init/property_service.cpp +     * In the following logic, the only partition we would need to consider is "system", +     * since we only read from system-build.prop +     */ +    static void initialize() { +        var path = getRavenwoodRuntimePath(); +        var ravenwoodProps = readProperties(path + RAVENWOOD_BUILD_PROP); +        var deviceProps = readProperties(path + DEVICE_BUILD_PROP); + +        Log.i(TAG, "Default system properties:"); +        ravenwoodProps.forEach((key, origValue) -> { +            final String value; + +            // If a value starts with "$$$", then this is a reference to the device-side value. +            if (origValue.startsWith("$$$")) { +                var deviceKey = origValue.substring(3); +                var deviceValue = deviceProps.get(deviceKey); +                if (deviceValue == null) { +                    throw new RuntimeException("Failed to initialize system properties. Key '" +                             + deviceKey + "' doesn't exist in the device side build.prop"); +                } +                value = deviceValue;              } else { -                continue; -            } -            if (!sDefaultValues.containsKey(key)) { -                sDefaultValues.put(key, entry.getValue()); +                value = origValue;              } -        } - -        // Some other custom values -        sDefaultValues.put("ro.board.first_api_level", "1"); -        sDefaultValues.put("ro.product.first_api_level", "1"); -        sDefaultValues.put("ro.soc.manufacturer", "Android"); -        sDefaultValues.put("ro.soc.model", "Ravenwood"); -        sDefaultValues.put(RAVENWOOD_SYSPROP, "1"); - -        // Log all values -        sDefaultValues.forEach((key, value) -> RavenwoodCommonUtils.log(TAG, key + "=" + value)); +            Log.i(TAG, key + "=" + value); +            sDefaultValues.put(key, value); +        });          // Copy ro.product.* and ro.build.* to all partitions, just in case          // We don't want to log these because these are just a lot of duplicate values @@ -104,6 +115,13 @@ public class RavenwoodSystemProperties {                  }              }          } +        if (RAVENWOOD_VERBOSE_LOGGING) { +            // Dump all properties for local debugging. +            Log.v(TAG, "All system properties:"); +            for (var key : sDefaultValues.keySet().stream().sorted().toList()) { +                Log.v(TAG, "" + key + "=" + sDefaultValues.get(key)); +            } +        }      }      private volatile boolean mIsImmutable; diff --git a/ravenwood/runtime-helper-src/framework/android/util/Log_host.java b/ravenwood/runtime-helper-src/framework/android/util/Log_host.java index d232ef2076be..c85bd23db893 100644 --- a/ravenwood/runtime-helper-src/framework/android/util/Log_host.java +++ b/ravenwood/runtime-helper-src/framework/android/util/Log_host.java @@ -18,6 +18,7 @@ package android.util;  import android.util.Log.Level;  import com.android.internal.os.RuntimeInit; +import com.android.ravenwood.common.RavenwoodCommonUtils;  import java.io.PrintStream; @@ -35,6 +36,9 @@ public class Log_host {      }      public static int println_native(int bufID, int priority, String tag, String msg) { +        if (priority < Log.INFO && !RavenwoodCommonUtils.RAVENWOOD_VERBOSE_LOGGING) { +            return msg.length(); // No verbose logging. +        }          final String buffer;          switch (bufID) {              case Log.LOG_ID_MAIN: buffer = "main"; break; diff --git a/ravenwood/runtime-helper-src/framework/com/android/internal/os/LongArrayContainer_host.java b/ravenwood/runtime-helper-src/framework/com/android/internal/os/LongArrayContainer_host.java deleted file mode 100644 index c18c307ad1e3..000000000000 --- a/ravenwood/runtime-helper-src/framework/com/android/internal/os/LongArrayContainer_host.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - *      http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.internal.os; - -import java.util.Arrays; -import java.util.HashMap; - -public class LongArrayContainer_host { -    private static final HashMap<Long, long[]> sInstances = new HashMap<>(); -    private static long sNextId = 1; - -    public static long native_init(int arrayLength) { -        long[] array = new long[arrayLength]; -        long instanceId = sNextId++; -        sInstances.put(instanceId, array); -        return instanceId; -    } - -    static long[] getInstance(long instanceId) { -        return sInstances.get(instanceId); -    } - -    public static void native_setValues(long instanceId, long[] values) { -        System.arraycopy(values, 0, getInstance(instanceId), 0, values.length); -    } - -    public static void native_getValues(long instanceId, long[] values) { -        System.arraycopy(getInstance(instanceId), 0, values, 0, values.length); -    } - -    public static boolean native_combineValues(long instanceId, long[] array, int[] indexMap) { -        long[] values = getInstance(instanceId); - -        boolean nonZero = false; -        Arrays.fill(array, 0); - -        for (int i = 0; i < values.length; i++) { -            int index = indexMap[i]; -            if (index < 0 || index >= array.length) { -                throw new IndexOutOfBoundsException("Index " + index + " is out of bounds: [0, " -                        + (array.length - 1) + "]"); -            } -            if (values[i] != 0) { -                array[index] += values[i]; -                nonZero = true; -            } -        } -        return nonZero; -    } -} diff --git a/ravenwood/runtime-jni/ravenwood_initializer.cpp b/ravenwood/runtime-jni/ravenwood_initializer.cpp new file mode 100644 index 000000000000..89fb7c3c3510 --- /dev/null +++ b/ravenwood/runtime-jni/ravenwood_initializer.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2024 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. + */ + + /* +  * This file is compiled into a single SO file, which we load at the very first. +  * We can do process-wide initialization here. +  */ + +#include <fcntl.h> +#include <unistd.h> + +#include "jni_helper.h" + +static void maybeRedirectLog() { +    auto ravenwoodLogOut = getenv("RAVENWOOD_LOG_OUT"); +    if (ravenwoodLogOut == NULL) { +        return; +    } +    ALOGI("RAVENWOOD_LOG_OUT set. Redirecting output to %s", ravenwoodLogOut); + +    // Redirect stdin / stdout to /dev/tty. +    int ttyFd = open(ravenwoodLogOut, O_WRONLY | O_APPEND); +    if (ttyFd == -1) { +        ALOGW("$RAVENWOOD_LOG_OUT is set to %s, but failed to open: %s ", ravenwoodLogOut, +                strerror(errno)); +        return; +    } +    dup2(ttyFd, 1); +    dup2(ttyFd, 2); +} + +extern "C" jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) { +    ALOGI("%s: JNI_OnLoad", __FILE__); + +    maybeRedirectLog(); +    return JNI_VERSION_1_4; +} diff --git a/ravenwood/runtime-jni/ravenwood_runtime.cpp b/ravenwood/runtime-jni/ravenwood_runtime.cpp index 5b75e9854758..c1993f691686 100644 --- a/ravenwood/runtime-jni/ravenwood_runtime.cpp +++ b/ravenwood/runtime-jni/ravenwood_runtime.cpp @@ -180,24 +180,6 @@ static jint Linux_gettid(JNIEnv* env, jobject) {      return syscall(__NR_gettid);  } -static void maybeRedirectLog() { -    auto ravenwoodLogOut = getenv("RAVENWOOD_LOG_OUT"); -    if (ravenwoodLogOut == NULL) { -        return; -    } -    ALOGI("RAVENWOOD_LOG_OUT set. Redirecting output to %s", ravenwoodLogOut); - -    // Redirect stdin / stdout to /dev/tty. -    int ttyFd = open(ravenwoodLogOut, O_WRONLY); -    if (ttyFd == -1) { -        ALOGW("$RAVENWOOD_LOG_OUT is set to %s, but failed to open: %s ", ravenwoodLogOut, -                strerror(errno)); -        return; -    } -    dup2(ttyFd, 1); -    dup2(ttyFd, 2); -} -  // ---- Registration ----  extern void register_android_system_OsConstants(JNIEnv* env); @@ -218,8 +200,6 @@ static const JNINativeMethod sMethods[] =  };  extern "C" jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) { -    maybeRedirectLog(); -      ALOGI("%s: JNI_OnLoad", __FILE__);      JNIEnv* env = GetJNIEnvOrDie(vm); diff --git a/ravenwood/scripts/run-ravenwood-tests.sh b/ravenwood/scripts/run-ravenwood-tests.sh index 672c685aa6d7..fe2269a8dc38 100755 --- a/ravenwood/scripts/run-ravenwood-tests.sh +++ b/ravenwood/scripts/run-ravenwood-tests.sh @@ -26,14 +26,14 @@  # Regex to identify slow tests, in PCRE -SLOW_TEST_RE='^(SystemUiRavenTests|CtsIcuTestCasesRavenwood)$' +SLOW_TEST_RE='^(SystemUiRavenTests|CtsIcuTestCasesRavenwood|CarSystemUIRavenTests)$'  smoke=0  include_re=""  exclude_re=""  smoke_exclude_re=""  dry_run="" -while getopts "sx:f:d" opt; do +while getopts "sx:f:dt" opt; do  case "$opt" in      s)          # Remove slow tests. @@ -51,6 +51,9 @@ case "$opt" in          # Dry run          dry_run="echo"          ;; +    t) +        export RAVENWOOD_LOG_OUT=$(tty) +        ;;      '?')          exit 1          ;; @@ -67,7 +70,7 @@ filter() {      if [[ "$re" == "" ]] ; then          cat # No filtering      else -        grep $grep_arg -P "$re" +        grep $grep_arg -iP "$re"      fi  } diff --git a/ravenwood/tests/services-test/test/com/android/ravenwoodtest/servicestest/RavenwoodServicesTest.java b/ravenwood/tests/services-test/test/com/android/ravenwoodtest/servicestest/RavenwoodServicesTest.java index 8ce15f006ac2..52bf92e25f19 100644 --- a/ravenwood/tests/services-test/test/com/android/ravenwoodtest/servicestest/RavenwoodServicesTest.java +++ b/ravenwood/tests/services-test/test/com/android/ravenwoodtest/servicestest/RavenwoodServicesTest.java @@ -19,18 +19,23 @@ package com.android.ravenwoodtest.servicestest;  import static org.junit.Assert.assertArrayEquals;  import static org.junit.Assert.assertEquals;  import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail;  import android.content.Context;  import android.hardware.SerialManager;  import android.hardware.SerialManagerInternal;  import android.platform.test.annotations.DisabledOnRavenwood; -import android.platform.test.ravenwood.RavenwoodRule; +import android.platform.test.ravenwood.RavenwoodConfig; +import android.platform.test.ravenwood.RavenwoodConfig.Config;  import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry;  import com.android.server.LocalServices; -import org.junit.Rule; +import com.google.common.collect.Lists; + +import org.junit.Before;  import org.junit.Test;  import org.junit.runner.RunWith; @@ -38,18 +43,25 @@ import org.junit.runner.RunWith;  public class RavenwoodServicesTest {      private static final String TEST_VIRTUAL_PORT = "virtual:example"; -    @Rule -    public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder() +    @Config +    public static final RavenwoodConfig sRavenwood = new RavenwoodConfig.Builder()              .setProcessSystem()              .setServicesRequired(SerialManager.class)              .build(); +    private Context mContext; + +    @Before +    public void setUp() { +        mContext = InstrumentationRegistry.getInstrumentation().getContext(); +    } +      @Test      public void testDefined() {          final SerialManager fromName = (SerialManager) -                mRavenwood.getContext().getSystemService(Context.SERIAL_SERVICE); +                mContext.getSystemService(Context.SERIAL_SERVICE);          final SerialManager fromClass = -                mRavenwood.getContext().getSystemService(SerialManager.class); +                mContext.getSystemService(SerialManager.class);          assertNotNull(fromName);          assertNotNull(fromClass);          assertEquals(fromName, fromClass); @@ -63,9 +75,9 @@ public class RavenwoodServicesTest {          // Verify that we can obtain a manager, and talk to the backend service, and that no          // serial ports are configured by default          final SerialManager service = (SerialManager) -                mRavenwood.getContext().getSystemService(Context.SERIAL_SERVICE); +                mContext.getSystemService(Context.SERIAL_SERVICE);          final String[] ports = service.getSerialPorts(); -        final String[] refPorts = mRavenwood.getContext().getResources().getStringArray( +        final String[] refPorts = mContext.getResources().getStringArray(                  com.android.internal.R.array.config_serialPorts);          assertArrayEquals(refPorts, ports);      } @@ -73,7 +85,7 @@ public class RavenwoodServicesTest {      @Test      public void testDriven() {          final SerialManager service = (SerialManager) -                mRavenwood.getContext().getSystemService(Context.SERIAL_SERVICE); +                mContext.getSystemService(Context.SERIAL_SERVICE);          final SerialManagerInternal internal = LocalServices.getService(                  SerialManagerInternal.class); @@ -81,8 +93,17 @@ public class RavenwoodServicesTest {              throw new UnsupportedOperationException(                      "Needs socketpair() to offer accurate emulation");          }); -        final String[] ports = service.getSerialPorts(); -        assertEquals(1, ports.length); -        assertEquals(TEST_VIRTUAL_PORT, ports[0]); +        try { +            final String[] ports = service.getSerialPorts(); +            for (var port : ports) { +                if (TEST_VIRTUAL_PORT.equals(port)) { +                    return; // Pass +                } +            } +            fail("Virtual port " + TEST_VIRTUAL_PORT + " not found. Actual=" +                    + Lists.newArrayList(ports)); +        } finally { +            internal.removeVirtualSerialPortForTest(TEST_VIRTUAL_PORT); +        }      }  } diff --git a/ravenwood/texts/build.prop-sample-cuttlefish b/ravenwood/texts/build.prop-sample-cuttlefish new file mode 100644 index 000000000000..f78b727f5779 --- /dev/null +++ b/ravenwood/texts/build.prop-sample-cuttlefish @@ -0,0 +1,132 @@ +# This is file is generated with `aosp_cf_x86_64_phone-trunk_staging-eng` on 2024-11-06. +# We have this file here only as a reference. We don't actually use this file anywhere. + +#################################### +# from generate_common_build_props +# These properties identify this partition image. +#################################### +ro.product.system.brand=Android +ro.product.system.device=generic +ro.product.system.manufacturer=Android +ro.product.system.model=mainline +ro.product.system.name=mainline +ro.system.product.cpu.abilist=x86_64,x86,arm64-v8a,armeabi-v7a,armeabi +ro.system.product.cpu.abilist32=x86,armeabi-v7a,armeabi +ro.system.product.cpu.abilist64=x86_64,arm64-v8a +ro.system.build.date=Tue Nov  5 13:25:43 PST 2024 +ro.system.build.date.utc=1730841943 +ro.system.build.fingerprint=generic/aosp_cf_x86_64_phone/vsoc_x86_64:Baklava/MAIN/eng.omakot:eng/test-keys +ro.system.build.id=MAIN +ro.system.build.tags=test-keys +ro.system.build.type=eng +ro.system.build.version.incremental=eng.omakot +ro.system.build.version.release=15 +ro.system.build.version.release_or_codename=Baklava +ro.system.build.version.sdk=35 +#################################### +# from gen_build_prop.py:generate_build_info +#################################### +# begin build properties +ro.build.legacy.id=MAIN +ro.build.display.id=aosp_cf_x86_64_phone-eng Baklava MAIN eng.omakot test-keys +ro.build.version.incremental=eng.omakot +ro.build.version.sdk=35 +ro.build.version.preview_sdk=1 +ro.build.version.preview_sdk_fingerprint=2ef06129940d459014cf4dede3950d71 +ro.build.version.codename=Baklava +ro.build.version.all_codenames=Baklava +ro.build.version.known_codenames=Base,Base11,Cupcake,Donut,Eclair,Eclair01,EclairMr1,Froyo,Gingerbread,GingerbreadMr1,Honeycomb,HoneycombMr1,HoneycombMr2,IceCreamSandwich,IceCreamSandwichMr1,JellyBean,JellyBeanMr1,JellyBeanMr2,Kitkat,KitkatWatch,Lollipop,LollipopMr1,M,N,NMr1,O,OMr1,P,Q,R,S,Sv2,Tiramisu,UpsideDownCake,VanillaIceCream,Baklava +ro.build.version.release=15 +ro.build.version.release_or_codename=Baklava +ro.build.version.release_or_preview_display=Baklava +ro.build.version.security_patch=2024-08-05 +ro.build.version.base_os= +ro.build.version.min_supported_target_sdk=28 +ro.build.date=Tue Nov  5 13:25:43 PST 2024 +ro.build.date.utc=1730841943 +ro.build.type=eng +ro.build.user=omakoto +ro.build.host=omakoto-ct1.c.googlers.com +ro.build.tags=test-keys +ro.build.flavor=aosp_cf_x86_64_phone-eng +# ro.product.cpu.abi and ro.product.cpu.abi2 are obsolete, +# use ro.product.cpu.abilist instead. +ro.product.cpu.abi=x86_64 +ro.product.locale=en-US +ro.wifi.channels= +# ro.build.product is obsolete; use ro.product.device +ro.build.product=vsoc_x86_64 +# Do not try to parse description or thumbprint +ro.build.description=aosp_cf_x86_64_phone-eng Baklava MAIN eng.omakot test-keys +# end build properties +#################################### +# from variable ADDITIONAL_SYSTEM_PROPERTIES +#################################### +ro.treble.enabled=true +ro.llndk.api_level=202504 +ro.actionable_compatible_property.enabled=true +persist.debug.dalvik.vm.core_platform_api_policy=just-warn +ro.postinstall.fstab.prefix=/system +ro.kernel.android.checkjni=1 +ro.secure=0 +ro.allow.mock.location=1 +dalvik.vm.lockprof.threshold=500 +ro.debuggable=1 +dalvik.vm.image-dex2oat-filter=extract +init.svc_debug.no_fatal.zygote=true +net.bt.name=Android +ro.force.debuggable=0 +#################################### +# from variable PRODUCT_SYSTEM_PROPERTIES +#################################### +debug.atrace.tags.enableflags=0 +persist.traced.enable=1 +dalvik.vm.image-dex2oat-Xms=64m +dalvik.vm.image-dex2oat-Xmx=64m +dalvik.vm.dex2oat-Xms=64m +dalvik.vm.dex2oat-Xmx=512m +dalvik.vm.usejit=true +dalvik.vm.dexopt.secondary=true +dalvik.vm.dexopt.thermal-cutoff=2 +dalvik.vm.appimageformat=lz4 +ro.dalvik.vm.native.bridge=0 +pm.dexopt.post-boot=verify +pm.dexopt.first-boot=verify +pm.dexopt.boot-after-ota=verify +pm.dexopt.boot-after-mainline-update=verify +pm.dexopt.install=speed-profile +pm.dexopt.install-fast=skip +pm.dexopt.install-bulk=speed-profile +pm.dexopt.install-bulk-secondary=verify +pm.dexopt.install-bulk-downgraded=verify +pm.dexopt.install-bulk-secondary-downgraded=verify +pm.dexopt.bg-dexopt=speed-profile +pm.dexopt.ab-ota=speed-profile +pm.dexopt.inactive=verify +pm.dexopt.cmdline=verify +pm.dexopt.shared=speed +dalvik.vm.disable-art-service-dexopt=true +dalvik.vm.disable-odrefresh=true +dalvik.vm.dex2oat-resolve-startup-strings=true +dalvik.vm.dex2oat-max-image-block-size=524288 +dalvik.vm.minidebuginfo=true +dalvik.vm.dex2oat-minidebuginfo=true +dalvik.vm.madvise.vdexfile.size=104857600 +dalvik.vm.madvise.odexfile.size=104857600 +dalvik.vm.madvise.artfile.size=4294967295 +dalvik.vm.usap_pool_enabled=false +dalvik.vm.usap_refill_threshold=1 +dalvik.vm.usap_pool_size_max=3 +dalvik.vm.usap_pool_size_min=1 +dalvik.vm.usap_pool_refill_delay_ms=3000 +dalvik.vm.useartservice=true +dalvik.vm.enable_pr_dexopt=true +ro.cp_system_other_odex=1 +ro.apex.updatable=true +ro.launcher.depth.widget=0 +#################################### +# from variable PRODUCT_SYSTEM_DEFAULT_PROPERTIES +#################################### +# Auto-added by post_process_props.py +persist.sys.usb.config=adb +# end of file diff --git a/ravenwood/texts/ravenwood-annotation-allowed-classes.txt b/ravenwood/texts/ravenwood-annotation-allowed-classes.txt index a26fe66da2ab..5d24c3aea728 100644 --- a/ravenwood/texts/ravenwood-annotation-allowed-classes.txt +++ b/ravenwood/texts/ravenwood-annotation-allowed-classes.txt @@ -12,7 +12,9 @@ com.android.internal.os.BatteryStatsHistory  com.android.internal.os.BatteryStatsHistoryIterator  com.android.internal.os.Clock  com.android.internal.os.LongArrayMultiStateCounter +com.android.internal.os.LongArrayMultiStateCounter_ravenwood  com.android.internal.os.LongMultiStateCounter +com.android.internal.os.LongMultiStateCounter_ravenwood  com.android.internal.os.MonotonicClock  com.android.internal.os.PowerProfile  com.android.internal.os.PowerStats @@ -140,6 +142,7 @@ android.os.LocaleList  android.os.Looper  android.os.Message  android.os.MessageQueue +android.os.MessageQueue_ravenwood  android.os.PackageTagsList  android.os.Parcel  android.os.ParcelFileDescriptor @@ -232,6 +235,7 @@ android.database.Cursor  android.database.CursorIndexOutOfBoundsException  android.database.CursorJoiner  android.database.CursorWindow +android.database.CursorWindow_ravenwood  android.database.CursorWrapper  android.database.DataSetObservable  android.database.DataSetObserver diff --git a/ravenwood/texts/ravenwood-build.prop b/ravenwood/texts/ravenwood-build.prop new file mode 100644 index 000000000000..93a18cffec50 --- /dev/null +++ b/ravenwood/texts/ravenwood-build.prop @@ -0,0 +1,44 @@ +# This file contains system properties used on ravenwood. + +ro.is_on_ravenwood=1 + +ro.board.first_api_level=1 +ro.product.first_api_level=1 +ro.soc.manufacturer=Android +ro.soc.model=Ravenwood +ro.debuggable=1 + +# The ones starting with "ro.product" or "ro.bild" will be copied to all "partitions" too. +# See RavenwoodSystemProperties. +ro.product.brand=Android +ro.product.device=Ravenwood +ro.product.manufacturer=Android +ro.product.model=Ravenwood +ro.product.name=Ravenwood +ro.product.cpu.abilist=x86_64 +ro.product.cpu.abilist32= +ro.product.cpu.abilist64=x86_64 + +ro.build.date=Thu Jan 01 00:00:00 GMT 2024 +ro.build.date.utc=1704092400 +ro.build.id=MAIN +ro.build.tags=dev-keys +ro.build.type=userdebug +ro.build.version.incremental=userdebug.ravenwood.20240101 + +# These are what we used to use on Ravenwood, copied here as a reference. +#ro.build.version.codename=REL +#ro.build.version.all_codenames=REL +#ro.build.version.known_codenames=REL +#ro.build.version.release=14 +#ro.build.version.release_or_codename=VanillaIceCream +#ro.build.version.sdk=34 + +# We pull in the following values from the real build.prop file. +ro.build.version.codename=$$$ro.build.version.codename +ro.build.version.all_codenames=$$$ro.build.version.codename +ro.build.version.known_codenames=$$$ro.build.version.codename +ro.build.version.release=$$$ro.build.version.release +ro.build.version.release_or_codename=$$$ro.build.version.release_or_codename +ro.build.version.release_or_preview_display=$$$ro.build.version.release_or_preview_display +ro.build.version.sdk=$$$ro.build.version.sdk diff --git a/services/Android.bp b/services/Android.bp index e8d6630dab68..d99ed3dbdba8 100644 --- a/services/Android.bp +++ b/services/Android.bp @@ -242,6 +242,7 @@ java_library {          "services.wifi",          "service-blobstore",          "service-jobscheduler", +        "service-connectivity-b-pre-jarjar", // Move it to mainline module          "android.hidl.base-V1.0-java",      ], diff --git a/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java b/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java index 2e9a4dcb45aa..a10039f9bf6c 100644 --- a/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java +++ b/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java @@ -462,7 +462,9 @@ public final class AutoFillUI {                          @Override                          public void onShown() { -                            mCallback.onShown(UI_TYPE_DIALOG, response.getDatasets().size()); +                            if (mCallback != null) { +                                mCallback.onShown(UI_TYPE_DIALOG, response.getDatasets().size()); +                            }                          }                          @Override @@ -511,7 +513,9 @@ public final class AutoFillUI {                          @Override                          public void startIntentSender(IntentSender intentSender) { -                            mCallback.startIntentSenderAndFinishSession(intentSender); +                            if (mCallback != null) { +                                mCallback.startIntentSenderAndFinishSession(intentSender); +                            }                          }                          private void log(int type) { diff --git a/services/core/Android.bp b/services/core/Android.bp index 349f3ee2b9f0..f08c876e3104 100644 --- a/services/core/Android.bp +++ b/services/core/Android.bp @@ -233,6 +233,7 @@ java_library_static {          "core_os_flags_lib",          "connectivity_flags_lib",          "dreams_flags_lib", +        "aconfig_flags_java",          "aconfig_new_storage_flags_lib",          "powerstats_flags_lib",          "locksettings_flags_lib", diff --git a/services/core/java/com/android/server/am/OWNERS b/services/core/java/com/android/server/am/OWNERS index 2a30ad0e0f3f..6f99673a9ce6 100644 --- a/services/core/java/com/android/server/am/OWNERS +++ b/services/core/java/com/android/server/am/OWNERS @@ -61,6 +61,9 @@ per-file *Oom* = file:/OOM_ADJUSTER_OWNERS  per-file SettingsToPropertiesMapper.java = omakoto@google.com, yamasani@google.com, dzshen@google.com, zhidou@google.com, tedbauer@google.com  per-file CarUserSwitchingDialog.java = file:platform/packages/services/Car:/OWNERS +# Activity Security +per-file ActivityManager* = file:/ACTIVITY_SECURITY_OWNERS +  # Londoners  michaelwr@google.com #{LAST_RESORT_SUGGESTION}  narayan@google.com #{LAST_RESORT_SUGGESTION} diff --git a/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java b/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java index 5c3640fa375d..4ec2a04551e9 100644 --- a/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java +++ b/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java @@ -39,6 +39,7 @@ import android.aconfigd.Aconfigd.StorageRequestMessages;  import android.aconfigd.Aconfigd.StorageReturnMessage;  import android.aconfigd.Aconfigd.StorageReturnMessages;  import static com.android.aconfig_new_storage.Flags.enableAconfigStorageDaemon; +import static com.android.aconfig.flags.Flags.enableSystemAconfigdRust;  import java.io.DataInputStream;  import java.io.DataOutputStream; @@ -391,9 +392,11 @@ public class SettingsToPropertiesMapper {      static ProtoInputStream sendAconfigdRequests(ProtoOutputStream requests) {          // connect to aconfigd socket          LocalSocket client = new LocalSocket(); -        try{ +        String socketName = enableSystemAconfigdRust() +                    ? "aconfigd_system" : "aconfigd"; +        try {              client.connect(new LocalSocketAddress( -                "aconfigd", LocalSocketAddress.Namespace.RESERVED)); +                socketName, LocalSocketAddress.Namespace.RESERVED));              Slog.d(TAG, "connected to aconfigd socket");          } catch (IOException ioe) {              logErr("failed to connect to aconfigd socket", ioe); diff --git a/services/core/java/com/android/server/input/KeyboardLayoutManager.java b/services/core/java/com/android/server/input/KeyboardLayoutManager.java index 97c32b986d38..49934126ab8c 100644 --- a/services/core/java/com/android/server/input/KeyboardLayoutManager.java +++ b/services/core/java/com/android/server/input/KeyboardLayoutManager.java @@ -255,17 +255,6 @@ class KeyboardLayoutManager implements InputManager.InputDeviceListener {          }      } -    private static boolean isCompatibleLocale(Locale systemLocale, Locale keyboardLocale) { -        // Different languages are never compatible -        if (!systemLocale.getLanguage().equals(keyboardLocale.getLanguage())) { -            return false; -        } -        // If both the system and the keyboard layout have a country specifier, they must be equal. -        return TextUtils.isEmpty(systemLocale.getCountry()) -                || TextUtils.isEmpty(keyboardLocale.getCountry()) -                || systemLocale.getCountry().equals(keyboardLocale.getCountry()); -    } -      @MainThread      private void updateKeyboardLayouts() {          // Scan all input devices state for keyboard layouts that have been uninstalled. @@ -953,21 +942,33 @@ class KeyboardLayoutManager implements InputManager.InputDeviceListener {              return;          } +        List<String> layoutNames = new ArrayList<>(); +        for (String layoutDesc : config.getConfiguredLayouts()) { +            KeyboardLayout kl = getKeyboardLayout(layoutDesc); +            if (kl == null) { +                // b/349033234: Weird state with stale keyboard layout configured. +                // Possibly due to race condition between KCM providing package being removed and +                // corresponding layouts being removed from Datastore and cache. +                // {@see updateKeyboardLayouts()} +                // +                // Ideally notification will be correctly shown after the keyboard layouts are +                // configured again with the new package state. +                return; +            } +            layoutNames.add(kl.getLabel()); +        }          showKeyboardLayoutNotification(                  r.getString(                          R.string.keyboard_layout_notification_selected_title,                          inputDevice.getName()), -                createConfiguredNotificationText(mContext, config.getConfiguredLayouts()), +                createConfiguredNotificationText(mContext, layoutNames),                  inputDevice);      }      @MainThread      private String createConfiguredNotificationText(@NonNull Context context, -            @NonNull Set<String> selectedLayouts) { +            @NonNull List<String> layoutNames) {          final Resources r = context.getResources(); -        List<String> layoutNames = new ArrayList<>(); -        selectedLayouts.forEach( -                (layoutDesc) -> layoutNames.add(getKeyboardLayout(layoutDesc).getLabel()));          Collections.sort(layoutNames);          switch (layoutNames.size()) {              case 1: diff --git a/services/core/java/com/android/server/media/MediaSession2Record.java b/services/core/java/com/android/server/media/MediaSession2Record.java index 89555a9f1de4..c8a87994ee16 100644 --- a/services/core/java/com/android/server/media/MediaSession2Record.java +++ b/services/core/java/com/android/server/media/MediaSession2Record.java @@ -161,6 +161,11 @@ public class MediaSession2Record extends MediaSessionRecordImpl {      }      @Override +    public void onGlobalPrioritySessionActiveChanged(boolean isGlobalPrioritySessionActive) { +        // NA as MediaSession2 doesn't support UserEngagementStates for FGS. +    } + +    @Override      public boolean sendMediaButton(String packageName, int pid, int uid, boolean asSystemService,              KeyEvent ke, int sequenceId, ResultReceiver cb) {          // TODO(jaewan): Implement. diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java index 0a9109b3e98c..0d779af22c2d 100644 --- a/services/core/java/com/android/server/media/MediaSessionRecord.java +++ b/services/core/java/com/android/server/media/MediaSessionRecord.java @@ -234,51 +234,49 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde      private final Runnable mUserEngagementTimeoutExpirationRunnable =              () -> {                  synchronized (mLock) { -                    updateUserEngagedStateIfNeededLocked(/* isTimeoutExpired= */ true); +                    updateUserEngagedStateIfNeededLocked( +                            /* isTimeoutExpired= */ true, +                            /* isGlobalPrioritySessionActive= */ false);                  }              };      @GuardedBy("mLock")      private @UserEngagementState int mUserEngagementState = USER_DISENGAGED; -    @IntDef({USER_PERMANENTLY_ENGAGED, USER_TEMPORARY_ENGAGED, USER_DISENGAGED}) +    @IntDef({USER_PERMANENTLY_ENGAGED, USER_TEMPORARILY_ENGAGED, USER_DISENGAGED})      @Retention(RetentionPolicy.SOURCE)      private @interface UserEngagementState {}      /** -     * Indicates that the session is active and in one of the user engaged states. +     * Indicates that the session is {@linkplain MediaSession#isActive() active} and in one of the +     * {@linkplain PlaybackState#isActive() active states}.       *       * @see #updateUserEngagedStateIfNeededLocked(boolean)       */      private static final int USER_PERMANENTLY_ENGAGED = 0;      /** -     * Indicates that the session is active and in {@link PlaybackState#STATE_PAUSED} state. +     * Indicates that the session is {@linkplain MediaSession#isActive() active} and has recently +     * switched to one of the {@linkplain PlaybackState#isActive() inactive states}.       *       * @see #updateUserEngagedStateIfNeededLocked(boolean)       */ -    private static final int USER_TEMPORARY_ENGAGED = 1; +    private static final int USER_TEMPORARILY_ENGAGED = 1;      /** -     * Indicates that the session is either not active or in one of the user disengaged states +     * Indicates that the session is either not {@linkplain MediaSession#isActive() active} or in +     * one of the {@linkplain PlaybackState#isActive() inactive states}.       *       * @see #updateUserEngagedStateIfNeededLocked(boolean)       */      private static final int USER_DISENGAGED = 2;      /** -     * Indicates the duration of the temporary engaged states, in milliseconds. +     * Indicates the duration of the temporary engaged state, in milliseconds.       * -     * <p>Some {@link MediaSession} states like {@link PlaybackState#STATE_PAUSED} are temporarily -     * engaged, meaning the corresponding session is only considered in an engaged state for the -     * duration of this timeout, and only if coming from an engaged state. -     * -     * <p>For example, if a session is transitioning from a user-engaged state {@link -     * PlaybackState#STATE_PLAYING} to a temporary user-engaged state {@link -     * PlaybackState#STATE_PAUSED}, then the session will be considered in a user-engaged state for -     * the duration of this timeout, starting at the transition instant. However, a temporary -     * user-engaged state is not considered user-engaged when transitioning from a non-user engaged -     * state {@link PlaybackState#STATE_STOPPED}. +     * <p>When switching to an {@linkplain PlaybackState#isActive() inactive state}, the user is +     * treated as temporarily engaged, meaning the corresponding session is only considered in an +     * engaged state for the duration of this timeout, and only if coming from an engaged state.       */      private static final int TEMP_USER_ENGAGED_TIMEOUT_MS = 600000; @@ -604,7 +602,8 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde              mSessionCb.mCb.asBinder().unlinkToDeath(this, 0);              mDestroyed = true;              mPlaybackState = null; -            updateUserEngagedStateIfNeededLocked(/* isTimeoutExpired= */ true); +            updateUserEngagedStateIfNeededLocked( +                    /* isTimeoutExpired= */ true, /* isGlobalPrioritySessionActive= */ false);              mHandler.post(MessageHandler.MSG_DESTROYED);          }      } @@ -621,6 +620,24 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde          mHandler.post(mUserEngagementTimeoutExpirationRunnable);      } +    @Override +    public void onGlobalPrioritySessionActiveChanged(boolean isGlobalPrioritySessionActive) { +        mHandler.post( +                () -> { +                    synchronized (mLock) { +                        if (isGlobalPrioritySessionActive) { +                            mHandler.removeCallbacks(mUserEngagementTimeoutExpirationRunnable); +                        } else { +                            if (mUserEngagementState == USER_TEMPORARILY_ENGAGED) { +                                mHandler.postDelayed( +                                        mUserEngagementTimeoutExpirationRunnable, +                                        TEMP_USER_ENGAGED_TIMEOUT_MS); +                            } +                        } +                    } +                }); +    } +      /**       * Sends media button.       * @@ -1111,21 +1128,20 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde      }      @GuardedBy("mLock") -    private void updateUserEngagedStateIfNeededLocked(boolean isTimeoutExpired) { +    private void updateUserEngagedStateIfNeededLocked( +            boolean isTimeoutExpired, boolean isGlobalPrioritySessionActive) {          if (!Flags.enableNotifyingActivityManagerWithMediaSessionStatusChange()) {              return;          }          int oldUserEngagedState = mUserEngagementState;          int newUserEngagedState; -        if (!isActive() || mPlaybackState == null || mDestroyed) { +        if (!isActive() || mPlaybackState == null) {              newUserEngagedState = USER_DISENGAGED; -        } else if (isActive() && mPlaybackState.isActive()) { +        } else if (mPlaybackState.isActive()) {              newUserEngagedState = USER_PERMANENTLY_ENGAGED; -        } else if (mPlaybackState.getState() == PlaybackState.STATE_PAUSED) { -            newUserEngagedState = -                    oldUserEngagedState == USER_PERMANENTLY_ENGAGED || !isTimeoutExpired -                            ? USER_TEMPORARY_ENGAGED -                            : USER_DISENGAGED; +        } else if (oldUserEngagedState == USER_PERMANENTLY_ENGAGED +                || (oldUserEngagedState == USER_TEMPORARILY_ENGAGED && !isTimeoutExpired)) { +            newUserEngagedState = USER_TEMPORARILY_ENGAGED;          } else {              newUserEngagedState = USER_DISENGAGED;          } @@ -1134,7 +1150,7 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde          }          mUserEngagementState = newUserEngagedState; -        if (newUserEngagedState == USER_TEMPORARY_ENGAGED) { +        if (newUserEngagedState == USER_TEMPORARILY_ENGAGED && !isGlobalPrioritySessionActive) {              mHandler.postDelayed(                      mUserEngagementTimeoutExpirationRunnable, TEMP_USER_ENGAGED_TIMEOUT_MS);          } else { @@ -1189,9 +1205,11 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde                          .logFgsApiEnd(ActivityManager.FOREGROUND_SERVICE_API_TYPE_MEDIA_PLAYBACK,                                  callingUid, callingPid);              } +            boolean isGlobalPrioritySessionActive = mService.isGlobalPrioritySessionActive();              synchronized (mLock) {                  mIsActive = active; -                updateUserEngagedStateIfNeededLocked(/* isTimeoutExpired= */ false); +                updateUserEngagedStateIfNeededLocked( +                        /* isTimeoutExpired= */ false, isGlobalPrioritySessionActive);              }              long token = Binder.clearCallingIdentity();              try { @@ -1348,9 +1366,11 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde              boolean shouldUpdatePriority = ALWAYS_PRIORITY_STATES.contains(newState)                      || (!TRANSITION_PRIORITY_STATES.contains(oldState)                      && TRANSITION_PRIORITY_STATES.contains(newState)); +            boolean isGlobalPrioritySessionActive = mService.isGlobalPrioritySessionActive();              synchronized (mLock) {                  mPlaybackState = state; -                updateUserEngagedStateIfNeededLocked(/* isTimeoutExpired= */ false); +                updateUserEngagedStateIfNeededLocked( +                        /* isTimeoutExpired= */ false, isGlobalPrioritySessionActive);              }              final long token = Binder.clearCallingIdentity();              try { diff --git a/services/core/java/com/android/server/media/MediaSessionRecordImpl.java b/services/core/java/com/android/server/media/MediaSessionRecordImpl.java index 15f90d4fdd0e..6c3b1234935a 100644 --- a/services/core/java/com/android/server/media/MediaSessionRecordImpl.java +++ b/services/core/java/com/android/server/media/MediaSessionRecordImpl.java @@ -206,6 +206,10 @@ public abstract class MediaSessionRecordImpl {       */      public abstract void expireTempEngaged(); +    /** Notifies record that the global priority session active state changed. */ +    public abstract void onGlobalPrioritySessionActiveChanged( +            boolean isGlobalPrioritySessionActive); +      @Override      public final boolean equals(Object o) {          if (this == o) return true; diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java index 1ebc856af2d8..2b29fbd9c5b5 100644 --- a/services/core/java/com/android/server/media/MediaSessionService.java +++ b/services/core/java/com/android/server/media/MediaSessionService.java @@ -362,6 +362,7 @@ public class MediaSessionService extends SystemService implements Monitor {                                      + record.isActive());                  }                  user.pushAddressedPlayerChangedLocked(); +                mHandler.post(this::notifyGlobalPrioritySessionActiveChanged);              } else {                  if (!user.mPriorityStack.contains(record)) {                      Log.w(TAG, "Unknown session updated. Ignoring."); @@ -394,11 +395,16 @@ public class MediaSessionService extends SystemService implements Monitor {      // Currently only media1 can become global priority session.      void setGlobalPrioritySession(MediaSessionRecord record) { +        boolean globalPrioritySessionActiveChanged = false;          synchronized (mLock) {              FullUserRecord user = getFullUserRecordLocked(record.getUserId());              if (mGlobalPrioritySession != record) {                  Log.d(TAG, "Global priority session is changed from " + mGlobalPrioritySession                          + " to " + record); +                globalPrioritySessionActiveChanged = +                        (mGlobalPrioritySession == null && record.isActive()) +                                || (mGlobalPrioritySession != null +                                        && mGlobalPrioritySession.isActive() != record.isActive());                  mGlobalPrioritySession = record;                  if (user != null && user.mPriorityStack.contains(record)) {                      // Handle the global priority session separately. @@ -409,6 +415,30 @@ public class MediaSessionService extends SystemService implements Monitor {                  }              }          } +        if (globalPrioritySessionActiveChanged) { +            mHandler.post(this::notifyGlobalPrioritySessionActiveChanged); +        } +    } + +    /** Returns whether the global priority session is active. */ +    boolean isGlobalPrioritySessionActive() { +        synchronized (mLock) { +            return isGlobalPriorityActiveLocked(); +        } +    } + +    private void notifyGlobalPrioritySessionActiveChanged() { +        if (!Flags.enableNotifyingActivityManagerWithMediaSessionStatusChange()) { +            return; +        } +        synchronized (mLock) { +            boolean isGlobalPriorityActive = isGlobalPriorityActiveLocked(); +            for (Set<MediaSessionRecordImpl> records : mUserEngagedSessionsForFgs.values()) { +                for (MediaSessionRecordImpl record : records) { +                    record.onGlobalPrioritySessionActiveChanged(isGlobalPriorityActive); +                } +            } +        }      }      private List<MediaSessionRecord> getActiveSessionsLocked(int userId) { @@ -646,8 +676,11 @@ public class MediaSessionService extends SystemService implements Monitor {          if (mGlobalPrioritySession == session) {              mGlobalPrioritySession = null; -            if (session.isActive() && user != null) { -                user.pushAddressedPlayerChangedLocked(); +            if (session.isActive()) { +                if (user != null) { +                    user.pushAddressedPlayerChangedLocked(); +                } +                mHandler.post(this::notifyGlobalPrioritySessionActiveChanged);              }          } else {              if (user != null) { diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java index 2a3be1e119bf..7de2815eba6b 100644 --- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java +++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java @@ -513,12 +513,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {      private boolean mLoadedRestrictBackground;      /** -     * Whether or not network for apps in proc-states greater than -     * {@link NetworkPolicyManager#BACKGROUND_THRESHOLD_STATE} is always blocked. -     */ -    private boolean mBackgroundNetworkRestricted; - -    /**       * Whether or not metered firewall chains should be used for uid policy controlling access to       * metered networks.       */ @@ -1117,14 +1111,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {                          writePolicyAL();                      } -                    // The flag is boot-stable. -                    mBackgroundNetworkRestricted = Flags.networkBlockedForTopSleepingAndAbove(); -                    if (mBackgroundNetworkRestricted) { -                        // Firewall rules and UidBlockedState will get updated in -                        // updateRulesForGlobalChangeAL below. -                        enableFirewallChainUL(FIREWALL_CHAIN_BACKGROUND, true); -                    } - +                    enableFirewallChainUL(FIREWALL_CHAIN_BACKGROUND, true);                      setRestrictBackgroundUL(mLoadedRestrictBackground, "init_service");                      updateRulesForGlobalChangeAL(false);                      updateNotificationsNL(); @@ -1135,11 +1122,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {                  final int changes = ActivityManager.UID_OBSERVER_PROCSTATE                          | ActivityManager.UID_OBSERVER_GONE                          | ActivityManager.UID_OBSERVER_CAPABILITY; - -                final int cutpoint = mBackgroundNetworkRestricted ? PROCESS_STATE_UNKNOWN -                        : NetworkPolicyManager.FOREGROUND_THRESHOLD_STATE;                  mActivityManagerInternal.registerNetworkPolicyUidObserver(mUidObserver, changes, -                        cutpoint, "android"); +                        PROCESS_STATE_UNKNOWN, "android");                  mNetworkManager.registerObserver(mAlertObserver);              } catch (RemoteException e) {                  // ignored; both services live in system_server @@ -1280,21 +1264,19 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {                  // different chains may change.                  return true;              } -            if (mBackgroundNetworkRestricted) { -                if ((previousProcState >= BACKGROUND_THRESHOLD_STATE) +            if ((previousProcState >= BACKGROUND_THRESHOLD_STATE)                      != (newProcState >= BACKGROUND_THRESHOLD_STATE)) { -                    // Proc-state change crossed BACKGROUND_THRESHOLD_STATE: The network rules will -                    // need to be re-evaluated for the background chain. -                    return true; -                } -                if (mUseDifferentDelaysForBackgroundChain -                        && newProcState >= BACKGROUND_THRESHOLD_STATE -                        && getBackgroundTransitioningDelay(newProcState) -                        < getBackgroundTransitioningDelay(previousProcState)) { -                    // The old and new proc-state both are in the blocked state but the background -                    // transition delay is reduced, so we may have to update the rules sooner. -                    return true; -                } +                // Proc-state change crossed BACKGROUND_THRESHOLD_STATE: The network rules will +                // need to be re-evaluated for the background chain. +                return true; +            } +            if (mUseDifferentDelaysForBackgroundChain +                    && newProcState >= BACKGROUND_THRESHOLD_STATE +                    && getBackgroundTransitioningDelay(newProcState) +                    < getBackgroundTransitioningDelay(previousProcState)) { +                // The old and new proc-state both are in the blocked state but the background +                // transition delay is reduced, so we may have to update the rules sooner. +                return true;              }              final int networkCapabilities = PROCESS_CAPABILITY_POWER_RESTRICTED_NETWORK                      | PROCESS_CAPABILITY_USER_RESTRICTED_NETWORK; @@ -1367,9 +1349,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {              // on background handler thread, and POWER_SAVE_WHITELIST_CHANGED is protected              synchronized (mUidRulesFirstLock) {                  updatePowerSaveAllowlistUL(); -                if (mBackgroundNetworkRestricted) { -                    updateRulesForBackgroundChainUL(); -                } +                updateRulesForBackgroundChainUL();                  updateRulesForRestrictPowerUL();                  updateRulesForAppIdleUL();              } @@ -4100,8 +4080,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {                  fout.println();                  fout.println("Flags:"); -                fout.println(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE + ": " -                        + mBackgroundNetworkRestricted);                  fout.println(Flags.FLAG_USE_METERED_FIREWALL_CHAINS + ": "                          + mUseMeteredFirewallChains);                  fout.println(Flags.FLAG_USE_DIFFERENT_DELAYS_FOR_BACKGROUND_CHAIN + ": " @@ -4251,35 +4229,33 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {                      fout.decreaseIndent();                  } -                if (mBackgroundNetworkRestricted) { +                fout.println(); +                if (mUseDifferentDelaysForBackgroundChain) { +                    fout.print("Background restrictions short delay: "); +                    TimeUtils.formatDuration(mBackgroundRestrictionShortDelayMs, fout);                      fout.println(); -                    if (mUseDifferentDelaysForBackgroundChain) { -                        fout.print("Background restrictions short delay: "); -                        TimeUtils.formatDuration(mBackgroundRestrictionShortDelayMs, fout); -                        fout.println(); -                        fout.print("Background restrictions long delay: "); -                        TimeUtils.formatDuration(mBackgroundRestrictionLongDelayMs, fout); -                        fout.println(); -                    } +                    fout.print("Background restrictions long delay: "); +                    TimeUtils.formatDuration(mBackgroundRestrictionLongDelayMs, fout); +                    fout.println(); +                } -                    size = mBackgroundTransitioningUids.size(); -                    if (size > 0) { -                        final long nowUptime = SystemClock.uptimeMillis(); -                        fout.println("Uids transitioning to background:"); -                        fout.increaseIndent(); -                        for (int i = 0; i < size; i++) { -                            fout.print("UID="); -                            fout.print(mBackgroundTransitioningUids.keyAt(i)); -                            fout.print(", "); -                            TimeUtils.formatDuration(mBackgroundTransitioningUids.valueAt(i), -                                    nowUptime, fout); -                            fout.println(); -                        } -                        fout.decreaseIndent(); +                size = mBackgroundTransitioningUids.size(); +                if (size > 0) { +                    final long nowUptime = SystemClock.uptimeMillis(); +                    fout.println("Uids transitioning to background:"); +                    fout.increaseIndent(); +                    for (int i = 0; i < size; i++) { +                        fout.print("UID="); +                        fout.print(mBackgroundTransitioningUids.keyAt(i)); +                        fout.print(", "); +                        TimeUtils.formatDuration(mBackgroundTransitioningUids.valueAt(i), +                                nowUptime, fout); +                        fout.println();                      } -                    fout.println(); +                    fout.decreaseIndent();                  } +                fout.println();                  final SparseBooleanArray knownUids = new SparseBooleanArray();                  collectKeys(mUidState, knownUids); @@ -4465,51 +4441,49 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {                      }                      updatePowerRestrictionRules = true;                  } -                if (mBackgroundNetworkRestricted) { -                    final boolean wasAllowed = isProcStateAllowedNetworkWhileBackground( -                            oldUidState); -                    final boolean isAllowed = isProcStateAllowedNetworkWhileBackground(newUidState); -                    if (!wasAllowed && isAllowed) { -                        mBackgroundTransitioningUids.delete(uid); -                        updateRuleForBackgroundUL(uid); -                        updatePowerRestrictionRules = true; -                    } else if (!isAllowed) { -                        final int transitionIdx = mBackgroundTransitioningUids.indexOfKey(uid); -                        final long completionTimeMs = SystemClock.uptimeMillis() -                                + getBackgroundTransitioningDelay(procState); -                        boolean completionTimeUpdated = false; -                        if (wasAllowed) { -                            // Rules need to transition from allowed to blocked after the respective -                            // delay. -                            if (transitionIdx < 0) { -                                // This is just a defensive check in case the upstream code ever -                                // makes multiple calls for the same process state change. -                                mBackgroundTransitioningUids.put(uid, completionTimeMs); -                                completionTimeUpdated = true; -                            } -                        } else if (mUseDifferentDelaysForBackgroundChain) { -                            // wasAllowed was false, but the transition delay may have reduced. -                            // Currently, this can happen when the uid transitions from -                            // LAST_ACTIVITY to CACHED_ACTIVITY, for example. -                            if (transitionIdx >= 0 -                                    && completionTimeMs < mBackgroundTransitioningUids.valueAt( -                                    transitionIdx)) { -                                mBackgroundTransitioningUids.setValueAt(transitionIdx, -                                        completionTimeMs); -                                completionTimeUpdated = true; -                            } +                final boolean wasAllowed = isProcStateAllowedNetworkWhileBackground( +                        oldUidState); +                final boolean isAllowed = isProcStateAllowedNetworkWhileBackground(newUidState); +                if (!wasAllowed && isAllowed) { +                    mBackgroundTransitioningUids.delete(uid); +                    updateRuleForBackgroundUL(uid); +                    updatePowerRestrictionRules = true; +                } else if (!isAllowed) { +                    final int transitionIdx = mBackgroundTransitioningUids.indexOfKey(uid); +                    final long completionTimeMs = SystemClock.uptimeMillis() +                            + getBackgroundTransitioningDelay(procState); +                    boolean completionTimeUpdated = false; +                    if (wasAllowed) { +                        // Rules need to transition from allowed to blocked after the respective +                        // delay. +                        if (transitionIdx < 0) { +                            // This is just a defensive check in case the upstream code ever +                            // makes multiple calls for the same process state change. +                            mBackgroundTransitioningUids.put(uid, completionTimeMs); +                            completionTimeUpdated = true;                          } -                        if (completionTimeUpdated -                                && completionTimeMs < mNextProcessBackgroundUidsTime) { -                            // Many uids may be in this "transitioning" state at the same time, -                            // so we always keep one message to process transition completion at -                            // the earliest time. -                            mHandler.removeMessages(MSG_PROCESS_BACKGROUND_TRANSITIONING_UIDS); -                            mHandler.sendEmptyMessageAtTime( -                                    MSG_PROCESS_BACKGROUND_TRANSITIONING_UIDS, completionTimeMs); -                            mNextProcessBackgroundUidsTime = completionTimeMs; +                    } else if (mUseDifferentDelaysForBackgroundChain) { +                        // wasAllowed was false, but the transition delay may have reduced. +                        // Currently, this can happen when the uid transitions from +                        // LAST_ACTIVITY to CACHED_ACTIVITY, for example. +                        if (transitionIdx >= 0 +                                && completionTimeMs < mBackgroundTransitioningUids.valueAt( +                                transitionIdx)) { +                            mBackgroundTransitioningUids.setValueAt(transitionIdx, +                                    completionTimeMs); +                            completionTimeUpdated = true;                          }                      } +                    if (completionTimeUpdated +                            && completionTimeMs < mNextProcessBackgroundUidsTime) { +                        // Many uids may be in this "transitioning" state at the same time, +                        // so we always keep one message to process transition completion at +                        // the earliest time. +                        mHandler.removeMessages(MSG_PROCESS_BACKGROUND_TRANSITIONING_UIDS); +                        mHandler.sendEmptyMessageAtTime( +                                MSG_PROCESS_BACKGROUND_TRANSITIONING_UIDS, completionTimeMs); +                        mNextProcessBackgroundUidsTime = completionTimeMs; +                    }                  }                  if (mLowPowerStandbyActive) {                      boolean allowedInLpsChanged = @@ -4545,12 +4519,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {                  if (mRestrictPower) {                      updateRuleForRestrictPowerUL(uid);                  } -                if (mBackgroundNetworkRestricted) { -                    // Uid is no longer running, there is no point in any grace period of network -                    // access during transitions to lower importance proc-states. -                    mBackgroundTransitioningUids.delete(uid); -                    updateRuleForBackgroundUL(uid); -                } +                // Uid is no longer running, there is no point in any grace period of network +                // access during transitions to lower importance proc-states. +                mBackgroundTransitioningUids.delete(uid); +                updateRuleForBackgroundUL(uid);                  updateRulesForPowerRestrictionsUL(uid);                  if (mLowPowerStandbyActive) {                      updateRuleForLowPowerStandbyUL(uid); @@ -5021,9 +4993,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {                      "updateRulesForGlobalChangeAL: " + (restrictedNetworksChanged ? "R" : "-"));          }          try { -            if (mBackgroundNetworkRestricted) { -                updateRulesForBackgroundChainUL(); -            } +            updateRulesForBackgroundChainUL();              updateRulesForAppIdleUL();              updateRulesForRestrictPowerUL();              updateRulesForRestrictBackgroundUL(); @@ -5183,9 +5153,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {              updateRuleForAppIdleUL(uid, PROCESS_STATE_UNKNOWN);              updateRuleForDeviceIdleUL(uid);              updateRuleForRestrictPowerUL(uid); -            if (mBackgroundNetworkRestricted) { -                updateRuleForBackgroundUL(uid); -            } +            updateRuleForBackgroundUL(uid);              // Update internal rules.              updateRulesForPowerRestrictionsUL(uid);          } @@ -5358,9 +5326,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {          updateRuleForDeviceIdleUL(uid);          updateRuleForAppIdleUL(uid, PROCESS_STATE_UNKNOWN);          updateRuleForRestrictPowerUL(uid); -        if (mBackgroundNetworkRestricted) { -            updateRuleForBackgroundUL(uid); -        } +        updateRuleForBackgroundUL(uid);          // If the uid has the necessary permissions, then it should be added to the restricted mode          // firewall allowlist. @@ -5611,7 +5577,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {              newBlockedReasons |= (mLowPowerStandbyActive ? BLOCKED_REASON_LOW_POWER_STANDBY : 0);              newBlockedReasons |= (isUidIdle ? BLOCKED_REASON_APP_STANDBY : 0);              newBlockedReasons |= (uidBlockedState.blockedReasons & BLOCKED_REASON_RESTRICTED_MODE); -            newBlockedReasons |= mBackgroundNetworkRestricted ? BLOCKED_REASON_APP_BACKGROUND : 0; +            newBlockedReasons |= BLOCKED_REASON_APP_BACKGROUND;              newAllowedReasons |= (isSystem(uid) ? ALLOWED_REASON_SYSTEM : 0);              newAllowedReasons |= (isForeground ? ALLOWED_REASON_FOREGROUND : 0); @@ -5624,8 +5590,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {                      & ALLOWED_REASON_RESTRICTED_MODE_PERMISSIONS);              newAllowedReasons |= (isAllowlistedFromLowPowerStandbyUL(uid))                      ? ALLOWED_REASON_LOW_POWER_STANDBY_ALLOWLIST : 0; -            newAllowedReasons |= (mBackgroundNetworkRestricted -                    && isUidExemptFromBackgroundRestrictions(uid)) +            newAllowedReasons |= isUidExemptFromBackgroundRestrictions(uid)                      ? ALLOWED_REASON_NOT_IN_BACKGROUND : 0;              uidBlockedState.blockedReasons = (uidBlockedState.blockedReasons diff --git a/services/core/java/com/android/server/net/flags.aconfig b/services/core/java/com/android/server/net/flags.aconfig index 7f04e665567e..3c0ff6115fcd 100644 --- a/services/core/java/com/android/server/net/flags.aconfig +++ b/services/core/java/com/android/server/net/flags.aconfig @@ -2,13 +2,6 @@ package: "com.android.server.net"  container: "system"  flag { -    name: "network_blocked_for_top_sleeping_and_above" -    namespace: "backstage_power" -    description: "Block network access for apps in a low importance background state" -    bug: "304347838" -} - -flag {      name: "use_metered_firewall_chains"      namespace: "backstage_power"      description: "Use metered firewall chains to control access to metered networks" diff --git a/services/core/java/com/android/server/vcn/VcnContext.java b/services/core/java/com/android/server/vcn/VcnContext.java index 6ce868540070..9213d96ad4ca 100644 --- a/services/core/java/com/android/server/vcn/VcnContext.java +++ b/services/core/java/com/android/server/vcn/VcnContext.java @@ -74,10 +74,6 @@ public class VcnContext {          return mFeatureFlags;      } -    public boolean isFlagSafeModeTimeoutConfigEnabled() { -        return mFeatureFlags.safeModeTimeoutConfig(); -    } -      /**       * Verifies that the caller is running on the VcnContext Thread.       * diff --git a/services/core/java/com/android/server/vcn/VcnGatewayConnection.java b/services/core/java/com/android/server/vcn/VcnGatewayConnection.java index 2d3bc84debff..2325f358e301 100644 --- a/services/core/java/com/android/server/vcn/VcnGatewayConnection.java +++ b/services/core/java/com/android/server/vcn/VcnGatewayConnection.java @@ -1263,7 +1263,7 @@ public class VcnGatewayConnection extends StateMachine {          final PersistableBundleWrapper carrierConfig = snapshot.getCarrierConfigForSubGrp(subGrp);          int resultSeconds = defaultSeconds; -        if (vcnContext.isFlagSafeModeTimeoutConfigEnabled() && carrierConfig != null) { +        if (carrierConfig != null) {              resultSeconds =                      carrierConfig.getInt(                              VcnManager.VCN_SAFE_MODE_TIMEOUT_SECONDS_KEY, defaultSeconds); diff --git a/services/core/java/com/android/server/wm/OWNERS b/services/core/java/com/android/server/wm/OWNERS index 431023163d0a..63cd59e45ea6 100644 --- a/services/core/java/com/android/server/wm/OWNERS +++ b/services/core/java/com/android/server/wm/OWNERS @@ -34,4 +34,5 @@ per-file *TransitionTracer.java = file:platform/development:/tools/winscope/OWNE  # Files related to activity security  per-file ActivityStarter.java = file:/ACTIVITY_SECURITY_OWNERS +per-file ActivityStartController.java = file:/ACTIVITY_SECURITY_OWNERS  per-file ActivityTaskManagerService.java = file:/ACTIVITY_SECURITY_OWNERS diff --git a/services/tests/servicestests/src/com/android/server/net/NetworkPolicyManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/net/NetworkPolicyManagerServiceTest.java index dddab657be14..5a7027edc20d 100644 --- a/services/tests/servicestests/src/com/android/server/net/NetworkPolicyManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/net/NetworkPolicyManagerServiceTest.java @@ -2158,13 +2158,11 @@ public class NetworkPolicyManagerServiceTest {      }      @Test -    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)      public void testBackgroundChainEnabled() throws Exception {          verify(mNetworkManager).setFirewallChainEnabled(FIREWALL_CHAIN_BACKGROUND, true);      }      @Test -    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)      @RequiresFlagsDisabled(Flags.FLAG_USE_DIFFERENT_DELAYS_FOR_BACKGROUND_CHAIN)      public void testBackgroundChainOnProcStateChangeSameDelay() throws Exception {          // initialization calls setFirewallChainEnabled, so we want to reset the invocations. @@ -2194,10 +2192,7 @@ public class NetworkPolicyManagerServiceTest {      }      @Test -    @RequiresFlagsEnabled({ -            Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE, -            Flags.FLAG_USE_DIFFERENT_DELAYS_FOR_BACKGROUND_CHAIN -    }) +    @RequiresFlagsEnabled(Flags.FLAG_USE_DIFFERENT_DELAYS_FOR_BACKGROUND_CHAIN)      public void testBackgroundChainOnProcStateChangeDifferentDelays() throws Exception {          // The app will be blocked when there is no prior proc-state.          assertTrue(mService.isUidNetworkingBlocked(UID_A, false)); @@ -2247,7 +2242,6 @@ public class NetworkPolicyManagerServiceTest {      }      @Test -    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)      public void testBackgroundChainOnAllowlistChange() throws Exception {          // initialization calls setFirewallChainEnabled, so we want to reset the invocations.          clearInvocations(mNetworkManager); @@ -2285,7 +2279,6 @@ public class NetworkPolicyManagerServiceTest {      }      @Test -    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)      public void testBackgroundChainOnTempAllowlistChange() throws Exception {          // initialization calls setFirewallChainEnabled, so we want to reset the invocations.          clearInvocations(mNetworkManager); @@ -2387,7 +2380,6 @@ public class NetworkPolicyManagerServiceTest {      }      @Test -    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)      public void testUidObserverFiltersProcStateChanges() throws Exception {          int testProcStateSeq = 0;          try (SyncBarrier b = new SyncBarrier(mService.mUidEventHandler)) { @@ -2450,7 +2442,6 @@ public class NetworkPolicyManagerServiceTest {      }      @Test -    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)      public void testUidObserverFiltersStaleChanges() throws Exception {          final int testProcStateSeq = 51;          try (SyncBarrier b = new SyncBarrier(mService.mUidEventHandler)) { @@ -2470,7 +2461,6 @@ public class NetworkPolicyManagerServiceTest {      }      @Test -    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)      public void testUidObserverFiltersCapabilityChanges() throws Exception {          int testProcStateSeq = 0;          try (SyncBarrier b = new SyncBarrier(mService.mUidEventHandler)) { @@ -2559,7 +2549,6 @@ public class NetworkPolicyManagerServiceTest {      }      @Test -    @RequiresFlagsEnabled(Flags.FLAG_NETWORK_BLOCKED_FOR_TOP_SLEEPING_AND_ABOVE)      public void testObsoleteHandleUidChanged() throws Exception {          callAndWaitOnUidGone(UID_A);          assertTrue(mService.isUidNetworkingBlocked(UID_A, false)); diff --git a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionTest.java b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionTest.java index 49665f7a3304..613b92616707 100644 --- a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionTest.java +++ b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionTest.java @@ -360,12 +360,10 @@ public class VcnGatewayConnectionTest extends VcnGatewayConnectionTestBase {      private void verifyGetSafeModeTimeoutMs(              boolean isInTestMode, -            boolean isConfigTimeoutSupported,              PersistableBundleWrapper carrierConfig,              long expectedTimeoutMs)              throws Exception {          doReturn(isInTestMode).when(mVcnContext).isInTestMode(); -        doReturn(isConfigTimeoutSupported).when(mVcnContext).isFlagSafeModeTimeoutConfigEnabled();          final TelephonySubscriptionSnapshot snapshot = mock(TelephonySubscriptionSnapshot.class);          doReturn(carrierConfig).when(snapshot).getCarrierConfigForSubGrp(TEST_SUB_GRP); @@ -377,16 +375,7 @@ public class VcnGatewayConnectionTest extends VcnGatewayConnectionTestBase {      }      @Test -    public void testGetSafeModeTimeoutMs_configTimeoutUnsupported() throws Exception { -        verifyGetSafeModeTimeoutMs( -                false /* isInTestMode */, -                false /* isConfigTimeoutSupported */, -                null /* carrierConfig */, -                TimeUnit.SECONDS.toMillis(SAFEMODE_TIMEOUT_SECONDS)); -    } - -    @Test -    public void testGetSafeModeTimeoutMs_configTimeoutSupported() throws Exception { +    public void testGetSafeModeTimeoutMs() throws Exception {          final int carrierConfigTimeoutSeconds = 20;          final PersistableBundleWrapper carrierConfig = mock(PersistableBundleWrapper.class);          doReturn(carrierConfigTimeoutSeconds) @@ -395,17 +384,14 @@ public class VcnGatewayConnectionTest extends VcnGatewayConnectionTestBase {          verifyGetSafeModeTimeoutMs(                  false /* isInTestMode */, -                true /* isConfigTimeoutSupported */,                  carrierConfig,                  TimeUnit.SECONDS.toMillis(carrierConfigTimeoutSeconds));      }      @Test -    public void testGetSafeModeTimeoutMs_configTimeoutSupported_carrierConfigNull() -            throws Exception { +    public void testGetSafeModeTimeoutMs_carrierConfigNull() throws Exception {          verifyGetSafeModeTimeoutMs(                  false /* isInTestMode */, -                true /* isConfigTimeoutSupported */,                  null /* carrierConfig */,                  TimeUnit.SECONDS.toMillis(SAFEMODE_TIMEOUT_SECONDS));      } @@ -420,7 +406,6 @@ public class VcnGatewayConnectionTest extends VcnGatewayConnectionTestBase {          verifyGetSafeModeTimeoutMs(                  true /* isInTestMode */, -                true /* isConfigTimeoutSupported */,                  carrierConfig,                  TimeUnit.SECONDS.toMillis(carrierConfigTimeoutSeconds));      } diff --git a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionTestBase.java b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionTestBase.java index 4c7b25aaa7c3..8374fd944568 100644 --- a/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionTestBase.java +++ b/tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionTestBase.java @@ -222,7 +222,6 @@ public class VcnGatewayConnectionTestBase {          doReturn(mTestLooper.getLooper()).when(mVcnContext).getLooper();          doReturn(mVcnNetworkProvider).when(mVcnContext).getVcnNetworkProvider();          doReturn(mFeatureFlags).when(mVcnContext).getFeatureFlags(); -        doReturn(true).when(mVcnContext).isFlagSafeModeTimeoutConfigEnabled();          doReturn(mUnderlyingNetworkController)                  .when(mDeps) diff --git a/tools/systemfeatures/src/com/android/systemfeatures/SystemFeaturesGenerator.kt b/tools/systemfeatures/src/com/android/systemfeatures/SystemFeaturesGenerator.kt index 1abe77fd3ceb..f260e2733843 100644 --- a/tools/systemfeatures/src/com/android/systemfeatures/SystemFeaturesGenerator.kt +++ b/tools/systemfeatures/src/com/android/systemfeatures/SystemFeaturesGenerator.kt @@ -188,7 +188,7 @@ object SystemFeaturesGenerator {                          ?: throw IllegalArgumentException(                              "Invalid feature version input for $name: ${featureArgs[1]}"                          ) -                FeatureInfo(name, featureArgs[1].toInt(), readonly = true) +                FeatureInfo(name, featureVersion, readonly = true)              }          }      }  |