1 package com.android.server.pm;
3 * Copyright (C) 2006 The Android Open Source Project
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 import java.io.FileInputStream;
20 import java.io.FileNotFoundException;
21 import java.io.IOException;
22 import java.io.InputStream;
23 import java.util.HashMap;
24 import java.util.List;
26 import org.xmlpull.v1.XmlPullParser;
27 import org.xmlpull.v1.XmlPullParserException;
29 import android.app.Activity;
30 import android.content.res.AssetManager;
31 import android.util.Log;
32 import android.util.Xml;
35 * class xmlCheckExt is trying to check by xml rules definition
37 public class xmlCheckExt implements ICheckExt {
38 final private String TAG = "xmlCheckExt";
39 final private String CHECKXMLPATH = "/system/lib/arm/check.xml";
40 private HashMap<String,String > mMap = new HashMap<String,String >();
42 public boolean doCheck(String... params) {
44 String param_tag = null;
48 if (params.length == 0)
51 param_tag = params[1];
52 XmlPullParser xmlParser = Xml.newPullParser();
53 File file = new File(CHECKXMLPATH);
57 in = new FileInputStream(file);
58 xmlParser.setInput(in, "utf-8");
60 eventType = xmlParser.getEventType();
61 while (eventType != XmlPullParser.END_DOCUMENT) {
63 case XmlPullParser.START_TAG:
64 tag = xmlParser.getName();
65 Log.d(TAG,"<"+tag+">");
66 addTag(tag, xmlParser.nextText());
68 case XmlPullParser.END_TAG:
69 tag = xmlParser.getName();
70 Log.d(TAG,"</"+tag+">");
75 eventType = xmlParser.next();
78 } catch (XmlPullParserException e) {
79 // TODO Auto-generated catch block
81 } catch (FileNotFoundException e) {
82 // TODO Auto-generated catch block
84 } catch (IOException e) {
85 // TODO Auto-generated catch block
88 return checkPkgName(param, param_tag);
93 * add tag name to hash map
95 * tag - tag name in xml
96 * text - text for the tag
100 boolean addTag(String tag, String text) {
101 String pkgName = text;
102 Log.d(TAG, " pkgName = " + pkgName);
103 if(!mMap.containsKey(pkgName))
104 mMap.put(pkgName,tag);
108 boolean checkPkgName(String pkgName, String tag) {
109 String value = mMap.get(pkgName);
113 return value.equals(tag);