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

Commit 5f5d459a authored by sandeepbandaru's avatar sandeepbandaru
Browse files

Add unbind timeout based on secure settings values

Bug: 340551198
Change-Id: Idce4dcc2b5b38c903d6b116e59e2b46c1b97cb18
parent fa2c476e
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -22,11 +22,14 @@ import static android.content.Context.BIND_INCLUDE_CAPABILITIES;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import android.service.ondeviceintelligence.IOnDeviceIntelligenceService;
import android.service.ondeviceintelligence.OnDeviceIntelligenceService;

import com.android.internal.infra.ServiceConnector;

import java.util.concurrent.TimeUnit;

/**
 * Manages the connection to the remote on-device intelligence service. Also, handles unbinding
 * logic set by the service implementation via a Secure Settings flag.
@@ -49,8 +52,9 @@ public class RemoteOnDeviceIntelligenceService extends

    @Override
    protected long getAutoDisconnectTimeoutMs() {
        // Disable automatic unbinding.
        // TODO: add logic to fetch this flag via SecureSettings.
        return -1;
        return Settings.Secure.getLongForUser(mContext.getContentResolver(),
                Settings.Secure.ON_DEVICE_INTELLIGENCE_UNBIND_TIMEOUT_MS,
                TimeUnit.SECONDS.toMillis(30),
                mContext.getUserId());
    }
}
+9 −5
Original line number Diff line number Diff line
@@ -22,14 +22,18 @@ import static android.content.Context.BIND_INCLUDE_CAPABILITIES;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import android.service.ondeviceintelligence.IOnDeviceSandboxedInferenceService;
import android.service.ondeviceintelligence.OnDeviceSandboxedInferenceService;

import com.android.internal.infra.ServiceConnector;

import java.util.concurrent.TimeUnit;


/**
 * Manages the connection to the remote on-device sand boxed inference service. Also, handles unbinding
 * Manages the connection to the remote on-device sand boxed inference service. Also, handles
 * unbinding
 * logic set by the service implementation via a SecureSettings flag.
 */
public class RemoteOnDeviceSandboxedInferenceService extends
@@ -54,11 +58,11 @@ public class RemoteOnDeviceSandboxedInferenceService extends
        connect();
    }


    @Override
    protected long getAutoDisconnectTimeoutMs() {
        // Disable automatic unbinding.
        // TODO: add logic to fetch this flag via SecureSettings.
        return -1;
        return Settings.Secure.getLongForUser(mContext.getContentResolver(),
                Settings.Secure.ON_DEVICE_INFERENCE_UNBIND_TIMEOUT_MS,
                TimeUnit.SECONDS.toMillis(30),
                mContext.getUserId());
    }
}