/**
   * Checks if an app has been idle for a while and filters out apps that are excluded. It returns
   * false if the current system state allows all apps to be considered active. This happens if the
   * device is plugged in or temporarily allowed to make exceptions. Called by interface impls.
   */
  boolean isAppIdleFiltered(String packageName, int userId) {
    if (packageName == null) return false;
    synchronized (mLock) {
      // Temporary exemption, probably due to device charging or occasional allowance to
      // be allowed to sync, etc.
      if (mAppIdleParoled) {
        return false;
      }
    }
    if (packageName.equals("android")) return false;
    try {
      if (mDeviceIdleController.isPowerSaveWhitelistApp(packageName)) {
        return false;
      }
    } catch (RemoteException re) {
    }
    // TODO: Optimize this check
    if (isActiveDeviceAdmin(packageName, userId)) {
      return false;
    }

    if (mAppWidgetManager != null && mAppWidgetManager.isBoundWidgetPackage(packageName, userId)) {
      return false;
    }

    return isAppIdleUnfiltered(packageName, userId);
  }