1 /* 2 * Copyright (C) 2016 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 package android.car.cluster.renderer; 17 18 import static com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport.DEPRECATED_CODE; 19 20 import android.annotation.Nullable; 21 import android.annotation.SystemApi; 22 import android.annotation.UiThread; 23 import android.car.annotation.AddedInOrBefore; 24 import android.content.Context; 25 26 import com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport; 27 import com.android.internal.annotations.GuardedBy; 28 29 /** 30 * @deprecated This class is unused. Refer to {@link InstrumentClusterRenderingService} for 31 * documentation on how to build a instrument cluster renderer. 32 * 33 * @hide 34 */ 35 @Deprecated 36 @SystemApi 37 @ExcludeFromCodeCoverageGeneratedReport(reason = DEPRECATED_CODE) 38 public abstract class InstrumentClusterRenderer { 39 40 private final Object mLock = new Object(); 41 42 @GuardedBy("mLock") 43 @Nullable private NavigationRenderer mNavigationRenderer; 44 45 /** 46 * Called when instrument cluster renderer is created. 47 */ 48 @AddedInOrBefore(majorVersion = 33) onCreate(Context context)49 public abstract void onCreate(Context context); 50 51 /** 52 * Called when instrument cluster renderer is started. 53 */ 54 @AddedInOrBefore(majorVersion = 33) onStart()55 public abstract void onStart(); 56 57 /** 58 * Called when instrument cluster renderer is stopped. 59 */ 60 @AddedInOrBefore(majorVersion = 33) onStop()61 public abstract void onStop(); 62 63 @AddedInOrBefore(majorVersion = 33) createNavigationRenderer()64 protected abstract NavigationRenderer createNavigationRenderer(); 65 66 /** The method is thread-safe, callers should cache returned object. */ 67 @Nullable 68 @AddedInOrBefore(majorVersion = 33) getNavigationRenderer()69 public NavigationRenderer getNavigationRenderer() { 70 synchronized (mLock) { 71 return mNavigationRenderer; 72 } 73 } 74 75 /** 76 * This method is called by car service after onCreateView to initialize private members. The 77 * method should not be overridden by subclasses. 78 */ 79 @UiThread 80 @AddedInOrBefore(majorVersion = 33) initialize()81 public final void initialize() { 82 synchronized (mLock) { 83 mNavigationRenderer = createNavigationRenderer(); 84 } 85 } 86 } 87 88