John Spurlock | 48f37ec | 2012-10-05 16:32:51 -0400 | [diff] [blame] | 1 | package com.android.systemui.statusbar.policy; |
| 2 | |
| 3 | import android.app.ActivityManager; |
| 4 | import android.content.BroadcastReceiver; |
| 5 | import android.content.Context; |
| 6 | import android.content.Intent; |
| 7 | import android.content.IntentFilter; |
| 8 | |
| 9 | public class CurrentUserTracker extends BroadcastReceiver { |
| 10 | |
| 11 | private int mCurrentUserId; |
| 12 | |
| 13 | public CurrentUserTracker(Context context) { |
| 14 | IntentFilter filter = new IntentFilter(Intent.ACTION_USER_SWITCHED); |
| 15 | context.registerReceiver(this, filter); |
| 16 | mCurrentUserId = ActivityManager.getCurrentUser(); |
| 17 | } |
| 18 | |
| 19 | public int getCurrentUserId() { |
| 20 | return mCurrentUserId; |
| 21 | } |
| 22 | |
| 23 | @Override |
| 24 | public void onReceive(Context context, Intent intent) { |
| 25 | if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) { |
| 26 | mCurrentUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0); |
| 27 | } |
| 28 | } |
| 29 | } |