Loading services/tests/servicestests/src/com/android/server/usage/UsageStatsDatabaseTest.java +4 −20 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import static junit.framework.TestCase.fail; import static org.testng.Assert.assertEquals; import android.app.usage.EventList; import android.app.usage.TimeSparseArray; import android.app.usage.UsageEvents.Event; import android.app.usage.UsageStats; Loading Loading @@ -130,10 +129,6 @@ public class UsageStatsDatabaseTest { mIntervalStats.keyguardHiddenTracker.count = 5; mIntervalStats.keyguardHiddenTracker.duration = 4444444; if (mIntervalStats.events == null) { mIntervalStats.events = new EventList(); } for (int i = 0; i < numberOfEvents; i++) { Event event = new Event(); final int packageInt = ((i / 3) % 7); //clusters of 3 events from 7 "apps" Loading Loading @@ -320,22 +315,11 @@ public class UsageStatsDatabaseTest { } } assertEquals(stats1.activeConfiguration, stats2.activeConfiguration); if (stats1.events == null) { // If stats1 events are null, stats2 should be null or empty if (stats2.events != null) { assertEquals(stats2.events.size(), 0); } } else if (stats2.events == null) { // If stats2 events are null, stats1 should be null or empty assertEquals(stats1.events.size(), 0); } else { assertEquals(stats1.events.size(), stats2.events.size()); for (int i = 0; i < stats1.events.size(); i++) { compareUsageEvent(stats1.events.get(i), stats2.events.get(i), i, minVersion); } } } /** * Runs the Write Read test. Loading Loading @@ -421,7 +405,7 @@ public class UsageStatsDatabaseTest { // Clear non backed up data from expected IntervalStats mIntervalStats.activeConfiguration = null; mIntervalStats.configurations.clear(); if (mIntervalStats.events != null) mIntervalStats.events.clear(); mIntervalStats.events.clear(); // The written and read IntervalStats should match compareIntervalStats(mIntervalStats, stats.get(0), version); Loading services/usage/java/com/android/server/usage/UsageStatsDatabase.java +29 −31 Original line number Diff line number Diff line Loading @@ -930,7 +930,6 @@ public class UsageStatsDatabase { } } if (statsOut.events != null) { final int eventSize = statsOut.events.size(); for (int i = 0; i < eventSize; i++) { final UsageEvents.Event event = statsOut.events.get(i); Loading Loading @@ -965,7 +964,6 @@ public class UsageStatsDatabase { } } } } if (failures != 0) { if (failures > failureLogLimit) { Loading Loading @@ -1198,7 +1196,7 @@ public class UsageStatsDatabase { if (stats == null) return; stats.activeConfiguration = null; stats.configurations.clear(); if (stats.events != null) stats.events.clear(); stats.events.clear(); } private byte[] serializeIntervalStats(IntervalStats stats, int version) { Loading services/usage/java/com/android/server/usage/UsageStatsProto.java +2 −10 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.server.usage; import android.app.usage.ConfigurationStats; import android.app.usage.EventList; import android.app.usage.UsageEvents; import android.app.usage.UsageStats; import android.content.res.Configuration; Loading Loading @@ -303,10 +302,6 @@ final class UsageStatsProto { if (event.mPackage == null) { throw new ProtocolException("no package field present"); } if (statsOut.events == null) { statsOut.events = new EventList(); } statsOut.events.insert(event); } Loading Loading @@ -514,10 +509,7 @@ final class UsageStatsProto { statsOut.packageStats.clear(); statsOut.configurations.clear(); statsOut.activeConfiguration = null; if (statsOut.events != null) { statsOut.events.clear(); } while (true) { switch (proto.nextField()) { Loading Loading @@ -607,7 +599,7 @@ final class UsageStatsProto { writeConfigStats(proto, IntervalStatsProto.CONFIGURATIONS, stats, stats.configurations.valueAt(i), active); } final int eventCount = stats.events != null ? stats.events.size() : 0; final int eventCount = stats.events.size(); for (int i = 0; i < eventCount; i++) { writeEvent(proto, IntervalStatsProto.EVENT_LOG, stats, stats.events.get(i)); } Loading services/usage/java/com/android/server/usage/UsageStatsXmlV1.java +2 −5 Original line number Diff line number Diff line Loading @@ -384,10 +384,7 @@ final class UsageStatsXmlV1 { statsOut.packageStats.clear(); statsOut.configurations.clear(); statsOut.activeConfiguration = null; if (statsOut.events != null) { statsOut.events.clear(); } statsOut.endTime = statsOut.beginTime + XmlUtils.readLongAttribute(parser, END_TIME_ATTR); try { Loading Loading @@ -481,7 +478,7 @@ final class UsageStatsXmlV1 { xml.endTag(null, CONFIGURATIONS_TAG); xml.startTag(null, EVENT_LOG_TAG); final int eventCount = stats.events != null ? stats.events.size() : 0; final int eventCount = stats.events.size(); for (int i = 0; i < eventCount; i++) { writeEvent(xml, stats, stats.events.get(i)); } Loading tests/UsageStatsPerfTests/src/com/android/frameworks/perftests/usage/tests/UsageStatsDatabasePerfTest.java +0 −4 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.frameworks.perftests.usage.tests; import static junit.framework.Assert.assertEquals; import android.app.usage.EventList; import android.app.usage.UsageEvents; import android.app.usage.UsageStatsManager; import android.content.Context; Loading Loading @@ -84,9 +83,6 @@ public class UsageStatsDatabasePerfTest { private static void populateIntervalStats(IntervalStats intervalStats, int packageCount, int eventsPerPackage) { if (intervalStats.events == null) { intervalStats.events = new EventList(); } for (int pkg = 0; pkg < packageCount; pkg++) { UsageEvents.Event event = new UsageEvents.Event(); event.mPackage = "fake.package.name" + pkg; Loading Loading
services/tests/servicestests/src/com/android/server/usage/UsageStatsDatabaseTest.java +4 −20 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import static junit.framework.TestCase.fail; import static org.testng.Assert.assertEquals; import android.app.usage.EventList; import android.app.usage.TimeSparseArray; import android.app.usage.UsageEvents.Event; import android.app.usage.UsageStats; Loading Loading @@ -130,10 +129,6 @@ public class UsageStatsDatabaseTest { mIntervalStats.keyguardHiddenTracker.count = 5; mIntervalStats.keyguardHiddenTracker.duration = 4444444; if (mIntervalStats.events == null) { mIntervalStats.events = new EventList(); } for (int i = 0; i < numberOfEvents; i++) { Event event = new Event(); final int packageInt = ((i / 3) % 7); //clusters of 3 events from 7 "apps" Loading Loading @@ -320,22 +315,11 @@ public class UsageStatsDatabaseTest { } } assertEquals(stats1.activeConfiguration, stats2.activeConfiguration); if (stats1.events == null) { // If stats1 events are null, stats2 should be null or empty if (stats2.events != null) { assertEquals(stats2.events.size(), 0); } } else if (stats2.events == null) { // If stats2 events are null, stats1 should be null or empty assertEquals(stats1.events.size(), 0); } else { assertEquals(stats1.events.size(), stats2.events.size()); for (int i = 0; i < stats1.events.size(); i++) { compareUsageEvent(stats1.events.get(i), stats2.events.get(i), i, minVersion); } } } /** * Runs the Write Read test. Loading Loading @@ -421,7 +405,7 @@ public class UsageStatsDatabaseTest { // Clear non backed up data from expected IntervalStats mIntervalStats.activeConfiguration = null; mIntervalStats.configurations.clear(); if (mIntervalStats.events != null) mIntervalStats.events.clear(); mIntervalStats.events.clear(); // The written and read IntervalStats should match compareIntervalStats(mIntervalStats, stats.get(0), version); Loading
services/usage/java/com/android/server/usage/UsageStatsDatabase.java +29 −31 Original line number Diff line number Diff line Loading @@ -930,7 +930,6 @@ public class UsageStatsDatabase { } } if (statsOut.events != null) { final int eventSize = statsOut.events.size(); for (int i = 0; i < eventSize; i++) { final UsageEvents.Event event = statsOut.events.get(i); Loading Loading @@ -965,7 +964,6 @@ public class UsageStatsDatabase { } } } } if (failures != 0) { if (failures > failureLogLimit) { Loading Loading @@ -1198,7 +1196,7 @@ public class UsageStatsDatabase { if (stats == null) return; stats.activeConfiguration = null; stats.configurations.clear(); if (stats.events != null) stats.events.clear(); stats.events.clear(); } private byte[] serializeIntervalStats(IntervalStats stats, int version) { Loading
services/usage/java/com/android/server/usage/UsageStatsProto.java +2 −10 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.server.usage; import android.app.usage.ConfigurationStats; import android.app.usage.EventList; import android.app.usage.UsageEvents; import android.app.usage.UsageStats; import android.content.res.Configuration; Loading Loading @@ -303,10 +302,6 @@ final class UsageStatsProto { if (event.mPackage == null) { throw new ProtocolException("no package field present"); } if (statsOut.events == null) { statsOut.events = new EventList(); } statsOut.events.insert(event); } Loading Loading @@ -514,10 +509,7 @@ final class UsageStatsProto { statsOut.packageStats.clear(); statsOut.configurations.clear(); statsOut.activeConfiguration = null; if (statsOut.events != null) { statsOut.events.clear(); } while (true) { switch (proto.nextField()) { Loading Loading @@ -607,7 +599,7 @@ final class UsageStatsProto { writeConfigStats(proto, IntervalStatsProto.CONFIGURATIONS, stats, stats.configurations.valueAt(i), active); } final int eventCount = stats.events != null ? stats.events.size() : 0; final int eventCount = stats.events.size(); for (int i = 0; i < eventCount; i++) { writeEvent(proto, IntervalStatsProto.EVENT_LOG, stats, stats.events.get(i)); } Loading
services/usage/java/com/android/server/usage/UsageStatsXmlV1.java +2 −5 Original line number Diff line number Diff line Loading @@ -384,10 +384,7 @@ final class UsageStatsXmlV1 { statsOut.packageStats.clear(); statsOut.configurations.clear(); statsOut.activeConfiguration = null; if (statsOut.events != null) { statsOut.events.clear(); } statsOut.endTime = statsOut.beginTime + XmlUtils.readLongAttribute(parser, END_TIME_ATTR); try { Loading Loading @@ -481,7 +478,7 @@ final class UsageStatsXmlV1 { xml.endTag(null, CONFIGURATIONS_TAG); xml.startTag(null, EVENT_LOG_TAG); final int eventCount = stats.events != null ? stats.events.size() : 0; final int eventCount = stats.events.size(); for (int i = 0; i < eventCount; i++) { writeEvent(xml, stats, stats.events.get(i)); } Loading
tests/UsageStatsPerfTests/src/com/android/frameworks/perftests/usage/tests/UsageStatsDatabasePerfTest.java +0 −4 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.frameworks.perftests.usage.tests; import static junit.framework.Assert.assertEquals; import android.app.usage.EventList; import android.app.usage.UsageEvents; import android.app.usage.UsageStatsManager; import android.content.Context; Loading Loading @@ -84,9 +83,6 @@ public class UsageStatsDatabasePerfTest { private static void populateIntervalStats(IntervalStats intervalStats, int packageCount, int eventsPerPackage) { if (intervalStats.events == null) { intervalStats.events = new EventList(); } for (int pkg = 0; pkg < packageCount; pkg++) { UsageEvents.Event event = new UsageEvents.Event(); event.mPackage = "fake.package.name" + pkg; Loading