Search in sources :

Example 6 with UserHandle

use of android.os.UserHandle in project platform_frameworks_base by android.

the class LockSettingsService method onUnlockUser.

public void onUnlockUser(final int userId) {
    // Hide notification first, as tie managed profile lock takes time
    hideEncryptionNotification(new UserHandle(userId));
    if (mUserManager.getUserInfo(userId).isManagedProfile()) {
        // As tieManagedProfileLockIfNecessary() may try to unlock user, we should not do it
        // in onUnlockUser() synchronously, otherwise it may cause a deadlock
        mHandler.post(new Runnable() {

            @Override
            public void run() {
                tieManagedProfileLockIfNecessary(userId, null);
            }
        });
    }
    // Now we have unlocked the parent user we should show notifications
    // about any profiles that exist.
    List<UserInfo> profiles = mUserManager.getProfiles(userId);
    for (int i = 0; i < profiles.size(); i++) {
        UserInfo profile = profiles.get(i);
        final boolean isSecure = mStorage.hasPassword(profile.id) || mStorage.hasPattern(profile.id);
        if (isSecure && profile.isManagedProfile()) {
            UserHandle userHandle = profile.getUserHandle();
            if (!mUserManager.isUserUnlockingOrUnlocked(userHandle) && !mUserManager.isQuietModeEnabled(userHandle)) {
                showEncryptionNotificationForProfile(userHandle);
            }
        }
    }
}
Also used : UserHandle(android.os.UserHandle) UserInfo(android.content.pm.UserInfo)

Example 7 with UserHandle

use of android.os.UserHandle in project platform_frameworks_base by android.

the class LockSettingsService method maybeShowEncryptionNotifications.

/**
     * If the account is credential-encrypted, show notification requesting the user to unlock
     * the device.
     */
private void maybeShowEncryptionNotifications() {
    final List<UserInfo> users = mUserManager.getUsers();
    for (int i = 0; i < users.size(); i++) {
        UserInfo user = users.get(i);
        UserHandle userHandle = user.getUserHandle();
        final boolean isSecure = mStorage.hasPassword(user.id) || mStorage.hasPattern(user.id);
        if (isSecure && !mUserManager.isUserUnlockingOrUnlocked(userHandle)) {
            if (!user.isManagedProfile()) {
            // When the user is locked, we communicate it loud-and-clear
            // on the lockscreen; we only show a notification below for
            // locked managed profiles.
            } else {
                UserInfo parent = mUserManager.getProfileParent(user.id);
                if (parent != null && mUserManager.isUserUnlockingOrUnlocked(parent.getUserHandle()) && !mUserManager.isQuietModeEnabled(userHandle)) {
                    // Only show notifications for managed profiles once their parent
                    // user is unlocked.
                    showEncryptionNotificationForProfile(userHandle);
                }
            }
        }
    }
}
Also used : UserHandle(android.os.UserHandle) UserInfo(android.content.pm.UserInfo)

Example 8 with UserHandle

use of android.os.UserHandle in project platform_frameworks_base by android.

the class SyncManager method whiteListExistingSyncAdaptersIfNeeded.

private void whiteListExistingSyncAdaptersIfNeeded() {
    if (!mSyncStorageEngine.shouldGrantSyncAdaptersAccountAccess()) {
        return;
    }
    List<UserInfo> users = mUserManager.getUsers(true);
    final int userCount = users.size();
    for (int i = 0; i < userCount; i++) {
        UserHandle userHandle = users.get(i).getUserHandle();
        final int userId = userHandle.getIdentifier();
        for (RegisteredServicesCache.ServiceInfo<SyncAdapterType> service : mSyncAdapters.getAllServices(userId)) {
            String packageName = service.componentName.getPackageName();
            for (Account account : mAccountManager.getAccountsByTypeAsUser(service.type.accountType, userHandle)) {
                if (!canAccessAccount(account, packageName, userId)) {
                    mAccountManager.updateAppPermission(account, AccountManager.ACCOUNT_ACCESS_TOKEN_TYPE, service.uid, true);
                }
            }
        }
    }
}
Also used : Account(android.accounts.Account) UserHandle(android.os.UserHandle) UserInfo(android.content.pm.UserInfo) SyncAdapterType(android.content.SyncAdapterType) EndPoint(com.android.server.content.SyncStorageEngine.EndPoint) RegisteredServicesCache(android.content.pm.RegisteredServicesCache)

Example 9 with UserHandle

use of android.os.UserHandle in project platform_frameworks_base by android.

the class DreamController method startDream.

public void startDream(Binder token, ComponentName name, boolean isTest, boolean canDoze, int userId, PowerManager.WakeLock wakeLock) {
    stopDream(true);
    Trace.traceBegin(Trace.TRACE_TAG_POWER, "startDream");
    try {
        // Close the notification shade. No need to send to all, but better to be explicit.
        mContext.sendBroadcastAsUser(mCloseNotificationShadeIntent, UserHandle.ALL);
        Slog.i(TAG, "Starting dream: name=" + name + ", isTest=" + isTest + ", canDoze=" + canDoze + ", userId=" + userId);
        mCurrentDream = new DreamRecord(token, name, isTest, canDoze, userId, wakeLock);
        mDreamStartTime = SystemClock.elapsedRealtime();
        MetricsLogger.visible(mContext, mCurrentDream.mCanDoze ? MetricsEvent.DOZING : MetricsEvent.DREAMING);
        try {
            mIWindowManager.addWindowToken(token, WindowManager.LayoutParams.TYPE_DREAM);
        } catch (RemoteException ex) {
            Slog.e(TAG, "Unable to add window token for dream.", ex);
            stopDream(true);
            return;
        }
        Intent intent = new Intent(DreamService.SERVICE_INTERFACE);
        intent.setComponent(name);
        intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        try {
            if (!mContext.bindServiceAsUser(intent, mCurrentDream, Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE, new UserHandle(userId))) {
                Slog.e(TAG, "Unable to bind dream service: " + intent);
                stopDream(true);
                return;
            }
        } catch (SecurityException ex) {
            Slog.e(TAG, "Unable to bind dream service: " + intent, ex);
            stopDream(true);
            return;
        }
        mCurrentDream.mBound = true;
        mHandler.postDelayed(mStopUnconnectedDreamRunnable, DREAM_CONNECTION_TIMEOUT);
    } finally {
        Trace.traceEnd(Trace.TRACE_TAG_POWER);
    }
}
Also used : UserHandle(android.os.UserHandle) Intent(android.content.Intent) RemoteException(android.os.RemoteException)

Example 10 with UserHandle

use of android.os.UserHandle in project platform_frameworks_base by android.

the class RemoteDisplayProviderProxy method bind.

private void bind() {
    if (!mBound) {
        if (DEBUG) {
            Slog.d(TAG, this + ": Binding");
        }
        Intent service = new Intent(RemoteDisplayState.SERVICE_INTERFACE);
        service.setComponent(mComponentName);
        try {
            mBound = mContext.bindServiceAsUser(service, this, Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE, new UserHandle(mUserId));
            if (!mBound && DEBUG) {
                Slog.d(TAG, this + ": Bind failed");
            }
        } catch (SecurityException ex) {
            if (DEBUG) {
                Slog.d(TAG, this + ": Bind failed", ex);
            }
        }
    }
}
Also used : UserHandle(android.os.UserHandle) Intent(android.content.Intent)

Aggregations

UserHandle (android.os.UserHandle)568 Intent (android.content.Intent)231 RemoteException (android.os.RemoteException)163 PendingIntent (android.app.PendingIntent)132 ComponentName (android.content.ComponentName)69 Context (android.content.Context)68 UserInfo (android.content.pm.UserInfo)66 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)62 Bundle (android.os.Bundle)50 IBinder (android.os.IBinder)49 UserManager (android.os.UserManager)44 PackageManager (android.content.pm.PackageManager)40 ApplicationInfo (android.content.pm.ApplicationInfo)30 IOException (java.io.IOException)30 ArrayList (java.util.ArrayList)30 ActivityNotFoundException (android.content.ActivityNotFoundException)28 Notification (android.app.Notification)27 ServiceConnection (android.content.ServiceConnection)27 IPackageManager (android.content.pm.IPackageManager)27 Pair (android.util.Pair)23