Home | History | Annotate | Download | only in sample
      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 
     17 package com.android.car.cluster.sample;
     18 
     19 import android.car.cluster.renderer.InstrumentClusterRenderingService;
     20 import android.car.cluster.renderer.NavigationRenderer;
     21 import android.view.KeyEvent;
     22 
     23 /**
     24  * Service for {@link InstrumentClusterController}. This is entry-point of the instrument cluster
     25  * renderer. This service will be bound from Car Service.
     26  */
     27 public class InstrumentClusterRenderingServiceImpl extends InstrumentClusterRenderingService {
     28 
     29     private InstrumentClusterController mController;
     30 
     31     @Override
     32     public void onCreate() {
     33         super.onCreate();
     34 
     35         mController = new InstrumentClusterController(this /* context */);
     36     }
     37 
     38     @Override
     39     public void onDestroy() {
     40         super.onDestroy();
     41 
     42         if (mController != null) {
     43             mController.onDestroy();
     44             mController = null;
     45         }
     46     }
     47 
     48     @Override
     49     protected NavigationRenderer getNavigationRenderer() {
     50         return mController.getNavigationRenderer();
     51     }
     52 
     53     @Override
     54     protected void onKeyEvent(KeyEvent keyEvent) {
     55         // No need to handle key events in this implementation.
     56     }
     57 }
     58