Proper SDK 24 version check
* not targetting SDK 24 due to https://gitlab.com/fdroid/fdroidserver/issues/185
This commit is contained in:
parent
16f97125d7
commit
5facd1b9a1
@ -91,9 +91,7 @@ public class DefaultInstaller extends Installer {
|
||||
|
||||
@Override
|
||||
protected boolean supportsContentUri() {
|
||||
// TODO: replace Android N check with proper version code
|
||||
//if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
// Android N only supports content Uris
|
||||
return "N".equals(Build.VERSION.CODENAME);
|
||||
return Build.VERSION.SDK_INT >= 24; // TODO: Use Build.VERSION_CODES.N
|
||||
}
|
||||
}
|
||||
|
@ -79,13 +79,11 @@ public class DefaultInstallerActivity extends FragmentActivity {
|
||||
throw new RuntimeException("Set the data uri to point to an apk location!");
|
||||
}
|
||||
// https://code.google.com/p/android/issues/detail?id=205827
|
||||
// TODO: re-enable after Android N release
|
||||
//if ((Build.VERSION.SDK_INT <= Build.VERSION_CODES.M)
|
||||
// && (!uri.getScheme().equals("file"))) {
|
||||
// throw new RuntimeException("PackageInstaller <= Android 6 only supports file scheme!");
|
||||
//}
|
||||
// TODO: replace with proper version check after Android N release
|
||||
if (("N".equals(Build.VERSION.CODENAME))
|
||||
if ((Build.VERSION.SDK_INT < 24) // TODO: Use Build.VERSION_CODES.N
|
||||
&& (!uri.getScheme().equals("file"))) {
|
||||
throw new RuntimeException("PackageInstaller < Android N only supports file scheme!");
|
||||
}
|
||||
if ((Build.VERSION.SDK_INT >= 24) // TODO: Use Build.VERSION_CODES.N
|
||||
&& (!uri.getScheme().equals("content"))) {
|
||||
throw new RuntimeException("PackageInstaller >= Android N only supports content scheme!");
|
||||
}
|
||||
@ -105,26 +103,13 @@ public class DefaultInstallerActivity extends FragmentActivity {
|
||||
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
|
||||
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
||||
intent.putExtra(Intent.EXTRA_ALLOW_REPLACE, true);
|
||||
} else if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
|
||||
} else if (Build.VERSION.SDK_INT < 24) { // TODO: Use Build.VERSION_CODES.N
|
||||
intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
|
||||
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
|
||||
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
||||
} else { // Android N
|
||||
intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
|
||||
// EXTRA_RETURN_RESULT throws a RuntimeException on N
|
||||
// https://gitlab.com/fdroid/fdroidclient/issues/631
|
||||
//intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
|
||||
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
||||
// grant READ permission for this content Uri
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
}
|
||||
|
||||
// TODO: remove whole block after Android N release
|
||||
if ("N".equals(Build.VERSION.CODENAME)) {
|
||||
intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
|
||||
// EXTRA_RETURN_RESULT throws a RuntimeException on N
|
||||
// https://gitlab.com/fdroid/fdroidclient/issues/631
|
||||
intent.putExtra(Intent.EXTRA_RETURN_RESULT, false);
|
||||
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
|
||||
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
||||
// grant READ permission for this content Uri
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
@ -188,13 +173,6 @@ public class DefaultInstallerActivity extends FragmentActivity {
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: remove Android N hack after release
|
||||
// Fallback on N for https://gitlab.com/fdroid/fdroidclient/issues/631
|
||||
if ("N".equals(Build.VERSION.CODENAME)) {
|
||||
installer.sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_COMPLETE);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (resultCode) {
|
||||
case Activity.RESULT_OK:
|
||||
installer.sendBroadcastInstall(downloadUri,
|
||||
|
Loading…
x
Reference in New Issue
Block a user