diff options
Diffstat (limited to 'adservices/apk/java/com/android/adservices/shell/AdServicesShellCommandService.java')
-rw-r--r-- | adservices/apk/java/com/android/adservices/shell/AdServicesShellCommandService.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/adservices/apk/java/com/android/adservices/shell/AdServicesShellCommandService.java b/adservices/apk/java/com/android/adservices/shell/AdServicesShellCommandService.java new file mode 100644 index 000000000..8d07378ca --- /dev/null +++ b/adservices/apk/java/com/android/adservices/shell/AdServicesShellCommandService.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2023 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.adservices.shell; + +import android.annotation.Nullable; +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; + +import com.android.adservices.LogUtil; +import com.android.adservices.service.FlagsFactory; +import com.android.adservices.service.shell.ShellCommandServiceImpl; + +import java.util.Objects; + +/** Implements a service which runs the shell command in the adservices process. */ +public final class AdServicesShellCommandService extends Service { + + /** The binder service. This field must only be accessed on the main thread. */ + private ShellCommandServiceImpl mShellCommandService; + + @Override + public void onCreate() { + if (!FlagsFactory.getFlags().getAdServicesShellCommandEnabled()) { + LogUtil.e("Shell command service is not enabled."); + return; + } + + mShellCommandService = new ShellCommandServiceImpl(); + } + + @Nullable + @Override + public IBinder onBind(Intent intent) { + if (!FlagsFactory.getFlags().getAdServicesShellCommandEnabled()) { + LogUtil.e("Shell command service is not enabled."); + return null; + } + return Objects.requireNonNull(mShellCommandService); + } + + // TODO(b/308009734): Implement dump method. +} |