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
|
@Override
|
||||||
protected boolean supportsContentUri() {
|
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
|
// 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!");
|
throw new RuntimeException("Set the data uri to point to an apk location!");
|
||||||
}
|
}
|
||||||
// https://code.google.com/p/android/issues/detail?id=205827
|
// https://code.google.com/p/android/issues/detail?id=205827
|
||||||
// TODO: re-enable after Android N release
|
if ((Build.VERSION.SDK_INT < 24) // TODO: Use Build.VERSION_CODES.N
|
||||||
//if ((Build.VERSION.SDK_INT <= Build.VERSION_CODES.M)
|
&& (!uri.getScheme().equals("file"))) {
|
||||||
// && (!uri.getScheme().equals("file"))) {
|
throw new RuntimeException("PackageInstaller < Android N only supports file scheme!");
|
||||||
// throw new RuntimeException("PackageInstaller <= Android 6 only supports file scheme!");
|
}
|
||||||
//}
|
if ((Build.VERSION.SDK_INT >= 24) // TODO: Use Build.VERSION_CODES.N
|
||||||
// TODO: replace with proper version check after Android N release
|
|
||||||
if (("N".equals(Build.VERSION.CODENAME))
|
|
||||||
&& (!uri.getScheme().equals("content"))) {
|
&& (!uri.getScheme().equals("content"))) {
|
||||||
throw new RuntimeException("PackageInstaller >= Android N only supports content scheme!");
|
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_RETURN_RESULT, true);
|
||||||
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
||||||
intent.putExtra(Intent.EXTRA_ALLOW_REPLACE, 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.setAction(Intent.ACTION_INSTALL_PACKAGE);
|
||||||
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
|
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
|
||||||
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
||||||
} else { // Android N
|
} else { // Android N
|
||||||
intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
|
intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
|
||||||
// EXTRA_RETURN_RESULT throws a RuntimeException on N
|
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
|
||||||
// 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_NOT_UNKNOWN_SOURCE, true);
|
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
|
||||||
// grant READ permission for this content Uri
|
// grant READ permission for this content Uri
|
||||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
@ -188,13 +173,6 @@ public class DefaultInstallerActivity extends FragmentActivity {
|
|||||||
break;
|
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) {
|
switch (resultCode) {
|
||||||
case Activity.RESULT_OK:
|
case Activity.RESULT_OK:
|
||||||
installer.sendBroadcastInstall(downloadUri,
|
installer.sendBroadcastInstall(downloadUri,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user