// Path: PluginManager/src/main/java/com/android/common/SystemPropertiesCompat.java
// public class SystemPropertiesCompat {
// 
//     private static Class<?> sClass;
// 
//     private static Class getMyClass() throws ClassNotFoundException {
//         if (sClass == null) {
//             sClass = Class.forName("android.os.SystemProperties");
//         }
//         return sClass;
//     }
// 
//     private static String getInner(String key, String defaultValue) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
//         Class clazz = getMyClass();
//         return (String) MethodUtils.invokeStaticMethod(clazz, "get", key, defaultValue);
//     }
// 
//     public static String get(String key, String defaultValue) {
//         try {
//             return getInner(key, defaultValue);
//         } catch (Exception e) {
//             return defaultValue;
//         }
//     }
// }


import android.content.pm.ProviderInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.Signature;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import com.android.common.SystemPropertiesCompat;
import java.io.File;
import java.util.HashSet;
import java.util.List;
import android.content.Context;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.InstrumentationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
/*
**        DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang <zhangyong232@gmail.com>
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin.  If not, see <http://www.gnu.org/licenses/lgpl.txt>
**
**/

package com.reginald.pluginm.parser;




/**
 * Created by Andy Zhang(zhangyong232@gmail.com) on 2015/2/13.
 */
abstract class PackageParser {
    protected Context mContext;

    protected Object mPackageParser;

    PackageParser(Context context) {
        mContext = context;
    }

    public final static int PARSE_IS_SYSTEM = 1 << 0;
    public final static int PARSE_CHATTY = 1 << 1;
    public final static int PARSE_MUST_BE_APK = 1 << 2;
    public final static int PARSE_IGNORE_PROCESSES = 1 << 3;
    public final static int PARSE_FORWARD_LOCK = 1 << 4;
    public final static int PARSE_ON_SDCARD = 1 << 5;
    public final static int PARSE_IS_SYSTEM_DIR = 1 << 6;
    public final static int PARSE_IS_PRIVILEGED = 1 << 7;
    public final static int PARSE_COLLECT_CERTIFICATES = 1 << 8;
    public final static int PARSE_TRUSTED_OVERLAY = 1 << 9;

    public static PackageParser newPluginParser(Context context) throws Exception {

        if (VERSION.SDK_INT >= VERSION_CODES.P) {
            return new PackageParserApi28(context);
        } else if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP_MR1) {
// Path: PluginManager/src/main/java/com/android/common/SystemPropertiesCompat.java
// public class SystemPropertiesCompat {
// 
//     private static Class<?> sClass;
// 
//     private static Class getMyClass() throws ClassNotFoundException {
//         if (sClass == null) {
//             sClass = Class.forName("android.os.SystemProperties");
//         }
//         return sClass;
//     }
// 
//     private static String getInner(String key, String defaultValue) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
//         Class clazz = getMyClass();
//         return (String) MethodUtils.invokeStaticMethod(clazz, "get", key, defaultValue);
//     }
// 
//     public static String get(String key, String defaultValue) {
//         try {
//             return getInner(key, defaultValue);
//         } catch (Exception e) {
//             return defaultValue;
//         }
//     }
// }


// Path: PluginManager/src/main/java/com/reginald/pluginm/parser/PackageParser.java
import android.content.pm.ProviderInfo;
import android.content.pm.ServiceInfo;
import android.content.pm.Signature;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import com.android.common.SystemPropertiesCompat;
import java.io.File;
import java.util.HashSet;
import java.util.List;
import android.content.Context;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.InstrumentationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;

/*
**        DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang <zhangyong232@gmail.com>
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin.  If not, see <http://www.gnu.org/licenses/lgpl.txt>
**
**/

package com.reginald.pluginm.parser;




/**
 * Created by Andy Zhang(zhangyong232@gmail.com) on 2015/2/13.
 */
abstract class PackageParser {
    protected Context mContext;

    protected Object mPackageParser;

    PackageParser(Context context) {
        mContext = context;
    }

    public final static int PARSE_IS_SYSTEM = 1 << 0;
    public final static int PARSE_CHATTY = 1 << 1;
    public final static int PARSE_MUST_BE_APK = 1 << 2;
    public final static int PARSE_IGNORE_PROCESSES = 1 << 3;
    public final static int PARSE_FORWARD_LOCK = 1 << 4;
    public final static int PARSE_ON_SDCARD = 1 << 5;
    public final static int PARSE_IS_SYSTEM_DIR = 1 << 6;
    public final static int PARSE_IS_PRIVILEGED = 1 << 7;
    public final static int PARSE_COLLECT_CERTIFICATES = 1 << 8;
    public final static int PARSE_TRUSTED_OVERLAY = 1 << 9;

    public static PackageParser newPluginParser(Context context) throws Exception {

        if (VERSION.SDK_INT >= VERSION_CODES.P) {
            return new PackageParserApi28(context);
        } else if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP_MR1) {
            if ("1".equals(SystemPropertiesCompat.get("ro.build.version.preview_sdk", ""))) {