Search in sources :

Example 31 with FeatureInfo

use of android.content.pm.FeatureInfo in project android_frameworks_base by DirtyUnicorns.

the class PackageManagerShellCommand method runListFeatures.

private int runListFeatures() throws RemoteException {
    final PrintWriter pw = getOutPrintWriter();
    final List<FeatureInfo> list = mInterface.getSystemAvailableFeatures().getList();
    // sort by name
    Collections.sort(list, new Comparator<FeatureInfo>() {

        public int compare(FeatureInfo o1, FeatureInfo o2) {
            if (o1.name == o2.name)
                return 0;
            if (o1.name == null)
                return -1;
            if (o2.name == null)
                return 1;
            return o1.name.compareTo(o2.name);
        }
    });
    final int count = (list != null) ? list.size() : 0;
    for (int p = 0; p < count; p++) {
        FeatureInfo fi = list.get(p);
        pw.print("feature:");
        if (fi.name != null) {
            pw.print(fi.name);
            if (fi.version > 0) {
                pw.print("=");
                pw.print(fi.version);
            }
            pw.println();
        } else {
            pw.println("reqGlEsVersion=0x" + Integer.toHexString(fi.reqGlEsVersion));
        }
    }
    return 0;
}
Also used : FeatureInfo(android.content.pm.FeatureInfo) PrintWriter(java.io.PrintWriter)

Example 32 with FeatureInfo

use of android.content.pm.FeatureInfo in project acra by ACRA.

the class DeviceFeaturesCollector method collect.

/**
     * collects device features
     *
     * @param reportField   the ReportField to collect
     * @param reportBuilder the current reportBuilder
     * @return Element of all device feature names
     */
@NonNull
@Override
Element collect(ReportField reportField, ReportBuilder reportBuilder) {
    final ComplexElement result = new ComplexElement();
    try {
        final PackageManager pm = context.getPackageManager();
        final FeatureInfo[] features = pm.getSystemAvailableFeatures();
        for (final FeatureInfo feature : features) {
            final String featureName = feature.name;
            if (featureName != null) {
                result.put(featureName, true);
            } else {
                result.put("glEsVersion", feature.getGlEsVersion());
            }
        }
    } catch (Throwable e) {
        ACRA.log.w(LOG_TAG, "Couldn't retrieve DeviceFeatures for " + context.getPackageName(), e);
    }
    return result;
}
Also used : PackageManager(android.content.pm.PackageManager) FeatureInfo(android.content.pm.FeatureInfo) ComplexElement(org.acra.model.ComplexElement) NonNull(android.support.annotation.NonNull)

Example 33 with FeatureInfo

use of android.content.pm.FeatureInfo in project android_frameworks_base by DirtyUnicorns.

the class SystemConfig method addFeature.

private void addFeature(String name, int version) {
    FeatureInfo fi = mAvailableFeatures.get(name);
    if (fi == null) {
        fi = new FeatureInfo();
        fi.name = name;
        fi.version = version;
        mAvailableFeatures.put(name, fi);
    } else {
        fi.version = Math.max(fi.version, version);
    }
}
Also used : FeatureInfo(android.content.pm.FeatureInfo)

Example 34 with FeatureInfo

use of android.content.pm.FeatureInfo in project android_frameworks_base by AOSPA.

the class SystemConfig method addFeature.

private void addFeature(String name, int version) {
    FeatureInfo fi = mAvailableFeatures.get(name);
    if (fi == null) {
        fi = new FeatureInfo();
        fi.name = name;
        fi.version = version;
        mAvailableFeatures.put(name, fi);
    } else {
        fi.version = Math.max(fi.version, version);
    }
}
Also used : FeatureInfo(android.content.pm.FeatureInfo)

Example 35 with FeatureInfo

use of android.content.pm.FeatureInfo in project android_frameworks_base by AOSPA.

the class CameraBinderTestUtils method isFeatureAvailable.

public static final boolean isFeatureAvailable(Context context, String feature) {
    final PackageManager packageManager = context.getPackageManager();
    final FeatureInfo[] featuresList = packageManager.getSystemAvailableFeatures();
    for (FeatureInfo f : featuresList) {
        if (f.name != null && f.name.equals(feature)) {
            return true;
        }
    }
    return false;
}
Also used : PackageManager(android.content.pm.PackageManager) FeatureInfo(android.content.pm.FeatureInfo)

Aggregations

FeatureInfo (android.content.pm.FeatureInfo)42 PackageManager (android.content.pm.PackageManager)23 PrintWriter (java.io.PrintWriter)4 ArrayList (java.util.ArrayList)4 FileReader (java.io.FileReader)3 IOException (java.io.IOException)3 NonNull (android.annotation.NonNull)2 IntentFilterVerificationInfo (android.content.pm.IntentFilterVerificationInfo)2 PackageParser (android.content.pm.PackageParser)2 ParceledListSlice (android.content.pm.ParceledListSlice)2 ArrayMap (android.util.ArrayMap)2 FastXmlSerializer (com.android.internal.util.FastXmlSerializer)2 IndentingPrintWriter (com.android.internal.util.IndentingPrintWriter)2 BufferedOutputStream (java.io.BufferedOutputStream)2 BufferedReader (java.io.BufferedReader)2 FileOutputStream (java.io.FileOutputStream)2 Map (java.util.Map)2 XmlSerializer (org.xmlpull.v1.XmlSerializer)2 RemoteException (android.os.RemoteException)1 NonNull (android.support.annotation.NonNull)1