Example usage for android.os UserHandle UserHandle

List of usage examples for android.os UserHandle UserHandle

Introduction

In this page you can find the example usage for android.os UserHandle UserHandle.

Prototype

public UserHandle(Parcel in) 

Source Link

Document

Instantiate a new UserHandle from the data in a Parcel that was previously written with #writeToParcel(Parcel,int) .

Usage

From source file:com.android.tv.settings.MainFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    mAuthenticatorHelper = new AuthenticatorHelper(getContext(), new UserHandle(UserHandle.myUserId()),
            new AuthenticatorHelper.OnAccountsUpdateListener() {
                @Override//from  w ww  .  jav a  2s  . co m
                public void onAccountsUpdate(UserHandle userHandle) {
                    updateAccounts();
                }
            });
    mBtAdapter = BluetoothAdapter.getDefaultAdapter();
    mConnectivityListener = new ConnectivityListener(getContext(), new ConnectivityListener.Listener() {
        @Override
        public void onConnectivityChange() {
            updateWifi();
        }
    });

    final TvInputManager manager = (TvInputManager) getContext().getSystemService(Context.TV_INPUT_SERVICE);
    if (manager != null) {
        for (final TvInputInfo input : manager.getTvInputList()) {
            if (input.isPassthroughInput()) {
                mInputSettingNeeded = true;
            }
        }
    }
    super.onCreate(savedInstanceState);
}

From source file:com.android.tv.settings.users.AppRestrictionsFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mUser = new UserHandle(savedInstanceState.getInt(EXTRA_USER_ID));
    } else {// ww w . j ava  2s  .c  o  m
        Bundle args = getArguments();
        if (args != null) {
            if (args.containsKey(EXTRA_USER_ID)) {
                mUser = new UserHandle(args.getInt(EXTRA_USER_ID));
            }
            mNewUser = args.getBoolean(EXTRA_NEW_USER, false);
        }
    }

    if (mUser == null) {
        mUser = android.os.Process.myUserHandle();
    }

    mHelper = new AppRestrictionsHelper(getContext(), mUser);
    mHelper.setLeanback(true);
    mPackageManager = getActivity().getPackageManager();
    mIPm = AppGlobals.getPackageManager();
    mUserManager = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
    mRestrictedProfile = mUserManager.getUserInfo(mUser.getIdentifier()).isRestricted();
    try {
        mSysPackageInfo = mPackageManager.getPackageInfo("android", PackageManager.GET_SIGNATURES);
    } catch (PackageManager.NameNotFoundException nnfe) {
        Log.e(TAG, "Could not find system package signatures", nnfe);
    }
    mAppList = getAppPreferenceGroup();
    mAppList.setOrderingAsAdded(false);
}

From source file:com.android.managedprovisioning.ProfileOwnerProvisioningService.java

/**
 * Notify the mdm that provisioning has completed. When the mdm has received the intent, stop
 * the service and notify the {@link ProfileOwnerProvisioningActivity} so that it can finish
 * itself./*from ww  w.j a v a  2s.  co  m*/
 */
private void notifyMdmAndCleanup() {
    // Set DPM userProvisioningState appropriately and persist mParams for use during
    // FinalizationActivity if necessary.
    mUtils.markUserProvisioningStateInitiallyDone(this, mParams);

    if (mParams.provisioningAction.equals(ACTION_PROVISION_MANAGED_PROFILE)) {
        // Set the user_setup_complete flag on the managed-profile as setup-wizard is never run
        // for that user. This is not relevant for other cases since
        // Utils.markUserProvisioningStateInitiallyDone() communicates provisioning state to
        // setup-wizard via DPM.setUserProvisioningState() if necessary.
        mUtils.markUserSetupComplete(this, mManagedProfileOrUserInfo.id);
    }

    // If profile owner provisioning was started after current user setup is completed, then we
    // can directly send the ACTION_PROFILE_PROVISIONING_COMPLETE broadcast to the MDM.
    // But if the provisioning was started as part of setup wizard flow, we signal setup-wizard
    // should shutdown via DPM.setUserProvisioningState(), which will result in a finalization
    // intent being sent to us once setup-wizard finishes. As part of the finalization intent
    // handling we then broadcast ACTION_PROFILE_PROVISIONING_COMPLETE.
    if (mUtils.isUserSetupCompleted(this)) {
        UserHandle managedUserHandle = new UserHandle(mManagedProfileOrUserInfo.id);

        // Use an ordered broadcast, so that we only finish when the mdm has received it.
        // Avoids a lag in the transition between provisioning and the mdm.
        BroadcastReceiver mdmReceivedSuccessReceiver = new MdmReceivedSuccessReceiver(mParams.accountToMigrate,
                mParams.deviceAdminComponentName.getPackageName());

        Intent completeIntent = new Intent(ACTION_PROFILE_PROVISIONING_COMPLETE);
        completeIntent.setComponent(mParams.deviceAdminComponentName);
        completeIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES | Intent.FLAG_RECEIVER_FOREGROUND);
        if (mParams.adminExtrasBundle != null) {
            completeIntent.putExtra(EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE, mParams.adminExtrasBundle);
        }

        sendOrderedBroadcastAsUser(completeIntent, managedUserHandle, null, mdmReceivedSuccessReceiver, null,
                Activity.RESULT_OK, null, null);
        ProvisionLogger.logd(
                "Provisioning complete broadcast has been sent to user " + managedUserHandle.getIdentifier());
    }
}