• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.power;
18 
19 import android.os.WorkSource.WorkChain;
20 
21 import com.android.internal.util.FrameworkStatsLog;
22 
23 public class FrameworkStatsLogger {
24     public enum WakelockEventType {
25         ACQUIRE,
26         RELEASE
27     }
28 
29     /** Log WakelockStateChanged push atom without a WorkChain. */
wakelockStateChanged( int ownerUid, String tag, int powerManagerWakeLockLevel, WakelockEventType eventType)30     public void wakelockStateChanged(
31             int ownerUid, String tag, int powerManagerWakeLockLevel, WakelockEventType eventType) {
32         int event =
33                 (eventType == WakelockEventType.ACQUIRE)
34                         ? FrameworkStatsLog.WAKELOCK_STATE_CHANGED__STATE__ACQUIRE
35                         : FrameworkStatsLog.WAKELOCK_STATE_CHANGED__STATE__RELEASE;
36         FrameworkStatsLog.write_non_chained(
37                 FrameworkStatsLog.WAKELOCK_STATE_CHANGED,
38                 ownerUid,
39                 null,
40                 powerManagerWakeLockLevel,
41                 tag,
42                 event,
43                 FrameworkStatsLog.WAKELOCK_STATE_CHANGED__PROCESS_STATE__PROCESS_STATE_UNKNOWN);
44     }
45 
46     /** Log WakelockStateChanged push atom with a WorkChain. */
wakelockStateChanged( String tag, WorkChain wc, int powerManagerWakeLockLevel, WakelockEventType eventType)47     public void wakelockStateChanged(
48             String tag, WorkChain wc, int powerManagerWakeLockLevel, WakelockEventType eventType) {
49         int event =
50                 (eventType == WakelockEventType.ACQUIRE)
51                         ? FrameworkStatsLog.WAKELOCK_STATE_CHANGED__STATE__ACQUIRE
52                         : FrameworkStatsLog.WAKELOCK_STATE_CHANGED__STATE__RELEASE;
53         FrameworkStatsLog.write(
54                 FrameworkStatsLog.WAKELOCK_STATE_CHANGED,
55                 wc.getUids(),
56                 wc.getTags(),
57                 powerManagerWakeLockLevel,
58                 tag,
59                 event,
60                 FrameworkStatsLog.WAKELOCK_STATE_CHANGED__PROCESS_STATE__PROCESS_STATE_UNKNOWN);
61     }
62 }
63