summaryrefslogtreecommitdiff
path: root/services/appfunctions/java
diff options
context:
space:
mode:
author Utkarsh Nigam <utkarshnigam@google.com> 2024-09-20 08:46:24 +0000
committer Utkarsh Nigam <utkarshnigam@google.com> 2024-09-20 08:46:24 +0000
commit807d168a125a6e3b17f4f2fa58c92047e680c928 (patch)
tree760329e1a483027652f632a61bb95ac05f50edeb /services/appfunctions/java
parent97344c760045dd600bcb23793604a31a8d64c088 (diff)
Remove timeout logic from AppFunctionManagerService.
https://docs.google.com/document/d/1d2KLWoymaaf-UXKmSgWJeuzMTct4k1G53ZQMhx_6_M8/edit?tab=t.0 Change-Id: Icc87315c1ec594030b3a8ce266fb2c0cd93f3064 Flag: android.app.appfunctions.flags.enable_app_function_manager Test: atest CtsAppFunctionTestCases -c Bug: 360864791
Diffstat (limited to 'services/appfunctions/java')
-rw-r--r--services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java18
-rw-r--r--services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java8
-rw-r--r--services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCallerImpl.java19
3 files changed, 4 insertions, 41 deletions
diff --git a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java
index 165a9452fb0a..1e723b5a1da2 100644
--- a/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java
@@ -204,9 +204,7 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub {
serviceIntent,
targetUser,
safeExecuteAppFunctionCallback,
- /* bindFlags= */ Context.BIND_AUTO_CREATE,
- /* timeoutInMillis= */ mServiceConfig
- .getExecuteAppFunctionTimeoutMillis());
+ /* bindFlags= */ Context.BIND_AUTO_CREATE);
})
.exceptionally(
ex -> {
@@ -221,13 +219,11 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub {
@NonNull Intent serviceIntent,
@NonNull UserHandle targetUser,
@NonNull SafeOneTimeExecuteAppFunctionCallback safeExecuteAppFunctionCallback,
- int bindFlags,
- long timeoutInMillis) {
+ int bindFlags) {
boolean bindServiceResult =
mRemoteServiceCaller.runServiceCall(
serviceIntent,
bindFlags,
- timeoutInMillis,
targetUser,
new RunServiceCallCallback<IAppFunctionService>() {
@Override
@@ -268,16 +264,6 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub {
"Failed to connect to AppFunctionService",
/* extras= */ null));
}
-
- @Override
- public void onTimedOut() {
- Slog.e(TAG, "Timed out");
- safeExecuteAppFunctionCallback.onResult(
- ExecuteAppFunctionResponse.newFailure(
- ExecuteAppFunctionResponse.RESULT_TIMED_OUT,
- "Binding to AppFunctionService timed out.",
- /* extras= */ null));
- }
});
if (!bindServiceResult) {
diff --git a/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java b/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java
index 58597c38bb94..cd5c3831bc0d 100644
--- a/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java
@@ -43,7 +43,6 @@ public interface RemoteServiceCaller<T> {
* @param intent An Intent object that describes the service that should be bound.
* @param bindFlags Flags used to control the binding process See {@link
* android.content.Context#bindService}.
- * @param timeoutInMillis The maximum time in milliseconds to wait for the service connection.
* @param userHandle The UserHandle of the user for which the service should be bound.
* @param callback A callback to be invoked for various events. See {@link
* RunServiceCallCallback}.
@@ -51,7 +50,6 @@ public interface RemoteServiceCaller<T> {
boolean runServiceCall(
@NonNull Intent intent,
int bindFlags,
- long timeoutInMillis,
@NonNull UserHandle userHandle,
@NonNull RunServiceCallCallback<T> callback);
@@ -75,11 +73,5 @@ public interface RemoteServiceCaller<T> {
/** Called when the service connection was failed to establish. */
void onFailedToConnect();
-
- /**
- * Called when the whole operation(i.e. binding and the service call) takes longer than
- * allowed.
- */
- void onTimedOut();
}
}
diff --git a/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCallerImpl.java b/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCallerImpl.java
index eea17eeca371..070a99d5bb28 100644
--- a/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCallerImpl.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCallerImpl.java
@@ -62,12 +62,11 @@ public class RemoteServiceCallerImpl<T> implements RemoteServiceCaller<T> {
public boolean runServiceCall(
@NonNull Intent intent,
int bindFlags,
- long timeoutInMillis,
@NonNull UserHandle userHandle,
@NonNull RunServiceCallCallback<T> callback) {
OneOffServiceConnection serviceConnection =
new OneOffServiceConnection(
- intent, bindFlags, timeoutInMillis, userHandle, callback);
+ intent, bindFlags, userHandle, callback);
return serviceConnection.bindAndRun();
}
@@ -76,28 +75,17 @@ public class RemoteServiceCallerImpl<T> implements RemoteServiceCaller<T> {
implements ServiceConnection, ServiceUsageCompleteListener {
private final Intent mIntent;
private final int mFlags;
- private final long mTimeoutMillis;
private final UserHandle mUserHandle;
private final RunServiceCallCallback<T> mCallback;
- private final Runnable mTimeoutCallback;
OneOffServiceConnection(
@NonNull Intent intent,
int flags,
- long timeoutMillis,
@NonNull UserHandle userHandle,
@NonNull RunServiceCallCallback<T> callback) {
mIntent = intent;
mFlags = flags;
- mTimeoutMillis = timeoutMillis;
mCallback = callback;
- mTimeoutCallback =
- () ->
- mExecutor.execute(
- () -> {
- safeUnbind();
- mCallback.onTimedOut();
- });
mUserHandle = userHandle;
}
@@ -105,9 +93,7 @@ public class RemoteServiceCallerImpl<T> implements RemoteServiceCaller<T> {
boolean bindServiceResult =
mContext.bindServiceAsUser(mIntent, this, mFlags, mUserHandle);
- if (bindServiceResult) {
- mHandler.postDelayed(mTimeoutCallback, mTimeoutMillis);
- } else {
+ if(!bindServiceResult) {
safeUnbind();
}
@@ -141,7 +127,6 @@ public class RemoteServiceCallerImpl<T> implements RemoteServiceCaller<T> {
private void safeUnbind() {
try {
- mHandler.removeCallbacks(mTimeoutCallback);
mContext.unbindService(this);
} catch (Exception ex) {
Log.w(TAG, "Failed to unbind", ex);