Search in sources :

Example 1 with KeyValueListParser

use of android.util.KeyValueListParser in project android_frameworks_base by ResurrectionRemix.

the class ShortcutService method updateConfigurationLocked.

/**
     * Load the configuration from Settings.
     */
@VisibleForTesting
boolean updateConfigurationLocked(String config) {
    boolean result = true;
    final KeyValueListParser parser = new KeyValueListParser(',');
    try {
        parser.setString(config);
    } catch (IllegalArgumentException e) {
        // Failed to parse the settings string, log this and move on
        // with defaults.
        Slog.e(TAG, "Bad shortcut manager settings", e);
        result = false;
    }
    mSaveDelayMillis = Math.max(0, (int) parser.getLong(ConfigConstants.KEY_SAVE_DELAY_MILLIS, DEFAULT_SAVE_DELAY_MS));
    mResetInterval = Math.max(1, parser.getLong(ConfigConstants.KEY_RESET_INTERVAL_SEC, DEFAULT_RESET_INTERVAL_SEC) * 1000L);
    mMaxUpdatesPerInterval = Math.max(0, (int) parser.getLong(ConfigConstants.KEY_MAX_UPDATES_PER_INTERVAL, DEFAULT_MAX_UPDATES_PER_INTERVAL));
    mMaxShortcuts = Math.max(0, (int) parser.getLong(ConfigConstants.KEY_MAX_SHORTCUTS, DEFAULT_MAX_SHORTCUTS_PER_APP));
    final int iconDimensionDp = Math.max(1, injectIsLowRamDevice() ? (int) parser.getLong(ConfigConstants.KEY_MAX_ICON_DIMENSION_DP_LOWRAM, DEFAULT_MAX_ICON_DIMENSION_LOWRAM_DP) : (int) parser.getLong(ConfigConstants.KEY_MAX_ICON_DIMENSION_DP, DEFAULT_MAX_ICON_DIMENSION_DP));
    mMaxIconDimension = injectDipToPixel(iconDimensionDp);
    mIconPersistFormat = CompressFormat.valueOf(parser.getString(ConfigConstants.KEY_ICON_FORMAT, DEFAULT_ICON_PERSIST_FORMAT));
    mIconPersistQuality = (int) parser.getLong(ConfigConstants.KEY_ICON_QUALITY, DEFAULT_ICON_PERSIST_QUALITY);
    return result;
}
Also used : KeyValueListParser(android.util.KeyValueListParser) VisibleForTesting(com.android.internal.annotations.VisibleForTesting)

Example 2 with KeyValueListParser

use of android.util.KeyValueListParser in project android_frameworks_base by crdroidandroid.

the class ShortcutService method updateConfigurationLocked.

/**
     * Load the configuration from Settings.
     */
@VisibleForTesting
boolean updateConfigurationLocked(String config) {
    boolean result = true;
    final KeyValueListParser parser = new KeyValueListParser(',');
    try {
        parser.setString(config);
    } catch (IllegalArgumentException e) {
        // Failed to parse the settings string, log this and move on
        // with defaults.
        Slog.e(TAG, "Bad shortcut manager settings", e);
        result = false;
    }
    mSaveDelayMillis = Math.max(0, (int) parser.getLong(ConfigConstants.KEY_SAVE_DELAY_MILLIS, DEFAULT_SAVE_DELAY_MS));
    mResetInterval = Math.max(1, parser.getLong(ConfigConstants.KEY_RESET_INTERVAL_SEC, DEFAULT_RESET_INTERVAL_SEC) * 1000L);
    mMaxUpdatesPerInterval = Math.max(0, (int) parser.getLong(ConfigConstants.KEY_MAX_UPDATES_PER_INTERVAL, DEFAULT_MAX_UPDATES_PER_INTERVAL));
    mMaxShortcuts = Math.max(0, (int) parser.getLong(ConfigConstants.KEY_MAX_SHORTCUTS, DEFAULT_MAX_SHORTCUTS_PER_APP));
    final int iconDimensionDp = Math.max(1, injectIsLowRamDevice() ? (int) parser.getLong(ConfigConstants.KEY_MAX_ICON_DIMENSION_DP_LOWRAM, DEFAULT_MAX_ICON_DIMENSION_LOWRAM_DP) : (int) parser.getLong(ConfigConstants.KEY_MAX_ICON_DIMENSION_DP, DEFAULT_MAX_ICON_DIMENSION_DP));
    mMaxIconDimension = injectDipToPixel(iconDimensionDp);
    mIconPersistFormat = CompressFormat.valueOf(parser.getString(ConfigConstants.KEY_ICON_FORMAT, DEFAULT_ICON_PERSIST_FORMAT));
    mIconPersistQuality = (int) parser.getLong(ConfigConstants.KEY_ICON_QUALITY, DEFAULT_ICON_PERSIST_QUALITY);
    return result;
}
Also used : KeyValueListParser(android.util.KeyValueListParser) VisibleForTesting(com.android.internal.annotations.VisibleForTesting)

Example 3 with KeyValueListParser

use of android.util.KeyValueListParser in project platform_frameworks_base by android.

the class ShortcutService method updateConfigurationLocked.

/**
     * Load the configuration from Settings.
     */
@VisibleForTesting
boolean updateConfigurationLocked(String config) {
    boolean result = true;
    final KeyValueListParser parser = new KeyValueListParser(',');
    try {
        parser.setString(config);
    } catch (IllegalArgumentException e) {
        // Failed to parse the settings string, log this and move on
        // with defaults.
        Slog.e(TAG, "Bad shortcut manager settings", e);
        result = false;
    }
    mSaveDelayMillis = Math.max(0, (int) parser.getLong(ConfigConstants.KEY_SAVE_DELAY_MILLIS, DEFAULT_SAVE_DELAY_MS));
    mResetInterval = Math.max(1, parser.getLong(ConfigConstants.KEY_RESET_INTERVAL_SEC, DEFAULT_RESET_INTERVAL_SEC) * 1000L);
    mMaxUpdatesPerInterval = Math.max(0, (int) parser.getLong(ConfigConstants.KEY_MAX_UPDATES_PER_INTERVAL, DEFAULT_MAX_UPDATES_PER_INTERVAL));
    mMaxShortcuts = Math.max(0, (int) parser.getLong(ConfigConstants.KEY_MAX_SHORTCUTS, DEFAULT_MAX_SHORTCUTS_PER_APP));
    final int iconDimensionDp = Math.max(1, injectIsLowRamDevice() ? (int) parser.getLong(ConfigConstants.KEY_MAX_ICON_DIMENSION_DP_LOWRAM, DEFAULT_MAX_ICON_DIMENSION_LOWRAM_DP) : (int) parser.getLong(ConfigConstants.KEY_MAX_ICON_DIMENSION_DP, DEFAULT_MAX_ICON_DIMENSION_DP));
    mMaxIconDimension = injectDipToPixel(iconDimensionDp);
    mIconPersistFormat = CompressFormat.valueOf(parser.getString(ConfigConstants.KEY_ICON_FORMAT, DEFAULT_ICON_PERSIST_FORMAT));
    mIconPersistQuality = (int) parser.getLong(ConfigConstants.KEY_ICON_QUALITY, DEFAULT_ICON_PERSIST_QUALITY);
    return result;
}
Also used : KeyValueListParser(android.util.KeyValueListParser) VisibleForTesting(com.android.internal.annotations.VisibleForTesting)

Example 4 with KeyValueListParser

use of android.util.KeyValueListParser in project android_frameworks_base by DirtyUnicorns.

the class ShortcutService method updateConfigurationLocked.

/**
     * Load the configuration from Settings.
     */
@VisibleForTesting
boolean updateConfigurationLocked(String config) {
    boolean result = true;
    final KeyValueListParser parser = new KeyValueListParser(',');
    try {
        parser.setString(config);
    } catch (IllegalArgumentException e) {
        // Failed to parse the settings string, log this and move on
        // with defaults.
        Slog.e(TAG, "Bad shortcut manager settings", e);
        result = false;
    }
    mSaveDelayMillis = Math.max(0, (int) parser.getLong(ConfigConstants.KEY_SAVE_DELAY_MILLIS, DEFAULT_SAVE_DELAY_MS));
    mResetInterval = Math.max(1, parser.getLong(ConfigConstants.KEY_RESET_INTERVAL_SEC, DEFAULT_RESET_INTERVAL_SEC) * 1000L);
    mMaxUpdatesPerInterval = Math.max(0, (int) parser.getLong(ConfigConstants.KEY_MAX_UPDATES_PER_INTERVAL, DEFAULT_MAX_UPDATES_PER_INTERVAL));
    mMaxShortcuts = Math.max(0, (int) parser.getLong(ConfigConstants.KEY_MAX_SHORTCUTS, DEFAULT_MAX_SHORTCUTS_PER_APP));
    final int iconDimensionDp = Math.max(1, injectIsLowRamDevice() ? (int) parser.getLong(ConfigConstants.KEY_MAX_ICON_DIMENSION_DP_LOWRAM, DEFAULT_MAX_ICON_DIMENSION_LOWRAM_DP) : (int) parser.getLong(ConfigConstants.KEY_MAX_ICON_DIMENSION_DP, DEFAULT_MAX_ICON_DIMENSION_DP));
    mMaxIconDimension = injectDipToPixel(iconDimensionDp);
    mIconPersistFormat = CompressFormat.valueOf(parser.getString(ConfigConstants.KEY_ICON_FORMAT, DEFAULT_ICON_PERSIST_FORMAT));
    mIconPersistQuality = (int) parser.getLong(ConfigConstants.KEY_ICON_QUALITY, DEFAULT_ICON_PERSIST_QUALITY);
    return result;
}
Also used : KeyValueListParser(android.util.KeyValueListParser) VisibleForTesting(com.android.internal.annotations.VisibleForTesting)

Aggregations

KeyValueListParser (android.util.KeyValueListParser)4 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)4