• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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.settingslib.metadata
18 
19 import android.content.Context
20 
21 /** Metrics logger for preference actions triggered by user interaction. */
22 interface PreferenceUiActionMetricsLogger {
23 
24     /**
25      * Logs preference value change due to user interaction.
26      *
27      * Note: Preference value changed by external Set is excluded.
28      */
logPreferenceValueChangenull29     fun logPreferenceValueChange(
30         screen: PreferenceScreenMetadata,
31         preference: PreferenceMetadata,
32         value: Any?,
33     )
34 }
35 
36 /** Metrics logger for preference remote operations (e.g. external get/set). */
37 interface PreferenceRemoteOpMetricsLogger {
38 
39     /** Logs get preference metadata operation. */
40     fun logGetterApi(
41         context: Context,
42         callingUid: Int,
43         preferenceCoordinate: PreferenceCoordinate,
44         screen: PreferenceScreenMetadata?,
45         preference: PreferenceMetadata?,
46         errorCode: Int,
47         latencyMs: Long,
48     )
49 
50     /** Logs set preference value operation. */
51     fun logSetterApi(
52         context: Context,
53         callingUid: Int,
54         preferenceCoordinate: PreferenceCoordinate,
55         screen: PreferenceScreenMetadata?,
56         preference: PreferenceMetadata?,
57         errorCode: Int,
58         latencyMs: Long,
59     )
60 
61     /** Logs get preference graph operation. */
62     fun logGraphApi(context: Context, callingUid: Int, success: Boolean, latencyMs: Long)
63 }
64