class MultiUserUtils {

  public static boolean hasMultipleUsers(@Nullable IDevice device, long timeout, TimeUnit units, boolean defaultValue) {
    if (device == null) {
      return defaultValue;
    }

    if (device.getVersion().getApiLevel() < AndroidVersion.SUPPORTS_MULTI_USER.getApiLevel()) {
      return false;
    }

    PmListUserReceiver receiver = new PmListUserReceiver();
    try {
      device.executeShellCommand("pm list users", receiver, timeout, units);
    }
    catch (Exception e) {
      Logger.getInstance(MultiUserUtils.class).warn("Timed out waiting for output from `pm list users`, returning " + defaultValue);
      return defaultValue;
    }

    return receiver.getNumUsers() > 1;
  }

}