From 3667c512b0367649306a060954a02eddb26684df Mon Sep 17 00:00:00 2001 From: Rafa Hernandez Date: Mon, 19 Feb 2018 10:10:11 -0400 Subject: [PATCH] fix(app): validate installation status Signed-off-by: Rafa Hernandez --- .../mdm/agent/ui/InstallAppActivity.java | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/flyve/mdm/agent/ui/InstallAppActivity.java b/app/src/main/java/org/flyve/mdm/agent/ui/InstallAppActivity.java index dd20dfefb3..b41fc1d21f 100644 --- a/app/src/main/java/org/flyve/mdm/agent/ui/InstallAppActivity.java +++ b/app/src/main/java/org/flyve/mdm/agent/ui/InstallAppActivity.java @@ -137,29 +137,33 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { status = "2"; // installed } else { FlyveLog.d("Installation failed"); + finish(); } } - PackageManager packageManager = InstallAppActivity.this.getPackageManager(); - - PackageInfo packageInfo = packageManager.getPackageArchiveInfo(appPath, 0); - packageInfo.applicationInfo.sourceDir = appPath; - packageInfo.applicationInfo.publicSourceDir = appPath; + try { + PackageManager packageManager = InstallAppActivity.this.getPackageManager(); - String appName = packageManager.getApplicationLabel(packageInfo.applicationInfo).toString(); - String appPackage = packageInfo.packageName; + PackageInfo packageInfo = packageManager.getPackageArchiveInfo(appPath, 0); + packageInfo.applicationInfo.sourceDir = appPath; + packageInfo.applicationInfo.publicSourceDir = appPath; + String appName = packageManager.getApplicationLabel(packageInfo.applicationInfo).toString(); + String appPackage = packageInfo.packageName; - AppDataBase dataBase = AppDataBase.getAppDatabase(InstallAppActivity.this); - Application apps = new Application(); + AppDataBase dataBase = AppDataBase.getAppDatabase(InstallAppActivity.this); + Application apps = new Application(); - apps.appId = id; - apps.appName = appName; - apps.appPath = appPath; - apps.appStatus = status; // 1 pending | 2 installed - apps.appPackage = appPackage; + apps.appId = id; + apps.appName = appName; + apps.appPath = appPath; + apps.appStatus = status; // 1 pending | 2 installed + apps.appPackage = appPackage; - dataBase.applicationDao().insert(apps); + dataBase.applicationDao().insert(apps); + } catch (Exception ex) { + FlyveLog.e(ex.getMessage()); + } finish(); }