let whitelabel builds set custom Privileged Extension

For fullstack custom builds, they'll also need a whitelabel build of
Privileged Extension, which will have a different Application ID and
signing key than F-Droid Privileged Extension.
This commit is contained in:
Hans-Christoph Steiner 2018-07-20 11:47:52 +02:00
parent e374a3da5a
commit b75fc8e011
4 changed files with 8 additions and 5 deletions

View File

@ -17,6 +17,8 @@ def preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
def fullApplicationId = "org.fdroid.fdroid"
def basicApplicationId = "org.fdroid.basic"
// yes, this actually needs both quotes https://stackoverflow.com/a/41391841
def privilegedExtensionApplicationId = '"org.fdroid.fdroid.privileged"'
android {
compileSdkVersion 27
@ -35,6 +37,7 @@ android {
minifyEnabled true
useProguard true
shrinkResources true
buildConfigField "String", "PRIVILEGED_EXTENSION_PACKAGE_NAME", privilegedExtensionApplicationId
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'src/androidTest/proguard-rules.pro'
}

View File

@ -5,7 +5,6 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.util.Log;
import org.fdroid.fdroid.BuildConfig;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.installer.PrivilegedInstaller;
@ -33,7 +32,7 @@ public class PackageManagerCompat {
if (Build.VERSION.SDK_INT < 11) return;
try {
if (Build.VERSION.SDK_INT >= 24 && PrivilegedInstaller.isDefault(context)) {
mPm.setInstallerPackageName(packageName, "org.fdroid.fdroid.privileged");
mPm.setInstallerPackageName(packageName, PrivilegedInstaller.PRIVILEGED_EXTENSION_PACKAGE_NAME);
} else {
mPm.setInstallerPackageName(packageName, BuildConfig.APPLICATION_ID);
}

View File

@ -86,7 +86,8 @@ public class ApkFileProvider extends FileProvider {
private static Uri getSafeUri(Context context, SanitizedFile tempFile, boolean useContentUri) {
if (useContentUri) {
Uri apkUri = getUriForFile(context, AUTHORITY, tempFile);
context.grantUriPermission("org.fdroid.fdroid.privileged", apkUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
context.grantUriPermission(PrivilegedInstaller.PRIVILEGED_EXTENSION_PACKAGE_NAME,
apkUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
context.grantUriPermission("com.android.bluetooth", apkUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
return apkUri;
}

View File

@ -31,6 +31,7 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.support.annotation.NonNull;
import android.util.Log;
import org.fdroid.fdroid.BuildConfig;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.data.Apk;
@ -67,8 +68,7 @@ public class PrivilegedInstaller extends Installer {
private static final String PRIVILEGED_EXTENSION_SERVICE_INTENT
= "org.fdroid.fdroid.privileged.IPrivilegedService";
public static final String PRIVILEGED_EXTENSION_PACKAGE_NAME
= "org.fdroid.fdroid.privileged";
public static final String PRIVILEGED_EXTENSION_PACKAGE_NAME = BuildConfig.PRIVILEGED_EXTENSION_PACKAGE_NAME;
public static final int IS_EXTENSION_INSTALLED_NO = 0;
public static final int IS_EXTENSION_INSTALLED_YES = 1;