Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a534368e authored by Stanislav Zholnin's avatar Stanislav Zholnin
Browse files

Use updated DeviceConfig API's new getters to simplify invocations.

Test: manual verification
Change-Id: I213f25c9b16d7988617bcf127461a9097a8e16b3
parent 94904dcb
Loading
Loading
Loading
Loading
+2 −18
Original line number Original line Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.view.contentcapture.ContentCaptureManager.LOGGING_LEVEL_DE
import static android.view.contentcapture.ContentCaptureManager.LOGGING_LEVEL_OFF;
import static android.view.contentcapture.ContentCaptureManager.LOGGING_LEVEL_OFF;
import static android.view.contentcapture.ContentCaptureManager.LOGGING_LEVEL_VERBOSE;
import static android.view.contentcapture.ContentCaptureManager.LOGGING_LEVEL_VERBOSE;


import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.os.Build;
import android.os.Build;
import android.provider.DeviceConfig;
import android.provider.DeviceConfig;
@@ -47,21 +46,6 @@ public final class ContentCaptureHelper {
        return text == null ? null : text.length() + "_chars";
        return text == null ? null : text.length() + "_chars";
    }
    }


    /**
     * Gets the value of a device config property from the Content Capture namespace.
     */
    public static int getIntDeviceConfigProperty(@NonNull String key, int defaultValue) {
        final String value = DeviceConfig.getProperty(DeviceConfig.NAMESPACE_CONTENT_CAPTURE, key);
        if (value == null) return defaultValue;

        try {
            return Integer.parseInt(value);
        } catch (Exception e) {
            Log.w(TAG, "error parsing value (" + value + ") of property " + key + ": " + e);
            return defaultValue;
        }
    }

    /**
    /**
     * Gets the default logging level for the device.
     * Gets the default logging level for the device.
     */
     */
@@ -75,8 +59,8 @@ public final class ContentCaptureHelper {
     */
     */
    public static void setLoggingLevel() {
    public static void setLoggingLevel() {
        final int defaultLevel = getDefaultLoggingLevel();
        final int defaultLevel = getDefaultLoggingLevel();
        final int level = getIntDeviceConfigProperty(DEVICE_CONFIG_PROPERTY_LOGGING_LEVEL,
        final int level = DeviceConfig.getInt(DeviceConfig.NAMESPACE_CONTENT_CAPTURE,
                defaultLevel);
                DEVICE_CONFIG_PROPERTY_LOGGING_LEVEL, defaultLevel);
        setLoggingLevel(level);
        setLoggingLevel(level);
    }
    }


+12 −6
Original line number Original line Diff line number Diff line
@@ -250,18 +250,23 @@ public final class ContentCaptureManagerService extends


    private void setFineTuneParamsFromDeviceConfig() {
    private void setFineTuneParamsFromDeviceConfig() {
        synchronized (mLock) {
        synchronized (mLock) {
            mDevCfgMaxBufferSize = ContentCaptureHelper.getIntDeviceConfigProperty(
            mDevCfgMaxBufferSize = DeviceConfig.getInt(
                    DeviceConfig.NAMESPACE_CONTENT_CAPTURE,
                    ContentCaptureManager.DEVICE_CONFIG_PROPERTY_MAX_BUFFER_SIZE,
                    ContentCaptureManager.DEVICE_CONFIG_PROPERTY_MAX_BUFFER_SIZE,
                    ContentCaptureManager.DEFAULT_MAX_BUFFER_SIZE);
                    ContentCaptureManager.DEFAULT_MAX_BUFFER_SIZE);
            mDevCfgIdleFlushingFrequencyMs = ContentCaptureHelper.getIntDeviceConfigProperty(
            mDevCfgIdleFlushingFrequencyMs = DeviceConfig.getInt(
                    DeviceConfig.NAMESPACE_CONTENT_CAPTURE,
                    ContentCaptureManager.DEVICE_CONFIG_PROPERTY_IDLE_FLUSH_FREQUENCY,
                    ContentCaptureManager.DEVICE_CONFIG_PROPERTY_IDLE_FLUSH_FREQUENCY,
                    ContentCaptureManager.DEFAULT_IDLE_FLUSHING_FREQUENCY_MS);
                    ContentCaptureManager.DEFAULT_IDLE_FLUSHING_FREQUENCY_MS);
            mDevCfgTextChangeFlushingFrequencyMs = ContentCaptureHelper.getIntDeviceConfigProperty(
            mDevCfgTextChangeFlushingFrequencyMs = DeviceConfig.getInt(
                    DeviceConfig.NAMESPACE_CONTENT_CAPTURE,
                    ContentCaptureManager.DEVICE_CONFIG_PROPERTY_TEXT_CHANGE_FLUSH_FREQUENCY,
                    ContentCaptureManager.DEVICE_CONFIG_PROPERTY_TEXT_CHANGE_FLUSH_FREQUENCY,
                    ContentCaptureManager.DEFAULT_TEXT_CHANGE_FLUSHING_FREQUENCY_MS);
                    ContentCaptureManager.DEFAULT_TEXT_CHANGE_FLUSHING_FREQUENCY_MS);
            mDevCfgLogHistorySize = ContentCaptureHelper.getIntDeviceConfigProperty(
            mDevCfgLogHistorySize = DeviceConfig.getInt(
                    DeviceConfig.NAMESPACE_CONTENT_CAPTURE,
                    ContentCaptureManager.DEVICE_CONFIG_PROPERTY_LOG_HISTORY_SIZE, 20);
                    ContentCaptureManager.DEVICE_CONFIG_PROPERTY_LOG_HISTORY_SIZE, 20);
            mDevCfgIdleUnbindTimeoutMs = ContentCaptureHelper.getIntDeviceConfigProperty(
            mDevCfgIdleUnbindTimeoutMs = DeviceConfig.getInt(
                    DeviceConfig.NAMESPACE_CONTENT_CAPTURE,
                    ContentCaptureManager.DEVICE_CONFIG_PROPERTY_IDLE_UNBIND_TIMEOUT,
                    ContentCaptureManager.DEVICE_CONFIG_PROPERTY_IDLE_UNBIND_TIMEOUT,
                    (int) AbstractRemoteService.PERMANENT_BOUND_TIMEOUT_MS);
                    (int) AbstractRemoteService.PERMANENT_BOUND_TIMEOUT_MS);
            if (verbose) {
            if (verbose) {
@@ -276,7 +281,8 @@ public final class ContentCaptureManagerService extends
    }
    }


    private void setLoggingLevelFromDeviceConfig() {
    private void setLoggingLevelFromDeviceConfig() {
        mDevCfgLoggingLevel = ContentCaptureHelper.getIntDeviceConfigProperty(
        mDevCfgLoggingLevel = DeviceConfig.getInt(
                DeviceConfig.NAMESPACE_CONTENT_CAPTURE,
                ContentCaptureManager.DEVICE_CONFIG_PROPERTY_LOGGING_LEVEL,
                ContentCaptureManager.DEVICE_CONFIG_PROPERTY_LOGGING_LEVEL,
                ContentCaptureHelper.getDefaultLoggingLevel());
                ContentCaptureHelper.getDefaultLoggingLevel());
        ContentCaptureHelper.setLoggingLevel(mDevCfgLoggingLevel);
        ContentCaptureHelper.setLoggingLevel(mDevCfgLoggingLevel);