blob: b5b5c1d06f6faa7e00fda8a341f0a853ea0529fc [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;
Amith Yamasani37a40c22015-06-17 13:25:42 -070024import android.util.ArrayMap;
Dianne Hackborn80a4af22012-08-27 19:18:31 -070025
Amith Yamasani37a40c22015-06-17 13:25:42 -070026public final class UserState {
Dianne Hackborn36d337a2012-10-08 14:33:47 -070027 // User is first coming up.
Dianne Hackborn80a4af22012-08-27 19:18:31 -070028 public final static int STATE_BOOTING = 0;
Dianne Hackborn36d337a2012-10-08 14:33:47 -070029 // User is in the normal running state.
Dianne Hackborn80a4af22012-08-27 19:18:31 -070030 public final static int STATE_RUNNING = 1;
Dianne Hackborn36d337a2012-10-08 14:33:47 -070031 // User is in the initial process of being stopped.
Dianne Hackborn80a4af22012-08-27 19:18:31 -070032 public final static int STATE_STOPPING = 2;
Dianne Hackborn36d337a2012-10-08 14:33:47 -070033 // User is in the final phase of stopping, sending Intent.ACTION_SHUTDOWN.
34 public final static int STATE_SHUTDOWN = 3;
Dianne Hackborn80a4af22012-08-27 19:18:31 -070035
36 public final UserHandle mHandle;
37 public final ArrayList<IStopUserCallback> mStopCallbacks
38 = new ArrayList<IStopUserCallback>();
39
40 public int mState = STATE_BOOTING;
Dianne Hackbornd4ac8d72012-09-27 23:20:10 -070041 public boolean switching;
42 public boolean initializing;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -080043 public boolean unlocked;
Dianne Hackborn80a4af22012-08-27 19:18:31 -070044
Amith Yamasani37a40c22015-06-17 13:25:42 -070045 /**
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 Sharkeyf9fc6d62015-11-08 16:46:05 -080051 public UserState(UserHandle handle) {
Dianne Hackborn80a4af22012-08-27 19:18:31 -070052 mHandle = handle;
53 }
54
55 void dump(String prefix, PrintWriter pw) {
Dianne Hackborn36d337a2012-10-08 14:33:47 -070056 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 Hackbornd4ac8d72012-09-27 23:20:10 -070064 if (switching) pw.print(" SWITCHING");
65 if (initializing) pw.print(" INITIALIZING");
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -080066 if (unlocked) {
67 pw.print(" UNLOCKED");
68 } else {
69 pw.print(" LOCKED");
70 }
Dianne Hackbornd4ac8d72012-09-27 23:20:10 -070071 pw.println();
Dianne Hackborn80a4af22012-08-27 19:18:31 -070072 }
73}