blob: c655bb16bfd7a27f39c2b81a2fe07e3327398d54 [file] [log] [blame]
Kenny Rootcf0b38c2011-03-22 14:17:59 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server.pm;
18
19import com.android.internal.util.XmlUtils;
20import com.android.server.PreferredComponent;
21
22import org.xmlpull.v1.XmlPullParser;
23import org.xmlpull.v1.XmlPullParserException;
24import org.xmlpull.v1.XmlSerializer;
25
26import android.content.ComponentName;
27import android.content.IntentFilter;
28import android.util.Log;
29
30import java.io.IOException;
31
32class PreferredActivity extends IntentFilter implements PreferredComponent.Callbacks {
33 private static final String TAG = "PreferredActivity";
34
35 private static final boolean DEBUG_FILTERS = false;
Amith Yamasania3f133a2012-08-09 17:11:28 -070036 static final String ATTR_USER_ID = "userId";
Kenny Rootcf0b38c2011-03-22 14:17:59 -070037
38 final PreferredComponent mPref;
39
40 PreferredActivity(IntentFilter filter, int match, ComponentName[] set, ComponentName activity) {
41 super(filter);
42 mPref = new PreferredComponent(this, match, set, activity);
43 }
44
45 PreferredActivity(XmlPullParser parser) throws XmlPullParserException, IOException {
46 mPref = new PreferredComponent(this, parser);
47 }
48
Dianne Hackborn8a2ed1d2013-01-29 15:18:29 -080049 public void writeToXml(XmlSerializer serializer, boolean full) throws IOException {
50 mPref.writeToXml(serializer, full);
Kenny Rootcf0b38c2011-03-22 14:17:59 -070051 serializer.startTag(null, "filter");
Amith Yamasania3f133a2012-08-09 17:11:28 -070052 super.writeToXml(serializer);
Kenny Rootcf0b38c2011-03-22 14:17:59 -070053 serializer.endTag(null, "filter");
54 }
55
56 public boolean onReadTag(String tagName, XmlPullParser parser) throws XmlPullParserException,
57 IOException {
58 if (tagName.equals("filter")) {
59 if (DEBUG_FILTERS) {
60 Log.i(TAG, "Starting to parse filter...");
61 }
62 readFromXml(parser);
63 if (DEBUG_FILTERS) {
64 Log.i(TAG, "Finished filter: depth=" + parser.getDepth() + " tag="
65 + parser.getName());
66 }
67 } else {
68 PackageManagerService.reportSettingsProblem(Log.WARN,
69 "Unknown element under <preferred-activities>: " + parser.getName());
70 XmlUtils.skipCurrentTag(parser);
71 }
72 return true;
73 }
74}