1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server.dreams; 18 19 import android.annotation.NonNull; 20 21 import com.android.internal.logging.UiEvent; 22 import com.android.internal.logging.UiEventLogger; 23 24 /** 25 * Logging interface for Dream UI events. Normal implementation is DreamUiEventLoggerImpl. 26 * 27 * See DreamUiEventReported atom in atoms.proto for more context. 28 * @hide 29 */ 30 public interface DreamUiEventLogger { 31 /** Put your Event IDs in enums that implement this interface, and document them using the 32 * UiEventEnum annotation. 33 * Event IDs must be globally unique. This will be enforced by tooling (forthcoming). 34 * OEMs should use event IDs above 100000 and below 1000000 (1 million). 35 */ 36 enum DreamUiEventEnum implements UiEventLogger.UiEventEnum { 37 @UiEvent(doc = "The screensaver has started.") 38 DREAM_START(577), 39 40 @UiEvent(doc = "The screensaver has stopped.") 41 DREAM_STOP(578); 42 43 private final int mId; 44 DreamUiEventEnum(int id)45 DreamUiEventEnum(int id) { 46 mId = id; 47 } 48 49 @Override getId()50 public int getId() { 51 return mId; 52 } 53 } 54 55 /** 56 * Log a simple event with dream component name, with no package information. Does nothing if 57 * event.getId() <= 0. 58 * @param event an enum implementing UiEventEnum interface. 59 * @param dreamComponentName the component name of the dream in use. 60 */ log(@onNull UiEventLogger.UiEventEnum event, @NonNull String dreamComponentName)61 void log(@NonNull UiEventLogger.UiEventEnum event, @NonNull String dreamComponentName); 62 } 63