Java Code Examples for android.content.pm.ParceledListSlice#getList()

The following examples show how to use android.content.pm.ParceledListSlice#getList() . 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: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        ParceledListSlice<FeatureInfo> parceledList =
                mPM.getSystemAvailableFeatures();
        if (parceledList == null) {
            return new FeatureInfo[0];
        }
        final List<FeatureInfo> list = parceledList.getList();
        final FeatureInfo[] res = new FeatureInfo[list.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return res;
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 2
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
/**
 * @hide
 */
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentReceivers(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        flags,  userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 3
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public List<PackageInfo> getPackagesHoldingPermissions(
        String[] permissions, int flags) {
    final int userId = mContext.getUserId();
    try {
        ParceledListSlice<PackageInfo> parceledList =
                mPM.getPackagesHoldingPermissions(permissions, flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 4
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<PermissionInfo> queryPermissionsByGroup(String group, int flags)
        throws NameNotFoundException {
    try {
        ParceledListSlice<PermissionInfo> parceledList =
                mPM.queryPermissionsByGroup(group, flags);
        if (parceledList != null) {
            List<PermissionInfo> pi = parceledList.getList();
            if (pi != null) {
                return pi;
            }
        }
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }

    throw new NameNotFoundException(group);
}
 
Example 5
Source File: ApplicationPackageManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryIntentContentProvidersAsUser(
        Intent intent, int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentContentProviders(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 6
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
/** @hide Same as above but for a specific user */
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
        int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList = mPM.queryIntentActivities(
                intent,
                intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                updateFlagsForComponent(flags, userId, intent),
                userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 7
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<PermissionInfo> queryPermissionsByGroup(String group, int flags)
        throws NameNotFoundException {
    try {
        ParceledListSlice<PermissionInfo> parceledList =
                mPM.queryPermissionsByGroup(group, flags);
        if (parceledList != null) {
            List<PermissionInfo> pi = parceledList.getList();
            if (pi != null) {
                return pi;
            }
        }
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }

    throw new NameNotFoundException(group);
}
 
Example 8
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
/** @hide Same as above but for a specific user */
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
        int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentActivities(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 9
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
/** @hide Same as above but for a specific user */
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
        int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentActivities(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 10
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<PermissionInfo> queryPermissionsByGroup(String group, int flags)
        throws NameNotFoundException {
    try {
        ParceledListSlice<PermissionInfo> parceledList =
                mPM.queryPermissionsByGroup(group, flags);
        if (parceledList != null) {
            List<PermissionInfo> pi = parceledList.getList();
            if (pi != null) {
                return pi;
            }
        }
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }

    throw new NameNotFoundException(group);
}
 
Example 11
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<IntentFilter> getAllIntentFilters(String packageName) {
    try {
        ParceledListSlice<IntentFilter> parceledList =
                mPM.getAllIntentFilters(packageName);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 12
Source File: ApplicationPackageManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<IntentFilter> getAllIntentFilters(String packageName) {
    try {
        ParceledListSlice<IntentFilter> parceledList =
                mPM.getAllIntentFilters(packageName);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 13
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<IntentFilter> getAllIntentFilters(String packageName) {
    try {
        ParceledListSlice<IntentFilter> parceledList =
                mPM.getAllIntentFilters(packageName);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 14
Source File: DisplayManagerGlobal.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves ambient brightness stats.
 */
public List<AmbientBrightnessDayStats> getAmbientBrightnessStats() {
    try {
        ParceledListSlice<AmbientBrightnessDayStats> stats = mDm.getAmbientBrightnessStats();
        if (stats == null) {
            return Collections.emptyList();
        }
        return stats.getList();
    } catch (RemoteException ex) {
        throw ex.rethrowFromSystemServer();
    }
}
 
Example 15
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<IntentFilterVerificationInfo> getIntentFilterVerifications(String packageName) {
    try {
        ParceledListSlice<IntentFilterVerificationInfo> parceledList =
                mPM.getIntentFilterVerifications(packageName);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 16
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/** @hide */
@SuppressWarnings("unchecked")
@Override
public List<EphemeralApplicationInfo> getEphemeralApplications() {
    try {
        ParceledListSlice<EphemeralApplicationInfo> slice =
                mPM.getEphemeralApplications(mContext.getUserId());
        if (slice != null) {
            return slice.getList();
        }
        return Collections.emptyList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 17
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<ProviderInfo> queryContentProviders(String processName,
        int uid, int flags, String metaDataKey) {
    try {
        ParceledListSlice<ProviderInfo> slice = mPM.queryContentProviders(processName, uid,
                updateFlagsForComponent(flags, UserHandle.getUserId(uid), null), metaDataKey);
        return slice != null ? slice.getList() : Collections.<ProviderInfo>emptyList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 18
Source File: ActivityManagerShellCommand.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
int runGetStandbyBucket(PrintWriter pw) throws RemoteException {
    int userId = UserHandle.USER_CURRENT;

    String opt;
    while ((opt=getNextOption()) != null) {
        if (opt.equals("--user")) {
            userId = UserHandle.parseUserArg(getNextArgRequired());
        } else {
            getErrPrintWriter().println("Error: Unknown option: " + opt);
            return -1;
        }
    }
    String packageName = getNextArg();

    IUsageStatsManager usm = IUsageStatsManager.Stub.asInterface(ServiceManager.getService(
            Context.USAGE_STATS_SERVICE));
    if (packageName != null) {
        int bucket = usm.getAppStandbyBucket(packageName, null, userId);
        pw.println(bucket);
    } else {
        ParceledListSlice<AppStandbyInfo> buckets = usm.getAppStandbyBuckets(
                SHELL_PACKAGE_NAME, userId);
        for (AppStandbyInfo bucketInfo : buckets.getList()) {
            pw.print(bucketInfo.mPackageName); pw.print(": ");
            pw.println(bucketInfo.mStandbyBucket);
        }
    }
    return 0;
}
 
Example 19
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/** @hide */
@Override
@SuppressWarnings("unchecked")
public List<PackageInfo> getInstalledPackagesAsUser(int flags, int userId) {
    try {
        ParceledListSlice<PackageInfo> parceledList =
                mPM.getInstalledPackages(updateFlagsForPackage(flags, userId), userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 20
Source File: UsageStatsManager.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Gets application usage stats for the given time range, aggregated by the specified interval.
 * <p>The returned list will contain a {@link UsageStats} object for each package that
 * has data for an interval that is a subset of the time range given. To illustrate:</p>
 * <pre>
 * intervalType = INTERVAL_YEARLY
 * beginTime = 2013
 * endTime = 2015 (exclusive)
 *
 * Results:
 * 2013 - com.example.alpha
 * 2013 - com.example.beta
 * 2014 - com.example.alpha
 * 2014 - com.example.beta
 * 2014 - com.example.charlie
 * </pre>
 *
 * <p> The caller must have {@link android.Manifest.permission#PACKAGE_USAGE_STATS} </p>
 *
 * @param intervalType The time interval by which the stats are aggregated.
 * @param beginTime The inclusive beginning of the range of stats to include in the results.
 * @param endTime The exclusive end of the range of stats to include in the results.
 * @return A list of {@link UsageStats}
 *
 * @see #INTERVAL_DAILY
 * @see #INTERVAL_WEEKLY
 * @see #INTERVAL_MONTHLY
 * @see #INTERVAL_YEARLY
 * @see #INTERVAL_BEST
 */
public List<UsageStats> queryUsageStats(int intervalType, long beginTime, long endTime) {
    try {
        @SuppressWarnings("unchecked")
        ParceledListSlice<UsageStats> slice = mService.queryUsageStats(intervalType, beginTime,
                endTime, mContext.getOpPackageName());
        if (slice != null) {
            return slice.getList();
        }
    } catch (RemoteException e) {
        // fallthrough and return the empty list.
    }
    return Collections.emptyList();
}