Installer: define all methods as abstract that need to be implemented in subclasses
This commit is contained in:
parent
04577d213c
commit
df696ed81e
@ -20,6 +20,7 @@
|
||||
package org.fdroid.fdroid.installer;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
@ -49,9 +50,7 @@ public class DefaultInstaller extends Installer {
|
||||
private static final int REQUEST_CODE_DELETE = 1;
|
||||
|
||||
@Override
|
||||
public void installPackage(File apkFile) throws AndroidNotCompatibleException {
|
||||
super.installPackage(apkFile);
|
||||
|
||||
public void installPackageInternal(File apkFile) throws AndroidNotCompatibleException {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(Uri.fromFile(apkFile),
|
||||
@ -64,9 +63,7 @@ public class DefaultInstaller extends Installer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePackage(String packageName) throws AndroidNotCompatibleException {
|
||||
super.deletePackage(packageName);
|
||||
|
||||
public void deletePackageInternal(String packageName) throws AndroidNotCompatibleException {
|
||||
PackageInfo pkgInfo = null;
|
||||
try {
|
||||
pkgInfo = mPm.getPackageInfo(packageName, 0);
|
||||
@ -109,4 +106,10 @@ public class DefaultInstaller extends Installer {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installPackageInternal(List<File> apkFiles) throws AndroidNotCompatibleException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.fdroid.fdroid.installer;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
@ -53,9 +54,7 @@ public class DefaultInstallerSdk14 extends Installer {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void installPackage(File apkFile) throws AndroidNotCompatibleException {
|
||||
super.installPackage(apkFile);
|
||||
|
||||
public void installPackageInternal(File apkFile) throws AndroidNotCompatibleException {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
|
||||
intent.setData(Uri.fromFile(apkFile));
|
||||
@ -76,9 +75,7 @@ public class DefaultInstallerSdk14 extends Installer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePackage(String packageName) throws AndroidNotCompatibleException {
|
||||
super.deletePackage(packageName);
|
||||
|
||||
public void deletePackageInternal(String packageName) throws AndroidNotCompatibleException {
|
||||
PackageInfo pkgInfo = null;
|
||||
try {
|
||||
pkgInfo = mPm.getPackageInfo(packageName, 0);
|
||||
@ -138,4 +135,10 @@ public class DefaultInstallerSdk14 extends Installer {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installPackageInternal(List<File> apkFiles) throws AndroidNotCompatibleException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ abstract public class Installer {
|
||||
return;
|
||||
}
|
||||
|
||||
// extended class now actually installs the package
|
||||
installPackageInternal(apkFile);
|
||||
}
|
||||
|
||||
public void installPackage(List<File> apkFiles) throws AndroidNotCompatibleException {
|
||||
@ -211,7 +211,7 @@ abstract public class Installer {
|
||||
}
|
||||
}
|
||||
|
||||
// extended class now actually installs the package
|
||||
installPackageInternal(apkFiles);
|
||||
}
|
||||
|
||||
public void deletePackage(String packageName) throws AndroidNotCompatibleException {
|
||||
@ -223,9 +223,18 @@ abstract public class Installer {
|
||||
return;
|
||||
}
|
||||
|
||||
// extended class now actually deletes the package
|
||||
deletePackageInternal(packageName);
|
||||
}
|
||||
|
||||
protected abstract void installPackageInternal(File apkFile)
|
||||
throws AndroidNotCompatibleException;
|
||||
|
||||
protected abstract void installPackageInternal(List<File> apkFiles)
|
||||
throws AndroidNotCompatibleException;
|
||||
|
||||
protected abstract void deletePackageInternal(String packageName)
|
||||
throws AndroidNotCompatibleException;
|
||||
|
||||
public abstract boolean handleOnActivityResult(int requestCode, int resultCode, Intent data);
|
||||
|
||||
public abstract boolean supportsUnattendedOperations();
|
||||
|
@ -52,9 +52,7 @@ public class RootInstaller extends Installer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installPackage(final File apkFile) throws AndroidNotCompatibleException {
|
||||
super.installPackage(apkFile);
|
||||
|
||||
public void installPackageInternal(final File apkFile) throws AndroidNotCompatibleException {
|
||||
rootSession = createShellBuilder().open(new Shell.OnCommandResultListener() {
|
||||
|
||||
// Callback to report whether the shell was successfully
|
||||
@ -77,9 +75,7 @@ public class RootInstaller extends Installer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installPackage(final List<File> apkFiles) throws AndroidNotCompatibleException {
|
||||
super.installPackage(apkFiles);
|
||||
|
||||
public void installPackageInternal(final List<File> apkFiles) throws AndroidNotCompatibleException {
|
||||
rootSession = createShellBuilder().open(new Shell.OnCommandResultListener() {
|
||||
|
||||
// Callback to report whether the shell was successfully
|
||||
@ -102,9 +98,7 @@ public class RootInstaller extends Installer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePackage(final String packageName) throws AndroidNotCompatibleException {
|
||||
super.deletePackage(packageName);
|
||||
|
||||
public void deletePackageInternal(final String packageName) throws AndroidNotCompatibleException {
|
||||
rootSession = createShellBuilder().open(new Shell.OnCommandResultListener() {
|
||||
|
||||
// Callback to report whether the shell was successfully
|
||||
|
@ -21,6 +21,7 @@ package org.fdroid.fdroid.installer;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -124,9 +125,7 @@ public class SystemPermissionInstaller extends Installer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installPackage(File apkFile) throws AndroidNotCompatibleException {
|
||||
super.installPackage(apkFile);
|
||||
|
||||
public void installPackageInternal(File apkFile) throws AndroidNotCompatibleException {
|
||||
Uri packageURI = Uri.fromFile(apkFile);
|
||||
try {
|
||||
mInstallMethod.invoke(mPm, new Object[] {
|
||||
@ -138,9 +137,7 @@ public class SystemPermissionInstaller extends Installer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePackage(String packageName) throws AndroidNotCompatibleException {
|
||||
super.deletePackage(packageName);
|
||||
|
||||
public void deletePackageInternal(String packageName) throws AndroidNotCompatibleException {
|
||||
try {
|
||||
mDeleteMethod.invoke(mPm, new Object[] {
|
||||
packageName, mDeleteObserver, 0
|
||||
@ -466,4 +463,10 @@ public class SystemPermissionInstaller extends Installer {
|
||||
* failed to delete the package since the user is restricted.
|
||||
*/
|
||||
public static final int DELETE_FAILED_USER_RESTRICTED = -3;
|
||||
|
||||
@Override
|
||||
protected void installPackageInternal(List<File> apkFiles) throws AndroidNotCompatibleException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user