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();
}
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();
}
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;
}
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()));
}
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);
}
}
});
}
Aggregations