Пример #1
0
        private static double GetPowerUsage(IntPtr dataHandle, PowerUsageResourceType rtype)
        {
            double          batteryUsage = 0;
            PowerUsageError ret          = (PowerUsageError)Interop.PowerUsage.UsageDataGetPowerUsagePerResource(dataHandle, rtype, out batteryUsage);

            if (ret != PowerUsageError.None)
            {
                Log.Error(PowerUsageErrorFactory.LogTag, "Error getting battery usage for resource" + ret);
                throw PowerUsageErrorFactory.ThrowPowerUsageException(ret);
            }
            return(batteryUsage);
        }
Пример #2
0
        /// <summary>
        /// Gets the battery usage in mAh(milli-Ampere hour) by a resource for certain time interval.
        /// </summary>
        /// <since_tizen> 7 </since_tizen>
        /// <param name="rtype">Identifier of resource type. BLE, WiFi, CPU etc.</param>
        /// <param name="start">Start Time for data in DateTime.</param>
        /// <param name="end">End Time for data in DateTime.</param>
        /// <returns>Returns the battery usage in mAh(milli-Ampere hour) by a resource for certain time interval.</returns>
        /// <feature>http://tizen.org/feature/battery</feature>
        /// <privilege>http://tizen.org/privilege/systemmonitor</privilege>
        /// <exception cref="ArgumentException">When an invalid parameter value is set.</exception>
        /// <exception cref="UnauthorizedAccessException">If the privilege is not set.</exception>
        /// <exception cref="InvalidOperationException">In case of any system error.</exception>
        /// <exception cref="NotSupportedException">In case power usage is not supported</exception>
        public static double GetPowerUsage(PowerUsageResourceType rtype, DateTime start, DateTime end)
        {
            double          batteryUsage = 0;
            PowerUsageError ret          = (PowerUsageError)Interop.PowerUsage.GetPowerUsageByResource(rtype, Convert.ToInt32(((DateTimeOffset)start).ToUnixTimeSeconds()), Convert.ToInt32(((DateTimeOffset)end).ToUnixTimeSeconds()), out batteryUsage);

            if (ret != PowerUsageError.None)
            {
                if (ret == PowerUsageError.RecordNotFound)
                {
                    Log.Error(PowerUsageErrorFactory.LogTag, "Error PowerUsageResourceType is not supported");
                    throw new ArgumentException($"{rtype} is not supproted", nameof(rtype));
                }
                else
                {
                    Log.Error(PowerUsageErrorFactory.LogTag, "Error getting battery usage by resource ," + ret);
                    throw PowerUsageErrorFactory.ThrowPowerUsageException(ret);
                }
            }
            return(batteryUsage);
        }
Пример #3
0
 internal static extern int GetPowerUsageByAppPerResource(string appID, PowerUsageResourceType rtype, int startTime, int endTime, out double batteryUsage);
Пример #4
0
 internal static extern int GetPowerUsageByResource(PowerUsageResourceType rtype, int startTime, int endTime, out double batteryUsage);
Пример #5
0
 internal static extern int UsageDataGetPowerUsagePerResource(IntPtr dataHandle, PowerUsageResourceType rtype, out double batteryUsage);