Formatting

This commit is contained in:
Peter Serwylo 2017-05-05 13:53:06 +10:00
parent bf8aedd79c
commit 2f4b00dc75
2 changed files with 11 additions and 12 deletions

View File

@ -368,20 +368,21 @@ public class FDroidApp extends Application {
if (resultCode == Activity.RESULT_CANCELED) { if (resultCode == Activity.RESULT_CANCELED) {
return; return;
} }
String bluetoothPackageName = null; String bluetoothPackageName = null;
String className = null; String className = null;
boolean found = false; boolean found = false;
Intent sendBt = null; Intent sendBt = null;
try { try {
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
ApplicationInfo appInfo = pm.getApplicationInfo(packageName, ApplicationInfo appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
PackageManager.GET_META_DATA);
sendBt = new Intent(Intent.ACTION_SEND); 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.setType("application/zip");
sendBt.putExtra(Intent.EXTRA_STREAM, sendBt.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + appInfo.publicSourceDir));
Uri.parse("file://" + appInfo.publicSourceDir));
// not all devices have the same Bluetooth Activities, so // not all devices have the same Bluetooth Activities, so
// let's find it // let's find it
for (ResolveInfo info : pm.queryIntentActivities(sendBt, 0)) { 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); Log.e(TAG, "Could not get application info to send via bluetooth", e);
found = false; found = false;
} }
if (sendBt != null) { if (sendBt != null) {
if (found) { if (found) {
sendBt.setClassName(bluetoothPackageName, className); sendBt.setClassName(bluetoothPackageName, className);

View File

@ -245,12 +245,10 @@ public abstract class Installer {
try { try {
// move apk file to private directory for installation and check hash // move apk file to private directory for installation and check hash
sanitizedUri = ApkFileProvider.getSafeUri( sanitizedUri = ApkFileProvider.getSafeUri(context, localApkUri, apk, supportsContentUri());
context, localApkUri, apk, supportsContentUri());
} catch (IOException e) { } catch (IOException e) {
Log.e(TAG, e.getMessage(), e); Log.e(TAG, e.getMessage(), e);
sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_INTERRUPTED, sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_INTERRUPTED, e.getMessage());
e.getMessage());
return; return;
} }
@ -260,8 +258,7 @@ public abstract class Installer {
apkVerifier.verifyApk(); apkVerifier.verifyApk();
} catch (ApkVerifier.ApkVerificationException e) { } catch (ApkVerifier.ApkVerificationException e) {
Log.e(TAG, e.getMessage(), e); Log.e(TAG, e.getMessage(), e);
sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_INTERRUPTED, sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_INTERRUPTED, e.getMessage());
e.getMessage());
return; return;
} catch (ApkVerifier.ApkPermissionUnequalException e) { } catch (ApkVerifier.ApkPermissionUnequalException e) {
// if permissions of apk are not the ones listed in the repo // if permissions of apk are not the ones listed in the repo