1 /*
2  * Copyright (C) 2021 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.server.uwb;
18 
19 import android.content.Context;
20 import android.util.Log;
21 
22 import com.android.internal.annotations.Keep;
23 import com.android.server.SystemService;
24 
25 /**
26  * Uwb System service.
27  */
28 @Keep
29 public class UwbService extends SystemService {
30     private static final String TAG = "UwbService";
31 
32     private final UwbServiceImpl mImpl;
33 
UwbService(Context context)34     public UwbService(Context context) {
35         super(context);
36         mImpl = new UwbServiceImpl(context, new UwbInjector(new UwbContext(context)));
37     }
38 
39     @Override
onStart()40     public void onStart() {
41         Log.i(TAG, "Registering " + Context.UWB_SERVICE);
42         publishBinderService(Context.UWB_SERVICE, mImpl);
43     }
44 
45     @Override
onBootPhase(int phase)46     public void onBootPhase(int phase) {
47         if (phase == SystemService.PHASE_BOOT_COMPLETED) {
48             mImpl.initialize();
49         }
50     }
51 
52     @Override
onUserSwitching(TargetUser from, TargetUser to)53     public void onUserSwitching(TargetUser from, TargetUser to) {
54         mImpl.handleUserSwitch(to.getUserHandle().getIdentifier());
55     }
56 
57     @Override
onUserUnlocking(TargetUser user)58     public void onUserUnlocking(TargetUser user) {
59         mImpl.handleUserUnlock(user.getUserHandle().getIdentifier());
60     }
61 }
62