blob: 225ebc1af788bf2269db38f6d061a52ec6e8b9f3 [file] [log] [blame]
Daniel Sandler50a53132012-10-24 15:02:27 -04001/*
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
John Spurlock48f37ec2012-10-05 16:32:51 -040017package com.android.systemui.statusbar.policy;
18
19import android.app.ActivityManager;
20import android.content.BroadcastReceiver;
21import android.content.Context;
22import android.content.Intent;
23import android.content.IntentFilter;
24
25public class CurrentUserTracker extends BroadcastReceiver {
26
27 private int mCurrentUserId;
28
29 public CurrentUserTracker(Context context) {
30 IntentFilter filter = new IntentFilter(Intent.ACTION_USER_SWITCHED);
31 context.registerReceiver(this, filter);
32 mCurrentUserId = ActivityManager.getCurrentUser();
33 }
34
35 public int getCurrentUserId() {
36 return mCurrentUserId;
37 }
38
39 @Override
40 public void onReceive(Context context, Intent intent) {
41 if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) {
42 mCurrentUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
43 }
44 }
45}