From 2f4b00dc7518ffb6442767307ddf172c272ace5e Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Fri, 5 May 2017 13:53:06 +1000 Subject: [PATCH] Formatting --- app/src/main/java/org/fdroid/fdroid/FDroidApp.java | 14 ++++++++------ .../org/fdroid/fdroid/installer/Installer.java | 9 +++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/FDroidApp.java b/app/src/main/java/org/fdroid/fdroid/FDroidApp.java index b0d494051..3dabde160 100644 --- a/app/src/main/java/org/fdroid/fdroid/FDroidApp.java +++ b/app/src/main/java/org/fdroid/fdroid/FDroidApp.java @@ -368,20 +368,21 @@ public class FDroidApp extends Application { if (resultCode == Activity.RESULT_CANCELED) { return; } + String bluetoothPackageName = null; String className = null; boolean found = false; Intent sendBt = null; + try { PackageManager pm = getPackageManager(); - ApplicationInfo appInfo = pm.getApplicationInfo(packageName, - PackageManager.GET_META_DATA); + ApplicationInfo appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); sendBt = new Intent(Intent.ACTION_SEND); - // The APK type is blocked by stock Android, so use zip - // sendBt.setType("application/vnd.android.package-archive"); + + // The APK type ("application/vnd.android.package-archive") is blocked by stock Android, so use zip sendBt.setType("application/zip"); - sendBt.putExtra(Intent.EXTRA_STREAM, - Uri.parse("file://" + appInfo.publicSourceDir)); + sendBt.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + appInfo.publicSourceDir)); + // not all devices have the same Bluetooth Activities, so // let's find it for (ResolveInfo info : pm.queryIntentActivities(sendBt, 0)) { @@ -397,6 +398,7 @@ public class FDroidApp extends Application { Log.e(TAG, "Could not get application info to send via bluetooth", e); found = false; } + if (sendBt != null) { if (found) { sendBt.setClassName(bluetoothPackageName, className); diff --git a/app/src/main/java/org/fdroid/fdroid/installer/Installer.java b/app/src/main/java/org/fdroid/fdroid/installer/Installer.java index 7bf061005..aa0805648 100644 --- a/app/src/main/java/org/fdroid/fdroid/installer/Installer.java +++ b/app/src/main/java/org/fdroid/fdroid/installer/Installer.java @@ -245,12 +245,10 @@ public abstract class Installer { try { // move apk file to private directory for installation and check hash - sanitizedUri = ApkFileProvider.getSafeUri( - context, localApkUri, apk, supportsContentUri()); + sanitizedUri = ApkFileProvider.getSafeUri(context, localApkUri, apk, supportsContentUri()); } catch (IOException e) { Log.e(TAG, e.getMessage(), e); - sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_INTERRUPTED, - e.getMessage()); + sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_INTERRUPTED, e.getMessage()); return; } @@ -260,8 +258,7 @@ public abstract class Installer { apkVerifier.verifyApk(); } catch (ApkVerifier.ApkVerificationException e) { Log.e(TAG, e.getMessage(), e); - sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_INTERRUPTED, - e.getMessage()); + sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_INTERRUPTED, e.getMessage()); return; } catch (ApkVerifier.ApkPermissionUnequalException e) { // if permissions of apk are not the ones listed in the repo