//读取系统配置文件/system/etc/media_codecc.xml

File file = new File("/system/etc/media_codecs.xml");

InputStream in = null;

try {

in = new FileInputStream(file);

} catch (Exception e) {

// TODO: handle exception

}

if(in == null)

{

android.util.Log.i("xp", "in == null");

}else{

android.util.Log.i("xp", "in != null");

}

boolean isHardcode = false;

XmlPullParserFactory pullFactory;

try {

pullFactory = XmlPullParserFactory.newInstance();

XmlPullParser xmlPullParser = pullFactory.newPullParser();

xmlPullParser.setInput(in, "UTF-8");

int eventType = xmlPullParser.getEventType();

while (eventType != XmlPullParser.END_DOCUMENT) {

String tagName = xmlPullParser.getName();

switch (eventType) {

case XmlPullParser.START_TAG:

if ("MediaCodec".equals(tagName)) {

String componentName = xmlPullParser.getAttributeValue(0);

android.util.Log.i("xp", componentName);

if(componentName.startsWith("OMX."))

{

if(!componentName.startsWith("OMX.google."))

{

isHardcode = true;

}

}

}

}

eventType = xmlPullParser.next();

}

} catch (Exception e) {

// TODO: handle exception

}

android.util.Log.i("xp", ""+isHardcode);

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐