Java Code Examples for android.os.UserManager#get()

The following examples show how to use android.os.UserManager#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FingerprintService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public FingerprintService(Context context) {
    super(context);
    mContext = context;
    mKeyguardPackage = ComponentName.unflattenFromString(context.getResources().getString(
            com.android.internal.R.string.config_keyguardComponent)).getPackageName();
    mAppOps = context.getSystemService(AppOpsManager.class);
    mPowerManager = mContext.getSystemService(PowerManager.class);
    mAlarmManager = mContext.getSystemService(AlarmManager.class);
    mContext.registerReceiver(mLockoutReceiver, new IntentFilter(ACTION_LOCKOUT_RESET),
            RESET_FINGERPRINT_LOCKOUT, null /* handler */);
    mUserManager = UserManager.get(mContext);
    mTimedLockoutCleared = new SparseBooleanArray();
    mFailedAttempts = new SparseIntArray();
    mStatusBarService = IStatusBarService.Stub.asInterface(
            ServiceManager.getService(Context.STATUS_BAR_SERVICE));
    mActivityManager = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE))
            .getService();
}
 
Example 2
Source File: SettingsProvider.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onCreate() {
    Settings.setInSystemServer();
    synchronized (mLock) {
        mUserManager = UserManager.get(getContext());
        mPackageManager = AppGlobals.getPackageManager();
        mHandlerThread = new HandlerThread(LOG_TAG,
                Process.THREAD_PRIORITY_BACKGROUND);
        mHandlerThread.start();
        mHandler = new Handler(mHandlerThread.getLooper());
        mSettingsRegistry = new SettingsRegistry();
    }
    mHandler.post(() -> {
        registerBroadcastReceivers();
        startWatchingUserRestrictionChanges();
    });
    ServiceManager.addService("settings", new SettingsService(this));
    return true;
}
 
Example 3
Source File: CameraServiceProxy.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public void onStart() {
    mUserManager = UserManager.get(mContext);
    if (mUserManager == null) {
        // Should never see this unless someone messes up the SystemServer service boot order.
        throw new IllegalStateException("UserManagerService must start before" +
                " CameraServiceProxy!");
    }

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_USER_ADDED);
    filter.addAction(Intent.ACTION_USER_REMOVED);
    filter.addAction(Intent.ACTION_USER_INFO_CHANGED);
    filter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED);
    filter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED);
    mContext.registerReceiver(mIntentReceiver, filter);

    publishBinderService(CAMERA_SERVICE_PROXY_BINDER_NAME, mCameraServiceProxy);
    publishLocalService(CameraServiceProxy.class, this);

    CameraStatsJobService.schedule(mContext);
}
 
Example 4
Source File: FingerprintService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
boolean isCurrentUserOrProfile(int userId) {
    UserManager um = UserManager.get(mContext);
    if (um == null) {
        Slog.e(TAG, "Unable to acquire UserManager");
        return false;
    }

    final long token = Binder.clearCallingIdentity();
    try {
        // Allow current user or profiles of the current user...
        for (int profileId : um.getEnabledProfileIds(ActivityManager.getCurrentUser())) {
            if (profileId == userId) {
                return true;
            }
        }
    } finally {
        Binder.restoreCallingIdentity(token);
    }

    return false;
}
 
Example 5
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
UserManager getUserManager() {
    synchronized (mLock) {
        if (mUserManager == null) {
            mUserManager = UserManager.get(mContext);
        }
        return mUserManager;
    }
}
 
Example 6
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
UserManager getUserManager() {
    synchronized (mLock) {
        if (mUserManager == null) {
            mUserManager = UserManager.get(mContext);
        }
        return mUserManager;
    }
}
 
Example 7
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
UserManager getUserManager() {
    synchronized (mLock) {
        if (mUserManager == null) {
            mUserManager = UserManager.get(mContext);
        }
        return mUserManager;
    }
}
 
Example 8
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
UserManager getUserManager() {
    synchronized (mLock) {
        if (mUserManager == null) {
            mUserManager = UserManager.get(mContext);
        }
        return mUserManager;
    }
}
 
Example 9
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
UserManager getUserManager() {
    synchronized (mLock) {
        if (mUserManager == null) {
            mUserManager = UserManager.get(mContext);
        }
        return mUserManager;
    }
}
 
Example 10
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
UserManager getUserManager() {
    synchronized (mLock) {
        if (mUserManager == null) {
            mUserManager = UserManager.get(mContext);
        }
        return mUserManager;
    }
}
 
Example 11
Source File: FingerprintService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
int getEffectiveUserId(int userId) {
    UserManager um = UserManager.get(mContext);
    if (um != null) {
        final long callingIdentity = Binder.clearCallingIdentity();
        userId = um.getCredentialOwnerProfile(userId);
        Binder.restoreCallingIdentity(callingIdentity);
    } else {
        Slog.e(TAG, "Unable to acquire UserManager");
    }
    return userId;
}
 
Example 12
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
UserManager getUserManager() {
    synchronized (mLock) {
        if (mUserManager == null) {
            mUserManager = UserManager.get(mContext);
        }
        return mUserManager;
    }
}
 
Example 13
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
UserManager getUserManager() {
    synchronized (mLock) {
        if (mUserManager == null) {
            mUserManager = UserManager.get(mContext);
        }
        return mUserManager;
    }
}
 
Example 14
Source File: LockSettingsStorage.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public Map<Integer, List<Long>> listSyntheticPasswordHandlesForAllUsers(String stateName) {
    Map<Integer, List<Long>> result = new ArrayMap<>();
    final UserManager um = UserManager.get(mContext);
    for (UserInfo user : um.getUsers(false)) {
        result.put(user.id, listSyntheticPasswordHandlesForUser(stateName, user.id));
    }
    return result;
}
 
Example 15
Source File: ActivityStartInterceptor.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Intercept the launch intent based on various signals. If an interception happened the
 * internal variables get assigned and need to be read explicitly by the caller.
 *
 * @return true if an interception occurred
 */
boolean intercept(Intent intent, ResolveInfo rInfo, ActivityInfo aInfo, String resolvedType,
        TaskRecord inTask, int callingPid, int callingUid, ActivityOptions activityOptions) {
    mUserManager = UserManager.get(mServiceContext);

    mIntent = intent;
    mCallingPid = callingPid;
    mCallingUid = callingUid;
    mRInfo = rInfo;
    mAInfo = aInfo;
    mResolvedType = resolvedType;
    mInTask = inTask;
    mActivityOptions = activityOptions;

    if (interceptSuspendedPackageIfNeeded()) {
        // Skip the rest of interceptions as the package is suspended by device admin so
        // no user action can undo this.
        return true;
    }
    if (interceptQuietProfileIfNeeded()) {
        // If work profile is turned off, skip the work challenge since the profile can only
        // be unlocked when profile's user is running.
        return true;
    }
    if (interceptHarmfulAppIfNeeded()) {
        // If the app has a "harmful app" warning associated with it, we should ask to uninstall
        // before issuing the work challenge.
        return true;
    }
    return interceptWorkProfileChallengeIfNeeded();
}
 
Example 16
Source File: ApplicationPackageManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
UserManager getUserManager() {
    synchronized (mLock) {
        if (mUserManager == null) {
            mUserManager = UserManager.get(mContext);
        }
        return mUserManager;
    }
}
 
Example 17
Source File: SettingsProvider.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreate() {
    mBackupManager = new BackupManager(getContext());
    mUserManager = UserManager.get(getContext());

    setAppOps(AppOpsManager.OP_NONE, AppOpsManager.OP_WRITE_SETTINGS);
    establishDbTracking(UserHandle.USER_OWNER);

    IntentFilter userFilter = new IntentFilter();
    userFilter.addAction(Intent.ACTION_USER_REMOVED);
    userFilter.addAction(Intent.ACTION_USER_ADDED);
    getContext().registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            final int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
                    UserHandle.USER_OWNER);
            if (intent.getAction().equals(Intent.ACTION_USER_REMOVED)) {
                onUserRemoved(userHandle);
            } else if (intent.getAction().equals(Intent.ACTION_USER_ADDED)) {
                onProfilesChanged();
            }
        }
    }, userFilter);

    onProfilesChanged();

    return true;
}
 
Example 18
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
UserManager getUserManager() {
    synchronized (mLock) {
        if (mUserManager == null) {
            mUserManager = UserManager.get(mContext);
        }
        return mUserManager;
    }
}