Loading services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java +2 −16 Original line number Diff line number Diff line Loading @@ -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 -> { Loading @@ -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 Loading Loading @@ -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) { Loading services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java +0 −8 Original line number Diff line number Diff line Loading @@ -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}. Loading @@ -51,7 +50,6 @@ public interface RemoteServiceCaller<T> { boolean runServiceCall( @NonNull Intent intent, int bindFlags, long timeoutInMillis, @NonNull UserHandle userHandle, @NonNull RunServiceCallCallback<T> callback); Loading @@ -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(); } } services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCallerImpl.java +2 −17 Original line number Diff line number Diff line Loading @@ -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(); } Loading @@ -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; } Loading @@ -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(); } Loading Loading @@ -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); Loading Loading
services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java +2 −16 Original line number Diff line number Diff line Loading @@ -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 -> { Loading @@ -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 Loading Loading @@ -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) { Loading
services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCaller.java +0 −8 Original line number Diff line number Diff line Loading @@ -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}. Loading @@ -51,7 +50,6 @@ public interface RemoteServiceCaller<T> { boolean runServiceCall( @NonNull Intent intent, int bindFlags, long timeoutInMillis, @NonNull UserHandle userHandle, @NonNull RunServiceCallCallback<T> callback); Loading @@ -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(); } }
services/appfunctions/java/com/android/server/appfunctions/RemoteServiceCallerImpl.java +2 −17 Original line number Diff line number Diff line Loading @@ -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(); } Loading @@ -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; } Loading @@ -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(); } Loading Loading @@ -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); Loading