1 /*
2  * Copyright (C) 2018 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.compatibility.common.util;
18 
19 import android.util.Log;
20 
21 /**
22  * Device-side utility class for override/reset thermal status.
23  */
24 public final class ThermalUtils {
25     private static final String TAG = "CtsThermalUtils";
26 
ThermalUtils()27     private ThermalUtils() {}
28 
29     /** Make the target device think it's not throttling. */
overrideThermalNotThrottling()30     public static void overrideThermalNotThrottling() throws Exception {
31         overrideThermalStatus(0);
32     }
33 
34     /**
35      * Make the target device think it's in given throttling status.
36      * @param status thermal status defined in android.os.Temperature
37      */
overrideThermalStatus(int status)38     public static void overrideThermalStatus(int status) throws Exception {
39         SystemUtil.runShellCommandForNoOutput("cmd thermalservice override-status " + status);
40 
41         Log.d(TAG, "override-status " + status);
42     }
43 
44     /** Cancel the thermal override status on target device. */
resetThermalStatus()45     public static void resetThermalStatus() throws Exception {
46         SystemUtil.runShellCommandForNoOutput("cmd thermalservice reset");
47 
48         Log.d(TAG, "reset");
49     }
50 }
51