Adding FLEDGE service stubs to APK

Moved service impls for custom audience and ad selection services to
service-core

Test: atest AdServicesServiceCoreUnitTest
        && atest AdServicesServiceCoreUnitTests
Bug: 225989402
Bug: 225990012
Bug: 225990194
Change-Id: Id854c341d83f79dcf9cf0cce96257d94bcadae67
diff --git a/adservices/apk/AndroidManifest.xml b/adservices/apk/AndroidManifest.xml
index 7a3c434..4db5fbd 100644
--- a/adservices/apk/AndroidManifest.xml
+++ b/adservices/apk/AndroidManifest.xml
@@ -20,7 +20,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.android.adservices.api">
 
-    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
+    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
 
     <!-- Permissions required for reading device configs -->
     <uses-permission android:name="android.permission.READ_DEVICE_CONFIG"/>
@@ -29,24 +29,45 @@
         android:label="Android AdServices"
         android:forceQueryable="true">
         <!-- TODO(b/221123093): Support multi-user. -->
-        <service android:name="com.android.adservices.topics.TopicsService"
-            android:exported="true"
-            android:singleUser="true"
-            android:visibleToInstantApps="false"
-            >
+        <service android:name="com.android.adservices.adselection.AdSelectionService"
+                 android:exported="true"
+                 android:singleUser="true"
+                 android:visibleToInstantApps="false">
             <intent-filter>
-                <action android:name="android.adservices.TOPICS_SERVICE" />
+                <action android:name="android.adservices.adselection.AD_SELECTION_SERVICE"/>
+            </intent-filter>
+        </service>
+
+        <!-- TODO(b/221123093): Support multi-user. -->
+        <service android:name=
+                     "com.android.adservices.customaudience.CustomAudienceManagementService"
+                 android:exported="true"
+                 android:singleUser="true"
+                 android:visibleToInstantApps="false">
+            <intent-filter>
+                <action android:name=
+                            "android.adservices.customaudience.CUSTOM_AUDIENCE_MANAGEMENT_SERVICE"/>
+            </intent-filter>
+        </service>
+
+        <!-- TODO(b/221123093): Support multi-user. -->
+        <service android:name="com.android.adservices.topics.TopicsService"
+                 android:exported="true"
+                 android:singleUser="true"
+                 android:visibleToInstantApps="false">
+            <intent-filter>
+                <action android:name="android.adservices.TOPICS_SERVICE"/>
             </intent-filter>
         </service>
 
         <!-- Daily maintenance Job. -->
         <service android:name="com.android.adservices.service.MaintenanceJobService"
-            android:permission="android.permission.BIND_JOB_SERVICE">
+                 android:permission="android.permission.BIND_JOB_SERVICE">
         </service>
 
         <!-- Epoch computation Job. -->
         <service android:name="com.android.adservices.service.topics.EpochJobService"
-            android:permission="android.permission.BIND_JOB_SERVICE">
+                 android:permission="android.permission.BIND_JOB_SERVICE">
         </service>
     </application>
 </manifest>
diff --git a/adservices/apk/java/com/android/adservices/adselection/AdSelectionService.java b/adservices/apk/java/com/android/adservices/adselection/AdSelectionService.java
new file mode 100644
index 0000000..4d5f857
--- /dev/null
+++ b/adservices/apk/java/com/android/adservices/adselection/AdSelectionService.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2022 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.adselection;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+
+import com.android.adservices.service.adselection.AdSelectionServiceImpl;
+
+import java.util.Objects;
+
+/** Ad Selection Service */
+public class AdSelectionService extends Service {
+
+    /** The binder service. This field will only be accessed on the main thread. */
+    private AdSelectionServiceImpl mAdSelectionService;
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        if (mAdSelectionService == null) {
+            mAdSelectionService =
+                    new AdSelectionServiceImpl(this);
+        }
+    }
+
+    @Override
+    public IBinder onBind(Intent intent) {
+        return Objects.requireNonNull(mAdSelectionService);
+    }
+}
diff --git a/adservices/apk/java/com/android/adservices/customaudience/CustomAudienceManagementService.java b/adservices/apk/java/com/android/adservices/customaudience/CustomAudienceManagementService.java
new file mode 100644
index 0000000..9bc6d35
--- /dev/null
+++ b/adservices/apk/java/com/android/adservices/customaudience/CustomAudienceManagementService.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2022 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.customaudience;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+
+import com.android.adservices.service.customaudience.CustomAudienceManagementServiceImpl;
+
+import java.util.Objects;
+
+/** Custom Audience Management Service */
+public class CustomAudienceManagementService extends Service {
+
+    /** The binder service. This field will only be accessed on the main thread. */
+    private CustomAudienceManagementServiceImpl mCustomAudienceManagementService;
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        if (mCustomAudienceManagementService == null) {
+            mCustomAudienceManagementService =
+                    new CustomAudienceManagementServiceImpl(this);
+        }
+    }
+
+    @Override
+    public IBinder onBind(Intent intent) {
+        return Objects.requireNonNull(mCustomAudienceManagementService);
+    }
+}
diff --git a/adservices/framework/java/android/adservices/adselection/AdSelectionServiceImpl.java b/adservices/service-core/java/com/android/adservices/service/adselection/AdSelectionServiceImpl.java
similarity index 82%
rename from adservices/framework/java/android/adservices/adselection/AdSelectionServiceImpl.java
rename to adservices/service-core/java/com/android/adservices/service/adselection/AdSelectionServiceImpl.java
index d2de528..73d86e3 100644
--- a/adservices/framework/java/android/adservices/adselection/AdSelectionServiceImpl.java
+++ b/adservices/service-core/java/com/android/adservices/service/adselection/AdSelectionServiceImpl.java
@@ -14,8 +14,15 @@
  * limitations under the License.
  */
 
-package android.adservices.adselection;
+package com.android.adservices.service.adselection;
 
+import android.adservices.adselection.AdSelectionCallback;
+import android.adservices.adselection.AdSelectionConfig;
+import android.adservices.adselection.AdSelectionResponse;
+import android.adservices.adselection.AdSelectionService;
+import android.adservices.adselection.ReportImpressionCallback;
+import android.adservices.adselection.ReportImpressionRequest;
+import android.adservices.adselection.ReportImpressionResponse;
 import android.annotation.NonNull;
 import android.content.Context;
 import android.os.RemoteException;
@@ -49,6 +56,7 @@
     @Override
     public void runAdSelection(
             @NonNull AdSelectionConfig adSelectionConfig, @NonNull AdSelectionCallback callback) {
+        // TODO(b/225988784): Offload work to thread pool
         // TODO(b/221876756): Implement
         Objects.requireNonNull(adSelectionConfig);
         Objects.requireNonNull(callback);
@@ -69,6 +77,7 @@
     public void reportImpression(
             @NonNull ReportImpressionRequest requestParams,
             @NonNull ReportImpressionCallback callback) {
+        // TODO(b/225988784): Offload work to thread pool
         // TODO(b/212300065): Implement
         Objects.requireNonNull(requestParams);
         Objects.requireNonNull(callback);
diff --git a/adservices/framework/java/android/adservices/customaudience/CustomAudienceManagementServiceImpl.java b/adservices/service-core/java/com/android/adservices/service/customaudience/CustomAudienceManagementServiceImpl.java
similarity index 86%
rename from adservices/framework/java/android/adservices/customaudience/CustomAudienceManagementServiceImpl.java
rename to adservices/service-core/java/com/android/adservices/service/customaudience/CustomAudienceManagementServiceImpl.java
index 8f0ef68..d73aebd 100644
--- a/adservices/framework/java/android/adservices/customaudience/CustomAudienceManagementServiceImpl.java
+++ b/adservices/service-core/java/com/android/adservices/service/customaudience/CustomAudienceManagementServiceImpl.java
@@ -14,8 +14,12 @@
  * limitations under the License.
  */
 
-package android.adservices.customaudience;
+package com.android.adservices.service.customaudience;
 
+import android.adservices.customaudience.CustomAudience;
+import android.adservices.customaudience.CustomAudienceManagementResponse;
+import android.adservices.customaudience.ICustomAudienceCallback;
+import android.adservices.customaudience.ICustomAudienceManagementService;
 import android.annotation.NonNull;
 import android.content.Context;
 import android.os.RemoteException;
@@ -52,6 +56,7 @@
         Objects.requireNonNull(customAudience);
         Objects.requireNonNull(callback);
 
+        // TODO(b/225988784): Offload work to thread pool
         try {
             callback.onResult(
                     new CustomAudienceManagementResponse.Builder()
@@ -77,6 +82,7 @@
         Objects.requireNonNull(name);
         Objects.requireNonNull(callback);
 
+        // TODO(b/225988784): Offload work to thread pool
         try {
             callback.onResult(
                     new CustomAudienceManagementResponse.Builder()