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 fullApplicationId = "org.fdroid.fdroid"
def basicApplicationId = "org.fdroid.basic" def basicApplicationId = "org.fdroid.basic"
// yes, this actually needs both quotes https://stackoverflow.com/a/41391841
def privilegedExtensionApplicationId = '"org.fdroid.fdroid.privileged"'
android { android {
compileSdkVersion 27 compileSdkVersion 27
@ -35,6 +37,7 @@ android {
minifyEnabled true minifyEnabled true
useProguard true useProguard true
shrinkResources true shrinkResources true
buildConfigField "String", "PRIVILEGED_EXTENSION_PACKAGE_NAME", privilegedExtensionApplicationId
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'src/androidTest/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.content.pm.PackageManager;
import android.os.Build; import android.os.Build;
import android.util.Log; import android.util.Log;
import org.fdroid.fdroid.BuildConfig; import org.fdroid.fdroid.BuildConfig;
import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.installer.PrivilegedInstaller; import org.fdroid.fdroid.installer.PrivilegedInstaller;
@ -33,7 +32,7 @@ public class PackageManagerCompat {
if (Build.VERSION.SDK_INT < 11) return; if (Build.VERSION.SDK_INT < 11) return;
try { try {
if (Build.VERSION.SDK_INT >= 24 && PrivilegedInstaller.isDefault(context)) { 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 { } else {
mPm.setInstallerPackageName(packageName, BuildConfig.APPLICATION_ID); 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) { private static Uri getSafeUri(Context context, SanitizedFile tempFile, boolean useContentUri) {
if (useContentUri) { if (useContentUri) {
Uri apkUri = getUriForFile(context, AUTHORITY, tempFile); 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); context.grantUriPermission("com.android.bluetooth", apkUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
return apkUri; return apkUri;
} }

View File

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