update:2019.03.18

fix:增加桌面,应用市场,updatetools静默安装。增加亮屏后检测更新
add:
This commit is contained in:
2020-03-18 18:40:06 +08:00
parent e898f83670
commit f51ceac69d
8 changed files with 385 additions and 30 deletions

View File

@@ -16,6 +16,7 @@ import android.widget.Toast;
import androidx.core.content.FileProvider;
import com.info.sn.BuildConfig;
import com.info.sn.R;
import java.io.BufferedReader;
@@ -335,6 +336,49 @@ public class ApkUtils {
e.printStackTrace();
}
}
public static boolean installApp(Context context, String apkPath) {
ToastUtil.show("正在安装应用...");
Process process = null;
BufferedReader successResult = null;
BufferedReader errorResult = null;
StringBuilder successMsg = new StringBuilder();
StringBuilder errorMsg = new StringBuilder();
try {
process = new ProcessBuilder("pm", "install", "-i", BuildConfig.APPLICATION_ID, "--user", "0", apkPath).start();
successResult = new BufferedReader(new InputStreamReader(process.getInputStream()));
errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String s;
while ((s = successResult.readLine()) != null) {
successMsg.append(s);
}
while ((s = errorResult.readLine()) != null) {
errorMsg.append(s);
}
} catch (Exception e) {
} finally {
try {
if (successResult != null) {
successResult.close();
}
if (errorResult != null) {
errorResult.close();
}
} catch (Exception e) {
}
if (process != null) {
process.destroy();
}
}
Log.e("result", "" + errorMsg.toString());
//如果含有“success”认为安装成功
Log.e("installApp", successMsg.toString());
// if (!successMsg.toString().equalsIgnoreCase("success")) {
// ApkUtils.install(context, new File(apkPath));
// }
return successMsg.toString().equalsIgnoreCase("success");
}
public static void deleteApkInSilence(String packageName) {
Class<?> pmService;