private RunningState(Context context) { mApplicationContext = context.getApplicationContext(); mAm = (ActivityManager) mApplicationContext.getSystemService(Context.ACTIVITY_SERVICE); mPm = mApplicationContext.getPackageManager(); mUm = (UserManager) mApplicationContext.getSystemService(Context.USER_SERVICE); mMyUserId = UserHandle.myUserId(); mHideManagedProfiles = mMyUserId != UserHandle.USER_OWNER; mResumed = false; mBackgroundThread = new HandlerThread("RunningState:Background"); mBackgroundThread.start(); mBackgroundHandler = new BackgroundHandler(mBackgroundThread.getLooper()); mUmBroadcastReceiver.register(mApplicationContext); }
void resume(OnRefreshUiListener listener) { synchronized (mLock) { mResumed = true; mRefreshUiListener = listener; boolean usersChanged = mUmBroadcastReceiver.checkUsersChangedLocked(); boolean configChanged = mInterestingConfigChanges.applyNewConfig(mApplicationContext.getResources()); if (usersChanged || configChanged) { mHaveData = false; mBackgroundHandler.removeMessages(MSG_RESET_CONTENTS); mBackgroundHandler.removeMessages(MSG_UPDATE_CONTENTS); mBackgroundHandler.sendEmptyMessage(MSG_RESET_CONTENTS); } if (!mBackgroundHandler.hasMessages(MSG_UPDATE_CONTENTS)) { mBackgroundHandler.sendEmptyMessage(MSG_UPDATE_CONTENTS); } mHandler.sendEmptyMessage(MSG_UPDATE_TIME); } }