Search in sources :

Example 1 with FeatureInfo

use of android.content.pm.FeatureInfo in project cw-omnibus by commonsguy.

the class AbstractMapActivity method getVersionFromPackageManager.

// following from
// https://android.googlesource.com/platform/cts/+/master/tests/tests/graphics/src/android/opengl/cts/OpenGlEsVersionTest.java
/*
   * Copyright (C) 2010 The Android Open Source Project
   * 
   * Licensed under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in
   * compliance with the License. You may obtain a copy of
   * the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in
   * writing, software distributed under the License is
   * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   * CONDITIONS OF ANY KIND, either express or implied. See
   * the License for the specific language governing
   * permissions and limitations under the License.
   */
private static int getVersionFromPackageManager(Context context) {
    PackageManager packageManager = context.getPackageManager();
    FeatureInfo[] featureInfos = packageManager.getSystemAvailableFeatures();
    if (featureInfos != null && featureInfos.length > 0) {
        for (FeatureInfo featureInfo : featureInfos) {
            // gl es version feature.
            if (featureInfo.name == null) {
                if (featureInfo.reqGlEsVersion != FeatureInfo.GL_ES_VERSION_UNDEFINED) {
                    return getMajorVersion(featureInfo.reqGlEsVersion);
                } else {
                    // Lack of property means OpenGL ES
                    return 1;
                // version 1
                }
            }
        }
    }
    return 1;
}
Also used : PackageManager(android.content.pm.PackageManager) FeatureInfo(android.content.pm.FeatureInfo)

Example 2 with FeatureInfo

use of android.content.pm.FeatureInfo in project cw-omnibus by commonsguy.

the class AbstractMapActivity method getVersionFromPackageManager.

// following from
// https://android.googlesource.com/platform/cts/+/master/tests/tests/graphics/src/android/opengl/cts/OpenGlEsVersionTest.java
/*
   * Copyright (C) 2010 The Android Open Source Project
   * 
   * Licensed under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in
   * compliance with the License. You may obtain a copy of
   * the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in
   * writing, software distributed under the License is
   * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   * CONDITIONS OF ANY KIND, either express or implied. See
   * the License for the specific language governing
   * permissions and limitations under the License.
   */
private static int getVersionFromPackageManager(Context context) {
    PackageManager packageManager = context.getPackageManager();
    FeatureInfo[] featureInfos = packageManager.getSystemAvailableFeatures();
    if (featureInfos != null && featureInfos.length > 0) {
        for (FeatureInfo featureInfo : featureInfos) {
            // gl es version feature.
            if (featureInfo.name == null) {
                if (featureInfo.reqGlEsVersion != FeatureInfo.GL_ES_VERSION_UNDEFINED) {
                    return getMajorVersion(featureInfo.reqGlEsVersion);
                } else {
                    // Lack of property means OpenGL ES
                    return 1;
                // version 1
                }
            }
        }
    }
    return 1;
}
Also used : PackageManager(android.content.pm.PackageManager) FeatureInfo(android.content.pm.FeatureInfo)

Example 3 with FeatureInfo

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

the class Pm method runListFeatures.

/**
     * Lists all of the features supported by the current device.
     *
     * pm list features
     */
private void runListFeatures() {
    try {
        List<FeatureInfo> list = new ArrayList<FeatureInfo>();
        FeatureInfo[] rawList = mPm.getSystemAvailableFeatures();
        for (int i = 0; i < rawList.length; i++) {
            list.add(rawList[i]);
        }
        // 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);
            }
        });
        int count = (list != null) ? list.size() : 0;
        for (int p = 0; p < count; p++) {
            FeatureInfo fi = list.get(p);
            System.out.print("feature:");
            if (fi.name != null)
                System.out.println(fi.name);
            else
                System.out.println("reqGlEsVersion=0x" + Integer.toHexString(fi.reqGlEsVersion));
        }
    } catch (RemoteException e) {
        System.err.println(e.toString());
        System.err.println(PM_NOT_RUNNING_ERR);
    }
}
Also used : ArrayList(java.util.ArrayList) FeatureInfo(android.content.pm.FeatureInfo) RemoteException(android.os.RemoteException)

Example 4 with FeatureInfo

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

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 5 with FeatureInfo

use of android.content.pm.FeatureInfo in project cw-omnibus by commonsguy.

the class AbstractMapActivity method getVersionFromPackageManager.

// following from
// https://android.googlesource.com/platform/cts/+/master/tests/tests/graphics/src/android/opengl/cts/OpenGlEsVersionTest.java
/*
   * Copyright (C) 2010 The Android Open Source Project
   * 
   * Licensed under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in
   * compliance with the License. You may obtain a copy of
   * the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in
   * writing, software distributed under the License is
   * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   * CONDITIONS OF ANY KIND, either express or implied. See
   * the License for the specific language governing
   * permissions and limitations under the License.
   */
private static int getVersionFromPackageManager(Context context) {
    PackageManager packageManager = context.getPackageManager();
    FeatureInfo[] featureInfos = packageManager.getSystemAvailableFeatures();
    if (featureInfos != null && featureInfos.length > 0) {
        for (FeatureInfo featureInfo : featureInfos) {
            // gl es version feature.
            if (featureInfo.name == null) {
                if (featureInfo.reqGlEsVersion != FeatureInfo.GL_ES_VERSION_UNDEFINED) {
                    return getMajorVersion(featureInfo.reqGlEsVersion);
                } else {
                    // Lack of property means OpenGL ES
                    return 1;
                // version 1
                }
            }
        }
    }
    return 1;
}
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