blob: b3d82bca2de8cc721b2bd157cdd88cafe7592d84 [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;
Dianne Hackborn80a4af22012-08-27 19:18:31 -070043
Amith Yamasani37a40c22015-06-17 13:25:42 -070044 /**
45 * The last time that a provider was reported to usage stats as being brought to important
46 * foreground procstate.
47 */
48 public final ArrayMap<String,Long> mProviderLastReportedFg = new ArrayMap<>();
49
50 public UserState(UserHandle handle, boolean initial) {
Dianne Hackborn80a4af22012-08-27 19:18:31 -070051 mHandle = handle;
52 }
53
54 void dump(String prefix, PrintWriter pw) {
Dianne Hackborn36d337a2012-10-08 14:33:47 -070055 pw.print(prefix); pw.print("mState=");
56 switch (mState) {
57 case STATE_BOOTING: pw.print("BOOTING"); break;
58 case STATE_RUNNING: pw.print("RUNNING"); break;
59 case STATE_STOPPING: pw.print("STOPPING"); break;
60 case STATE_SHUTDOWN: pw.print("SHUTDOWN"); break;
61 default: pw.print(mState); break;
62 }
Dianne Hackbornd4ac8d72012-09-27 23:20:10 -070063 if (switching) pw.print(" SWITCHING");
64 if (initializing) pw.print(" INITIALIZING");
65 pw.println();
Dianne Hackborn80a4af22012-08-27 19:18:31 -070066 }
67}