Merge branch 'android-n' into 'master'

Workaround for Android N2 preview bug with EXTRA_RETURN_RESULT

A workaround for the bug discussed in https://gitlab.com/fdroid/fdroidclient/issues/631
The check against N is ugly, because: https://commonsware.com/blog/2016/03/17/backwards-compatibility-n-developer-preview.html

After removing EXTRA_RETURN_RESULT for Android N, we no longer get a result back on N, so instead of a proper error handling I always assume that the installation succeeds. Better than nothing...

See merge request !286
This commit is contained in:
Daniel Martí 2016-05-12 21:43:22 +00:00
commit 9a6e2f0c71

View File

@ -56,12 +56,16 @@ public class DefaultSdk14Installer extends Installer {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
intent.setData(Uri.fromFile(apkFile));
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
// EXTRA_RETURN_RESULT throws a RuntimeException on N
// https://gitlab.com/fdroid/fdroidclient/issues/631
if (!"N".equals(Build.VERSION.CODENAME)) {
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
}
// following extras only work when being installed as system-app
// https://code.google.com/p/android/issues/detail?id=42253
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
if (android.os.Build.VERSION.SDK_INT < 16) {
if (Build.VERSION.SDK_INT < 16) {
// deprecated in Android 4.1
intent.putExtra(Intent.EXTRA_ALLOW_REPLACE, true);
}
@ -103,6 +107,10 @@ public class DefaultSdk14Installer extends Installer {
mCallback.onError(InstallerCallback.OPERATION_INSTALL,
InstallerCallback.ERROR_CODE_OTHER);
}
// Fallback on N for https://gitlab.com/fdroid/fdroidclient/issues/631
if ("N".equals(Build.VERSION.CODENAME)) {
mCallback.onSuccess(InstallerCallback.OPERATION_INSTALL);
}
return true;
case REQUEST_CODE_DELETE: