1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ondevicepersonalization.services; 18 19 import static com.android.ondevicepersonalization.services.OnDevicePersonalizationBroadcastReceiver.restoreOdpJobs; 20 21 import android.adservices.ondevicepersonalization.aidl.IOnDevicePersonalizationManagingService; 22 import android.app.Service; 23 import android.content.Intent; 24 import android.os.IBinder; 25 import android.os.Trace; 26 27 28 import com.google.common.annotations.VisibleForTesting; 29 30 import java.util.concurrent.Executor; 31 32 /** Implementation of OnDevicePersonalization Service */ 33 public class OnDevicePersonalizationManagingServiceImpl extends Service { 34 private IOnDevicePersonalizationManagingService.Stub mBinder; 35 36 private Executor mExecutor; 37 OnDevicePersonalizationManagingServiceImpl()38 public OnDevicePersonalizationManagingServiceImpl() { 39 this.mExecutor = OnDevicePersonalizationExecutors.getBackgroundExecutor(); 40 } 41 42 @VisibleForTesting OnDevicePersonalizationManagingServiceImpl(Executor executor)43 public OnDevicePersonalizationManagingServiceImpl(Executor executor) { 44 this.mExecutor = executor; 45 } 46 47 @Override onCreate()48 public void onCreate() { 49 Trace.beginSection("OdpManagingService#Initialization"); 50 if (mBinder == null) { 51 mBinder = new OnDevicePersonalizationManagingServiceDelegate(this); 52 var unused = restoreOdpJobs(this, mExecutor); 53 } 54 Trace.endSection(); 55 } 56 57 @Override onBind(Intent intent)58 public IBinder onBind(Intent intent) { 59 return mBinder; 60 } 61 } 62