コード例 #1
0
        /// <summary>
        /// Query top 10 frequently used applications during the last 3 days
        /// </summary>
        /// <returns>List of application history information</returns>
        public List <StatsInfoItem> QueryFrequentlyUsedApplications()
        {
            try
            {
                // Create an UsageStatistics instance
                var usageStats = new UsageStatistics(UsageStatistics.SortOrderType.LaunchCountMost);
                // Query top 10 frequently used applications during the last 3 days
                var usageStatsResult = usageStats.Query(DateTime.Now.AddDays(-3), DateTime.Now, 10);

                List <StatsInfoItem> result = new List <StatsInfoItem>();
                foreach (var record in usageStatsResult)
                {
                    var appInfo = new ApplicationInfo(record.AppId);

                    string name = (!appInfo.Label.Equals(string.Empty)) ? appInfo.Label : record.AppId;
                    string info = "LaunchCount: " + record.LaunchCount + "\r\n";
                    info += "LastLaunchTime: " + record.LastLaunchTime + "\r\n";
                    info += "Duration: " + record.Duration + " secs";

                    // Add each record to the result list
                    result.Add(new StatsInfoItem(name, info));

                    appInfo.Dispose();
                }

                return(result);
            }
            catch (Exception e)
            {
                LogImplementation.DLog(e.Message.ToString());
            }

            return(null);
        }
コード例 #2
0
        public void FixtureTearDown()
        {
            _cleanupActions.ForEach(x => x?.Invoke());

            _default2dnPartyAppInfo.Dispose();
            _default3rdPartyAppInfo.Dispose();
        }
コード例 #3
0
        /// <summary>
        /// Query top 10 battery consuming applications since the last time when the device has fully charged
        /// </summary>
        /// <returns>List of application history information</returns>
        public List <StatsInfoItem> QueryBatteryConsumingApplications()
        {
            try
            {
                // Create a BatteryStatistics instance
                var batteryStats = new BatteryStatistics();
                // Query top 10 battery consuming applications since the last time when the device has fully charged
                var batteryStatsResult = batteryStats.Query(BatteryStatistics.GetLastFullyChargedTime(), DateTime.Now, 10);

                List <StatsInfoItem> result = new List <StatsInfoItem>();
                foreach (var record in batteryStatsResult)
                {
                    var appInfo = new ApplicationInfo(record.AppId);

                    string name = (!appInfo.Label.Equals(string.Empty)) ? appInfo.Label : record.AppId;
                    string info = "Consumption: " + record.Consumption + " %";

                    // Add each record to the result list
                    result.Add(new StatsInfoItem(name, info));

                    appInfo.Dispose();
                }

                return(result);
            }
            catch (Exception e)
            {
                LogImplementation.DLog(e.Message.ToString());
            }

            return(null);
        }
コード例 #4
0
        /// <summary>
        /// Query top 5 recently used applications during the last 5 hours
        /// </summary>
        /// <returns>List of application history information</returns>
        public List <StatsInfoItem> QueryRecentlyUsedApplications()
        {
            try
            {
                // Create a UsageStatistics
                var usageStats = new UsageStatistics(UsageStatistics.SortOrderType.LastLaunchTimeNewest);

                // Query top 5 recently used applications during the last 5 hours
                var usageStatsResult = usageStats.Query(DateTime.Now.AddHours(-5), DateTime.Now, 5);

                List <StatsInfoItem> result = new List <StatsInfoItem>();
                foreach (var record in usageStatsResult)
                {
                    var appInfo = new ApplicationInfo(record.AppId);

                    string name = (!appInfo.Label.Equals(string.Empty)) ? appInfo.Label : record.AppId;
                    string info = "LastLaunchTime:\r\n" + record.LastLaunchTime + "\r\n";
                    info += "LaunchCount: " + record.LaunchCount + "\r\n";
                    info += "Duration: " + record.Duration + " secs";

                    // Add each record to the result list
                    result.Add(new StatsInfoItem(name, info));

                    appInfo.Dispose();
                }

                return(result);
            }
            catch (Exception e)
            {
                log.Log(e.Message.ToString());
            }

            return(null);
        }
コード例 #5
0
 public void FixtureTearDown()
 {
     _default2dnPartyReadAppInfo.Dispose();
     _default2dnPartyWriteAppInfo.Dispose();
     _default3rdPartyReadAppInfo.Dispose();
     _default3rdPartyWriteAppInfo.Dispose();
     //appInfo.Dispose();
 }
コード例 #6
0
        /// <summary>
        /// To get the application icon path
        /// </summary>
        /// <param name="id">An application ID</param>
        /// <returns>The application icon path</returns>
        public string GetApplicationIconPath(string id)
        {
            var    info     = new ApplicationInfo(id);
            string iconPath = info.IconPath;

            info.Dispose();
            return(iconPath);
        }
コード例 #7
0
 public void FixtureTearDown()
 {
     _default2dnPartyAppInfo.Dispose();
     _default3rdPartyAppInfo.Dispose();
 }
コード例 #8
0
 public override void TearDown()
 {
     base.TearDown();
     Log.Info("Destroying the test of Oauth!");
     appInfo.Dispose();
 }