ConnectionRecord.java revision 0c3804950236fe170ebf6cc7a5f1e3e305b8f315
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 17package com.android.server.am; 18 19import android.app.IServiceConnection; 20import android.app.PendingIntent; 21import android.content.Context; 22 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. 30 final ActivityRecord activity; // If non-null, the owning activity. 31 final IServiceConnection conn; // The client connection. 32 final int flags; // Binding options. 33 final int clientLabel; // String resource labeling this client. 34 final PendingIntent clientIntent; // How to launch the client. 35 String stringName; // Caching of toString. 36 boolean serviceDead; // Well is it? 37 38 void dump(PrintWriter pw, String prefix) { 39 pw.println(prefix + "binding=" + binding); 40 if (activity != null) { 41 pw.println(prefix + "activity=" + activity); 42 } 43 pw.println(prefix + "conn=" + conn.asBinder() 44 + " flags=0x" + Integer.toHexString(flags)); 45 } 46 47 ConnectionRecord(AppBindRecord _binding, ActivityRecord _activity, 48 IServiceConnection _conn, int _flags, 49 int _clientLabel, PendingIntent _clientIntent) { 50 binding = _binding; 51 activity = _activity; 52 conn = _conn; 53 flags = _flags; 54 clientLabel = _clientLabel; 55 clientIntent = _clientIntent; 56 } 57 58 public String toString() { 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))); 65 sb.append(' '); 66 if ((flags&Context.BIND_AUTO_CREATE) != 0) { 67 sb.append("CR "); 68 } 69 if ((flags&Context.BIND_DEBUG_UNBIND) != 0) { 70 sb.append("DBG "); 71 } 72 if ((flags&Context.BIND_NOT_FOREGROUND) != 0) { 73 sb.append("NOTFG "); 74 } 75 if ((flags&Context.BIND_ABOVE_CLIENT) != 0) { 76 sb.append("ABCLT "); 77 } 78 if ((flags&Context.BIND_ALLOW_OOM_MANAGEMENT) != 0) { 79 sb.append("OOM "); 80 } 81 if ((flags&Context.BIND_WAIVE_PRIORITY) != 0) { 82 sb.append("WPRI "); 83 } 84 if ((flags&Context.BIND_IMPORTANT) != 0) { 85 sb.append("IMP "); 86 } 87 if ((flags&Context.BIND_ADJUST_WITH_ACTIVITY) != 0) { 88 sb.append("ACT "); 89 } 90 if ((flags&Context.BIND_NOT_VISIBLE) != 0) { 91 sb.append("NOTVIS "); 92 } 93 if (serviceDead) { 94 sb.append("DEAD "); 95 } 96 sb.append(binding.service.shortName); 97 sb.append(":@"); 98 sb.append(Integer.toHexString(System.identityHashCode(conn.asBinder()))); 99 sb.append('}'); 100 return stringName = sb.toString(); 101 } 102} 103