blob: 0e71f81bb43ac25d932fa584ba763f2338107034 [file] [log] [blame]
Dianne Hackborn80a4af22012-08-27 19:18:31 -07001/*
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
17package com.android.server.am;
18
19import java.io.PrintWriter;
20import java.util.ArrayList;
21
22import android.app.IStopUserCallback;
23import android.os.UserHandle;
24
25public class UserStartedState {
Dianne Hackborn36d337a2012-10-08 14:33:47 -070026 // User is first coming up.
Dianne Hackborn80a4af22012-08-27 19:18:31 -070027 public final static int STATE_BOOTING = 0;
Dianne Hackborn36d337a2012-10-08 14:33:47 -070028 // User is in the normal running state.
Dianne Hackborn80a4af22012-08-27 19:18:31 -070029 public final static int STATE_RUNNING = 1;
Dianne Hackborn36d337a2012-10-08 14:33:47 -070030 // User is in the initial process of being stopped.
Dianne Hackborn80a4af22012-08-27 19:18:31 -070031 public final static int STATE_STOPPING = 2;
Dianne Hackborn36d337a2012-10-08 14:33:47 -070032 // User is in the final phase of stopping, sending Intent.ACTION_SHUTDOWN.
33 public final static int STATE_SHUTDOWN = 3;
Dianne Hackborn80a4af22012-08-27 19:18:31 -070034
35 public final UserHandle mHandle;
36 public final ArrayList<IStopUserCallback> mStopCallbacks
37 = new ArrayList<IStopUserCallback>();
38
39 public int mState = STATE_BOOTING;
Dianne Hackbornd4ac8d72012-09-27 23:20:10 -070040 public boolean switching;
41 public boolean initializing;
Dianne Hackborn80a4af22012-08-27 19:18:31 -070042
43 public UserStartedState(UserHandle handle, boolean initial) {
44 mHandle = handle;
45 }
46
47 void dump(String prefix, PrintWriter pw) {
Dianne Hackborn36d337a2012-10-08 14:33:47 -070048 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 }
Dianne Hackbornd4ac8d72012-09-27 23:20:10 -070056 if (switching) pw.print(" SWITCHING");
57 if (initializing) pw.print(" INITIALIZING");
58 pw.println();
Dianne Hackborn80a4af22012-08-27 19:18:31 -070059 }
60}