// Path: util/src/main/java/com/ihongqiqu/util/ShellUtils.java
// public static class CommandResult {
// 
//     /**
//      * result of command *
//      */
//     public int result;
//     /**
//      * success message of command result *
//      */
//     public String successMsg;
//     /**
//      * error message of command result *
//      */
//     public String errorMsg;
// 
//     public CommandResult(int result) {
//         this.result = result;
//     }
// 
//     public CommandResult(int result, String successMsg, String errorMsg) {
//         this.result = result;
//         this.successMsg = successMsg;
//         this.errorMsg = errorMsg;
//     }
// }


import com.ihongqiqu.util.ShellUtils.CommandResult;
import java.io.File;
import java.util.List;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
     * app.</li>
     * </ul>
     *
     * @param context
     * @param filePath file path of package
     * @param pmParams pm install params
     * @return {@link PackageUtils#INSTALL_SUCCEEDED} means install success,
     * other means failed. details see {@link PackageUtils}
     * .INSTALL_FAILED_*. same to {@link PackageManager}.INSTALL_*
     */
    public static int installSilent(Context context, String filePath,
                                    String pmParams) {
        if (filePath == null || filePath.length() == 0) {
            return INSTALL_FAILED_INVALID_URI;
        }

        File file = new File(filePath);
        if (file.length() <= 0 || !file.exists() || !file.isFile()) {
            return INSTALL_FAILED_INVALID_URI;
        }

        /**
         * if context is system app, don't need root permission, but should add
         * <uses-permission android:name="android.permission.INSTALL_PACKAGES"
         * /> in mainfest
         **/
        StringBuilder command = new StringBuilder()
                .append("LD_LIBRARY_PATH=/vendor/lib:/system/lib pm install ")
                .append(pmParams == null ? "" : pmParams).append(" ")
                .append(filePath.replace(" ", "\\ "));
// Path: util/src/main/java/com/ihongqiqu/util/ShellUtils.java
// public static class CommandResult {
// 
//     /**
//      * result of command *
//      */
//     public int result;
//     /**
//      * success message of command result *
//      */
//     public String successMsg;
//     /**
//      * error message of command result *
//      */
//     public String errorMsg;
// 
//     public CommandResult(int result) {
//         this.result = result;
//     }
// 
//     public CommandResult(int result, String successMsg, String errorMsg) {
//         this.result = result;
//         this.successMsg = successMsg;
//         this.errorMsg = errorMsg;
//     }
// }


// Path: util/src/main/java/com/ihongqiqu/util/PackageUtils.java
import com.ihongqiqu.util.ShellUtils.CommandResult;
import java.io.File;
import java.util.List;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;

     * app.</li>
     * </ul>
     *
     * @param context
     * @param filePath file path of package
     * @param pmParams pm install params
     * @return {@link PackageUtils#INSTALL_SUCCEEDED} means install success,
     * other means failed. details see {@link PackageUtils}
     * .INSTALL_FAILED_*. same to {@link PackageManager}.INSTALL_*
     */
    public static int installSilent(Context context, String filePath,
                                    String pmParams) {
        if (filePath == null || filePath.length() == 0) {
            return INSTALL_FAILED_INVALID_URI;
        }

        File file = new File(filePath);
        if (file.length() <= 0 || !file.exists() || !file.isFile()) {
            return INSTALL_FAILED_INVALID_URI;
        }

        /**
         * if context is system app, don't need root permission, but should add
         * <uses-permission android:name="android.permission.INSTALL_PACKAGES"
         * /> in mainfest
         **/
        StringBuilder command = new StringBuilder()
                .append("LD_LIBRARY_PATH=/vendor/lib:/system/lib pm install ")
                .append(pmParams == null ? "" : pmParams).append(" ")
                .append(filePath.replace(" ", "\\ "));
        CommandResult commandResult = ShellUtils.execCommand(