FileDocCategorySizeDatePackage
CurrentUserTracker.javaAPI DocAndroid 5.1 API2025Thu Mar 12 22:22:42 GMT 2015com.android.systemui.settings

CurrentUserTracker

public abstract class CurrentUserTracker extends android.content.BroadcastReceiver

Fields Summary
private android.content.Context
mContext
private int
mCurrentUserId
Constructors Summary
public CurrentUserTracker(android.content.Context context)

        mContext = context;
    
Methods Summary
public intgetCurrentUserId()

        return mCurrentUserId;
    
public booleanisCurrentUserOwner()

        return mCurrentUserId == UserHandle.USER_OWNER;
    
public voidonReceive(android.content.Context context, android.content.Intent intent)

        if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) {
            int oldUserId = mCurrentUserId;
            mCurrentUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
            if (oldUserId != mCurrentUserId) {
                onUserSwitched(mCurrentUserId);
            }
        }
    
public abstract voidonUserSwitched(int newUserId)

public voidstartTracking()

        mCurrentUserId = ActivityManager.getCurrentUser();
        IntentFilter filter = new IntentFilter(Intent.ACTION_USER_SWITCHED);
        mContext.registerReceiver(this, filter);
    
public voidstopTracking()

        mContext.unregisterReceiver(this);