Use Build.VERSION_CODES.N in installer classes

This commit is contained in:
Dominik Schürmann 2016-07-25 14:33:01 +02:00
parent cbbc3ab60d
commit b37d07a829
2 changed files with 4 additions and 4 deletions

View File

@ -92,6 +92,6 @@ public class DefaultInstaller extends Installer {
@Override @Override
protected boolean supportsContentUri() { protected boolean supportsContentUri() {
// Android N only supports content Uris // Android N only supports content Uris
return Build.VERSION.SDK_INT >= 24; // TODO: Use Build.VERSION_CODES.N return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
} }
} }

View File

@ -79,11 +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
if ((Build.VERSION.SDK_INT < 24) // TODO: Use Build.VERSION_CODES.N if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
&& (!uri.getScheme().equals("file"))) { && (!uri.getScheme().equals("file"))) {
throw new RuntimeException("PackageInstaller < Android N only supports file scheme!"); throw new RuntimeException("PackageInstaller < Android N only supports file scheme!");
} }
if ((Build.VERSION.SDK_INT >= 24) // TODO: Use Build.VERSION_CODES.N if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
&& (!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!");
} }
@ -103,7 +103,7 @@ 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 < 24) { // TODO: Use Build.VERSION_CODES.N } else if (Build.VERSION.SDK_INT < 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);