android.os.UserManager Java Examples

The following examples show how to use android.os.UserManager. 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: TaskbarController.java    From Taskbar with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
int filterRealPinnedApps(Context context,
                         List<AppEntry> pinnedApps,
                         List<AppEntry> entries,
                         List<String> applicationIdsToRemove) {
    int realNumOfPinnedApps = 0;
    if(pinnedApps.size() > 0) {
        UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
        LauncherApps launcherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);

        for(AppEntry entry : pinnedApps) {
            boolean packageEnabled = launcherApps.isPackageEnabled(entry.getPackageName(),
                    userManager.getUserForSerialNumber(entry.getUserId(context)));

            if(packageEnabled)
                entries.add(entry);
            else
                realNumOfPinnedApps--;

            applicationIdsToRemove.add(entry.getPackageName());
        }

        realNumOfPinnedApps = realNumOfPinnedApps + pinnedApps.size();
    }
    return realNumOfPinnedApps;
}
 
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: MainActivity.java    From appauth-android-codelab with Apache License 2.0 6 votes vote down vote up
private void getAppRestrictions(){
  RestrictionsManager restrictionsManager =
          (RestrictionsManager) this
                  .getSystemService(Context.RESTRICTIONS_SERVICE);

  Bundle appRestrictions = restrictionsManager.getApplicationRestrictions();

  // Block user if KEY_RESTRICTIONS_PENDING is true, and save login hint if available
  if(!appRestrictions.isEmpty()){
    if(appRestrictions.getBoolean(UserManager.
            KEY_RESTRICTIONS_PENDING)!=true){
      mLoginHint = appRestrictions.getString(LOGIN_HINT);
    }
    else {
      Toast.makeText(this,R.string.restrictions_pending_block_user,
              Toast.LENGTH_LONG).show();
      finish();
    }
  }
}
 
Example #4
Source File: Vpn.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Updates UID ranges for this VPN and also updates its capabilities.
 *
 * <p>Should be called on primary ConnectivityService thread.
 */
public void onUserRemoved(int userHandle) {
    // clean up if restricted
    UserInfo user = UserManager.get(mContext).getUserInfo(userHandle);
    if (user.isRestricted() && user.restrictedProfileParentId == mUserHandle) {
        synchronized(Vpn.this) {
            final Set<UidRange> existingRanges = mNetworkCapabilities.getUids();
            if (existingRanges != null) {
                try {
                    final List<UidRange> removedRanges =
                        uidRangesForUser(userHandle, existingRanges);
                    existingRanges.removeAll(removedRanges);
                    // ConnectivityService will call {@link #updateCapabilities} and
                    // apply those for VPN network.
                    mNetworkCapabilities.setUids(existingRanges);
                } catch (Exception e) {
                    Log.wtf(TAG, "Failed to remove restricted user to owner", e);
                }
            }
            setVpnForcedLocked(mLockdown);
        }
    }
}
 
Example #5
Source File: Tethering.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void onUserRestrictionsChanged(int userId,
                                      Bundle newRestrictions,
                                      Bundle prevRestrictions) {
    final boolean newlyDisallowed =
            newRestrictions.getBoolean(UserManager.DISALLOW_CONFIG_TETHERING);
    final boolean previouslyDisallowed =
            prevRestrictions.getBoolean(UserManager.DISALLOW_CONFIG_TETHERING);
    final boolean tetheringDisallowedChanged = (newlyDisallowed != previouslyDisallowed);

    if (!tetheringDisallowedChanged) {
        return;
    }

    mWrapper.clearTetheredNotification();
    final boolean isTetheringActiveOnDevice = (mWrapper.getTetheredIfaces().length != 0);

    if (newlyDisallowed && isTetheringActiveOnDevice) {
        mWrapper.showTetheredNotification(
                com.android.internal.R.drawable.stat_sys_tether_general, false);
        mWrapper.untetherAll();
    }
}
 
Example #6
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
private void onImplicitDirectBoot(int userId) {
    // Only report if someone is relying on implicit behavior while the user
    // is locked; code running when unlocked is going to see both aware and
    // unaware components.
    if (StrictMode.vmImplicitDirectBootEnabled()) {
        // We can cache the unlocked state for the userId we're running as,
        // since any relocking of that user will always result in our
        // process being killed to release any CE FDs we're holding onto.
        if (userId == UserHandle.myUserId()) {
            if (mUserUnlocked) {
                return;
            } else if (mContext.getSystemService(UserManager.class)
                    .isUserUnlockingOrUnlocked(userId)) {
                mUserUnlocked = true;
            } else {
                StrictMode.onImplicitDirectBoot();
            }
        } else if (!mContext.getSystemService(UserManager.class)
                .isUserUnlockingOrUnlocked(userId)) {
            StrictMode.onImplicitDirectBoot();
        }
    }
}
 
Example #7
Source File: EventConditionProvider.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void reloadTrackers() {
    if (DEBUG) Slog.d(TAG, "reloadTrackers");
    for (int i = 0; i < mTrackers.size(); i++) {
        mTrackers.valueAt(i).setCallback(null);
    }
    mTrackers.clear();
    for (UserHandle user : UserManager.get(mContext).getUserProfiles()) {
        final Context context = user.isSystem() ? mContext : getContextForUser(mContext, user);
        if (context == null) {
            Slog.w(TAG, "Unable to create context for user " + user.getIdentifier());
            continue;
        }
        mTrackers.put(user.getIdentifier(), new CalendarTracker(mContext, context));
    }
    evaluateSubscriptions();
}
 
Example #8
Source File: PolicyManagementFragment.java    From android-testdpc with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    if (isDelegatedApp()) {
        mAdminComponentName = null;
    } else {
        mAdminComponentName = DeviceAdminReceiver.getComponentName(getActivity());
    }
    mDevicePolicyManager = (DevicePolicyManager) getActivity().getSystemService(
            Context.DEVICE_POLICY_SERVICE);
    mUserManager = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
    mTelephonyManager = (TelephonyManager) getActivity()
            .getSystemService(Context.TELEPHONY_SERVICE);
    mAccountManager = AccountManager.get(getActivity());
    mPackageManager = getActivity().getPackageManager();
    mPackageName = getActivity().getPackageName();

    mImageUri = getStorageUri("image.jpg");
    mVideoUri = getStorageUri("video.mp4");

    super.onCreate(savedInstanceState);
}
 
Example #9
Source File: BaseSettingsProviderTest.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
protected int getSecondaryUserId() {
    if (mSecondaryUserId == Integer.MIN_VALUE) {
        UserManager userManager = (UserManager) getContext()
                .getSystemService(Context.USER_SERVICE);
        List<UserInfo> users = userManager.getUsers();
        final int userCount = users.size();
        for (int i = 0; i < userCount; i++) {
            UserInfo user = users.get(i);
            if (!user.isPrimary() && !user.isManagedProfile()) {
                mSecondaryUserId = user.id;
                return mSecondaryUserId;
            }
        }
    }
    if (mSecondaryUserId == Integer.MIN_VALUE) {
        mSecondaryUserId =  UserHandle.USER_SYSTEM;
    }
    return mSecondaryUserId;
}
 
Example #10
Source File: IconCache.java    From Taskbar with Apache License 2.0 6 votes vote down vote up
public BitmapDrawable getIcon(Context context, PackageManager pm, LauncherActivityInfo appInfo) {
    UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
    String name = appInfo.getComponentName().flattenToString() + ":" + userManager.getSerialNumberForUser(appInfo.getUser());

    BitmapDrawable drawable;

    synchronized (drawables) {
        drawable = drawables.get(name);
        if(drawable == null) {
            Drawable loadedIcon = loadIcon(context, pm, appInfo);
            drawable = U.convertToBitmapDrawable(context, loadedIcon);

            drawables.put(name, drawable);
        }
    }

    return drawable;
}
 
Example #11
Source File: StorageManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void initIfReadyAndConnected() {
    Slog.d(TAG, "Thinking about init, mSystemReady=" + mSystemReady
            + ", mDaemonConnected=" + mDaemonConnected);
    if (mSystemReady && mDaemonConnected
            && !StorageManager.isFileEncryptedNativeOnly()) {
        // When booting a device without native support, make sure that our
        // user directories are locked or unlocked based on the current
        // emulation status.
        final boolean initLocked = StorageManager.isFileEncryptedEmulatedOnly();
        Slog.d(TAG, "Setting up emulation state, initlocked=" + initLocked);
        final List<UserInfo> users = mContext.getSystemService(UserManager.class).getUsers();
        for (UserInfo user : users) {
            try {
                if (initLocked) {
                    mVold.lockUserKey(user.id);
                } else {
                    mVold.unlockUserKey(user.id, user.serialNumber, encodeBytes(null),
                            encodeBytes(null));
                }
            } catch (Exception e) {
                Slog.wtf(TAG, e);
            }
        }
    }
}
 
Example #12
Source File: StorageManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Decide if volume is mountable per device policies.
 */
private boolean isMountDisallowed(VolumeInfo vol) {
    UserManager userManager = mContext.getSystemService(UserManager.class);

    boolean isUsbRestricted = false;
    if (vol.disk != null && vol.disk.isUsb()) {
        isUsbRestricted = userManager.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER,
                Binder.getCallingUserHandle());
    }

    boolean isTypeRestricted = false;
    if (vol.type == VolumeInfo.TYPE_PUBLIC || vol.type == VolumeInfo.TYPE_PRIVATE) {
        isTypeRestricted = userManager
                .hasUserRestriction(UserManager.DISALLOW_MOUNT_PHYSICAL_MEDIA,
                Binder.getCallingUserHandle());
    }

    return isUsbRestricted || isTypeRestricted;
}
 
Example #13
Source File: Utility.java    From Shelter with Do What The F*ck You Want To Public License 6 votes vote down vote up
public static void enforceUserRestrictions(Context context) {
    DevicePolicyManager manager = context.getSystemService(DevicePolicyManager.class);
    ComponentName adminComponent = new ComponentName(context.getApplicationContext(), ShelterDeviceAdminReceiver.class);
    manager.clearUserRestriction(adminComponent, UserManager.DISALLOW_INSTALL_APPS);
    manager.clearUserRestriction(adminComponent, UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES);
    manager.clearUserRestriction(adminComponent, UserManager.DISALLOW_UNINSTALL_APPS);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
        // Polyfill for UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES
        // Don't use this on Android Oreo and later, it will crash
        manager.setSecureSetting(adminComponent, Settings.Secure.INSTALL_NON_MARKET_APPS, "1");
    }

    // TODO: This should be configured by the user, instead of being enforced each time Shelter starts
    // TODO: But we should also have some default restrictions that are set the first time Shelter starts
    manager.addUserRestriction(adminComponent, UserManager.ALLOW_PARENT_PROFILE_APP_LINKING);
}
 
Example #14
Source File: SupervisedUserContentProvider.java    From delion with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private void updateEnabledState() {
    // This method uses AppRestrictions directly, rather than using the Policy interface,
    // because it must be callable in contexts in which the native library hasn't been
    // loaded. It will always be called from a background thread (except possibly in tests)
    // so can get the App Restrictions synchronously.
    UserManager userManager = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
    Bundle appRestrictions = userManager
            .getApplicationRestrictions(getContext().getPackageName());
    setEnabled(appRestrictions.getBoolean(SUPERVISED_USER_CONTENT_PROVIDER_ENABLED));
}
 
Example #15
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 #16
Source File: UserManagerCompatUtils.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
/**
 * Check if the calling user is running in an "unlocked" state. A user is unlocked only after
 * they've entered their credentials (such as a lock pattern or PIN), and credential-encrypted
 * private app data storage is available.
 * @param context context from which {@link UserManager} should be obtained.
 * @return One of {@link LockState}.
 */
@LockState
public static int getUserLockState(final Context context) {
    if (METHOD_isUserUnlocked == null) {
        return LOCK_STATE_UNKNOWN;
    }
    final UserManager userManager = context.getSystemService(UserManager.class);
    if (userManager == null) {
        return LOCK_STATE_UNKNOWN;
    }
    final Boolean result =
            (Boolean) CompatUtils.invoke(userManager, null, METHOD_isUserUnlocked);
    if (result == null) {
        return LOCK_STATE_UNKNOWN;
    }
    return result ? LOCK_STATE_UNLOCKED : LOCK_STATE_LOCKED;
}
 
Example #17
Source File: TextServicesManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public TextServicesManagerService(Context context) {
    mContext = context;
    mUserManager = mContext.getSystemService(UserManager.class);
    mSpellCheckerOwnerUserIdMap = new LazyIntToIntMap(callingUserId -> {
        if (DISABLE_PER_PROFILE_SPELL_CHECKER) {
            final long token = Binder.clearCallingIdentity();
            try {
                final UserInfo parent = mUserManager.getProfileParent(callingUserId);
                return (parent != null) ? parent.id : callingUserId;
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        } else {
            return callingUserId;
        }
    });

    mMonitor = new TextServicesMonitor();
    mMonitor.register(context, null, UserHandle.ALL, true);
}
 
Example #18
Source File: SubscribeDecoratorService.java    From nevo-decorators-sms-captchas with GNU General Public License v3.0 5 votes vote down vote up
public void loadSettings() {
    if ( Objects.requireNonNull(getSystemService(UserManager.class)).isUserUnlocked() ) {
        AppPreferences mAppPreference = new AppPreferences(this);
        mSettings = Settings.defaultValueFromContext(this).readFromTrayPreference(mAppPreference);

        mAppPreference.registerOnTrayPreferenceChangeListener(this::onSettingsChanged);
    }
    else {
        mSettings = Settings.defaultValueFromContext(createDeviceProtectedStorageContext());
    }
}
 
Example #19
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 #20
Source File: FeatureUtilities.java    From delion with Apache License 2.0 5 votes vote down vote up
@SuppressLint("InlinedApi")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private static boolean hasSyncPermissions(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return true;

    UserManager manager = (UserManager) context.getSystemService(Context.USER_SERVICE);
    Bundle userRestrictions = manager.getUserRestrictions();
    return !userRestrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false);
}
 
Example #21
Source File: Util.java    From android-testdpc with Apache License 2.0 5 votes vote down vote up
@TargetApi(VERSION_CODES.M)
public static boolean isPrimaryUser(Context context) {
    if (Util.SDK_INT >= VERSION_CODES.M) {
        UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
        return userManager.isSystemUser();
    } else {
        // Assume only DO can be primary user. This is not perfect but the cases in which it is
        // wrong are uncommon and require adb to set up.
        return isDeviceOwner(context);
    }
}
 
Example #22
Source File: SupervisedUserContentProvider.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private void updateEnabledState() {
    // This method uses AppRestrictions directly, rather than using the Policy interface,
    // because it must be callable in contexts in which the native library hasn't been
    // loaded. It will always be called from a background thread (except possibly in tests)
    // so can get the App Restrictions synchronously.
    UserManager userManager = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
    Bundle appRestrictions = userManager
            .getApplicationRestrictions(getContext().getPackageName());
    setEnabled(appRestrictions.getBoolean(SUPERVISED_USER_CONTENT_PROVIDER_ENABLED));
}
 
Example #23
Source File: ShutdownThread.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Request a reboot into safe mode.  Must be called from a Looper thread in which its UI
 * is shown.
 *
 * @param context Context used to display the shutdown progress dialog. This must be a context
 *                suitable for displaying UI (aka Themable).
 * @param confirm true if user confirmation is needed before shutting down.
 */
public static void rebootSafeMode(final Context context, boolean confirm) {
    UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
    if (um.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
        return;
    }

    mReboot = true;
    mRebootSafeMode = true;
    mRebootHasProgressBar = false;
    mReason = null;
    shutdownInner(context, confirm);
}
 
Example #24
Source File: ManagedServices.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void updateCache(@NonNull Context context) {
    UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
    if (userManager != null) {
        int currentUserId = ActivityManager.getCurrentUser();
        List<UserInfo> profiles = userManager.getProfiles(currentUserId);
        synchronized (mCurrentProfiles) {
            mCurrentProfiles.clear();
            for (UserInfo user : profiles) {
                mCurrentProfiles.put(user.id, user);
            }
        }
    }
}
 
Example #25
Source File: WallpaperManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public boolean hasNamedWallpaper(String name) {
    synchronized (mLock) {
        List<UserInfo> users;
        long ident = Binder.clearCallingIdentity();
        try {
            users = ((UserManager) mContext.getSystemService(Context.USER_SERVICE)).getUsers();
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
        for (UserInfo user: users) {
            // ignore managed profiles
            if (user.isManagedProfile()) {
                continue;
            }
            WallpaperData wd = mWallpaperMap.get(user.id);
            if (wd == null) {
                // User hasn't started yet, so load her settings to peek at the wallpaper
                loadSettingsLocked(user.id, false);
                wd = mWallpaperMap.get(user.id);
            }
            if (wd != null && name.equals(wd.name)) {
                return true;
            }
        }
    }
    return false;
}
 
Example #26
Source File: FavoriteAppTileService.java    From Taskbar with Apache License 2.0 5 votes vote down vote up
private void launchApp() {
    SharedPreferences pref = U.getSharedPreferences(this);
    UserManager userManager = (UserManager) getSystemService(USER_SERVICE);

    Intent shortcutIntent = new Intent(this, PersistentShortcutLaunchActivity.class);
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    shortcutIntent.setAction(Intent.ACTION_MAIN);
    shortcutIntent.putExtra("package_name", pref.getString(prefix + "package_name", null));
    shortcutIntent.putExtra("component_name", pref.getString(prefix + "component_name", null));
    shortcutIntent.putExtra("window_size", pref.getString(prefix + "window_size", null));
    shortcutIntent.putExtra("user_id", pref.getLong(prefix + "user_id", userManager.getSerialNumberForUser(Process.myUserHandle())));

    startActivityAndCollapse(shortcutIntent);
}
 
Example #27
Source File: DevicePolicies.java    From island with Apache License 2.0 5 votes vote down vote up
public void clearUserRestrictionsIfNeeded(final Context context, final String... keys) {
	Bundle restrictions = null;
	for (final String key : keys) {
		if (Users.isProfile() && UserManager.DISALLOW_SET_WALLPAPER.equals(key)) return;	// Immutable
		if (SDK_INT >= N) {
			if (restrictions == null) restrictions = mDevicePolicyManager.getUserRestrictions(sCachedComponent);
			if (restrictions.containsKey(key))
				mDevicePolicyManager.clearUserRestriction(sCachedComponent, key);
		} else {
			final UserManager um = (UserManager) context.getSystemService(USER_SERVICE);
			if (um == null || um.hasUserRestriction(key))
				mDevicePolicyManager.clearUserRestriction(sCachedComponent, key);
		}
	}
}
 
Example #28
Source File: U.java    From Taskbar with Apache License 2.0 5 votes vote down vote up
private static void launchAndroidForWork(Context context, ComponentName componentName, Bundle bundle, long userId, Runnable onError) {
    UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
    LauncherApps launcherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);

    try {
        launcherApps.startMainActivity(componentName, userManager.getUserForSerialNumber(userId), null, bundle);
    } catch (ActivityNotFoundException | NullPointerException
            | IllegalStateException | SecurityException e) {
        if(onError != null) launchApp(context, onError);
    }
}
 
Example #29
Source File: UserManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public UserInfo createUserEvenWhenDisallowed(String name, int flags,
        String[] disallowedPackages) {
    UserInfo user = createUserInternalUnchecked(name, flags, UserHandle.USER_NULL,
            disallowedPackages);
    // Keep this in sync with UserManager.createUser
    if (user != null && !user.isAdmin() && !user.isDemo()) {
        setUserRestriction(UserManager.DISALLOW_SMS, true, user.id);
        setUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS, true, user.id);
    }
    return user;
}
 
Example #30
Source File: LauncherAppsService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public LauncherAppsImpl(Context context) {
    mContext = context;
    mUm = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
    mUserManagerInternal = Preconditions.checkNotNull(
            LocalServices.getService(UserManagerInternal.class));
    mActivityManagerInternal = Preconditions.checkNotNull(
            LocalServices.getService(ActivityManagerInternal.class));
    mShortcutServiceInternal = Preconditions.checkNotNull(
            LocalServices.getService(ShortcutServiceInternal.class));
    mShortcutServiceInternal.addListener(mPackageMonitor);
    mCallbackHandler = BackgroundThread.getHandler();
}