Code cleanup and simplifications
This commit is contained in:
parent
70b392996c
commit
521218a45c
@ -64,26 +64,24 @@ public class DefaultInstaller extends Installer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void installPackageInternal(List<File> apkFiles) throws AndroidNotCompatibleException {
|
protected void installPackageInternal(List<File> apkFiles) throws AndroidNotCompatibleException {
|
||||||
// TODO Auto-generated method stub
|
// not used
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void deletePackageInternal(String packageName) throws AndroidNotCompatibleException {
|
protected void deletePackageInternal(String packageName) throws AndroidNotCompatibleException {
|
||||||
PackageInfo pkgInfo = null;
|
|
||||||
try {
|
try {
|
||||||
pkgInfo = mPm.getPackageInfo(packageName, 0);
|
PackageInfo pkgInfo = mPm.getPackageInfo(packageName, 0);
|
||||||
|
|
||||||
|
Uri uri = Uri.fromParts("package", pkgInfo.packageName, null);
|
||||||
|
Intent intent = new Intent(Intent.ACTION_DELETE, uri);
|
||||||
|
try {
|
||||||
|
mActivity.startActivityForResult(intent, REQUEST_CODE_DELETE);
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
throw new AndroidNotCompatibleException(e);
|
||||||
|
}
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
// already checked in super class
|
// already checked in super class
|
||||||
}
|
}
|
||||||
|
|
||||||
Uri uri = Uri.fromParts("package", pkgInfo.packageName, null);
|
|
||||||
Intent intent = new Intent(Intent.ACTION_DELETE, uri);
|
|
||||||
try {
|
|
||||||
mActivity.startActivityForResult(intent, REQUEST_CODE_DELETE);
|
|
||||||
} catch (ActivityNotFoundException e) {
|
|
||||||
throw new AndroidNotCompatibleException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -76,27 +76,25 @@ public class DefaultInstallerSdk14 extends Installer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void installPackageInternal(List<File> apkFiles) throws AndroidNotCompatibleException {
|
protected void installPackageInternal(List<File> apkFiles) throws AndroidNotCompatibleException {
|
||||||
// TODO Auto-generated method stub
|
// not used
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void deletePackageInternal(String packageName) throws AndroidNotCompatibleException {
|
protected void deletePackageInternal(String packageName) throws AndroidNotCompatibleException {
|
||||||
PackageInfo pkgInfo = null;
|
|
||||||
try {
|
try {
|
||||||
pkgInfo = mPm.getPackageInfo(packageName, 0);
|
PackageInfo pkgInfo = mPm.getPackageInfo(packageName, 0);
|
||||||
|
|
||||||
|
Uri uri = Uri.fromParts("package", pkgInfo.packageName, null);
|
||||||
|
Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, uri);
|
||||||
|
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
|
||||||
|
try {
|
||||||
|
mActivity.startActivityForResult(intent, REQUEST_CODE_DELETE);
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
throw new AndroidNotCompatibleException(e);
|
||||||
|
}
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
// already checked in super class
|
// already checked in super class
|
||||||
}
|
}
|
||||||
|
|
||||||
Uri uri = Uri.fromParts("package", pkgInfo.packageName, null);
|
|
||||||
Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, uri);
|
|
||||||
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
|
|
||||||
try {
|
|
||||||
mActivity.startActivityForResult(intent, REQUEST_CODE_DELETE);
|
|
||||||
} catch (ActivityNotFoundException e) {
|
|
||||||
throw new AndroidNotCompatibleException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -190,11 +190,7 @@ abstract public class Installer {
|
|||||||
(checkInstallPermission == PackageManager.PERMISSION_GRANTED
|
(checkInstallPermission == PackageManager.PERMISSION_GRANTED
|
||||||
&& checkDeletePermission == PackageManager.PERMISSION_GRANTED);
|
&& checkDeletePermission == PackageManager.PERMISSION_GRANTED);
|
||||||
|
|
||||||
if (permissionsGranted) {
|
return permissionsGranted;
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void installPackage(File apkFile) throws AndroidNotCompatibleException {
|
public void installPackage(File apkFile) throws AndroidNotCompatibleException {
|
||||||
|
@ -128,9 +128,8 @@ public class SystemInstaller extends Installer {
|
|||||||
protected void installPackageInternal(File apkFile) throws AndroidNotCompatibleException {
|
protected void installPackageInternal(File apkFile) throws AndroidNotCompatibleException {
|
||||||
Uri packageURI = Uri.fromFile(apkFile);
|
Uri packageURI = Uri.fromFile(apkFile);
|
||||||
try {
|
try {
|
||||||
mInstallMethod.invoke(mPm, new Object[] {
|
mInstallMethod.invoke(mPm, packageURI, mInstallObserver,
|
||||||
packageURI, mInstallObserver, INSTALL_REPLACE_EXISTING, null
|
INSTALL_REPLACE_EXISTING, null);
|
||||||
});
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new AndroidNotCompatibleException(e);
|
throw new AndroidNotCompatibleException(e);
|
||||||
}
|
}
|
||||||
@ -138,16 +137,13 @@ public class SystemInstaller extends Installer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void installPackageInternal(List<File> apkFiles) throws AndroidNotCompatibleException {
|
protected void installPackageInternal(List<File> apkFiles) throws AndroidNotCompatibleException {
|
||||||
// TODO Auto-generated method stub
|
// not used
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void deletePackageInternal(String packageName) throws AndroidNotCompatibleException {
|
protected void deletePackageInternal(String packageName) throws AndroidNotCompatibleException {
|
||||||
try {
|
try {
|
||||||
mDeleteMethod.invoke(mPm, new Object[] {
|
mDeleteMethod.invoke(mPm, packageName, mDeleteObserver, 0);
|
||||||
packageName, mDeleteObserver, 0
|
|
||||||
});
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new AndroidNotCompatibleException(e);
|
throw new AndroidNotCompatibleException(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user