// Path: PluginManager/src/main/java/com/reginald/pluginm/utils/Logger.java
// public class Logger {
//     public static final String TAG = "PluginM";
//     public static boolean LOG_ENABLED = BuildConfig.DEBUG_LOG;
//     public static boolean ALWAYS_SHOW_ERROR = true;
// 
//     public static void d(String tag, String msg) {
//         if (LOG_ENABLED) {
//             Log.d(TAG, getLogMsg(tag, msg));
//         }
//     }
// 
//     public static void d(String tag, String formatMsg, Object... args) {
//         if (LOG_ENABLED) {
//             d(tag, String.format(formatMsg, args));
//         }
//     }
// 
//     public static void i(String tag, String msg) {
//         if (LOG_ENABLED) {
//             Log.i(TAG, getLogMsg(tag, msg));
//         }
//     }
// 
//     public static void i(String tag, String formatMsg, Object... args) {
//         if (LOG_ENABLED) {
//             i(tag, String.format(formatMsg, args));
//         }
//     }
// 
//     public static void w(String tag, String msg) {
//         if (LOG_ENABLED) {
//             Log.w(TAG, getLogMsg(tag, msg));
//         }
//     }
// 
//     public static void w(String tag, String formatMsg, Object... args) {
//         if (LOG_ENABLED) {
//             w(tag, String.format(formatMsg, args));
//         }
//     }
// 
//     public static void w(String tag, String msg, Throwable e) {
//         if (LOG_ENABLED) {
//             Log.w(TAG, getLogMsg(tag, msg + " Exception: " + getExceptionMsg(e)));
//         }
//     }
// 
//     public static void w(String tag, Throwable e, String formatMsg, Object... args) {
//         if (LOG_ENABLED) {
//             w(tag, String.format(formatMsg, args), e);
//         }
//     }
// 
//     public static void e(String tag, String msg) {
//         if (LOG_ENABLED || ALWAYS_SHOW_ERROR) {
//             Log.e(TAG, getLogMsg(tag, msg));
//         }
//     }
// 
//     public static void e(String tag, String formatMsg, Object... args) {
//         if (LOG_ENABLED || ALWAYS_SHOW_ERROR) {
//             e(tag, String.format(formatMsg, args));
//         }
//     }
// 
//     public static void e(String tag, String msg, Throwable e) {
//         if (LOG_ENABLED || ALWAYS_SHOW_ERROR) {
//             Log.e(TAG, getLogMsg(tag, msg + " Exception: " + getExceptionMsg(e)));
//         }
//     }
// 
//     public static void e(String tag, Throwable e, String formatMsg, Object... args) {
//         if (LOG_ENABLED || ALWAYS_SHOW_ERROR) {
//             e(tag, String.format(formatMsg, args), e);
//         }
//     }
// 
//     private static String getLogMsg(String subTag, String msg) {
//         return "[" + subTag + "] " + msg;
//     }
// 
//     private static String getExceptionMsg(Throwable e) {
//         StringWriter sw = new StringWriter(1024);
//         PrintWriter pw = new PrintWriter(sw);
//         e.printStackTrace(pw);
//         pw.close();
//         return sw.toString();
//     }
// }


import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import com.reginald.pluginm.utils.Logger;
import java.util.HashMap;
import java.util.WeakHashMap;
package com.reginald.pluginm.stub;




/**
 * Created by lxy on 16-7-1.
 */
public class PluginServiceConnection implements ServiceConnection {
    private static final String TAG = "PluginServiceConnection";

    private static WeakHashMap<ServiceConnection, PluginServiceConnection> sConnectionMap = new WeakHashMap<>();
    private HashMap<ComponentName, ConnectionInfo> mBinderMap = new HashMap<>();
    private ServiceConnection mBase;

    public PluginServiceConnection(ServiceConnection serviceConnection) {
        mBase = serviceConnection;
    }

    public static PluginServiceConnection getConnection(ServiceConnection conn) {
        synchronized (sConnectionMap) {
            PluginServiceConnection pluginConn = sConnectionMap.get(conn);
// Path: PluginManager/src/main/java/com/reginald/pluginm/utils/Logger.java
// public class Logger {
//     public static final String TAG = "PluginM";
//     public static boolean LOG_ENABLED = BuildConfig.DEBUG_LOG;
//     public static boolean ALWAYS_SHOW_ERROR = true;
// 
//     public static void d(String tag, String msg) {
//         if (LOG_ENABLED) {
//             Log.d(TAG, getLogMsg(tag, msg));
//         }
//     }
// 
//     public static void d(String tag, String formatMsg, Object... args) {
//         if (LOG_ENABLED) {
//             d(tag, String.format(formatMsg, args));
//         }
//     }
// 
//     public static void i(String tag, String msg) {
//         if (LOG_ENABLED) {
//             Log.i(TAG, getLogMsg(tag, msg));
//         }
//     }
// 
//     public static void i(String tag, String formatMsg, Object... args) {
//         if (LOG_ENABLED) {
//             i(tag, String.format(formatMsg, args));
//         }
//     }
// 
//     public static void w(String tag, String msg) {
//         if (LOG_ENABLED) {
//             Log.w(TAG, getLogMsg(tag, msg));
//         }
//     }
// 
//     public static void w(String tag, String formatMsg, Object... args) {
//         if (LOG_ENABLED) {
//             w(tag, String.format(formatMsg, args));
//         }
//     }
// 
//     public static void w(String tag, String msg, Throwable e) {
//         if (LOG_ENABLED) {
//             Log.w(TAG, getLogMsg(tag, msg + " Exception: " + getExceptionMsg(e)));
//         }
//     }
// 
//     public static void w(String tag, Throwable e, String formatMsg, Object... args) {
//         if (LOG_ENABLED) {
//             w(tag, String.format(formatMsg, args), e);
//         }
//     }
// 
//     public static void e(String tag, String msg) {
//         if (LOG_ENABLED || ALWAYS_SHOW_ERROR) {
//             Log.e(TAG, getLogMsg(tag, msg));
//         }
//     }
// 
//     public static void e(String tag, String formatMsg, Object... args) {
//         if (LOG_ENABLED || ALWAYS_SHOW_ERROR) {
//             e(tag, String.format(formatMsg, args));
//         }
//     }
// 
//     public static void e(String tag, String msg, Throwable e) {
//         if (LOG_ENABLED || ALWAYS_SHOW_ERROR) {
//             Log.e(TAG, getLogMsg(tag, msg + " Exception: " + getExceptionMsg(e)));
//         }
//     }
// 
//     public static void e(String tag, Throwable e, String formatMsg, Object... args) {
//         if (LOG_ENABLED || ALWAYS_SHOW_ERROR) {
//             e(tag, String.format(formatMsg, args), e);
//         }
//     }
// 
//     private static String getLogMsg(String subTag, String msg) {
//         return "[" + subTag + "] " + msg;
//     }
// 
//     private static String getExceptionMsg(Throwable e) {
//         StringWriter sw = new StringWriter(1024);
//         PrintWriter pw = new PrintWriter(sw);
//         e.printStackTrace(pw);
//         pw.close();
//         return sw.toString();
//     }
// }


// Path: PluginManager/src/main/java/com/reginald/pluginm/stub/PluginServiceConnection.java
import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import com.reginald.pluginm.utils.Logger;
import java.util.HashMap;
import java.util.WeakHashMap;

package com.reginald.pluginm.stub;




/**
 * Created by lxy on 16-7-1.
 */
public class PluginServiceConnection implements ServiceConnection {
    private static final String TAG = "PluginServiceConnection";

    private static WeakHashMap<ServiceConnection, PluginServiceConnection> sConnectionMap = new WeakHashMap<>();
    private HashMap<ComponentName, ConnectionInfo> mBinderMap = new HashMap<>();
    private ServiceConnection mBase;

    public PluginServiceConnection(ServiceConnection serviceConnection) {
        mBase = serviceConnection;
    }

    public static PluginServiceConnection getConnection(ServiceConnection conn) {
        synchronized (sConnectionMap) {
            PluginServiceConnection pluginConn = sConnectionMap.get(conn);
            Logger.d(TAG, String.format("getConnection(%s) return %s", conn, pluginConn));