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

Commit 5daa6d5c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Added a DeviceConfig property for Content Capture idle timeout to...

Merge "Added a DeviceConfig property for Content Capture idle timeout to unbind from system server."
parents c29cb878 e764fa28
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -129,6 +129,14 @@ public final class ContentCaptureManager {
    @TestApi
    public static final String DEVICE_CONFIG_PROPERTY_LOGGING_LEVEL = "logging_level";

    /**
     * Sets how long (in ms) the service is bound while idle.
     *
     * <p>Use {@code 0} to keep it permanently bound.
     *
     * @hide
     */
    public static final String DEVICE_CONFIG_PROPERTY_IDLE_UNBIND_TIMEOUT = "idle_unbind_timeout";

    /** @hide */
    @TestApi
+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
    private static final int MSG_BIND = 1;
    private static final int MSG_UNBIND = 2;

    protected static final long PERMANENT_BOUND_TIMEOUT_MS = 0;
    public static final long PERMANENT_BOUND_TIMEOUT_MS = 0;

    protected static final int LAST_PRIVATE_MSG = MSG_UNBIND;

+15 −6
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import android.view.contentcapture.IContentCaptureManager;
import android.view.contentcapture.UserDataRemovalRequest;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.infra.AbstractRemoteService;
import com.android.internal.os.IResultReceiver;
import com.android.internal.util.DumpUtils;
import com.android.internal.util.Preconditions;
@@ -103,11 +104,12 @@ public final class ContentCaptureManagerService extends
    private boolean mDisabledByDeviceConfig;

    // Device-config settings that are cached and passed back to apps
    public int mDevCfgLoggingLevel;
    public int mDevCfgMaxBufferSize;
    public int mDevCfgIdleFlushingFrequencyMs;
    public int mDevCfgTextChangeFlushingFrequencyMs;
    public int mDevCfgLogHistorySize;
    int mDevCfgLoggingLevel;
    int mDevCfgMaxBufferSize;
    int mDevCfgIdleFlushingFrequencyMs;
    int mDevCfgTextChangeFlushingFrequencyMs;
    int mDevCfgLogHistorySize;
    int mDevCfgIdleUnbindTimeoutMs;

    public ContentCaptureManagerService(@NonNull Context context) {
        super(context, new FrameworkResourcesServiceNameResolver(context,
@@ -238,6 +240,7 @@ public final class ContentCaptureManagerService extends
            case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_IDLE_FLUSH_FREQUENCY:
            case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_LOG_HISTORY_SIZE:
            case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_TEXT_CHANGE_FLUSH_FREQUENCY:
            case ContentCaptureManager.DEVICE_CONFIG_PROPERTY_IDLE_UNBIND_TIMEOUT:
                setFineTuneParamsFromDeviceConfig();
                return;
            default:
@@ -257,11 +260,15 @@ public final class ContentCaptureManagerService extends
                ContentCaptureManager.DEFAULT_TEXT_CHANGE_FLUSHING_FREQUENCY_MS);
        mDevCfgLogHistorySize = ContentCaptureHelper.getIntDeviceConfigProperty(
                ContentCaptureManager.DEVICE_CONFIG_PROPERTY_LOG_HISTORY_SIZE, 20);
        mDevCfgIdleUnbindTimeoutMs = ContentCaptureHelper.getIntDeviceConfigProperty(
                ContentCaptureManager.DEVICE_CONFIG_PROPERTY_IDLE_UNBIND_TIMEOUT,
                (int) AbstractRemoteService.PERMANENT_BOUND_TIMEOUT_MS);
        if (verbose) {
            Slog.v(mTag, "setFineTuneParamsFromDeviceConfig(): bufferSize=" + mDevCfgMaxBufferSize
                    + ", idleFlush=" + mDevCfgIdleFlushingFrequencyMs
                    + ", textFluxh=" + mDevCfgTextChangeFlushingFrequencyMs
                    + ", logHistory=" + mDevCfgLogHistorySize);
                    + ", logHistory=" + mDevCfgLogHistorySize
                    + ", idleUnbindTimeoutMs=" + mDevCfgIdleUnbindTimeoutMs);
        }
    }

@@ -472,6 +479,8 @@ public final class ContentCaptureManagerService extends
        pw.print(prefix2); pw.print("textChangeFlushingFrequencyMs: ");
        pw.println(mDevCfgTextChangeFlushingFrequencyMs);
        pw.print(prefix2); pw.print("logHistorySize: "); pw.println(mDevCfgLogHistorySize);
        pw.print(prefix2); pw.print("idleUnbindTimeoutMs: ");
        pw.println(mDevCfgIdleUnbindTimeoutMs);
    }

    final class ContentCaptureManagerServiceStub extends IContentCaptureManager.Stub {
+1 −1
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ final class ContentCapturePerUserService
            mRemoteService = new RemoteContentCaptureService(mMaster.getContext(),
                    ContentCaptureService.SERVICE_INTERFACE, serviceComponentName,
                    mRemoteServiceCallback, mUserId, this, mMaster.isBindInstantServiceAllowed(),
                    mMaster.verbose);
                    mMaster.verbose, mMaster.mDevCfgIdleUnbindTimeoutMs);
        }
    }

+4 −3
Original line number Diff line number Diff line
@@ -38,14 +38,16 @@ final class RemoteContentCaptureService
        IContentCaptureService> {

    private final IBinder mServerCallback;
    private final int mIdleUnbindTimeoutMs;

    RemoteContentCaptureService(Context context, String serviceInterface,
            ComponentName serviceComponentName, IContentCaptureServiceCallback callback, int userId,
            ContentCaptureServiceCallbacks callbacks, boolean bindInstantServiceAllowed,
            boolean verbose) {
            boolean verbose, int idleUnbindTimeoutMs) {
        super(context, serviceInterface, serviceComponentName, userId, callbacks,
                bindInstantServiceAllowed, verbose, /* initialCapacity= */ 2);
        mServerCallback = callback.asBinder();
        mIdleUnbindTimeoutMs = idleUnbindTimeoutMs;

        // Bind right away, which will trigger a onConnected() on service's
        scheduleBind();
@@ -58,8 +60,7 @@ final class RemoteContentCaptureService

    @Override // from AbstractRemoteService
    protected long getTimeoutIdleBindMillis() {
        // TODO(b/111276913): read from Settings so it can be changed in the field
        return PERMANENT_BOUND_TIMEOUT_MS;
        return mIdleUnbindTimeoutMs;
    }

    @Override // from RemoteService