2021-04-09 07:34:35 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
namespace osu.Game.Utils
|
|
|
|
{
|
2021-04-10 05:55:41 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Provides access to the system's power status.
|
|
|
|
/// Currently implemented on iOS and Android only.
|
|
|
|
/// </summary>
|
2021-04-09 07:34:35 +08:00
|
|
|
public abstract class PowerStatus
|
|
|
|
{
|
|
|
|
/// <summary>
|
2021-04-10 05:55:41 +08:00
|
|
|
/// The maximum battery level considered as low, from 0 to 1.
|
2021-04-09 07:34:35 +08:00
|
|
|
/// </summary>
|
2021-04-11 14:11:28 +08:00
|
|
|
public abstract double BatteryCutoff { get; }
|
2021-04-09 08:28:23 +08:00
|
|
|
|
2021-04-10 05:55:41 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The charge level of the battery, from 0 to 1.
|
|
|
|
/// </summary>
|
2021-04-11 14:11:28 +08:00
|
|
|
public abstract double ChargeLevel { get; }
|
2021-04-09 07:34:35 +08:00
|
|
|
|
2021-04-11 14:11:28 +08:00
|
|
|
public abstract bool IsCharging { get; }
|
2021-04-10 05:55:41 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2021-04-11 14:02:32 +08:00
|
|
|
/// Whether the battery is currently low in charge.
|
|
|
|
/// Returns true if not charging and current charge level is lower than or equal to <see cref="BatteryCutoff"/>.
|
2021-04-10 05:55:41 +08:00
|
|
|
/// </summary>
|
|
|
|
public bool IsLowBattery => !IsCharging && ChargeLevel <= BatteryCutoff;
|
2021-04-09 07:34:35 +08:00
|
|
|
}
|
|
|
|
}
|