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; |
Amith Yamasani | 37a40c2 | 2015-06-17 13:25:42 -0700 | [diff] [blame] | 24 | import android.util.ArrayMap; |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 25 | |
Amith Yamasani | 37a40c2 | 2015-06-17 13:25:42 -0700 | [diff] [blame] | 26 | public final class UserState { |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 27 | // User is first coming up. |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 28 | public final static int STATE_BOOTING = 0; |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 29 | // User is in the normal running state. |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 30 | public final static int STATE_RUNNING = 1; |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 31 | // User is in the initial process of being stopped. |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 32 | public final static int STATE_STOPPING = 2; |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 33 | // User is in the final phase of stopping, sending Intent.ACTION_SHUTDOWN. |
| 34 | public final static int STATE_SHUTDOWN = 3; |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 35 | |
| 36 | public final UserHandle mHandle; |
| 37 | public final ArrayList<IStopUserCallback> mStopCallbacks |
| 38 | = new ArrayList<IStopUserCallback>(); |
| 39 | |
| 40 | public int mState = STATE_BOOTING; |
Dianne Hackborn | d4ac8d7 | 2012-09-27 23:20:10 -0700 | [diff] [blame] | 41 | public boolean switching; |
| 42 | public boolean initializing; |
Jeff Sharkey | f9fc6d6 | 2015-11-08 16:46:05 -0800 | [diff] [blame^] | 43 | public boolean unlocked; |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 44 | |
Amith Yamasani | 37a40c2 | 2015-06-17 13:25:42 -0700 | [diff] [blame] | 45 | /** |
| 46 | * The last time that a provider was reported to usage stats as being brought to important |
| 47 | * foreground procstate. |
| 48 | */ |
| 49 | public final ArrayMap<String,Long> mProviderLastReportedFg = new ArrayMap<>(); |
| 50 | |
Jeff Sharkey | f9fc6d6 | 2015-11-08 16:46:05 -0800 | [diff] [blame^] | 51 | public UserState(UserHandle handle) { |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 52 | mHandle = handle; |
| 53 | } |
| 54 | |
| 55 | void dump(String prefix, PrintWriter pw) { |
Dianne Hackborn | 36d337a | 2012-10-08 14:33:47 -0700 | [diff] [blame] | 56 | pw.print(prefix); pw.print("mState="); |
| 57 | switch (mState) { |
| 58 | case STATE_BOOTING: pw.print("BOOTING"); break; |
| 59 | case STATE_RUNNING: pw.print("RUNNING"); break; |
| 60 | case STATE_STOPPING: pw.print("STOPPING"); break; |
| 61 | case STATE_SHUTDOWN: pw.print("SHUTDOWN"); break; |
| 62 | default: pw.print(mState); break; |
| 63 | } |
Dianne Hackborn | d4ac8d7 | 2012-09-27 23:20:10 -0700 | [diff] [blame] | 64 | if (switching) pw.print(" SWITCHING"); |
| 65 | if (initializing) pw.print(" INITIALIZING"); |
Jeff Sharkey | f9fc6d6 | 2015-11-08 16:46:05 -0800 | [diff] [blame^] | 66 | if (unlocked) { |
| 67 | pw.print(" UNLOCKED"); |
| 68 | } else { |
| 69 | pw.print(" LOCKED"); |
| 70 | } |
Dianne Hackborn | d4ac8d7 | 2012-09-27 23:20:10 -0700 | [diff] [blame] | 71 | pw.println(); |
Dianne Hackborn | 80a4af2 | 2012-08-27 19:18:31 -0700 | [diff] [blame] | 72 | } |
| 73 | } |