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