Search in sources :

Example 1 with UserHandle

use of android.os.UserHandle in project android_frameworks_base by ParanoidAndroid.

the class QuickSettings method startSettingsActivity.

private void startSettingsActivity(Intent intent, boolean onlyProvisioned) {
    if (onlyProvisioned && !getService().isDeviceProvisioned())
        return;
    try {
        // Dismiss the lock screen when Settings starts.
        ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
    } catch (RemoteException e) {
    }
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
    collapsePanels();
}
Also used : UserHandle(android.os.UserHandle) RemoteException(android.os.RemoteException)

Example 2 with UserHandle

use of android.os.UserHandle in project android_frameworks_base by ParanoidAndroid.

the class UsbConfirmActivity method onClick.

public void onClick(DialogInterface dialog, int which) {
    if (which == AlertDialog.BUTTON_POSITIVE) {
        try {
            IBinder b = ServiceManager.getService(USB_SERVICE);
            IUsbManager service = IUsbManager.Stub.asInterface(b);
            final int uid = mResolveInfo.activityInfo.applicationInfo.uid;
            final int userId = UserHandle.myUserId();
            boolean alwaysUse = mAlwaysUse.isChecked();
            Intent intent = null;
            if (mDevice != null) {
                intent = new Intent(UsbManager.ACTION_USB_DEVICE_ATTACHED);
                intent.putExtra(UsbManager.EXTRA_DEVICE, mDevice);
                // grant permission for the device
                service.grantDevicePermission(mDevice, uid);
                // set or clear default setting
                if (alwaysUse) {
                    service.setDevicePackage(mDevice, mResolveInfo.activityInfo.packageName, userId);
                } else {
                    service.setDevicePackage(mDevice, null, userId);
                }
            } else if (mAccessory != null) {
                intent = new Intent(UsbManager.ACTION_USB_ACCESSORY_ATTACHED);
                intent.putExtra(UsbManager.EXTRA_ACCESSORY, mAccessory);
                // grant permission for the accessory
                service.grantAccessoryPermission(mAccessory, uid);
                // set or clear default setting
                if (alwaysUse) {
                    service.setAccessoryPackage(mAccessory, mResolveInfo.activityInfo.packageName, userId);
                } else {
                    service.setAccessoryPackage(mAccessory, null, userId);
                }
            }
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setComponent(new ComponentName(mResolveInfo.activityInfo.packageName, mResolveInfo.activityInfo.name));
            startActivityAsUser(intent, new UserHandle(userId));
        } catch (Exception e) {
            Log.e(TAG, "Unable to start activity", e);
        }
    }
    finish();
}
Also used : IBinder(android.os.IBinder) UserHandle(android.os.UserHandle) Intent(android.content.Intent) ComponentName(android.content.ComponentName) IUsbManager(android.hardware.usb.IUsbManager)

Example 3 with UserHandle

use of android.os.UserHandle in project android_frameworks_base by ParanoidAndroid.

the class FaceUnlock method start.

/**
     * Binds to the Face Unlock service.  Face Unlock will be started when the bind completes.  The
     * Face Unlock view is displayed to hide the backup lock while the service is starting up.
     * Called on the UI thread.
     */
public boolean start() {
    if (DEBUG)
        Log.d(TAG, "start()");
    if (mHandler.getLooper() != Looper.myLooper()) {
        Log.e(TAG, "start() called off of the UI thread");
    }
    if (mIsRunning) {
        Log.w(TAG, "start() called when already running");
    }
    if (!mBoundToService) {
        Log.d(TAG, "Binding to Face Unlock service for user=" + mLockPatternUtils.getCurrentUser());
        mContext.bindServiceAsUser(new Intent(IFaceLockInterface.class.getName()), mConnection, Context.BIND_AUTO_CREATE, new UserHandle(mLockPatternUtils.getCurrentUser()));
        mBoundToService = true;
    } else {
        Log.w(TAG, "Attempt to bind to Face Unlock when already bound");
    }
    mIsRunning = true;
    return true;
}
Also used : UserHandle(android.os.UserHandle) Intent(android.content.Intent)

Example 4 with UserHandle

use of android.os.UserHandle in project android_frameworks_base by ParanoidAndroid.

the class KeyguardAccountView method asyncCheckPassword.

private void asyncCheckPassword() {
    mCallback.userActivity(AWAKE_POKE_MILLIS);
    final String login = mLogin.getText().toString();
    final String password = mPassword.getText().toString();
    Account account = findIntendedAccount(login);
    if (account == null) {
        postOnCheckPasswordResult(false);
        return;
    }
    getProgressDialog().show();
    Bundle options = new Bundle();
    options.putString(AccountManager.KEY_PASSWORD, password);
    AccountManager.get(mContext).confirmCredentialsAsUser(account, options, null, /* activity */
    new AccountManagerCallback<Bundle>() {

        public void run(AccountManagerFuture<Bundle> future) {
            try {
                mCallback.userActivity(AWAKE_POKE_MILLIS);
                final Bundle result = future.getResult();
                final boolean verified = result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT);
                postOnCheckPasswordResult(verified);
            } catch (OperationCanceledException e) {
                postOnCheckPasswordResult(false);
            } catch (IOException e) {
                postOnCheckPasswordResult(false);
            } catch (AuthenticatorException e) {
                postOnCheckPasswordResult(false);
            } finally {
                mLogin.post(new Runnable() {

                    public void run() {
                        getProgressDialog().hide();
                    }
                });
            }
        }
    }, null, /* handler */
    new UserHandle(mLockPatternUtils.getCurrentUser()));
}
Also used : Account(android.accounts.Account) Bundle(android.os.Bundle) OperationCanceledException(android.accounts.OperationCanceledException) UserHandle(android.os.UserHandle) AuthenticatorException(android.accounts.AuthenticatorException) IOException(java.io.IOException)

Example 5 with UserHandle

use of android.os.UserHandle in project android_frameworks_base by ParanoidAndroid.

the class KeyguardActivityLauncher method startActivityForCurrentUser.

private void startActivityForCurrentUser(final Intent intent, final Bundle options, Handler worker, final Runnable onStarted) {
    final UserHandle user = new UserHandle(UserHandle.USER_CURRENT);
    if (worker == null || onStarted == null) {
        getContext().startActivityAsUser(intent, options, user);
        return;
    }
    // if worker + onStarted are supplied, run blocking activity launch call in the background
    worker.post(new Runnable() {

        @Override
        public void run() {
            try {
                WaitResult result = ActivityManagerNative.getDefault().startActivityAndWait(null, /*caller*/
                null, /*caller pkg*/
                intent, intent.resolveTypeIfNeeded(getContext().getContentResolver()), null, /*resultTo*/
                null, /*resultWho*/
                0, /*requestCode*/
                Intent.FLAG_ACTIVITY_NEW_TASK, null, /*profileFile*/
                null, /*profileFd*/
                options, user.getIdentifier());
                if (DEBUG)
                    Log.d(TAG, String.format("waitResult[%s,%s,%s,%s] at %s", result.result, result.thisTime, result.totalTime, result.who, SystemClock.uptimeMillis()));
            } catch (RemoteException e) {
                Log.w(TAG, "Error starting activity", e);
                return;
            }
            try {
                onStarted.run();
            } catch (Throwable t) {
                Log.w(TAG, "Error running onStarted callback", t);
            }
        }
    });
}
Also used : WaitResult(android.app.IActivityManager.WaitResult) UserHandle(android.os.UserHandle) RemoteException(android.os.RemoteException)

Aggregations

UserHandle (android.os.UserHandle)1087 Intent (android.content.Intent)306 RemoteException (android.os.RemoteException)205 Test (org.junit.Test)165 UserInfo (android.content.pm.UserInfo)152 PendingIntent (android.app.PendingIntent)134 Bundle (android.os.Bundle)127 Context (android.content.Context)126 ApplicationInfo (android.content.pm.ApplicationInfo)93 ArrayList (java.util.ArrayList)91 PackageManager (android.content.pm.PackageManager)86 UserManager (android.os.UserManager)85 ComponentName (android.content.ComponentName)82 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)82 Drawable (android.graphics.drawable.Drawable)61 IBinder (android.os.IBinder)49 IOException (java.io.IOException)45 Config (org.robolectric.annotation.Config)41 Account (android.accounts.Account)39 ResolveInfo (android.content.pm.ResolveInfo)37