1 /* 2 * Copyright (C) 2020 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.powerstats; 18 19 import android.content.Context; 20 import android.os.Message; 21 22 /** 23 * PowerStatsLogTrigger is the base class for other trigger classes. 24 * It provides the logPowerStatsData() function which sends a message 25 * to the PowerStatsLogger to read the rail energy data and log it to 26 * on-device storage. This class is abstract and cannot be instantiated. 27 */ 28 public abstract class PowerStatsLogTrigger { 29 private static final String TAG = PowerStatsLogTrigger.class.getSimpleName(); 30 31 protected Context mContext; 32 private PowerStatsLogger mPowerStatsLogger; 33 logPowerStatsData(int msgType)34 protected void logPowerStatsData(int msgType) { 35 Message.obtain(mPowerStatsLogger, msgType).sendToTarget(); 36 } 37 PowerStatsLogTrigger(Context context, PowerStatsLogger powerStatsLogger)38 public PowerStatsLogTrigger(Context context, PowerStatsLogger powerStatsLogger) { 39 mContext = context; 40 mPowerStatsLogger = powerStatsLogger; 41 } 42 } 43