blob: df833ad86c359cc0c213017b9f25a51f04616f0e [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
17package com.android.server.am;
18
Dianne Hackborn24c98e82014-09-14 17:23:54 -070019import android.util.ArraySet;
20
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import java.io.PrintWriter;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022
23/**
24 * An association between a service and one of its client applications.
25 */
Dianne Hackbornbe4e6aa2013-06-07 13:25:29 -070026final class AppBindRecord {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027 final ServiceRecord service; // The running service.
28 final IntentBindRecord intent; // The intent we are bound to.
Dianne Hackbornc68c9132011-07-29 01:25:18 -070029 final ProcessRecord client; // Who has started/bound the service.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030
Dianne Hackborn24c98e82014-09-14 17:23:54 -070031 final ArraySet<ConnectionRecord> connections = new ArraySet<>();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032 // All ConnectionRecord for this client.
33
34 void dump(PrintWriter pw, String prefix) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035 pw.println(prefix + "service=" + service);
36 pw.println(prefix + "client=" + client);
Dianne Hackborn1d442e02009-04-20 18:14:05 -070037 dumpInIntentBind(pw, prefix);
38 }
39
40 void dumpInIntentBind(PrintWriter pw, String prefix) {
Dianne Hackborn24c98e82014-09-14 17:23:54 -070041 final int N = connections.size();
42 if (N > 0) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043 pw.println(prefix + "Per-process Connections:");
Dianne Hackborn24c98e82014-09-14 17:23:54 -070044 for (int i=0; i<N; i++) {
45 ConnectionRecord c = connections.valueAt(i);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046 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}