1 /* 2 * Copyright (C) 2019 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.systemcaptions; 18 19 import android.annotation.NonNull; 20 import android.annotation.UserIdInt; 21 import android.content.Context; 22 23 import com.android.server.infra.AbstractMasterSystemService; 24 import com.android.server.infra.FrameworkResourcesServiceNameResolver; 25 26 /** A system service to bind to a remote system captions manager service. */ 27 public final class SystemCaptionsManagerService extends 28 AbstractMasterSystemService<SystemCaptionsManagerService, 29 SystemCaptionsManagerPerUserService> { 30 SystemCaptionsManagerService(@onNull Context context)31 public SystemCaptionsManagerService(@NonNull Context context) { 32 super(context, 33 new FrameworkResourcesServiceNameResolver( 34 context, 35 com.android.internal.R.string.config_defaultSystemCaptionsManagerService), 36 /*disallowProperty=*/ null, 37 /*packageUpdatePolicy=*/ PACKAGE_UPDATE_POLICY_REFRESH_EAGER 38 | PACKAGE_RESTART_POLICY_REFRESH_EAGER); 39 } 40 41 @Override onStart()42 public void onStart() { 43 // Do nothing. This service does not publish any local or system services. 44 } 45 46 @Override newServiceLocked( @serIdInt int resolvedUserId, boolean disabled)47 protected SystemCaptionsManagerPerUserService newServiceLocked( 48 @UserIdInt int resolvedUserId, boolean disabled) { 49 SystemCaptionsManagerPerUserService perUserService = 50 new SystemCaptionsManagerPerUserService(this, mLock, disabled, resolvedUserId); 51 perUserService.initializeLocked(); 52 return perUserService; 53 } 54 55 @Override onServiceRemoved( SystemCaptionsManagerPerUserService service, @UserIdInt int userId)56 protected void onServiceRemoved( 57 SystemCaptionsManagerPerUserService service, @UserIdInt int userId) { 58 synchronized (mLock) { 59 service.destroyLocked(); 60 } 61 } 62 } 63