From da735e0ab38bd403bd7c28f82a30816d3be7e4ed Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Sun, 31 Jan 2021 21:27:54 +0000 Subject: [PATCH] SuW: Avoid showing exceptions if packages are not installed Just check if the package is installed before trying to disable it. Test: Observe that the following exception is not longer shown. Exception occurred while executing 'disable': java.lang.IllegalArgumentException: Unknown package: com.android.provision at com.android.server.pm.PackageManagerService.setEnabledSetting(PackageManagerService.java:21052) at com.android.server.pm.PackageManagerService.setApplicationEnabledSetting(PackageManagerService.java:20910) at com.android.server.pm.PackageManagerShellCommand.runSetEnabledSetting(PackageManagerShellCommand.java:2151) at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:231) at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98) at android.os.ShellCommand.exec(ShellCommand.java:44) at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21736) at android.os.Binder.shellCommand(Binder.java:929) at android.os.Binder.onTransact(Binder.java:813) at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4621) at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4361) at android.os.Binder.execTransactInternal(Binder.java:1159) at android.os.Binder.execTransact(Binder.java:1123) Change-Id: I646f2803f95817d7d9f2b1dfe54a9c1f8c9988e7 --- start_lineage_wizard.sh | 12 ++++++++---- start_lineage_wizard_with_gms.sh | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/start_lineage_wizard.sh b/start_lineage_wizard.sh index 5ad5e793..09ab6d1f 100755 --- a/start_lineage_wizard.sh +++ b/start_lineage_wizard.sh @@ -2,8 +2,12 @@ adb root wait ${!} -adb shell pm disable com.google.android.setupwizard || true -wait ${!} -adb shell pm disable com.android.provision || true -wait ${!} +if adb shell pm list packages | grep com.google.android.setupwizard; then + adb shell pm disable com.google.android.setupwizard || true + wait ${!} +fi +if adb shell pm list packages | grep com.android.provision; then + adb shell pm disable com.android.provision || true + wait ${!} +fi adb shell am start org.lineageos.setupwizard/org.lineageos.setupwizard.SetupWizardTestActivity diff --git a/start_lineage_wizard_with_gms.sh b/start_lineage_wizard_with_gms.sh index 2e036257..11a533cd 100755 --- a/start_lineage_wizard_with_gms.sh +++ b/start_lineage_wizard_with_gms.sh @@ -4,8 +4,10 @@ adb root wait ${!} adb shell pm enable com.google.android.setupwizard || true wait ${!} -adb shell pm disable com.android.provision || true -wait ${!} +if adb shell pm list packages | grep com.android.provision; then + adb shell pm disable com.android.provision || true + wait ${!} +fi adb shell am start org.lineageos.setupwizard/org.lineageos.setupwizard.SetupWizardTestActivity wait ${!} sleep 1