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

Commit dfd1a472 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use codegen to catch LinkageErrors from plugins" into main

parents 0444f44e bab76df0
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -23,9 +23,7 @@ package {
}

java_library {

    name: "SystemUIPluginLib",

    srcs: [
        "bcsmartspace/src/**/*.java",
        "bcsmartspace/src/**/*.kt",
@@ -40,6 +38,8 @@ java_library {
        export_proguard_flags_files: true,
    },

    plugins: ["PluginAnnotationProcessor"],

    // If you add a static lib here, you may need to also add the package to the ClassLoaderFilter
    // in PluginInstance. That will ensure that loaded plugins have access to the related classes.
    // You should also add it to proguard_common.flags so that proguard does not remove the portions
@@ -53,7 +53,6 @@ java_library {
        "SystemUILogLib",
        "androidx.annotation_annotation",
    ],

}

android_app {
+33 −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.systemui.plugins

import com.android.systemui.plugins.annotations.ProtectedInterface
import com.android.systemui.plugins.annotations.ProtectedReturn
import com.android.systemui.plugins.annotations.ProvidesInterface

@ProtectedInterface
@ProvidesInterface(action = TestPlugin.ACTION, version = TestPlugin.VERSION)
/** Interface intended for use in tests */
interface TestPlugin : Plugin {
    companion object {
        const val VERSION = 1

        const val ACTION = "testAction"
    }

    @ProtectedReturn("return new Object();")
    /** Test method, implemented by test */
    fun methodThrowsError(): Object
}
+40 −4
Original line number Diff line number Diff line
@@ -21,7 +21,11 @@ import androidx.constraintlayout.widget.ConstraintSet
import com.android.internal.annotations.Keep
import com.android.systemui.log.core.MessageBuffer
import com.android.systemui.plugins.Plugin
import com.android.systemui.plugins.annotations.GeneratedImport
import com.android.systemui.plugins.annotations.ProtectedInterface
import com.android.systemui.plugins.annotations.ProtectedReturn
import com.android.systemui.plugins.annotations.ProvidesInterface
import com.android.systemui.plugins.annotations.SimpleProperty
import java.io.PrintWriter
import java.util.Locale
import java.util.TimeZone
@@ -31,6 +35,7 @@ import org.json.JSONObject
typealias ClockId = String

/** A Plugin which exposes the ClockProvider interface */
@ProtectedInterface
@ProvidesInterface(action = ClockProviderPlugin.ACTION, version = ClockProviderPlugin.VERSION)
interface ClockProviderPlugin : Plugin, ClockProvider {
    companion object {
@@ -40,31 +45,42 @@ interface ClockProviderPlugin : Plugin, ClockProvider {
}

/** Interface for building clocks and providing information about those clocks */
@ProtectedInterface
@GeneratedImport("java.util.List")
@GeneratedImport("java.util.ArrayList")
interface ClockProvider {
    /** Initializes the clock provider with debug log buffers */
    fun initialize(buffers: ClockMessageBuffers?)

    @ProtectedReturn("return new ArrayList<ClockMetadata>();")
    /** Returns metadata for all clocks this provider knows about */
    fun getClocks(): List<ClockMetadata>

    @ProtectedReturn("return null;")
    /** Initializes and returns the target clock design */
    fun createClock(settings: ClockSettings): ClockController
    fun createClock(settings: ClockSettings): ClockController?

    @ProtectedReturn("return new ClockPickerConfig(\"\", \"\", \"\", null);")
    /** Settings configuration parameters for the clock */
    fun getClockPickerConfig(id: ClockId): ClockPickerConfig
}

/** Interface for controlling an active clock */
@ProtectedInterface
interface ClockController {
    @get:SimpleProperty
    /** A small version of the clock, appropriate for smaller viewports */
    val smallClock: ClockFaceController

    @get:SimpleProperty
    /** A large version of the clock, appropriate when a bigger viewport is available */
    val largeClock: ClockFaceController

    @get:SimpleProperty
    /** Determines the way the hosting app should behave when rendering either clock face */
    val config: ClockConfig

    @get:SimpleProperty
    /** Events that clocks may need to respond to */
    val events: ClockEvents

@@ -76,19 +92,26 @@ interface ClockController {
}

/** Interface for a specific clock face version rendered by the clock */
@ProtectedInterface
interface ClockFaceController {
    @get:SimpleProperty
    @Deprecated("Prefer use of layout")
    /** View that renders the clock face */
    val view: View

    @get:SimpleProperty
    /** Layout specification for this clock */
    val layout: ClockFaceLayout

    @get:SimpleProperty
    /** Determines the way the hosting app should behave when rendering this clock face */
    val config: ClockFaceConfig

    @get:SimpleProperty
    /** Events specific to this clock face */
    val events: ClockFaceEvents

    @get:SimpleProperty
    /** Triggers for various animations */
    val animations: ClockAnimations
}
@@ -107,14 +130,21 @@ data class ClockMessageBuffers(

data class AodClockBurnInModel(val scale: Float, val translationX: Float, val translationY: Float)

/** Specifies layout information for the */
/** Specifies layout information for the clock face */
@ProtectedInterface
@GeneratedImport("java.util.ArrayList")
@GeneratedImport("android.view.View")
interface ClockFaceLayout {
    @get:ProtectedReturn("return new ArrayList<View>();")
    /** All clock views to add to the root constraint layout before applying constraints. */
    val views: List<View>

    @ProtectedReturn("return constraints;")
    /** Custom constraints to apply to Lockscreen ConstraintLayout. */
    fun applyConstraints(constraints: ConstraintSet): ConstraintSet

    @ProtectedReturn("return constraints;")
    /** Custom constraints to apply to preview ConstraintLayout. */
    fun applyPreviewConstraints(constraints: ConstraintSet): ConstraintSet

    fun applyAodBurnIn(aodBurnInModel: AodClockBurnInModel)
@@ -145,7 +175,9 @@ class DefaultClockFaceLayout(val view: View) : ClockFaceLayout {
}

/** Events that should call when various rendering parameters change */
@ProtectedInterface
interface ClockEvents {
    @get:ProtectedReturn("return false;")
    /** Set to enable or disable swipe interaction */
    var isReactiveTouchInteractionEnabled: Boolean

@@ -187,6 +219,7 @@ data class ClockReactiveSetting(
)

/** Methods which trigger various clock animations */
@ProtectedInterface
interface ClockAnimations {
    /** Runs an enter animation (if any) */
    fun enter()
@@ -230,6 +263,7 @@ interface ClockAnimations {
}

/** Events that have specific data about the related face */
@ProtectedInterface
interface ClockFaceEvents {
    /** Call every time tick */
    fun onTimeTick()
@@ -270,7 +304,9 @@ enum class ClockTickRate(val value: Int) {
/** Some data about a clock design */
data class ClockMetadata(val clockId: ClockId)

data class ClockPickerConfig(
data class ClockPickerConfig
@JvmOverloads
constructor(
    val id: String,

    /** Localized name of the clock */
@@ -338,7 +374,7 @@ data class ClockConfig(
    /** Transition to AOD should move smartspace like large clock instead of small clock */
    val useAlternateSmartspaceAODTransition: Boolean = false,

    /** Use ClockPickerConfig.isReactiveToTone instead */
    /** Deprecated version of isReactiveToTone; moved to ClockPickerConfig */
    @Deprecated("TODO(b/352049256): Remove in favor of ClockPickerConfig.isReactiveToTone")
    val isReactiveToTone: Boolean = true,

+62 −1
Original line number Diff line number Diff line
@@ -22,10 +22,44 @@ package {
    default_applicable_licenses: ["frameworks_base_packages_SystemUI_license"],
}

java_library {
    sdk_version: "current",
    name: "PluginAnnotationLib",
    host_supported: true,
    device_supported: true,
    srcs: [
        "src/**/annotations/*.java",
        "src/**/annotations/*.kt",
    ],
    optimize: {
        proguard_flags_files: ["proguard.flags"],
        // Ensure downstream clients that reference this as a shared lib
        // inherit the appropriate flags to preserve annotations.
        export_proguard_flags_files: true,
    },

    // Enforce that the library is built against java 8 so that there are
    // no compatibility issues with launcher
    java_version: "1.8",
}

java_library {
    sdk_version: "current",
    name: "PluginCoreLib",
    srcs: ["src/**/*.java"],
    device_supported: true,
    srcs: [
        "src/**/*.java",
        "src/**/*.kt",
    ],
    exclude_srcs: [
        "src/**/annotations/*.java",
        "src/**/annotations/*.kt",
        "src/**/processor/*.java",
        "src/**/processor/*.kt",
    ],
    static_libs: [
        "PluginAnnotationLib",
    ],
    optimize: {
        proguard_flags_files: ["proguard.flags"],
        // Ensure downstream clients that reference this as a shared lib
@@ -37,3 +71,30 @@ java_library {
    // no compatibility issues with launcher
    java_version: "1.8",
}

java_library {
    java_version: "1.8",
    name: "PluginAnnotationProcessorLib",
    host_supported: true,
    device_supported: false,
    srcs: [
        "src/**/processor/*.java",
        "src/**/processor/*.kt",
    ],
    plugins: ["auto_service_plugin"],
    static_libs: [
        "androidx.annotation_annotation",
        "auto_service_annotations",
        "auto_common",
        "PluginAnnotationLib",
        "guava",
        "jsr330",
    ],
}

java_plugin {
    name: "PluginAnnotationProcessor",
    processor_class: "com.android.systemui.plugins.processor.ProtectedPluginProcessor",
    static_libs: ["PluginAnnotationProcessorLib"],
    java_version: "1.8",
}
+3 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ package com.android.systemui.plugins;

import android.content.Context;

import com.android.systemui.plugins.annotations.ProtectedReturn;
import com.android.systemui.plugins.annotations.Requires;

/**
@@ -116,6 +117,8 @@ public interface Plugin {
     * @deprecated
     * @see Requires
     */
    @Deprecated
    @ProtectedReturn(statement = "return -1;")
    default int getVersion() {
        // Default of -1 indicates the plugin supports the new Requires model.
        return -1;
Loading