1 /* 2 * Copyright (C) 2012 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.server.am; 18 19 import java.io.PrintWriter; 20 import java.util.ArrayList; 21 22 import android.app.IStopUserCallback; 23 import android.os.UserHandle; 24 25 public final class UserStartedState { 26 // User is first coming up. 27 public final static int STATE_BOOTING = 0; 28 // User is in the normal running state. 29 public final static int STATE_RUNNING = 1; 30 // User is in the initial process of being stopped. 31 public final static int STATE_STOPPING = 2; 32 // User is in the final phase of stopping, sending Intent.ACTION_SHUTDOWN. 33 public final static int STATE_SHUTDOWN = 3; 34 35 public final UserHandle mHandle; 36 public final ArrayList<IStopUserCallback> mStopCallbacks 37 = new ArrayList<IStopUserCallback>(); 38 39 public int mState = STATE_BOOTING; 40 public boolean switching; 41 public boolean initializing; 42 43 public UserStartedState(UserHandle handle, boolean initial) { 44 mHandle = handle; 45 } 46 47 void dump(String prefix, PrintWriter pw) { 48 pw.print(prefix); pw.print("mState="); 49 switch (mState) { 50 case STATE_BOOTING: pw.print("BOOTING"); break; 51 case STATE_RUNNING: pw.print("RUNNING"); break; 52 case STATE_STOPPING: pw.print("STOPPING"); break; 53 case STATE_SHUTDOWN: pw.print("SHUTDOWN"); break; 54 default: pw.print(mState); break; 55 } 56 if (switching) pw.print(" SWITCHING"); 57 if (initializing) pw.print(" INITIALIZING"); 58 pw.println(); 59 } 60 } 61