Loading Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -254,6 +254,7 @@ java_defaults { ":statsd_aidl", "core/java/android/os/ISystemUpdateManager.aidl", "core/java/android/os/IThermalEventListener.aidl", "core/java/android/os/IThermalStatusListener.aidl", "core/java/android/os/IThermalService.aidl", "core/java/android/os/IUpdateLock.aidl", "core/java/android/os/IUserManager.aidl", Loading core/java/android/os/IThermalService.aidl +34 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.os; import android.os.IThermalEventListener; import android.os.IThermalStatusListener; import android.os.Temperature; import java.util.List; Loading @@ -30,31 +31,60 @@ interface IThermalService { * @param listener the IThermalEventListener to be notified. * {@hide} */ void registerThermalEventListener(in IThermalEventListener listener); boolean registerThermalEventListener(in IThermalEventListener listener); /** * Register a listener for thermal events on given temperature type. * @param listener the IThermalEventListener to be notified. * @param type the temperature type IThermalEventListener to be notified. * @return true if registered successfully. * {@hide} */ void registerThermalEventListenerWithType(in IThermalEventListener listener, in int type); boolean registerThermalEventListenerWithType(in IThermalEventListener listener, in int type); /** * Unregister a previously-registered listener for thermal events. * @param listener the IThermalEventListener to no longer be notified. * @return true if unregistered successfully. * {@hide} */ void unregisterThermalEventListener(in IThermalEventListener listener); boolean unregisterThermalEventListener(in IThermalEventListener listener); /** * Get current temperature with its throttling status. * @return list of android.os.Temperature * {@hide} */ List<Temperature> getCurrentTemperatures(); /** * Get current temperature with its throttling status on given temperature type. * @param type the temperature type to query. * @return list of android.os.Temperature * @return list of {@link android.os.Temperature}. * {@hide} */ List<Temperature> getCurrentTemperaturesWithType(in int type); /** * Register a listener for thermal status change. * @param listener the IThermalStatusListener to be notified. * @return true if registered successfully. * {@hide} */ boolean registerThermalStatusListener(in IThermalStatusListener listener); /** * Unregister a previously-registered listener for thermal status. * @param listener the IThermalStatusListener to no longer be notified. * @return true if unregistered successfully. * {@hide} */ boolean unregisterThermalStatusListener(in IThermalStatusListener listener); /** * Get current thermal status. * @return status defined in {@link android.os.Temperature}. * {@hide} */ int getCurrentStatus(); } core/java/android/os/IThermalStatusListener.aidl 0 → 100644 +29 −0 Original line number Diff line number Diff line /* ** Copyright 2018, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ package android.os; /** * Listener for thermal status. * {@hide} */ oneway interface IThermalStatusListener { /** * Called when overall thermal throttling status changed. * @param status defined in {@link android.os.Temperature#ThrottlingStatus}. */ void onStatusChange(int status); } core/java/android/os/Temperature.java +13 −8 Original line number Diff line number Diff line Loading @@ -25,9 +25,7 @@ import java.lang.annotation.RetentionPolicy; /** * Temperature values used by IThermalService. */ /** * * @hide */ public class Temperature implements Parcelable { Loading @@ -40,7 +38,6 @@ public class Temperature implements Parcelable { /** The level of the sensor is currently in throttling */ private int mStatus; /** @hide */ @IntDef(prefix = { "THROTTLING_" }, value = { THROTTLING_NONE, THROTTLING_LIGHT, Loading @@ -62,7 +59,6 @@ public class Temperature implements Parcelable { public static final int THROTTLING_WARNING = ThrottlingSeverity.WARNING; public static final int THROTTLING_SHUTDOWN = ThrottlingSeverity.SHUTDOWN; /** @hide */ @IntDef(prefix = { "TYPE_" }, value = { TYPE_UNKNOWN, TYPE_CPU, Loading Loading @@ -95,19 +91,28 @@ public class Temperature implements Parcelable { * * @return true if a temperature type is valid otherwise false. */ public static boolean isValidType(int type) { public static boolean isValidType(@Type int type) { return type >= TYPE_UNKNOWN && type <= TYPE_BCL_PERCENTAGE; } /** * Verify a valid throttling status. * * @return true if a status is valid otherwise false. */ public static boolean isValidStatus(@ThrottlingStatus int status) { return status >= THROTTLING_NONE && status <= THROTTLING_SHUTDOWN; } public Temperature() { this(Float.NaN, TYPE_UNKNOWN, "", THROTTLING_NONE); } public Temperature(float value, @Type int type, String name, int status) { public Temperature(float value, @Type int type, String name, @ThrottlingStatus int status) { mValue = value; mType = isValidType(type) ? type : TYPE_UNKNOWN; mName = name; mStatus = status; mStatus = isValidStatus(status) ? status : THROTTLING_NONE; } /** Loading services/core/java/com/android/server/power/ThermalManagerService.java +505 −227 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -254,6 +254,7 @@ java_defaults { ":statsd_aidl", "core/java/android/os/ISystemUpdateManager.aidl", "core/java/android/os/IThermalEventListener.aidl", "core/java/android/os/IThermalStatusListener.aidl", "core/java/android/os/IThermalService.aidl", "core/java/android/os/IUpdateLock.aidl", "core/java/android/os/IUserManager.aidl", Loading
core/java/android/os/IThermalService.aidl +34 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.os; import android.os.IThermalEventListener; import android.os.IThermalStatusListener; import android.os.Temperature; import java.util.List; Loading @@ -30,31 +31,60 @@ interface IThermalService { * @param listener the IThermalEventListener to be notified. * {@hide} */ void registerThermalEventListener(in IThermalEventListener listener); boolean registerThermalEventListener(in IThermalEventListener listener); /** * Register a listener for thermal events on given temperature type. * @param listener the IThermalEventListener to be notified. * @param type the temperature type IThermalEventListener to be notified. * @return true if registered successfully. * {@hide} */ void registerThermalEventListenerWithType(in IThermalEventListener listener, in int type); boolean registerThermalEventListenerWithType(in IThermalEventListener listener, in int type); /** * Unregister a previously-registered listener for thermal events. * @param listener the IThermalEventListener to no longer be notified. * @return true if unregistered successfully. * {@hide} */ void unregisterThermalEventListener(in IThermalEventListener listener); boolean unregisterThermalEventListener(in IThermalEventListener listener); /** * Get current temperature with its throttling status. * @return list of android.os.Temperature * {@hide} */ List<Temperature> getCurrentTemperatures(); /** * Get current temperature with its throttling status on given temperature type. * @param type the temperature type to query. * @return list of android.os.Temperature * @return list of {@link android.os.Temperature}. * {@hide} */ List<Temperature> getCurrentTemperaturesWithType(in int type); /** * Register a listener for thermal status change. * @param listener the IThermalStatusListener to be notified. * @return true if registered successfully. * {@hide} */ boolean registerThermalStatusListener(in IThermalStatusListener listener); /** * Unregister a previously-registered listener for thermal status. * @param listener the IThermalStatusListener to no longer be notified. * @return true if unregistered successfully. * {@hide} */ boolean unregisterThermalStatusListener(in IThermalStatusListener listener); /** * Get current thermal status. * @return status defined in {@link android.os.Temperature}. * {@hide} */ int getCurrentStatus(); }
core/java/android/os/IThermalStatusListener.aidl 0 → 100644 +29 −0 Original line number Diff line number Diff line /* ** Copyright 2018, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ package android.os; /** * Listener for thermal status. * {@hide} */ oneway interface IThermalStatusListener { /** * Called when overall thermal throttling status changed. * @param status defined in {@link android.os.Temperature#ThrottlingStatus}. */ void onStatusChange(int status); }
core/java/android/os/Temperature.java +13 −8 Original line number Diff line number Diff line Loading @@ -25,9 +25,7 @@ import java.lang.annotation.RetentionPolicy; /** * Temperature values used by IThermalService. */ /** * * @hide */ public class Temperature implements Parcelable { Loading @@ -40,7 +38,6 @@ public class Temperature implements Parcelable { /** The level of the sensor is currently in throttling */ private int mStatus; /** @hide */ @IntDef(prefix = { "THROTTLING_" }, value = { THROTTLING_NONE, THROTTLING_LIGHT, Loading @@ -62,7 +59,6 @@ public class Temperature implements Parcelable { public static final int THROTTLING_WARNING = ThrottlingSeverity.WARNING; public static final int THROTTLING_SHUTDOWN = ThrottlingSeverity.SHUTDOWN; /** @hide */ @IntDef(prefix = { "TYPE_" }, value = { TYPE_UNKNOWN, TYPE_CPU, Loading Loading @@ -95,19 +91,28 @@ public class Temperature implements Parcelable { * * @return true if a temperature type is valid otherwise false. */ public static boolean isValidType(int type) { public static boolean isValidType(@Type int type) { return type >= TYPE_UNKNOWN && type <= TYPE_BCL_PERCENTAGE; } /** * Verify a valid throttling status. * * @return true if a status is valid otherwise false. */ public static boolean isValidStatus(@ThrottlingStatus int status) { return status >= THROTTLING_NONE && status <= THROTTLING_SHUTDOWN; } public Temperature() { this(Float.NaN, TYPE_UNKNOWN, "", THROTTLING_NONE); } public Temperature(float value, @Type int type, String name, int status) { public Temperature(float value, @Type int type, String name, @ThrottlingStatus int status) { mValue = value; mType = isValidType(type) ? type : TYPE_UNKNOWN; mName = name; mStatus = status; mStatus = isValidStatus(status) ? status : THROTTLING_NONE; } /** Loading
services/core/java/com/android/server/power/ThermalManagerService.java +505 −227 File changed.Preview size limit exceeded, changes collapsed. Show changes