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.bluetooth.statemachine; 18 19 import android.annotation.SuppressLint; 20 import android.os.Message; 21 22 /** 23 * @hide 24 * 25 * The class for implementing states in a StateMachine 26 */ 27 @SuppressLint("AndroidFrameworkRequiresPermission") 28 public class State implements IState { 29 30 /** 31 * Constructor 32 */ State()33 protected State() { 34 } 35 36 @Override enter()37 public void enter() { 38 } 39 40 @Override exit()41 public void exit() { 42 } 43 44 @Override processMessage(Message msg)45 public boolean processMessage(Message msg) { 46 return false; 47 } 48 49 /** 50 * Name of State for debugging purposes. 51 * 52 * This default implementation returns the class name, returning 53 * the instance name would better in cases where a State class 54 * is used for multiple states. But normally there is one class per 55 * state and the class name is sufficient and easy to get. You may 56 * want to provide a setName or some other mechanism for setting 57 * another name if the class name is not appropriate. 58 * 59 */ 60 @Override getName()61 public String getName() { 62 String name = getClass().getName(); 63 int lastDollar = name.lastIndexOf('$'); 64 return name.substring(lastDollar + 1); 65 } 66 } 67