当前位置: 首页>>代码示例>>Java>>正文


Java UserHandle类代码示例

本文整理汇总了Java中android.os.UserHandle的典型用法代码示例。如果您正苦于以下问题:Java UserHandle类的具体用法?Java UserHandle怎么用?Java UserHandle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UserHandle类属于android.os包,在下文中一共展示了UserHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startActivityAsUser

import android.os.UserHandle; //导入依赖的package包/类
/**
 * @hide Implement to provide correct calling token.
 */
public void startActivityAsUser(Intent intent, Bundle options, UserHandle user) {
    if (mParent != null) {
        throw new RuntimeException("Can't be called from a child");
    }
    options = transferSpringboardActivityOptions(options);
    Instrumentation.ActivityResult ar =
            mInstrumentation.execStartActivity(
                    this, mMainThread.getApplicationThread(), mToken, this,
                    intent, -1, options, user);
    if (ar != null) {
        mMainThread.sendActivityResult(
                mToken, mEmbeddedID, -1, ar.getResultCode(),
                ar.getResultData());
    }
    cancelInputsAndStartExitTransition(options);
}
 
开发者ID:JessYanCoding,项目名称:ProgressManager,代码行数:20,代码来源:a.java

示例2: enableAndResetCache

import android.os.UserHandle; //导入依赖的package包/类
@Override
public void enableAndResetCache() {
    synchronized (this) {
        mUsers = new LongArrayMap<>();
        mUserToSerialMap = new HashMap<>();
        List<UserHandle> users = mUserManager.getUserProfiles();
        if (users != null) {
            for (UserHandle user : users) {
                long serial = mUserManager.getSerialNumberForUser(user);
                UserHandleCompat userCompat = UserHandleCompat.fromUser(user);
                mUsers.put(serial, userCompat);
                mUserToSerialMap.put(userCompat, serial);
            }
        }
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:17,代码来源:UserManagerCompatVL.java

示例3: shortcutExists

import android.os.UserHandle; //导入依赖的package包/类
/**
 * Returns true if the shortcuts already exists on the workspace. This must be called after
 * the workspace has been loaded. We identify a shortcut by its intent.
 */
private boolean shortcutExists(BgDataModel dataModel, Intent intent, UserHandle user) {
    final String intentWithPkg, intentWithoutPkg;
    if (intent == null) {
        // Skip items with null intents
        return true;
    }
    if (intent.getComponent() != null) {
        // If component is not null, an intent with null package will produce
        // the same result and should also be a match.
        String packageName = intent.getComponent().getPackageName();
        if (intent.getPackage() != null) {
            intentWithPkg = intent.toUri(0);
            intentWithoutPkg = new Intent(intent).setPackage(null).toUri(0);
        } else {
            intentWithPkg = new Intent(intent).setPackage(packageName).toUri(0);
            intentWithoutPkg = intent.toUri(0);
        }
    } else {
        intentWithPkg = intent.toUri(0);
        intentWithoutPkg = intent.toUri(0);
    }

    synchronized (dataModel) {
        for (ItemInfo item : dataModel.itemsIdMap) {
            if (item instanceof ShortcutInfo) {
                ShortcutInfo info = (ShortcutInfo) item;
                if (item.getIntent() != null && info.user.equals(user)) {
                    Intent copyIntent = new Intent(item.getIntent());
                    copyIntent.setSourceBounds(intent.getSourceBounds());
                    String s = copyIntent.toUri(0);
                    if (intentWithPkg.equals(s) || intentWithoutPkg.equals(s)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:44,代码来源:AddWorkspaceItemsTask.java

示例4: updateDeepShortcutMap

import android.os.UserHandle; //导入依赖的package包/类
/**
 * Clear all the deep shortcuts for the given package, and re-add the new shortcuts.
 */
public synchronized void updateDeepShortcutMap(
        String packageName, UserHandle user, List<ShortcutInfoCompat> shortcuts) {
    if (packageName != null) {
        Iterator<ComponentKey> keysIter = deepShortcutMap.keySet().iterator();
        while (keysIter.hasNext()) {
            ComponentKey next = keysIter.next();
            if (next.componentName.getPackageName().equals(packageName)
                    && next.user.equals(user)) {
                keysIter.remove();
            }
        }
    }

    // Now add the new shortcuts to the map.
    for (ShortcutInfoCompat shortcut : shortcuts) {
        boolean shouldShowInContainer = shortcut.isEnabled()
                && (shortcut.isDeclaredInManifest() || shortcut.isDynamic());
        if (shouldShowInContainer) {
            ComponentKey targetComponent
                    = new ComponentKey(shortcut.getActivity(), shortcut.getUserHandle());
            deepShortcutMap.addToList(targetComponent, shortcut.getId());
        }
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:28,代码来源:BgDataModel.java

示例5: updateIconsAndLabels

import android.os.UserHandle; //导入依赖的package包/类
public void updateIconsAndLabels(HashSet<String> packages, UserHandle user,
        ArrayList<AppInfo> outUpdates) {
    for (AppInfo info : data) {
        if (info.user.equals(user) && packages.contains(info.componentName.getPackageName())) {
            mIconCache.updateTitleAndIcon(info);
            outUpdates.add(info);
        }
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:10,代码来源:AllAppsList.java

示例6: getSerialNumberForUser

import android.os.UserHandle; //导入依赖的package包/类
@Override
public long getSerialNumberForUser(UserHandle user) {
    synchronized (this) {
        if (mUserToSerialMap != null) {
            Long serial = mUserToSerialMap.get(user);
            return serial == null ? 0 : serial;
        }
    }
    return mUserManager.getSerialNumberForUser(user);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:11,代码来源:UserManagerCompatVL.java

示例7: getUserForSerialNumber

import android.os.UserHandle; //导入依赖的package包/类
@Override
public UserHandle getUserForSerialNumber(long serialNumber) {
    synchronized (this) {
        if (mUsers != null) {
            return mUsers.get(serialNumber);
        }
    }
    return mUserManager.getUserForSerialNumber(serialNumber);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:10,代码来源:UserManagerCompatVL.java

示例8: scheduleManagedHeuristicRunnable

import android.os.UserHandle; //导入依赖的package包/类
private void scheduleManagedHeuristicRunnable(final ManagedProfileHeuristic heuristic,
        final UserHandle user, final List<LauncherActivityInfo> apps) {
    if (heuristic != null) {
        // Assume the app lists now is updated.
        mIsManagedHeuristicAppsUpdated = false;
        final Runnable managedHeuristicRunnable = new Runnable() {
            @Override
            public void run() {
                if (mIsManagedHeuristicAppsUpdated) {
                    // If app list is updated, we need to reschedule it otherwise old app
                    // list will override everything in processUserApps().
                    sWorker.post(new Runnable() {
                        public void run() {
                            final List<LauncherActivityInfo> updatedApps =
                                    mLauncherApps.getActivityList(null, user);
                            scheduleManagedHeuristicRunnable(heuristic, user,
                                    updatedApps);
                        }
                    });
                } else {
                    heuristic.processUserApps(apps);
                }
            }
        };
        runOnMainThread(new Runnable() {
            @Override
            public void run() {
                // Check isLoadingWorkspace on the UI thread, as it is updated on the UI
                // thread.
                if (mIsLoadingAndBindingWorkspace) {
                    synchronized (mBindCompleteRunnables) {
                        mBindCompleteRunnables.add(managedHeuristicRunnable);
                    }
                } else {
                    runOnWorkerThread(managedHeuristicRunnable);
                }
            }
        });
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:41,代码来源:LauncherModel.java

示例9: getUserProfiles

import android.os.UserHandle; //导入依赖的package包/类
@Override
public List<UserHandle> getUserProfiles() {
    synchronized (this) {
        if (mUsers != null) {
            return new ArrayList<>(mUserToSerialMap.keySet());
        }
    }

    List<UserHandle> users = mUserManager.getUserProfiles();
    return users == null ? Collections.<UserHandle>emptyList() : users;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:12,代码来源:UserManagerCompatVL.java

示例10: loadDeepShortcuts

import android.os.UserHandle; //导入依赖的package包/类
private void loadDeepShortcuts() {
    sBgDataModel.deepShortcutMap.clear();
    DeepShortcutManager shortcutManager = DeepShortcutManager.getInstance(mContext);
    mHasShortcutHostPermission = shortcutManager.hasHostPermission();
    if (mHasShortcutHostPermission) {
        for (UserHandle user : mUserManager.getUserProfiles()) {
            if (mUserManager.isUserUnlocked(user)) {
                List<ShortcutInfoCompat> shortcuts =
                        shortcutManager.queryForAllShortcuts(user);
                sBgDataModel.updateDeepShortcutMap(null, user, shortcuts);
            }
        }
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:15,代码来源:LauncherModel.java

示例11: sendOrderedBroadcastAsUser

import android.os.UserHandle; //导入依赖的package包/类
@RequiresApi(JELLY_BEAN_MR1) @SuppressLint("MissingPermission") @Override
public void sendOrderedBroadcastAsUser(final Intent intent, final UserHandle user, final String receiverPermission,
									   final BroadcastReceiver resultReceiver, final Handler scheduler, final int initialCode, final String initialData, final Bundle initialExtras) {
	mCondom.proceedBroadcast(this, intent, new CondomCore.WrappedProcedure() { @Override public void run() {
		mApplication.sendOrderedBroadcastAsUser(intent, user, receiverPermission, resultReceiver, scheduler, initialCode, initialData, initialExtras);
	}}, resultReceiver);
}
 
开发者ID:oasisfeng,项目名称:condom,代码行数:8,代码来源:CondomApplication.java

示例12: processUserApps

import android.os.UserHandle; //导入依赖的package包/类
/**
 * Checks the list of user apps, and generates package event accordingly.
 * {@see #onLauncherAppsAdded}, {@see #onLauncherPackageRemoved}
 */
void processUserApps(List<LauncherActivityInfo> apps, UserHandle user) {
    String prefKey = INSTALLED_PACKAGES_PREFIX + mUserManager.getSerialNumberForUser(user);
    HashSet<String> oldPackageSet = new HashSet<>();
    final boolean userAppsExisted = getUserApps(oldPackageSet, prefKey);

    HashSet<String> packagesRemoved = new HashSet<>(oldPackageSet);
    HashSet<String> newPackageSet = new HashSet<>();
    ArrayList<LauncherActivityInstallInfo> packagesAdded = new ArrayList<>();

    for (LauncherActivityInfo info : apps) {
        String packageName = info.getComponentName().getPackageName();
        newPackageSet.add(packageName);
        packagesRemoved.remove(packageName);

        if (!oldPackageSet.contains(packageName)) {
            oldPackageSet.add(packageName);
            packagesAdded.add(new LauncherActivityInstallInfo(
                    info, info.getFirstInstallTime()));
        }
    }

    if (!packagesAdded.isEmpty() || !packagesRemoved.isEmpty()) {
        mPrefs.edit().putStringSet(prefKey, newPackageSet).apply();

        if (!packagesAdded.isEmpty()) {
            Collections.sort(packagesAdded);
            onLauncherAppsAdded(packagesAdded, user, userAppsExisted);
        }

        if (!packagesRemoved.isEmpty()) {
            for (String pkg : packagesRemoved) {
                onLauncherPackageRemoved(pkg, user);
            }
        }
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:41,代码来源:CachedPackageTracker.java

示例13: getAllProviders

import android.os.UserHandle; //导入依赖的package包/类
@Override
public List<AppWidgetProviderInfo> getAllProviders() {
    ArrayList<AppWidgetProviderInfo> providers = new ArrayList<AppWidgetProviderInfo>();
    for (UserHandle user : mUserManager.getUserProfiles()) {
        providers.addAll(mAppWidgetManager.getInstalledProvidersForProfile(user));
    }
    return providers;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:9,代码来源:AppWidgetManagerCompatVL.java

示例14: ofComponents

import android.os.UserHandle; //导入依赖的package包/类
public static ItemInfoMatcher ofComponents(
        final HashSet<ComponentName> components, final UserHandle user) {
    return new ItemInfoMatcher() {
        @Override
        public boolean matches(ItemInfo info, ComponentName cn) {
            return components.contains(cn) && info.user.equals(user);
        }
    };
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:10,代码来源:ItemInfoMatcher.java

示例15: getAllProvidersMap

import android.os.UserHandle; //导入依赖的package包/类
@Override
public HashMap<ComponentKey, AppWidgetProviderInfo> getAllProvidersMap() {
    HashMap<ComponentKey, AppWidgetProviderInfo> result = new HashMap<>();
    for (UserHandle user : mUserManager.getUserProfiles()) {
        for (AppWidgetProviderInfo info :
                mAppWidgetManager.getInstalledProvidersForProfile(user)) {
            result.put(new ComponentKey(info.provider, user), info);
        }
    }
    return result;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:12,代码来源:AppWidgetManagerCompatVL.java


注:本文中的android.os.UserHandle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。