summaryrefslogtreecommitdiffstats
path: root/services/usage
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2015-04-30 17:32:25 -0700
committerAmith Yamasani <yamasani@google.com>2015-05-01 11:17:27 -0700
commite4a8da8ea241858b52d8122480316db79582c44d (patch)
tree4bb2aaa2e55c435a2c60426466683835dcfad9f8 /services/usage
parent403ac2d64f7ad53ecf9ccd713951cf151ea2f2bc (diff)
downloadframeworks_base-e4a8da8ea241858b52d8122480316db79582c44d.zip
frameworks_base-e4a8da8ea241858b52d8122480316db79582c44d.tar.gz
frameworks_base-e4a8da8ea241858b52d8122480316db79582c44d.tar.bz2
Exclude bound app widgets from idle app list
Track package names of bound app widgets and use the list when querying for idle apps. Bug: 20066058 Change-Id: If8039397a061ef04bb13aa38d57cd7f0221f5fc7
Diffstat (limited to 'services/usage')
-rw-r--r--services/usage/java/com/android/server/usage/UsageStatsService.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java
index c2e61c6..117cbe4 100644
--- a/services/usage/java/com/android/server/usage/UsageStatsService.java
+++ b/services/usage/java/com/android/server/usage/UsageStatsService.java
@@ -28,6 +28,7 @@ import android.app.usage.UsageEvents.Event;
import android.app.usage.UsageStats;
import android.app.usage.UsageStatsManagerInternal;
import android.app.usage.UsageStatsManagerInternal.AppIdleStateChangeListener;
+import android.appwidget.AppWidgetManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -56,6 +57,7 @@ import android.util.ArraySet;
import android.util.Slog;
import android.util.SparseArray;
+import com.android.internal.appwidget.IAppWidgetService;
import com.android.internal.os.BackgroundThread;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.SystemConfig;
@@ -96,6 +98,7 @@ public class UsageStatsService extends SystemService implements
Handler mHandler;
AppOpsManager mAppOps;
UserManager mUserManager;
+ AppWidgetManager mAppWidgetManager;
private final SparseArray<UserUsageStatsService> mUserState = new SparseArray<>();
private File mUsageStatsDir;
@@ -158,6 +161,7 @@ public class UsageStatsService extends SystemService implements
if (phase == PHASE_SYSTEM_SERVICES_READY) {
// Observe changes to the threshold
new SettingsObserver(mHandler).registerObserver();
+ mAppWidgetManager = getContext().getSystemService(AppWidgetManager.class);
} else if (phase == PHASE_BOOT_COMPLETED) {
setAppIdleParoled(getContext().getSystemService(BatteryManager.class).isCharging());
}
@@ -500,6 +504,11 @@ public class UsageStatsService extends SystemService implements
return false;
}
+ if (mAppWidgetManager != null
+ && mAppWidgetManager.isBoundWidgetPackage(packageName, userId)) {
+ return false;
+ }
+
final long lastUsed = getLastPackageAccessTime(packageName, userId);
return hasPassedIdleDuration(lastUsed);
}