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 36 void dump(PrintWriter pw, String prefix) { 37 pw.println(prefix + "binding=" + binding); 38 if (activity != null) { 39 pw.println(prefix + "activity=" + activity); 40 } 41 pw.println(prefix + "conn=" + conn.asBinder() 42 + " flags=0x" + Integer.toHexString(flags)); 43 } 44 45 ConnectionRecord(AppBindRecord _binding, ActivityRecord _activity, 46 IServiceConnection _conn, int _flags, 47 int _clientLabel, PendingIntent _clientIntent) { 48 binding = _binding; 49 activity = _activity; 50 conn = _conn; 51 flags = _flags; 52 clientLabel = _clientLabel; 53 clientIntent = _clientIntent; 54 } 55 56 public String toString() { 57 if (stringName != null) { 58 return stringName; 59 } 60 StringBuilder sb = new StringBuilder(128); 61 sb.append("ConnectionRecord{"); 62 sb.append(Integer.toHexString(System.identityHashCode(this))); 63 sb.append(' '); 64 sb.append(binding.service.shortName); 65 sb.append(":@"); 66 sb.append(Integer.toHexString(System.identityHashCode(conn.asBinder()))); 67 sb.append('}'); 68 return stringName = sb.toString(); 69 } 70 } 71