use of android.content.pm.ParceledListSlice in project platform_frameworks_base by android.
the class AppWidgetServiceImpl method startListening.
@Override
public ParceledListSlice<PendingHostUpdate> startListening(IAppWidgetHost callbacks, String callingPackage, int hostId, int[] appWidgetIds) {
final int userId = UserHandle.getCallingUserId();
if (DEBUG) {
Slog.i(TAG, "startListening() " + userId);
}
// Make sure the package runs under the caller uid.
mSecurityPolicy.enforceCallFromPackage(callingPackage);
synchronized (mLock) {
ensureGroupStateLoadedLocked(userId);
// NOTE: The lookup is enforcing security across users by making
// sure the caller can only access hosts it owns.
HostId id = new HostId(Binder.getCallingUid(), hostId, callingPackage);
Host host = lookupOrAddHostLocked(id);
host.callbacks = callbacks;
int N = appWidgetIds.length;
ArrayList<PendingHostUpdate> outUpdates = new ArrayList<>(N);
LongSparseArray<PendingHostUpdate> updatesMap = new LongSparseArray<>();
for (int i = 0; i < N; i++) {
if (host.getPendingUpdatesForId(appWidgetIds[i], updatesMap)) {
// We key the updates based on time, so that the values are sorted by time.
int M = updatesMap.size();
for (int j = 0; j < M; j++) {
outUpdates.add(updatesMap.valueAt(j));
}
}
}
return new ParceledListSlice<>(outUpdates);
}
}
use of android.content.pm.ParceledListSlice in project platform_frameworks_base by android.
the class AppWidgetServiceImpl method getInstalledProvidersForProfile.
@Override
public ParceledListSlice<AppWidgetProviderInfo> getInstalledProvidersForProfile(int categoryFilter, int profileId) {
final int userId = UserHandle.getCallingUserId();
if (DEBUG) {
Slog.i(TAG, "getInstalledProvidersForProfiles() " + userId);
}
// Ensure the profile is in the group and enabled.
if (!mSecurityPolicy.isEnabledGroupProfile(profileId)) {
return null;
}
synchronized (mLock) {
ensureGroupStateLoadedLocked(userId);
ArrayList<AppWidgetProviderInfo> result = new ArrayList<AppWidgetProviderInfo>();
final int providerCount = mProviders.size();
for (int i = 0; i < providerCount; i++) {
Provider provider = mProviders.get(i);
AppWidgetProviderInfo info = provider.info;
// Ignore an invalid provider or one not matching the filter.
if (provider.zombie || (info.widgetCategory & categoryFilter) == 0) {
continue;
}
// Add providers only for the requested profile that are white-listed.
final int providerProfileId = info.getProfile().getIdentifier();
if (providerProfileId == profileId && mSecurityPolicy.isProviderInCallerOrInProfileAndWhitelListed(provider.id.componentName.getPackageName(), providerProfileId)) {
result.add(cloneIfLocalBinder(info));
}
}
return new ParceledListSlice<AppWidgetProviderInfo>(result);
}
}
use of android.content.pm.ParceledListSlice in project platform_frameworks_base by android.
the class PackageManagerService method getInstalledApplications.
@Override
public ParceledListSlice<ApplicationInfo> getInstalledApplications(int flags, int userId) {
if (!sUserManager.exists(userId))
return ParceledListSlice.emptyList();
flags = updateFlagsForApplication(flags, userId, null);
final boolean listUninstalled = (flags & MATCH_UNINSTALLED_PACKAGES) != 0;
// writer
synchronized (mPackages) {
ArrayList<ApplicationInfo> list;
if (listUninstalled) {
list = new ArrayList<ApplicationInfo>(mSettings.mPackages.size());
for (PackageSetting ps : mSettings.mPackages.values()) {
ApplicationInfo ai;
if (ps.pkg != null) {
ai = PackageParser.generateApplicationInfo(ps.pkg, flags, ps.readUserState(userId), userId);
} else {
ai = generateApplicationInfoFromSettingsLPw(ps.name, flags, userId);
}
if (ai != null) {
list.add(ai);
}
}
} else {
list = new ArrayList<ApplicationInfo>(mPackages.size());
for (PackageParser.Package p : mPackages.values()) {
if (p.mExtras != null) {
ApplicationInfo ai = PackageParser.generateApplicationInfo(p, flags, ((PackageSetting) p.mExtras).readUserState(userId), userId);
if (ai != null) {
list.add(ai);
}
}
}
}
return new ParceledListSlice<ApplicationInfo>(list);
}
}
use of android.content.pm.ParceledListSlice in project platform_frameworks_base by android.
the class PackageManagerService method queryContentProviders.
@Override
@NonNull
public ParceledListSlice<ProviderInfo> queryContentProviders(String processName, int uid, int flags) {
final int userId = processName != null ? UserHandle.getUserId(uid) : UserHandle.getCallingUserId();
if (!sUserManager.exists(userId))
return ParceledListSlice.emptyList();
flags = updateFlagsForComponent(flags, userId, processName);
ArrayList<ProviderInfo> finalList = null;
// reader
synchronized (mPackages) {
final Iterator<PackageParser.Provider> i = mProviders.mProviders.values().iterator();
while (i.hasNext()) {
final PackageParser.Provider p = i.next();
PackageSetting ps = mSettings.mPackages.get(p.owner.packageName);
if (ps != null && p.info.authority != null && (processName == null || (p.info.processName.equals(processName) && UserHandle.isSameApp(p.info.applicationInfo.uid, uid))) && mSettings.isEnabledAndMatchLPr(p.info, flags, userId)) {
if (finalList == null) {
finalList = new ArrayList<ProviderInfo>(3);
}
ProviderInfo info = PackageParser.generateProviderInfo(p, flags, ps.readUserState(userId), userId);
if (info != null) {
finalList.add(info);
}
}
}
}
if (finalList != null) {
Collections.sort(finalList, mProviderInitOrderSorter);
return new ParceledListSlice<ProviderInfo>(finalList);
}
return ParceledListSlice.emptyList();
}
use of android.content.pm.ParceledListSlice in project platform_frameworks_base by android.
the class PackageManagerService method getInstalledPackages.
@Override
public ParceledListSlice<PackageInfo> getInstalledPackages(int flags, int userId) {
if (!sUserManager.exists(userId))
return ParceledListSlice.emptyList();
flags = updateFlagsForPackage(flags, userId, null);
final boolean listUninstalled = (flags & MATCH_UNINSTALLED_PACKAGES) != 0;
enforceCrossUserPermission(Binder.getCallingUid(), userId, true, /* requireFullPermission */
false, /* checkShell */
"get installed packages");
// writer
synchronized (mPackages) {
ArrayList<PackageInfo> list;
if (listUninstalled) {
list = new ArrayList<PackageInfo>(mSettings.mPackages.size());
for (PackageSetting ps : mSettings.mPackages.values()) {
final PackageInfo pi;
if (ps.pkg != null) {
pi = generatePackageInfo(ps, flags, userId);
} else {
pi = generatePackageInfo(ps, flags, userId);
}
if (pi != null) {
list.add(pi);
}
}
} else {
list = new ArrayList<PackageInfo>(mPackages.size());
for (PackageParser.Package p : mPackages.values()) {
final PackageInfo pi = generatePackageInfo((PackageSetting) p.mExtras, flags, userId);
if (pi != null) {
list.add(pi);
}
}
}
return new ParceledListSlice<PackageInfo>(list);
}
}
Aggregations