Methods Summary |
---|
UsageEvents.Event | buildEvent(java.lang.String packageName, java.lang.String className)Builds a UsageEvents.Event, but does not add it internally.
UsageEvents.Event event = new UsageEvents.Event();
event.mPackage = getCachedStringRef(packageName);
if (className != null) {
event.mClass = getCachedStringRef(className);
}
return event;
|
private java.lang.String | getCachedStringRef(java.lang.String str)
final int index = mStringCache.indexOf(str);
if (index < 0) {
mStringCache.add(str);
return str;
}
return mStringCache.valueAt(index);
|
android.app.usage.ConfigurationStats | getOrCreateConfigurationStats(android.content.res.Configuration config)Gets the ConfigurationStats object for the given configuration, or creates one and adds it
internally.
ConfigurationStats configStats = configurations.get(config);
if (configStats == null) {
configStats = new ConfigurationStats();
configStats.mBeginTimeStamp = beginTime;
configStats.mEndTimeStamp = endTime;
configStats.mConfiguration = config;
configurations.put(config, configStats);
}
return configStats;
|
android.app.usage.UsageStats | getOrCreateUsageStats(java.lang.String packageName)Gets the UsageStats object for the given package, or creates one and adds it internally.
UsageStats usageStats = packageStats.get(packageName);
if (usageStats == null) {
usageStats = new UsageStats();
usageStats.mPackageName = getCachedStringRef(packageName);
usageStats.mBeginTimeStamp = beginTime;
usageStats.mEndTimeStamp = endTime;
packageStats.put(usageStats.mPackageName, usageStats);
}
return usageStats;
|
void | update(java.lang.String packageName, long timeStamp, int eventType)
UsageStats usageStats = getOrCreateUsageStats(packageName);
// TODO(adamlesinski): Ensure that we recover from incorrect event sequences
// like double MOVE_TO_BACKGROUND, etc.
if (eventType == UsageEvents.Event.MOVE_TO_BACKGROUND ||
eventType == UsageEvents.Event.END_OF_DAY) {
if (usageStats.mLastEvent == UsageEvents.Event.MOVE_TO_FOREGROUND ||
usageStats.mLastEvent == UsageEvents.Event.CONTINUE_PREVIOUS_DAY) {
usageStats.mTotalTimeInForeground += timeStamp - usageStats.mLastTimeUsed;
}
}
usageStats.mLastEvent = eventType;
usageStats.mLastTimeUsed = timeStamp;
usageStats.mEndTimeStamp = timeStamp;
if (eventType == UsageEvents.Event.MOVE_TO_FOREGROUND) {
usageStats.mLaunchCount += 1;
}
endTime = timeStamp;
|
void | updateConfigurationStats(android.content.res.Configuration config, long timeStamp)
if (activeConfiguration != null) {
ConfigurationStats activeStats = configurations.get(activeConfiguration);
activeStats.mTotalTimeActive += timeStamp - activeStats.mLastTimeActive;
activeStats.mLastTimeActive = timeStamp - 1;
}
if (config != null) {
ConfigurationStats configStats = getOrCreateConfigurationStats(config);
configStats.mLastTimeActive = timeStamp;
configStats.mActivationCount += 1;
activeConfiguration = configStats.mConfiguration;
}
endTime = timeStamp;
|