Search in sources :

Example 26 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 27 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 28 with FeatureInfo

use of android.content.pm.FeatureInfo in project platform_frameworks_base by android.

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

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

the class PackageManagerService method getSystemAvailableFeatures.

public FeatureInfo[] getSystemAvailableFeatures() {
    Collection<FeatureInfo> featSet;
    synchronized (mPackages) {
        featSet = mAvailableFeatures.values();
        int size = featSet.size();
        if (size > 0) {
            FeatureInfo[] features = new FeatureInfo[size + 1];
            featSet.toArray(features);
            FeatureInfo fi = new FeatureInfo();
            fi.reqGlEsVersion = SystemProperties.getInt("ro.opengles.version", FeatureInfo.GL_ES_VERSION_UNDEFINED);
            features[size] = fi;
            return features;
        }
    }
    return null;
}
Also used : FeatureInfo(android.content.pm.FeatureInfo)

Example 30 with FeatureInfo

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

the class PackageManagerService method readPermissionsFromXml.

private void readPermissionsFromXml(File permFile) {
    FileReader permReader = null;
    try {
        permReader = new FileReader(permFile);
    } catch (FileNotFoundException e) {
        Slog.w(TAG, "Couldn't find or open permissions file " + permFile);
        return;
    }
    try {
        XmlPullParser parser = Xml.newPullParser();
        parser.setInput(permReader);
        XmlUtils.beginDocument(parser, "permissions");
        while (true) {
            XmlUtils.nextElement(parser);
            if (parser.getEventType() == XmlPullParser.END_DOCUMENT) {
                break;
            }
            String name = parser.getName();
            if ("group".equals(name)) {
                String gidStr = parser.getAttributeValue(null, "gid");
                if (gidStr != null) {
                    int gid = Process.getGidForName(gidStr);
                    mGlobalGids = appendInt(mGlobalGids, gid);
                } else {
                    Slog.w(TAG, "<group> without gid at " + parser.getPositionDescription());
                }
                XmlUtils.skipCurrentTag(parser);
                continue;
            } else if ("permission".equals(name)) {
                String perm = parser.getAttributeValue(null, "name");
                if (perm == null) {
                    Slog.w(TAG, "<permission> without name at " + parser.getPositionDescription());
                    XmlUtils.skipCurrentTag(parser);
                    continue;
                }
                perm = perm.intern();
                readPermission(parser, perm);
            } else if ("assign-permission".equals(name)) {
                String perm = parser.getAttributeValue(null, "name");
                if (perm == null) {
                    Slog.w(TAG, "<assign-permission> without name at " + parser.getPositionDescription());
                    XmlUtils.skipCurrentTag(parser);
                    continue;
                }
                String uidStr = parser.getAttributeValue(null, "uid");
                if (uidStr == null) {
                    Slog.w(TAG, "<assign-permission> without uid at " + parser.getPositionDescription());
                    XmlUtils.skipCurrentTag(parser);
                    continue;
                }
                int uid = Process.getUidForName(uidStr);
                if (uid < 0) {
                    Slog.w(TAG, "<assign-permission> with unknown uid \"" + uidStr + "\" at " + parser.getPositionDescription());
                    XmlUtils.skipCurrentTag(parser);
                    continue;
                }
                perm = perm.intern();
                HashSet<String> perms = mSystemPermissions.get(uid);
                if (perms == null) {
                    perms = new HashSet<String>();
                    mSystemPermissions.put(uid, perms);
                }
                perms.add(perm);
                XmlUtils.skipCurrentTag(parser);
            } else if ("library".equals(name)) {
                String lname = parser.getAttributeValue(null, "name");
                String lfile = parser.getAttributeValue(null, "file");
                if (lname == null) {
                    Slog.w(TAG, "<library> without name at " + parser.getPositionDescription());
                } else if (lfile == null) {
                    Slog.w(TAG, "<library> without file at " + parser.getPositionDescription());
                } else {
                    //Log.i(TAG, "Got library " + lname + " in " + lfile);
                    mSharedLibraries.put(lname, new SharedLibraryEntry(lfile, null));
                }
                XmlUtils.skipCurrentTag(parser);
                continue;
            } else if ("feature".equals(name)) {
                String fname = parser.getAttributeValue(null, "name");
                if (fname == null) {
                    Slog.w(TAG, "<feature> without name at " + parser.getPositionDescription());
                } else {
                    //Log.i(TAG, "Got feature " + fname);
                    FeatureInfo fi = new FeatureInfo();
                    fi.name = fname;
                    mAvailableFeatures.put(fname, fi);
                }
                XmlUtils.skipCurrentTag(parser);
                continue;
            } else {
                XmlUtils.skipCurrentTag(parser);
                continue;
            }
        }
        permReader.close();
    } catch (XmlPullParserException e) {
        Slog.w(TAG, "Got execption parsing permissions.", e);
    } catch (IOException e) {
        Slog.w(TAG, "Got execption parsing permissions.", e);
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) XmlPullParser(org.xmlpull.v1.XmlPullParser) FeatureInfo(android.content.pm.FeatureInfo) FileReader(java.io.FileReader) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException)

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