Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 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 class UserStartedState { |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 26 | // User is first coming up. |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 27 | public final static int STATE_BOOTING = 0; |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 28 | // User is in the normal running state. |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 29 | public final static int STATE_RUNNING = 1; |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 30 | // User is in the initial process of being stopped. |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 31 | public final static int STATE_STOPPING = 2; |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 32 | // User is in the final phase of stopping, sending Intent.ACTION_SHUTDOWN. |
| 33 | public final static int STATE_SHUTDOWN = 3; |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 34 | |
| 35 | public final UserHandle mHandle; |
| 36 | public final ArrayList<IStopUserCallback> mStopCallbacks |
| 37 | = new ArrayList<IStopUserCallback>(); |
| 38 | |
| 39 | public int mState = STATE_BOOTING; |
Dianne Hackborn | d4ac8d7 | 2012-09-27 23:20:10 -0700 | [diff] [blame] | 40 | public boolean switching; |
| 41 | public boolean initializing; |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 42 | |
| 43 | public UserStartedState(UserHandle handle, boolean initial) { |
| 44 | mHandle = handle; |
| 45 | } |
| 46 | |
| 47 | void dump(String prefix, PrintWriter pw) { |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 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 | } |
Dianne Hackborn | d4ac8d7 | 2012-09-27 23:20:10 -0700 | [diff] [blame] | 56 | if (switching) pw.print(" SWITCHING"); |
| 57 | if (initializing) pw.print(" INITIALIZING"); |
| 58 | pw.println(); |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 59 | } |
| 60 | } |