public PermissionMonitor(Context context, INetworkManagementService netd) { mContext = context; mPackageManager = context.getPackageManager(); mUserManager = UserManager.get(context); mNetd = netd; mIntentReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); int user = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL); int appUid = intent.getIntExtra(Intent.EXTRA_UID, -1); Uri appData = intent.getData(); String appName = appData != null ? appData.getSchemeSpecificPart() : null; if (Intent.ACTION_USER_ADDED.equals(action)) { onUserAdded(user); } else if (Intent.ACTION_USER_REMOVED.equals(action)) { onUserRemoved(user); } else if (Intent.ACTION_PACKAGE_ADDED.equals(action)) { onAppAdded(appName, appUid); } else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) { onAppRemoved(appUid); } } }; }
private void createHeader() { Activity activity = getActivity(); FrameLayout pinnedHeader = (FrameLayout) mRootView.findViewById(R.id.pinned_header); mSpinnerHeader = (ViewGroup) activity.getLayoutInflater().inflate(R.layout.apps_filter_spinner, pinnedHeader, false); mFilterSpinner = (Spinner) mSpinnerHeader.findViewById(R.id.filter_spinner); mFilterAdapter = new FilterSpinnerAdapter(this); mFilterSpinner.setAdapter(mFilterAdapter); mFilterSpinner.setOnItemSelectedListener(this); pinnedHeader.addView(mSpinnerHeader, 0); mFilterAdapter.enableFilter(getDefaultFilter()); if (mListType == LIST_TYPE_MAIN || mListType == LIST_TYPE_NOTIFICATION) { if (UserManager.get(getActivity()).getUserProfiles().size() > 1) { mFilterAdapter.enableFilter(FILTER_APPS_PERSONAL); mFilterAdapter.enableFilter(FILTER_APPS_WORK); } } if (mListType == LIST_TYPE_NOTIFICATION) { mFilterAdapter.enableFilter(FILTER_APPS_BLOCKED); mFilterAdapter.enableFilter(FILTER_APPS_PRIORITY); mFilterAdapter.enableFilter(FILTER_APPS_SENSITIVE); mFilterAdapter.enableFilter(FILTER_APPS_NO_PEEKING); } if (mListType == LIST_TYPE_HIGH_POWER) { mFilterAdapter.enableFilter(FILTER_APPS_POWER_WHITELIST_ALL); } if (mListType == LIST_TYPE_STORAGE) { mApplications.setOverrideFilter(new VolumeFilter(mVolumeUuid)); } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (UserManager.get(getActivity()).hasUserRestriction(UserManager.DISALLOW_FACTORY_RESET)) { return inflater.inflate(R.layout.master_clear_disallowed_screen, null); } mContentView = inflater.inflate(R.layout.master_clear_confirm, null); establishFinalConfirmationState(); return mContentView; }
@Override public void onClick(DialogInterface dialog, int which) { if (mReason == UNLAUNCHABLE_REASON_QUIET_MODE && which == DialogInterface.BUTTON_POSITIVE) { if (UserManager.get(this).trySetQuietModeDisabled(mUserId, mTarget) && mTarget != null) { try { startIntentSenderForResult(mTarget, -1, null, 0, 0, 0); } catch (IntentSender.SendIntentException e) { /* ignore */ } } } }