本文主要是介绍Android N(O) adb shell pm install package 流程分析,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
参考文献:https://blog.csdn.net/xuezhe__/article/details/73130567
1、alps/android_mtk/frameworks/base/cmds/pm/src/com/android/commands/pm/Pm.java
public static void main(String[] args) { int exitCode = 1;try { exitCode = new Pm().run(args);///step1} catch (Exception e) { Log.e(TAG, "Error", e);System.err.println("Error: " + e);if (e instanceof RemoteException) { System.err.println(PM_NOT_RUNNING_ERR);} } System.exit(exitCode); }
public int run(String[] args) throws RemoteException { boolean validCommand = false;if (args.length < 1) { return showUsage();} **************************************************** if ("install".equals(op)) { return runInstall();/step2}
private int runInstall() throws RemoteException { long startedTime = SystemClock.elapsedRealtime(); final InstallParams params = makeInstallParams(); final String inPath = nextArg();if (params.sessionParams.sizeBytes == -1 && !STDIN_PATH.equals(inPath)) { File file = new File(inPath);if (file.isFile()) { try { ApkLite baseApk = PackageParser.parseApkLite(file, 0); //step3PackageLite pkgLite = new PackageLite(null, baseApk, null, null, null, null,null, null); //step4params.sessionParams.setSize( PackageHelper.calculateInstalledSize(pkgLite, false,params.sessionParams.abiOverride));} catch (PackageParserException | IOException e) { System.err.println("Error: Failed to parse APK file: " + e);return 1;} } else { System.err.println("Error: Can't open non-file: " + inPath);return 1;} } final int sessionId = doCreateSession(params.sessionParams,params.installerPackageName, params.userId);/step5try
这篇关于Android N(O) adb shell pm install package 流程分析的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!