1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5  * except in compliance with the License. You may obtain a copy of the License at
6  *
7  *      http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the
10  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11  * KIND, either express or implied. See the License for the specific language governing
12  * permissions and limitations under the License.
13  */
14 package com.android.systemui.plugins.clocks
15 
16 import com.android.systemui.plugins.Plugin
17 import com.android.systemui.plugins.annotations.GeneratedImport
18 import com.android.systemui.plugins.annotations.ProtectedInterface
19 import com.android.systemui.plugins.annotations.ProtectedReturn
20 import com.android.systemui.plugins.annotations.ProvidesInterface
21 
22 /** A Plugin which exposes the ClockProvider interface */
23 @ProtectedInterface
24 @ProvidesInterface(action = ClockProviderPlugin.ACTION, version = ClockProviderPlugin.VERSION)
25 interface ClockProviderPlugin : Plugin, ClockProvider {
26     companion object {
27         const val ACTION = "com.android.systemui.action.PLUGIN_CLOCK_PROVIDER"
28         const val VERSION = 1
29     }
30 }
31 
32 /** Interface for building clocks and providing information about those clocks */
33 @ProtectedInterface
34 @GeneratedImport("java.util.List")
35 @GeneratedImport("java.util.ArrayList")
36 interface ClockProvider {
37     /** Initializes the clock provider with debug log buffers */
initializenull38     fun initialize(buffers: ClockMessageBuffers?)
39 
40     @ProtectedReturn("return new ArrayList<ClockMetadata>();")
41     /** Returns metadata for all clocks this provider knows about */
42     fun getClocks(): List<ClockMetadata>
43 
44     @ProtectedReturn("return null;")
45     /** Initializes and returns the target clock design */
46     fun createClock(settings: ClockSettings): ClockController?
47 
48     @ProtectedReturn("return new ClockPickerConfig(\"\", \"\", \"\", null);")
49     /** Settings configuration parameters for the clock */
50     fun getClockPickerConfig(settings: ClockSettings): ClockPickerConfig
51 }
52 
53 /** Identifies a clock design */
54 typealias ClockId = String
55 
56 /** Some data about a clock design */
57 data class ClockMetadata(val clockId: ClockId)
58