Merge branch 'nonapk' into 'master'
Add a DummyInstaller to handle non apk files See merge request !504
This commit is contained in:
commit
27453855b2
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 Chirayu Desai <chirayudesai1@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 3
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.fdroid.fdroid.installer;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import org.fdroid.fdroid.data.Apk;
|
||||||
|
|
||||||
|
public class DummyInstaller extends Installer {
|
||||||
|
|
||||||
|
public DummyInstaller(Context context, Apk apk) {
|
||||||
|
super(context, apk);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Intent getPermissionScreen() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Intent getUninstallScreen() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void installPackage(Uri localApkUri, Uri downloadUri) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void installPackageInternal(Uri localApkUri, Uri downloadUri) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void uninstallPackage() {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isUnattended() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean supportsContentUri() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -22,6 +22,7 @@ package org.fdroid.fdroid.installer;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import org.fdroid.fdroid.Utils;
|
import org.fdroid.fdroid.Utils;
|
||||||
import org.fdroid.fdroid.data.Apk;
|
import org.fdroid.fdroid.data.Apk;
|
||||||
@ -40,12 +41,17 @@ public class InstallerFactory {
|
|||||||
* @return instance of an Installer
|
* @return instance of an Installer
|
||||||
*/
|
*/
|
||||||
public static Installer create(Context context, Apk apk) {
|
public static Installer create(Context context, Apk apk) {
|
||||||
|
Log.d(TAG, "Apk.apkName " + apk.apkName);
|
||||||
if (apk == null || TextUtils.isEmpty(apk.packageName)) {
|
if (apk == null || TextUtils.isEmpty(apk.packageName)) {
|
||||||
throw new IllegalArgumentException("Apk.packageName must not be empty: " + apk);
|
throw new IllegalArgumentException("Apk.packageName must not be empty: " + apk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Installer installer;
|
Installer installer;
|
||||||
if (PrivilegedInstaller.isDefault(context)) {
|
if (!apk.apkName.endsWith(".apk")) {
|
||||||
|
Utils.debugLog(TAG, "Using DummyInstaller for " + apk.apkName);
|
||||||
|
installer = new DummyInstaller(context, apk);
|
||||||
|
} else if (PrivilegedInstaller.isDefault(context)) {
|
||||||
Utils.debugLog(TAG, "privileged extension correctly installed -> PrivilegedInstaller");
|
Utils.debugLog(TAG, "privileged extension correctly installed -> PrivilegedInstaller");
|
||||||
installer = new PrivilegedInstaller(context, apk);
|
installer = new PrivilegedInstaller(context, apk);
|
||||||
} else if (apk.packageName.equals(PrivilegedInstaller.PRIVILEGED_EXTENSION_PACKAGE_NAME)) {
|
} else if (apk.packageName.equals(PrivilegedInstaller.PRIVILEGED_EXTENSION_PACKAGE_NAME)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user