Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 90a5112c authored by Ben Reich's avatar Ben Reich
Browse files

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
parent 23c4bc7d
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -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",
    ],

+32 −0
Original line number Diff line number Diff line
/*
 * 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;
}
+1 −12
Original line number Diff line number Diff line
@@ -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);