Exemplo n.º 1
0
        /// <summary>
        /// Gets the battery level.
        /// </summary>
        /// <param name="freshness">The freshness.</param>
        /// <returns></returns>
        public BatteryInfo GetBatteryInfo(long freshness)
        {
            if (this.lastBatteryInfo != null &&
                this.lastBatteryCheckTime > DateTime.Now.AddMilliseconds(-freshness))
            {
                return(this.lastBatteryInfo);
            }

            var receiver = new BatteryReceiver();

            this.ExecuteShellCommand("dumpsys battery", receiver, BATTERY_TIMEOUT);
            this.lastBatteryInfo      = receiver.BatteryInfo;
            this.lastBatteryCheckTime = DateTime.Now;
            return(this.lastBatteryInfo);
        }
Exemplo n.º 2
0
Arquivo: Device.cs Projeto: vebin/madb
        /// <summary>
        /// Gets the battery level.
        /// </summary>
        /// <param name="freshness">The freshness.</param>
        /// <returns></returns>
        public BatteryInfo GetBatteryInfo(long freshness)
        {
            if (this.lastBatteryInfo != null
                                && this.lastBatteryCheckTime > DateTime.Now.AddMilliseconds(-freshness))
            {
                return this.lastBatteryInfo;
            }

            var receiver = new BatteryReceiver();
            this.ExecuteShellCommand("dumpsys battery", receiver, BATTERY_TIMEOUT);
            this.lastBatteryInfo = receiver.BatteryInfo;
            this.lastBatteryCheckTime = DateTime.Now;
            return this.lastBatteryInfo;
        }