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.car.internal; 18 19 import android.app.Service; 20 import android.content.Context; 21 22 import java.io.FileDescriptor; 23 import java.io.PrintWriter; 24 25 /** 26 * Helper class for {@code Service} that is proxied from car service to car service updated. 27 * 28 * <p> This is used as an interface between builtin and updatable car service. Do not change it 29 * without compatibility check. Adding a new method is ok but should have no-op default 30 * implementation. 31 * 32 * @hide 33 */ 34 public abstract class ProxiedService extends Service { 35 36 private Context mCarServiceBuiltinPackageContext; 37 38 /** Check {@link Service#attachBaseContext(Context)}. */ doAttachBaseContext(Context newBase)39 public void doAttachBaseContext(Context newBase) { 40 attachBaseContext(newBase); 41 } 42 43 /** Used by builtin CarService to set builtin {@code Context}. */ setBuiltinPackageContext(Context context)44 public void setBuiltinPackageContext(Context context) { 45 mCarServiceBuiltinPackageContext = context; 46 } 47 48 /** Returns the {@code Context} of builtin car service */ getBuiltinPackageContext()49 public Context getBuiltinPackageContext() { 50 return mCarServiceBuiltinPackageContext; 51 } 52 53 /** Check {@link Service#dump(FileDescriptor, PrintWriter, String[])}. */ doDump(FileDescriptor fd, PrintWriter writer, String[] args)54 public void doDump(FileDescriptor fd, PrintWriter writer, String[] args) { 55 dump(fd, writer, args); 56 } 57 } 58