blob: 612e345744692ff47e1ce90890ada4900b5c1ce5 [file] [log] [blame]
Kenny Root15a4d2f2010-03-11 18:20:12 -08001/*
2 * Copyright (C) 2007 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
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080017package android.content.pm;
18
19import android.os.Parcel;
20import android.os.Parcelable;
Dianne Hackborneb034652009-09-07 00:49:58 -070021import android.util.Printer;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022
23/**
24 * Information you can retrieve about a particular application
25 * service. This corresponds to information collected from the
26 * AndroidManifest.xml's <service> tags.
27 */
28public class ServiceInfo extends ComponentInfo
29 implements Parcelable {
30 /**
31 * Optional name of a permission required to be able to access this
32 * Service. From the "permission" attribute.
33 */
34 public String permission;
35
Dianne Hackborn0c5001d2011-04-12 18:16:08 -070036 /**
37 * Bit in {@link #flags}: If set, the service will automatically be
38 * stopped by the system if the user removes a task that is rooted
39 * in one of the application's activities. Set from the
40 * {@link android.R.attr#stopWithTask} attribute.
41 */
42 public static final int FLAG_STOP_WITH_TASK = 0x0001;
43
44 /**
45 * Options that have been set in the service declaration in the
46 * manifest.
47 * These include:
48 * {@link #FLAG_STOP_WITH_TASK}
49 */
50 public int flags;
51
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052 public ServiceInfo() {
53 }
54
55 public ServiceInfo(ServiceInfo orig) {
56 super(orig);
57 permission = orig.permission;
Dianne Hackborn0c5001d2011-04-12 18:16:08 -070058 flags = orig.flags;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080059 }
60
Dianne Hackborneb034652009-09-07 00:49:58 -070061 public void dump(Printer pw, String prefix) {
62 super.dumpFront(pw, prefix);
63 pw.println(prefix + "permission=" + permission);
Dianne Hackborn0c5001d2011-04-12 18:16:08 -070064 pw.println(prefix + "flags=0x" + Integer.toHexString(flags));
Dianne Hackborneb034652009-09-07 00:49:58 -070065 }
66
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080067 public String toString() {
68 return "ServiceInfo{"
69 + Integer.toHexString(System.identityHashCode(this))
70 + " " + name + "}";
71 }
72
73 public int describeContents() {
74 return 0;
75 }
76
77 public void writeToParcel(Parcel dest, int parcelableFlags) {
78 super.writeToParcel(dest, parcelableFlags);
79 dest.writeString(permission);
Dianne Hackborn0c5001d2011-04-12 18:16:08 -070080 dest.writeInt(flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080081 }
82
83 public static final Creator<ServiceInfo> CREATOR =
84 new Creator<ServiceInfo>() {
85 public ServiceInfo createFromParcel(Parcel source) {
86 return new ServiceInfo(source);
87 }
88 public ServiceInfo[] newArray(int size) {
89 return new ServiceInfo[size];
90 }
91 };
92
93 private ServiceInfo(Parcel source) {
94 super(source);
95 permission = source.readString();
Dianne Hackborn0c5001d2011-04-12 18:16:08 -070096 flags = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080097 }
98}