Kenny Root | 15a4d2f | 2010-03-11 18:20:12 -0800 | [diff] [blame] | 1 | /* |
| 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 17 | package android.content.pm; |
| 18 | |
| 19 | import android.os.Parcel; |
| 20 | import android.os.Parcelable; |
Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 21 | import android.util.Printer; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | |
| 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 | */ |
| 28 | public 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 Hackborn | 0c5001d | 2011-04-12 18:16:08 -0700 | [diff] [blame] | 36 | /** |
| 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 | /** |
Dianne Hackborn | a0c283e | 2012-02-09 10:47:01 -0800 | [diff] [blame] | 45 | * Bit in {@link #flags}: If set, the service will run in its own |
| 46 | * isolated process. Set from the |
| 47 | * {@link android.R.attr#isolatedProcess} attribute. |
| 48 | */ |
| 49 | public static final int FLAG_ISOLATED_PROCESS = 0x0002; |
| 50 | |
| 51 | /** |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 52 | * Bit in {@link #flags}: If set, the service can be bound and run in the |
| 53 | * calling application's package, rather than the package in which it is |
| 54 | * declared. Set from {@link android.R.attr#externalService} attribute. |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 55 | */ |
| 56 | public static final int FLAG_EXTERNAL_SERVICE = 0x0004; |
| 57 | |
| 58 | /** |
Todd Kennedy | 7bc3a70 | 2016-12-08 14:54:48 -0800 | [diff] [blame] | 59 | * Bit in {@link #flags} indicating if the service is visible to ephemeral applications. |
| 60 | * @hide |
| 61 | */ |
Todd Kennedy | c05f5d1 | 2017-04-25 11:11:40 -0700 | [diff] [blame] | 62 | public static final int FLAG_VISIBLE_TO_INSTANT_APP = 0x100000; |
Todd Kennedy | 7bc3a70 | 2016-12-08 14:54:48 -0800 | [diff] [blame] | 63 | |
| 64 | /** |
Dianne Hackborn | b4163a6 | 2012-08-02 18:31:26 -0700 | [diff] [blame] | 65 | * Bit in {@link #flags}: If set, a single instance of the service will |
| 66 | * run for all users on the device. Set from the |
| 67 | * {@link android.R.attr#singleUser} attribute. |
| 68 | */ |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 69 | public static final int FLAG_SINGLE_USER = 0x40000000; |
Dianne Hackborn | b4163a6 | 2012-08-02 18:31:26 -0700 | [diff] [blame] | 70 | |
| 71 | /** |
Dianne Hackborn | 0c5001d | 2011-04-12 18:16:08 -0700 | [diff] [blame] | 72 | * Options that have been set in the service declaration in the |
| 73 | * manifest. |
| 74 | * These include: |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 75 | * {@link #FLAG_STOP_WITH_TASK}, {@link #FLAG_ISOLATED_PROCESS}, |
| 76 | * {@link #FLAG_SINGLE_USER}. |
Dianne Hackborn | 0c5001d | 2011-04-12 18:16:08 -0700 | [diff] [blame] | 77 | */ |
| 78 | public int flags; |
| 79 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | public ServiceInfo() { |
| 81 | } |
| 82 | |
| 83 | public ServiceInfo(ServiceInfo orig) { |
| 84 | super(orig); |
| 85 | permission = orig.permission; |
Dianne Hackborn | 0c5001d | 2011-04-12 18:16:08 -0700 | [diff] [blame] | 86 | flags = orig.flags; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 87 | } |
| 88 | |
Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 89 | public void dump(Printer pw, String prefix) { |
Dianne Hackborn | 6ac42ae | 2015-12-08 17:22:10 -0800 | [diff] [blame] | 90 | dump(pw, prefix, DUMP_FLAG_ALL); |
| 91 | } |
| 92 | |
| 93 | /** @hide */ |
Yohei Yukawa | 8f27217 | 2017-08-31 00:26:01 -0700 | [diff] [blame] | 94 | void dump(Printer pw, String prefix, int dumpFlags) { |
Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 95 | super.dumpFront(pw, prefix); |
| 96 | pw.println(prefix + "permission=" + permission); |
Dianne Hackborn | 0c5001d | 2011-04-12 18:16:08 -0700 | [diff] [blame] | 97 | pw.println(prefix + "flags=0x" + Integer.toHexString(flags)); |
Yohei Yukawa | 8f27217 | 2017-08-31 00:26:01 -0700 | [diff] [blame] | 98 | super.dumpBack(pw, prefix, dumpFlags); |
Dianne Hackborn | eb03465 | 2009-09-07 00:49:58 -0700 | [diff] [blame] | 99 | } |
Yohei Yukawa | 8f27217 | 2017-08-31 00:26:01 -0700 | [diff] [blame] | 100 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 101 | public String toString() { |
| 102 | return "ServiceInfo{" |
| 103 | + Integer.toHexString(System.identityHashCode(this)) |
| 104 | + " " + name + "}"; |
| 105 | } |
| 106 | |
| 107 | public int describeContents() { |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | public void writeToParcel(Parcel dest, int parcelableFlags) { |
| 112 | super.writeToParcel(dest, parcelableFlags); |
| 113 | dest.writeString(permission); |
Dianne Hackborn | 0c5001d | 2011-04-12 18:16:08 -0700 | [diff] [blame] | 114 | dest.writeInt(flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | public static final Creator<ServiceInfo> CREATOR = |
| 118 | new Creator<ServiceInfo>() { |
| 119 | public ServiceInfo createFromParcel(Parcel source) { |
| 120 | return new ServiceInfo(source); |
| 121 | } |
| 122 | public ServiceInfo[] newArray(int size) { |
| 123 | return new ServiceInfo[size]; |
| 124 | } |
| 125 | }; |
| 126 | |
| 127 | private ServiceInfo(Parcel source) { |
| 128 | super(source); |
| 129 | permission = source.readString(); |
Dianne Hackborn | 0c5001d | 2011-04-12 18:16:08 -0700 | [diff] [blame] | 130 | flags = source.readInt(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 131 | } |
| 132 | } |