summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ben Reich <benreich@google.com> 2024-10-02 17:02:46 +1000
committer Ben Reich <benreich@google.com> 2024-10-04 08:14:04 +1000
commit90a5112c4488d4a3393e5e4505e4369191ae1563 (patch)
treed60a0bbe68f0fceb67fd72c2d5e24f2709b735ea
parent23c4bc7db2e4efe65fbee9112faa0ecf5a3d5d5c (diff)
Fix up build rules to enable Kotlin support
The app-compat-annotations library doesn't play nicely with the Kotlin compiler. This change isolates the files that rely on this into their own build rules and bypass the DocumentsUI-lib rule which will contain Kotlin files in the future. This change is almost identical to the change done in Settings at http://ag/18655752. Bug: 370880067 Test: mma DocumentsUIGoogle Flag: EXEMPT only build file changes Change-Id: Id9f2e6dce46f5251f7a99c12d94f50c68597dd19
-rw-r--r--Android.bp19
-rw-r--r--src/com/android/documentsui/ChangeIds.java32
-rw-r--r--src/com/android/documentsui/base/Shared.java13
3 files changed, 47 insertions, 17 deletions
diff --git a/Android.bp b/Android.bp
index c4b9ad3f1..f2ae7919c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -27,6 +27,14 @@ license {
license_text: [],
}
+java_library {
+ name: "docsui-change-ids",
+ srcs: ["src/com/android/documentsui/ChangeIds.java"],
+ libs: ["app-compat-annotations"],
+ min_sdk_version: "29",
+ sdk_version: "system_current",
+}
+
java_defaults {
name: "documentsui_defaults",
@@ -40,14 +48,11 @@ java_defaults {
"androidx.transition_transition",
"apache-commons-compress",
"com.google.android.material_material",
+ "docsui-change-ids",
"guava",
"modules-utils-build_system",
],
- libs: [
- "app-compat-annotations",
- ],
-
privileged: true,
certificate: "platform",
@@ -63,7 +68,7 @@ java_defaults {
platform_compat_config {
name: "documents-ui-compat-config",
- src: ":DocumentsUI",
+ src: ":docsui-change-ids",
}
java_library {
@@ -101,8 +106,12 @@ android_library {
"--auto-add-overlay",
],
+ // This is included in `documentsui_defaults`.
+ exclude_srcs: ["src/com/android/documentsui/ChangeIds.java"],
+
srcs: [
"src/**/*.java",
+ "src/**/*.kt",
":statslog-docsui-java-gen",
],
diff --git a/src/com/android/documentsui/ChangeIds.java b/src/com/android/documentsui/ChangeIds.java
new file mode 100644
index 000000000..5ddf40f8e
--- /dev/null
+++ b/src/com/android/documentsui/ChangeIds.java
@@ -0,0 +1,32 @@
+/*
+ * 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.documentsui;
+
+import android.compat.annotation.ChangeId;
+import android.compat.annotation.EnabledAfter;
+import android.os.Build;
+
+public final class ChangeIds {
+ /**
+ * We support restrict Storage Access Framework from {@link Build.VERSION_CODES#R}.
+ * App Compatibility flag that indicates whether the app should be restricted or not.
+ * This flag is turned on by default for all apps targeting >
+ * {@link Build.VERSION_CODES#Q}.
+ */
+ @ChangeId
+ @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.Q)
+ public static final long RESTRICT_STORAGE_ACCESS_FRAMEWORK = 141600225L;
+}
diff --git a/src/com/android/documentsui/base/Shared.java b/src/com/android/documentsui/base/Shared.java
index 5ac9de4d7..ac089999f 100644
--- a/src/com/android/documentsui/base/Shared.java
+++ b/src/com/android/documentsui/base/Shared.java
@@ -17,11 +17,10 @@
package com.android.documentsui.base;
import static com.android.documentsui.base.SharedMinimal.TAG;
+import static com.android.documentsui.ChangeIds.RESTRICT_STORAGE_ACCESS_FRAMEWORK;
import android.app.Activity;
import android.app.compat.CompatChanges;
-import android.compat.annotation.ChangeId;
-import android.compat.annotation.EnabledAfter;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -143,16 +142,6 @@ public final class Shared {
private static final Collator sCollator;
- /**
- * We support restrict Storage Access Framework from {@link android.os.Build.VERSION_CODES#R}.
- * App Compatibility flag that indicates whether the app should be restricted or not.
- * This flag is turned on by default for all apps targeting >
- * {@link android.os.Build.VERSION_CODES#Q}.
- */
- @ChangeId
- @EnabledAfter(targetSdkVersion = android.os.Build.VERSION_CODES.Q)
- private static final long RESTRICT_STORAGE_ACCESS_FRAMEWORK = 141600225L;
-
static {
sCollator = Collator.getInstance();
sCollator.setStrength(Collator.SECONDARY);