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 android.app.IServiceConnection; 20 import android.app.PendingIntent; 21 22 import java.io.PrintWriter; 23 24 /** 25 * Description of a single binding to a service. 26 */ 27 class ConnectionRecord { 28 final AppBindRecord binding; // The application/service binding. 29 final ActivityRecord activity; // If non-null, the owning activity. 30 final IServiceConnection conn; // The client connection. 31 final int flags; // Binding options. 32 final int clientLabel; // String resource labeling this client. 33 final PendingIntent clientIntent; // How to launch the client. 34 String stringName; // Caching of toString. 35 boolean serviceDead; // Well is it? 36 dump(PrintWriter pw, String prefix)37 void dump(PrintWriter pw, String prefix) { 38 pw.println(prefix + "binding=" + binding); 39 if (activity != null) { 40 pw.println(prefix + "activity=" + activity); 41 } 42 pw.println(prefix + "conn=" + conn.asBinder() 43 + " flags=0x" + Integer.toHexString(flags)); 44 } 45 ConnectionRecord(AppBindRecord _binding, ActivityRecord _activity, IServiceConnection _conn, int _flags, int _clientLabel, PendingIntent _clientIntent)46 ConnectionRecord(AppBindRecord _binding, ActivityRecord _activity, 47 IServiceConnection _conn, int _flags, 48 int _clientLabel, PendingIntent _clientIntent) { 49 binding = _binding; 50 activity = _activity; 51 conn = _conn; 52 flags = _flags; 53 clientLabel = _clientLabel; 54 clientIntent = _clientIntent; 55 } 56 toString()57 public String toString() { 58 if (stringName != null) { 59 return stringName; 60 } 61 StringBuilder sb = new StringBuilder(128); 62 sb.append("ConnectionRecord{"); 63 sb.append(Integer.toHexString(System.identityHashCode(this))); 64 sb.append(' '); 65 if (serviceDead) { 66 sb.append("DEAD "); 67 } 68 sb.append(binding.service.shortName); 69 sb.append(":@"); 70 sb.append(Integer.toHexString(System.identityHashCode(conn.asBinder()))); 71 sb.append('}'); 72 return stringName = sb.toString(); 73 } 74 } 75