Loading services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java +9 −5 Original line number Diff line number Diff line Loading @@ -43,9 +43,12 @@ import java.util.concurrent.TimeUnit; */ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { private static final String TAG = AppFunctionManagerServiceImpl.class.getSimpleName(); private final RemoteServiceCaller<IAppFunctionService> mRemoteServiceCaller; private final CallerValidator mCallerValidator; private final ServiceHelper mInternalServiceHelper; private final ServiceConfig mServiceConfig; public AppFunctionManagerServiceImpl(@NonNull Context context) { this(new RemoteServiceCallerImpl<>( Loading @@ -57,17 +60,20 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { /*unit=*/ TimeUnit.SECONDS, /*workQueue=*/ new LinkedBlockingQueue<>())), new CallerValidatorImpl(context), new ServiceHelperImpl(context)); new ServiceHelperImpl(context), new ServiceConfigImpl()); } @VisibleForTesting AppFunctionManagerServiceImpl(RemoteServiceCaller<IAppFunctionService> remoteServiceCaller, CallerValidator callerValidator, ServiceHelper appFunctionInternalServiceHelper) { ServiceHelper appFunctionInternalServiceHelper, ServiceConfig serviceConfig) { mRemoteServiceCaller = Objects.requireNonNull(remoteServiceCaller); mCallerValidator = Objects.requireNonNull(callerValidator); mInternalServiceHelper = Objects.requireNonNull(appFunctionInternalServiceHelper); mServiceConfig = serviceConfig; } @Override Loading Loading @@ -131,12 +137,10 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { ).build()); return; } bindAppFunctionServiceUnchecked(requestInternal, serviceIntent, targetUser, safeExecuteAppFunctionCallback, /*bindFlags=*/ Context.BIND_AUTO_CREATE, // TODO(b/357551503): Make timeout configurable. /*timeoutInMillis=*/ 30_000L); /*timeoutInMillis=*/ mServiceConfig.getExecutionTimeoutConfig()); } private void bindAppFunctionServiceUnchecked( Loading services/appfunctions/java/com/android/server/appfunctions/ServiceConfig.java 0 → 100644 +30 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.appfunctions; /** * This interface is used to expose configs to the AppFunctionManagerService. */ public interface ServiceConfig { // TODO(b/357551503): Obtain namespace from DeviceConfig. String NAMESPACE_APP_FUNCTIONS = "appfunctions"; /** * Returns the maximum time to wait for an app function execution to be complete. */ long getExecutionTimeoutConfig(); } services/appfunctions/java/com/android/server/appfunctions/ServiceConfigImpl.java 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.appfunctions; import android.provider.DeviceConfig; /** * Implementation of {@link ServiceConfig} */ public class ServiceConfigImpl implements ServiceConfig { static final String DEVICE_CONFIG_PROPERTY_EXECUTION_TIMEOUT = "execution_timeout"; static final long DEFAULT_EXECUTION_TIMEOUT_MS = 5000L; @Override public long getExecutionTimeoutConfig() { return DeviceConfig.getLong( NAMESPACE_APP_FUNCTIONS, DEVICE_CONFIG_PROPERTY_EXECUTION_TIMEOUT, DEFAULT_EXECUTION_TIMEOUT_MS ); } } Loading
services/appfunctions/java/com/android/server/appfunctions/AppFunctionManagerServiceImpl.java +9 −5 Original line number Diff line number Diff line Loading @@ -43,9 +43,12 @@ import java.util.concurrent.TimeUnit; */ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { private static final String TAG = AppFunctionManagerServiceImpl.class.getSimpleName(); private final RemoteServiceCaller<IAppFunctionService> mRemoteServiceCaller; private final CallerValidator mCallerValidator; private final ServiceHelper mInternalServiceHelper; private final ServiceConfig mServiceConfig; public AppFunctionManagerServiceImpl(@NonNull Context context) { this(new RemoteServiceCallerImpl<>( Loading @@ -57,17 +60,20 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { /*unit=*/ TimeUnit.SECONDS, /*workQueue=*/ new LinkedBlockingQueue<>())), new CallerValidatorImpl(context), new ServiceHelperImpl(context)); new ServiceHelperImpl(context), new ServiceConfigImpl()); } @VisibleForTesting AppFunctionManagerServiceImpl(RemoteServiceCaller<IAppFunctionService> remoteServiceCaller, CallerValidator callerValidator, ServiceHelper appFunctionInternalServiceHelper) { ServiceHelper appFunctionInternalServiceHelper, ServiceConfig serviceConfig) { mRemoteServiceCaller = Objects.requireNonNull(remoteServiceCaller); mCallerValidator = Objects.requireNonNull(callerValidator); mInternalServiceHelper = Objects.requireNonNull(appFunctionInternalServiceHelper); mServiceConfig = serviceConfig; } @Override Loading Loading @@ -131,12 +137,10 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub { ).build()); return; } bindAppFunctionServiceUnchecked(requestInternal, serviceIntent, targetUser, safeExecuteAppFunctionCallback, /*bindFlags=*/ Context.BIND_AUTO_CREATE, // TODO(b/357551503): Make timeout configurable. /*timeoutInMillis=*/ 30_000L); /*timeoutInMillis=*/ mServiceConfig.getExecutionTimeoutConfig()); } private void bindAppFunctionServiceUnchecked( Loading
services/appfunctions/java/com/android/server/appfunctions/ServiceConfig.java 0 → 100644 +30 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.appfunctions; /** * This interface is used to expose configs to the AppFunctionManagerService. */ public interface ServiceConfig { // TODO(b/357551503): Obtain namespace from DeviceConfig. String NAMESPACE_APP_FUNCTIONS = "appfunctions"; /** * Returns the maximum time to wait for an app function execution to be complete. */ long getExecutionTimeoutConfig(); }
services/appfunctions/java/com/android/server/appfunctions/ServiceConfigImpl.java 0 → 100644 +37 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.appfunctions; import android.provider.DeviceConfig; /** * Implementation of {@link ServiceConfig} */ public class ServiceConfigImpl implements ServiceConfig { static final String DEVICE_CONFIG_PROPERTY_EXECUTION_TIMEOUT = "execution_timeout"; static final long DEFAULT_EXECUTION_TIMEOUT_MS = 5000L; @Override public long getExecutionTimeoutConfig() { return DeviceConfig.getLong( NAMESPACE_APP_FUNCTIONS, DEVICE_CONFIG_PROPERTY_EXECUTION_TIMEOUT, DEFAULT_EXECUTION_TIMEOUT_MS ); } }