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 | |
Dianne Hackborn | 24c98e8 | 2014-09-14 17:23:54 -0700 | [diff] [blame] | 19 | import android.util.ArraySet; |
| 20 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | import java.io.PrintWriter; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | import java.util.Iterator; |
| 23 | |
| 24 | /** |
| 25 | * An association between a service and one of its client applications. |
| 26 | */ |
Dianne Hackborn | be4e6aa | 2013-06-07 13:25:29 -0700 | [diff] [blame] | 27 | final class AppBindRecord { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | final ServiceRecord service; // The running service. |
| 29 | final IntentBindRecord intent; // The intent we are bound to. |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 30 | final ProcessRecord client; // Who has started/bound the service. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | |
Dianne Hackborn | 24c98e8 | 2014-09-14 17:23:54 -0700 | [diff] [blame] | 32 | final ArraySet<ConnectionRecord> connections = new ArraySet<>(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | // All ConnectionRecord for this client. |
| 34 | |
| 35 | void dump(PrintWriter pw, String prefix) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | pw.println(prefix + "service=" + service); |
| 37 | pw.println(prefix + "client=" + client); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 38 | dumpInIntentBind(pw, prefix); |
| 39 | } |
| 40 | |
| 41 | void dumpInIntentBind(PrintWriter pw, String prefix) { |
Dianne Hackborn | 24c98e8 | 2014-09-14 17:23:54 -0700 | [diff] [blame] | 42 | final int N = connections.size(); |
| 43 | if (N > 0) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | pw.println(prefix + "Per-process Connections:"); |
Dianne Hackborn | 24c98e8 | 2014-09-14 17:23:54 -0700 | [diff] [blame] | 45 | for (int i=0; i<N; i++) { |
| 46 | ConnectionRecord c = connections.valueAt(i); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | pw.println(prefix + " " + c); |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | AppBindRecord(ServiceRecord _service, IntentBindRecord _intent, |
| 53 | ProcessRecord _client) { |
| 54 | service = _service; |
| 55 | intent = _intent; |
| 56 | client = _client; |
| 57 | } |
| 58 | |
| 59 | public String toString() { |
| 60 | return "AppBindRecord{" |
| 61 | + Integer.toHexString(System.identityHashCode(this)) |
| 62 | + " " + service.shortName + ":" + client.processName + "}"; |
| 63 | } |
| 64 | } |