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 java.io.PrintWriter; 20 import java.util.HashSet; 21 import java.util.Iterator; 22 23 /** 24 * An association between a service and one of its client applications. 25 */ 26 class AppBindRecord { 27 final ServiceRecord service; // The running service. 28 final IntentBindRecord intent; // The intent we are bound to. 29 final ProcessRecord client; // Who has started/bound the service. 30 31 final HashSet<ConnectionRecord> connections = new HashSet<ConnectionRecord>(); 32 // All ConnectionRecord for this client. 33 34 void dump(PrintWriter pw, String prefix) { 35 pw.println(prefix + "service=" + service); 36 pw.println(prefix + "client=" + client); 37 dumpInIntentBind(pw, prefix); 38 } 39 40 void dumpInIntentBind(PrintWriter pw, String prefix) { 41 if (connections.size() > 0) { 42 pw.println(prefix + "Per-process Connections:"); 43 Iterator<ConnectionRecord> it = connections.iterator(); 44 while (it.hasNext()) { 45 ConnectionRecord c = it.next(); 46 pw.println(prefix + " " + c); 47 } 48 } 49 } 50 51 AppBindRecord(ServiceRecord _service, IntentBindRecord _intent, 52 ProcessRecord _client) { 53 service = _service; 54 intent = _intent; 55 client = _client; 56 } 57 58 public String toString() { 59 return "AppBindRecord{" 60 + Integer.toHexString(System.identityHashCode(this)) 61 + " " + service.shortName + ":" + client.processName + "}"; 62 } 63 } 64