blob: 4ed3c3150b5a0cf57976e14439699f16e25772d9 [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
19import android.app.IServiceConnection;
Dianne Hackborndd9b82c2009-09-03 00:18:47 -070020import android.app.PendingIntent;
Dianne Hackborn0c380492012-08-20 17:23:30 -070021import android.content.Context;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022
23import java.io.PrintWriter;
24
25/**
26 * Description of a single binding to a service.
27 */
28class ConnectionRecord {
29 final AppBindRecord binding; // The application/service binding.
Dianne Hackborn01e4cfc2010-06-24 15:07:24 -070030 final ActivityRecord activity; // If non-null, the owning activity.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031 final IServiceConnection conn; // The client connection.
32 final int flags; // Binding options.
Dianne Hackborndd9b82c2009-09-03 00:18:47 -070033 final int clientLabel; // String resource labeling this client.
34 final PendingIntent clientIntent; // How to launch the client.
Dianne Hackbornf210d6b2009-04-13 18:42:49 -070035 String stringName; // Caching of toString.
Dianne Hackborn130b0d22011-07-26 22:07:48 -070036 boolean serviceDead; // Well is it?
Dianne Hackbornf210d6b2009-04-13 18:42:49 -070037
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038 void dump(PrintWriter pw, String prefix) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039 pw.println(prefix + "binding=" + binding);
Dianne Hackborn1d442e02009-04-20 18:14:05 -070040 if (activity != null) {
41 pw.println(prefix + "activity=" + activity);
42 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043 pw.println(prefix + "conn=" + conn.asBinder()
44 + " flags=0x" + Integer.toHexString(flags));
45 }
46
Dianne Hackborn01e4cfc2010-06-24 15:07:24 -070047 ConnectionRecord(AppBindRecord _binding, ActivityRecord _activity,
Dianne Hackborndd9b82c2009-09-03 00:18:47 -070048 IServiceConnection _conn, int _flags,
49 int _clientLabel, PendingIntent _clientIntent) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050 binding = _binding;
51 activity = _activity;
52 conn = _conn;
53 flags = _flags;
Dianne Hackborndd9b82c2009-09-03 00:18:47 -070054 clientLabel = _clientLabel;
55 clientIntent = _clientIntent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080056 }
57
58 public String toString() {
Dianne Hackbornf210d6b2009-04-13 18:42:49 -070059 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 Hackbornb12e1352012-09-26 11:39:20 -070065 sb.append(" u");
66 sb.append(binding.client.userId);
Dianne Hackbornf210d6b2009-04-13 18:42:49 -070067 sb.append(' ');
Dianne Hackborn0c380492012-08-20 17:23:30 -070068 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 Hackbornb12e1352012-09-26 11:39:20 -070075 sb.append("!FG ");
Dianne Hackborn0c380492012-08-20 17:23:30 -070076 }
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) {
90 sb.append("ACT ");
91 }
92 if ((flags&Context.BIND_NOT_VISIBLE) != 0) {
Dianne Hackbornb12e1352012-09-26 11:39:20 -070093 sb.append("!VIS ");
94 }
95 if ((flags&Context.BIND_VISIBLE) != 0) {
96 sb.append("VIS ");
Dianne Hackborn0c380492012-08-20 17:23:30 -070097 }
Dianne Hackborn130b0d22011-07-26 22:07:48 -070098 if (serviceDead) {
99 sb.append("DEAD ");
100 }
Dianne Hackbornf210d6b2009-04-13 18:42:49 -0700101 sb.append(binding.service.shortName);
102 sb.append(":@");
103 sb.append(Integer.toHexString(System.identityHashCode(conn.asBinder())));
104 sb.append('}');
105 return stringName = sb.toString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800106 }
107}