@Override
 public void onPluginStarted(String packageName) {
   Intent intent = new Intent(ACTION_PLUGIN_CHANGED);
   intent.putExtra(EXTRA_TYPE, "init");
   intent.putExtra(EXTRA_ID, packageName);
   PluginLoader.getApplicatoin().sendBroadcast(intent);
 }
  public static boolean copySo(File sourceDir, String so, String dest) {

    try {

      boolean isSuccess = false;

      if (Build.VERSION.SDK_INT >= 21) {
        String[] abis = Build.SUPPORTED_ABIS;
        if (abis != null) {
          for (String abi : abis) {
            LogUtil.d("try supported abi:", abi);
            String name = "lib" + File.separator + abi + File.separator + so;
            File sourceFile = new File(sourceDir, name);
            if (sourceFile.exists()) {
              isSuccess =
                  copyFile(
                      sourceFile.getAbsolutePath(),
                      dest + File.separator + "lib" + File.separator + so);
              // api21 64位系统的目录可能有些不同
              // copyFile(sourceFile.getAbsolutePath(), dest + File.separator +  name);
              break;
            }
          }
        }
      } else {
        LogUtil.d("supported api:", Build.CPU_ABI, Build.CPU_ABI2);

        String name = "lib" + File.separator + Build.CPU_ABI + File.separator + so;
        File sourceFile = new File(sourceDir, name);

        if (!sourceFile.exists() && Build.CPU_ABI2 != null) {
          name = "lib" + File.separator + Build.CPU_ABI2 + File.separator + so;
          sourceFile = new File(sourceDir, name);

          if (!sourceFile.exists()) {
            name = "lib" + File.separator + "armeabi" + File.separator + so;
            sourceFile = new File(sourceDir, name);
          }
        }
        if (sourceFile.exists()) {
          isSuccess =
              copyFile(
                  sourceFile.getAbsolutePath(),
                  dest + File.separator + "lib" + File.separator + so);
        }
      }

      if (!isSuccess) {
        Toast.makeText(
                PluginLoader.getApplicatoin(),
                "安装 " + so + " 失败: NO_MATCHING_ABIS",
                Toast.LENGTH_LONG)
            .show();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    return true;
  }
 @Override
 public void onPluginInstalled(String packageName, String version) {
   Intent intent = new Intent(ACTION_PLUGIN_CHANGED);
   intent.putExtra(EXTRA_TYPE, "install");
   intent.putExtra(EXTRA_ID, packageName);
   intent.putExtra(EXTRA_VERSION, version);
   PluginLoader.getApplicatoin().sendBroadcast(intent);
 }
  public static ArrayList<String> matchPlugin(Intent intent, int type) {
    ArrayList<String> result = null;

    String packageName = intent.getPackage();
    if (packageName == null && intent.getComponent() != null) {
      packageName = intent.getComponent().getPackageName();
    }
    if (packageName != null
        && !packageName.equals(PluginLoader.getApplicatoin().getPackageName())) {
      PluginDescriptor dp = getPluginDescriptorByPluginId(packageName);
      if (dp != null) {
        List<String> list = dp.matchPlugin(intent, type);
        if (list != null && list.size() > 0) {
          if (result == null) {
            result = new ArrayList<>();
          }
          result.addAll(list);
        }
      }
    } else {
      Iterator<PluginDescriptor> itr = getPlugins().iterator();
      while (itr.hasNext()) {
        List<String> list = itr.next().matchPlugin(intent, type);
        if (list != null && list.size() > 0) {
          if (result == null) {
            result = new ArrayList<>();
          }
          result.addAll(list);
        }
        if (result != null && type != PluginDescriptor.BROADCAST) {
          break;
        }
      }
    }
    return result;
  }
 @Override
 public void onPluginRemoveAll() {
   Intent intent = new Intent(ACTION_PLUGIN_CHANGED);
   intent.putExtra("type", "remove_all");
   PluginLoader.getApplicatoin().sendBroadcast(intent);
 }