fix "Send F-Droid via Bluetooth"
The 'com.mediatek.bluetooth' Bluetooth or android-23 devices were not being granted URI permissions.
This commit is contained in:
parent
9cfe8ef091
commit
ab8948eb5a
@ -257,7 +257,9 @@ public class StartSwapView extends RelativeLayout implements SwapWorkflowActivit
|
|||||||
textBluetoothVisible.setText(textResource);
|
textBluetoothVisible.setText(textResource);
|
||||||
|
|
||||||
bluetoothSwitch = (SwitchCompat) findViewById(R.id.switch_bluetooth);
|
bluetoothSwitch = (SwitchCompat) findViewById(R.id.switch_bluetooth);
|
||||||
Utils.debugLog(TAG, getManager().isBluetoothDiscoverable() ? "Initially marking switch as checked, because Bluetooth is discoverable." : "Initially marking switch as not-checked, because Bluetooth is not discoverable.");
|
Utils.debugLog(TAG, getManager().isBluetoothDiscoverable()
|
||||||
|
? "Initially marking switch as checked, because Bluetooth is discoverable."
|
||||||
|
: "Initially marking switch as not-checked, because Bluetooth is not discoverable.");
|
||||||
bluetoothSwitch.setOnCheckedChangeListener(onBluetoothSwitchToggled);
|
bluetoothSwitch.setOnCheckedChangeListener(onBluetoothSwitchToggled);
|
||||||
setBluetoothSwitchState(getManager().isBluetoothDiscoverable(), true);
|
setBluetoothSwitchState(getManager().isBluetoothDiscoverable(), true);
|
||||||
|
|
||||||
|
@ -580,7 +580,6 @@ public class FDroidApp extends Application {
|
|||||||
|
|
||||||
String bluetoothPackageName = null;
|
String bluetoothPackageName = null;
|
||||||
String className = null;
|
String className = null;
|
||||||
boolean found = false;
|
|
||||||
Intent sendBt = null;
|
Intent sendBt = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -599,20 +598,19 @@ public class FDroidApp extends Application {
|
|||||||
if ("com.android.bluetooth".equals(bluetoothPackageName)
|
if ("com.android.bluetooth".equals(bluetoothPackageName)
|
||||||
|| "com.mediatek.bluetooth".equals(bluetoothPackageName)) {
|
|| "com.mediatek.bluetooth".equals(bluetoothPackageName)) {
|
||||||
className = info.activityInfo.name;
|
className = info.activityInfo.name;
|
||||||
found = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
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;
|
className = null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Exception toLog = new RuntimeException("Error preparing file to send via Bluetooth", e);
|
Exception toLog = new RuntimeException("Error preparing file to send via Bluetooth", e);
|
||||||
ACRA.getErrorReporter().handleException(toLog, false);
|
ACRA.getErrorReporter().handleException(toLog, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendBt != null) {
|
if (sendBt != null) {
|
||||||
if (found) {
|
if (className != null) {
|
||||||
sendBt.setClassName(bluetoothPackageName, className);
|
sendBt.setClassName(bluetoothPackageName, className);
|
||||||
activity.startActivity(sendBt);
|
activity.startActivity(sendBt);
|
||||||
} else {
|
} else {
|
||||||
|
@ -37,14 +37,18 @@ import java.io.IOException;
|
|||||||
* either locally or for sending via bluetooth.
|
* either locally or for sending via bluetooth.
|
||||||
* <p/>
|
* <p/>
|
||||||
* APK handling for installations:
|
* APK handling for installations:
|
||||||
* 1. APKs are downloaded into a cache directory that is either created on SD card
|
* <ol>
|
||||||
|
* <li>APKs are downloaded into a cache directory that is either created on SD card
|
||||||
* <i>"/Android/data/[app_package_name]/cache/apks"</i> (if card is mounted and app has
|
* <i>"/Android/data/[app_package_name]/cache/apks"</i> (if card is mounted and app has
|
||||||
* appropriate permission) or on device's file system depending incoming parameters.
|
* appropriate permission) or on device's file system depending incoming parameters</li>
|
||||||
* 2. Before installation, the APK is copied into the private data directory of the F-Droid,
|
* <li>Before installation, the APK is copied into the private data directory of the F-Droid,
|
||||||
* <i>"/data/data/[app_package_name]/files/install-$random.apk"</i>.
|
* <i>"/data/data/[app_package_name]/files/install-$random.apk"</i></li>
|
||||||
* 3. The hash of the file is checked against the expected hash from the repository
|
* <li>The hash of the file is checked against the expected hash from the repository</li>
|
||||||
* 4. For Android < 7, a file Uri pointing to the File is returned, for Android >= 7,
|
* <li>For {@link Build.VERSION_CODES#M < android-23}, a {@code file://} {@link Uri}
|
||||||
* a content Uri is returned using support lib's FileProvider.
|
* pointing to the {@link File} is returned, for {@link Build.VERSION_CODES#M >= android-23},
|
||||||
|
* a {@code content://} {@code Uri} is returned using support lib's
|
||||||
|
* {@link FileProvider}</li>
|
||||||
|
* </ol>
|
||||||
*/
|
*/
|
||||||
public class ApkFileProvider extends FileProvider {
|
public class ApkFileProvider extends FileProvider {
|
||||||
|
|
||||||
@ -52,7 +56,7 @@ public class ApkFileProvider extends FileProvider {
|
|||||||
|
|
||||||
public static Uri getSafeUri(Context context, PackageInfo packageInfo) throws IOException {
|
public static Uri getSafeUri(Context context, PackageInfo packageInfo) throws IOException {
|
||||||
SanitizedFile tempApkFile = ApkCache.copyInstalledApkToFiles(context, packageInfo);
|
SanitizedFile tempApkFile = ApkCache.copyInstalledApkToFiles(context, packageInfo);
|
||||||
return getSafeUri(context, tempApkFile, Build.VERSION.SDK_INT >= 24);
|
return getSafeUri(context, tempApkFile, Build.VERSION.SDK_INT >= 23);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,12 +93,12 @@ public class ApkFileProvider extends FileProvider {
|
|||||||
context.grantUriPermission(PrivilegedInstaller.PRIVILEGED_EXTENSION_PACKAGE_NAME,
|
context.grantUriPermission(PrivilegedInstaller.PRIVILEGED_EXTENSION_PACKAGE_NAME,
|
||||||
apkUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
apkUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
context.grantUriPermission("com.android.bluetooth", apkUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
context.grantUriPermission("com.android.bluetooth", apkUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
context.grantUriPermission("com.mediatek.bluetooth", apkUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
return apkUri;
|
return apkUri;
|
||||||
|
} else {
|
||||||
|
tempFile.setReadable(true, false);
|
||||||
|
return Uri.fromFile(tempFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
tempFile.setReadable(true, false);
|
|
||||||
|
|
||||||
return Uri.fromFile(tempFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user