replugin 判断插件是否安装成功

360 插件里面 的类 RePluginCallbacks 的 onPluginNotExistsForActivity 方法 可以获取 未安装的插件名。

replugin 判断插件是否安装成功_第1张图片
image.png

通过获取插件的状态 PluginStatusController.getStatus(plugin) 来判断

public class HostRePluginCallbacks extends RePluginCallbacks{
    private static final String TAG = "HostRePluginCallbacks";
    public HostRePluginCallbacks(Context context) {
        super(context);
    }

    @Override
    public boolean onLoadLargePluginForActivity(Context context, String plugin, Intent intent, int process) {
        return super.onLoadLargePluginForActivity(context, plugin, intent, process);
    }

    @Override
    public boolean onPluginNotExistsForActivity(final Context context, final String plugin, Intent intent, int process) {
        // FIXME 当插件"没有安装"时触发此逻辑,可打开您的"下载对话框"并开始下载。
        // FIXME 其中"intent"需传递到"对话框"内,这样可在下载完成后,打开这个插件的Activity
        Log.e(TAG, "onPluginNotExistsForActivity: 插件没有安装 : plugin=" + plugin + "; intent=" + intent + "plugin.getStatus" + PluginStatusController.getStatus(plugin));
        if("host".equals(plugin)){
            Log.e(TAG, "onPluginNotExistsForActivity: host.equals(plugin)");
            return true;
        }
        /*if (RePlugin.getPluginInfo(plugin) != null) {
            Log.e(TAG, "onPluginNotExistsForActivity: PluginStatusController.getStatus: ok : info不为空... context=" + context + "; plugin=" + plugin + "; intent=" + intent);
            PluginToast.showLong(context, "此功能暂停使用");
            return true;
        }*/

        switch (PluginStatusController.getStatus(plugin)){
            case STATUS_DISABLE_BY_CLOUD://disable了,重新安装
                Log.e(TAG, "onPluginNotExistsForActivity: PluginStatusController.getStatus: disable了,重新安装... context=" + context + "; plugin=" + plugin + "; intent=" + intent);
           
                break;
            case STATUS_DISABLE_BY_CRASH:// 装了,但是crash掉了(比如Activity找不到)
                Log.e(TAG, "onPluginNotExistsForActivity: PluginStatusController.getStatus: crash掉了... context=" + context + "; plugin=" + plugin + "; intent=" + intent);
           
                break;
            case STATUS_OK:// 安装
                Log.e(TAG, "onPluginNotExistsForActivity: PluginStatusController.getStatus: ok : info是空的... context=" + context + "; plugin=" + plugin + "; intent=" + intent);
         
                break;
            default:
                Log.e(TAG, "onPluginNotExistsForActivity: PluginStatusController.getStatus: default... context=" + context + "; plugin=" + plugin + "; intent=" + intent);
            
                break;
        }
        return true;
    }
}

你可能感兴趣的:(replugin 判断插件是否安装成功)