The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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 | |
| 17 | package com.android.server.am; |
| 18 | |
| 19 | import android.app.IServiceConnection; |
Dianne Hackborn | dd9b82c | 2009-09-03 00:18:47 -0700 | [diff] [blame] | 20 | import android.app.PendingIntent; |
Dianne Hackborn | 0c38049 | 2012-08-20 17:23:30 -0700 | [diff] [blame] | 21 | import android.content.Context; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | |
| 23 | import java.io.PrintWriter; |
| 24 | |
| 25 | /** |
| 26 | * Description of a single binding to a service. |
| 27 | */ |
Dianne Hackborn | be4e6aa | 2013-06-07 13:25:29 -0700 | [diff] [blame] | 28 | final class ConnectionRecord { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | final AppBindRecord binding; // The application/service binding. |
Dianne Hackborn | daa0d5c | 2013-11-06 16:30:29 -0800 | [diff] [blame] | 30 | final ActivityRecord activity; // If non-null, the owning activity. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | final IServiceConnection conn; // The client connection. |
| 32 | final int flags; // Binding options. |
Dianne Hackborn | dd9b82c | 2009-09-03 00:18:47 -0700 | [diff] [blame] | 33 | final int clientLabel; // String resource labeling this client. |
| 34 | final PendingIntent clientIntent; // How to launch the client. |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 35 | String stringName; // Caching of toString. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 36 | boolean serviceDead; // Well is it? |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 37 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | void dump(PrintWriter pw, String prefix) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | pw.println(prefix + "binding=" + binding); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 40 | if (activity != null) { |
| 41 | pw.println(prefix + "activity=" + activity); |
| 42 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | pw.println(prefix + "conn=" + conn.asBinder() |
| 44 | + " flags=0x" + Integer.toHexString(flags)); |
| 45 | } |
| 46 | |
Dianne Hackborn | 01e4cfc | 2010-06-24 15:07:24 -0700 | [diff] [blame] | 47 | ConnectionRecord(AppBindRecord _binding, ActivityRecord _activity, |
Dianne Hackborn | dd9b82c | 2009-09-03 00:18:47 -0700 | [diff] [blame] | 48 | IServiceConnection _conn, int _flags, |
| 49 | int _clientLabel, PendingIntent _clientIntent) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 | binding = _binding; |
| 51 | activity = _activity; |
| 52 | conn = _conn; |
| 53 | flags = _flags; |
Dianne Hackborn | dd9b82c | 2009-09-03 00:18:47 -0700 | [diff] [blame] | 54 | clientLabel = _clientLabel; |
| 55 | clientIntent = _clientIntent; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | public String toString() { |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 59 | if (stringName != null) { |
| 60 | return stringName; |
| 61 | } |
| 62 | StringBuilder sb = new StringBuilder(128); |
| 63 | sb.append("ConnectionRecord{"); |
| 64 | sb.append(Integer.toHexString(System.identityHashCode(this))); |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 65 | sb.append(" u"); |
| 66 | sb.append(binding.client.userId); |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 67 | sb.append(' '); |
Dianne Hackborn | 0c38049 | 2012-08-20 17:23:30 -0700 | [diff] [blame] | 68 | if ((flags&Context.BIND_AUTO_CREATE) != 0) { |
| 69 | sb.append("CR "); |
| 70 | } |
| 71 | if ((flags&Context.BIND_DEBUG_UNBIND) != 0) { |
| 72 | sb.append("DBG "); |
| 73 | } |
| 74 | if ((flags&Context.BIND_NOT_FOREGROUND) != 0) { |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 75 | sb.append("!FG "); |
Dianne Hackborn | 0c38049 | 2012-08-20 17:23:30 -0700 | [diff] [blame] | 76 | } |
| 77 | if ((flags&Context.BIND_ABOVE_CLIENT) != 0) { |
| 78 | sb.append("ABCLT "); |
| 79 | } |
| 80 | if ((flags&Context.BIND_ALLOW_OOM_MANAGEMENT) != 0) { |
| 81 | sb.append("OOM "); |
| 82 | } |
| 83 | if ((flags&Context.BIND_WAIVE_PRIORITY) != 0) { |
| 84 | sb.append("WPRI "); |
| 85 | } |
| 86 | if ((flags&Context.BIND_IMPORTANT) != 0) { |
| 87 | sb.append("IMP "); |
| 88 | } |
| 89 | if ((flags&Context.BIND_ADJUST_WITH_ACTIVITY) != 0) { |
Dianne Hackborn | d69e4c1 | 2015-04-24 09:54:54 -0700 | [diff] [blame] | 90 | sb.append("WACT "); |
| 91 | } |
| 92 | if ((flags&Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE) != 0) { |
| 93 | sb.append("FGSA "); |
| 94 | } |
| 95 | if ((flags&Context.BIND_FOREGROUND_SERVICE) != 0) { |
| 96 | sb.append("FGS "); |
| 97 | } |
| 98 | if ((flags&Context.BIND_TREAT_LIKE_ACTIVITY) != 0) { |
| 99 | sb.append("LACT "); |
Dianne Hackborn | 0c38049 | 2012-08-20 17:23:30 -0700 | [diff] [blame] | 100 | } |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 101 | if ((flags&Context.BIND_VISIBLE) != 0) { |
| 102 | sb.append("VIS "); |
Dianne Hackborn | 0c38049 | 2012-08-20 17:23:30 -0700 | [diff] [blame] | 103 | } |
Dianne Hackborn | 8585d68 | 2013-07-18 15:39:51 -0700 | [diff] [blame] | 104 | if ((flags&Context.BIND_SHOWING_UI) != 0) { |
| 105 | sb.append("UI "); |
| 106 | } |
| 107 | if ((flags&Context.BIND_NOT_VISIBLE) != 0) { |
| 108 | sb.append("!VIS "); |
| 109 | } |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 110 | if (serviceDead) { |
| 111 | sb.append("DEAD "); |
| 112 | } |
Dianne Hackborn | f210d6b | 2009-04-13 18:42:49 -0700 | [diff] [blame] | 113 | sb.append(binding.service.shortName); |
| 114 | sb.append(":@"); |
| 115 | sb.append(Integer.toHexString(System.identityHashCode(conn.asBinder()))); |
| 116 | sb.append('}'); |
| 117 | return stringName = sb.toString(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 118 | } |
| 119 | } |