diff --git a/F-Droid-Privileged/build.gradle b/F-Droid-Privileged/build.gradle
index 0ff807fdd..69289d7dc 100644
--- a/F-Droid-Privileged/build.gradle
+++ b/F-Droid-Privileged/build.gradle
@@ -1,14 +1,9 @@
-buildscript {
- repositories {
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:1.3.1'
- }
-}
-
apply plugin: 'com.android.application'
+dependencies {
+ compile project(':privileged-api-lib')
+}
+
android {
compileSdkVersion 22
buildToolsVersion '23.0.0'
diff --git a/F-Droid/AndroidManifest.xml b/F-Droid/AndroidManifest.xml
index 60a124616..d703bb3ef 100644
--- a/F-Droid/AndroidManifest.xml
+++ b/F-Droid/AndroidManifest.xml
@@ -51,11 +51,7 @@
android:maxSdkVersion="18" />
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Privileged-F-Droid/src/main/aidl/org/fdroid/fdroid/privileged/IPrivilegedCallback.aidl b/Privileged-F-Droid/src/main/aidl/org/fdroid/fdroid/privileged/IPrivilegedCallback.aidl
deleted file mode 100644
index fc476fafe..000000000
--- a/Privileged-F-Droid/src/main/aidl/org/fdroid/fdroid/privileged/IPrivilegedCallback.aidl
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2015 Dominik Schürmann
- *
- * 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.privileged;
-
-interface IPrivilegedCallback {
-
- void handleResult(in String packageName, in int returnCode);
-
-}
\ No newline at end of file
diff --git a/Privileged-F-Droid/src/main/aidl/org/fdroid/fdroid/privileged/IPrivilegedService.aidl b/Privileged-F-Droid/src/main/aidl/org/fdroid/fdroid/privileged/IPrivilegedService.aidl
deleted file mode 100644
index b5b74ff4b..000000000
--- a/Privileged-F-Droid/src/main/aidl/org/fdroid/fdroid/privileged/IPrivilegedService.aidl
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2015 Dominik Schürmann
- *
- * 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.privileged;
-
-import org.fdroid.fdroid.privileged.IPrivilegedCallback;
-
-/**
- * Asynchronous (oneway) IPC calls!
- */
-oneway interface IPrivilegedService {
-
- /**
- * Docs based on PackageManager.installPackage()
- *
- * Install a package. Since this may take a little while, the result will
- * be posted back to the given callback. An installation will fail if the
- * package named in the package file's manifest is already installed, or if there's no space
- * available on the device.
- *
- * @param packageURI The location of the package file to install. This can be a 'file:' or a
- * 'content:' URI.
- * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
- * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
- * @param installerPackageName Optional package name of the application that is performing the
- * installation. This identifies which market the package came from.
- * @param callback An callback to get notified when the package installation is
- * complete.
- */
- void installPackage(in Uri packageURI, in int flags, in String installerPackageName,
- in IPrivilegedCallback callback);
-
-
- /**
- * Docs based on PackageManager.deletePackage()
- *
- * Attempts to delete a package. Since this may take a little while, the result will
- * be posted back to the given observer. A deletion will fail if the
- * named package cannot be found, or if the named package is a "system package".
- *
- * @param packageName The name of the package to delete
- * @param flags - possible values: {@link #DELETE_KEEP_DATA},
- * {@link #DELETE_ALL_USERS}.
- * @param callback An callback to get notified when the package deletion is
- * complete.
- */
- void deletePackage(in String packageName, in int flags, in IPrivilegedCallback callback);
-
-}
\ No newline at end of file
diff --git a/Privileged-F-Droid/src/main/java/android/content/pm/IPackageDeleteObserver.java b/Privileged-F-Droid/src/main/java/android/content/pm/IPackageDeleteObserver.java
deleted file mode 100644
index be0d4de81..000000000
--- a/Privileged-F-Droid/src/main/java/android/content/pm/IPackageDeleteObserver.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2015 Dominik Schürmann
- *
- * 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 android.content.pm;
-
-import android.os.Binder;
-import android.os.IBinder;
-import android.os.IInterface;
-import android.os.Parcel;
-import android.os.RemoteException;
-
-/**
- * Just a non-working implementation of this Stub to satisfy compiler!
- */
-public interface IPackageDeleteObserver extends IInterface {
-
- abstract class Stub extends Binder implements android.content.pm.IPackageDeleteObserver {
-
- public Stub() {
- throw new RuntimeException("Stub!");
- }
-
- public static IPackageDeleteObserver asInterface(IBinder obj) {
- throw new RuntimeException("Stub!");
- }
-
- public IBinder asBinder() {
- throw new RuntimeException("Stub!");
- }
-
- public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
- throws RemoteException {
- throw new RuntimeException("Stub!");
- }
- }
-
- void packageDeleted(java.lang.String packageName, int returnCode) throws RemoteException;
-}
diff --git a/Privileged-F-Droid/src/main/java/android/content/pm/IPackageInstallObserver.java b/Privileged-F-Droid/src/main/java/android/content/pm/IPackageInstallObserver.java
deleted file mode 100644
index ae5b3ab12..000000000
--- a/Privileged-F-Droid/src/main/java/android/content/pm/IPackageInstallObserver.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2015 Dominik Schürmann
- *
- * 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 android.content.pm;
-
-import android.os.Binder;
-import android.os.IBinder;
-import android.os.IInterface;
-import android.os.Parcel;
-import android.os.RemoteException;
-
-/**
- * Just a non-working implementation of this Stub to satisfy compiler!
- */
-public interface IPackageInstallObserver extends IInterface {
-
- abstract class Stub extends Binder implements android.content.pm.IPackageInstallObserver {
-
- public Stub() {
- throw new RuntimeException("Stub!");
- }
-
- public static android.content.pm.IPackageInstallObserver asInterface(IBinder obj) {
- throw new RuntimeException("Stub!");
- }
-
- public IBinder asBinder() {
- throw new RuntimeException("Stub!");
- }
-
- public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
- throws RemoteException {
- throw new RuntimeException("Stub!");
- }
- }
-
- void packageInstalled(String packageName, int returnCode) throws RemoteException;
-}
\ No newline at end of file
diff --git a/Privileged-F-Droid/src/main/java/org/fdroid/fdroid/privileged/PrivilegedService.java b/Privileged-F-Droid/src/main/java/org/fdroid/fdroid/privileged/PrivilegedService.java
deleted file mode 100644
index d717d4b8d..000000000
--- a/Privileged-F-Droid/src/main/java/org/fdroid/fdroid/privileged/PrivilegedService.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2015 Dominik Schürmann
- *
- * 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.privileged;
-
-import android.app.Service;
-import android.content.Intent;
-import android.content.pm.IPackageDeleteObserver;
-import android.content.pm.IPackageInstallObserver;
-import android.content.pm.PackageManager;
-import android.net.Uri;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.util.Log;
-
-import java.lang.reflect.Method;
-
-/**
- * This service provides an API via AIDL IPC for the main F-Droid app to install/delete packages.
- */
-public class PrivilegedService extends Service {
-
- public static final String TAG = "PrivilegedFDroid";
-
- private Method mInstallMethod;
- private Method mDeleteMethod;
-
- private void installPackageImpl(Uri packageURI, int flags, String installerPackageName,
- final IPrivilegedCallback callback) {
-
- // Internal callback from the system
- IPackageInstallObserver.Stub installObserver = new IPackageInstallObserver.Stub() {
- @Override
- public void packageInstalled(String packageName, int returnCode) throws RemoteException {
- // forward this internal callback to our callback
- try {
- callback.handleResult(packageName, returnCode);
- } catch (RemoteException e1) {
- Log.e(TAG, "RemoteException", e1);
- }
- }
- };
-
- // execute internal method
- try {
- mInstallMethod.invoke(getPackageManager(), packageURI, installObserver,
- flags, installerPackageName);
- } catch (Exception e) {
- Log.e(TAG, "Android not compatible!", e);
- try {
- callback.handleResult(null, 0);
- } catch (RemoteException e1) {
- Log.e(TAG, "RemoteException", e1);
- }
- }
- }
-
- private void deletePackageImpl(String packageName, int flags, final IPrivilegedCallback callback) {
-
- // Internal callback from the system
- IPackageDeleteObserver.Stub deleteObserver = new IPackageDeleteObserver.Stub() {
- @Override
- public void packageDeleted(String packageName, int returnCode) throws RemoteException {
- // forward this internal callback to our callback
- try {
- callback.handleResult(packageName, returnCode);
- } catch (RemoteException e1) {
- Log.e(TAG, "RemoteException", e1);
- }
- }
- };
-
- // execute internal method
- try {
- mDeleteMethod.invoke(getPackageManager(), packageName, deleteObserver, flags);
- } catch (Exception e) {
- Log.e(TAG, "Android not compatible!", e);
- try {
- callback.handleResult(null, 0);
- } catch (RemoteException e1) {
- Log.e(TAG, "RemoteException", e1);
- }
- }
-
- }
-
- private final IPrivilegedService.Stub mBinder = new IPrivilegedService.Stub() {
- @Override
- public void installPackage(Uri packageURI, int flags, String installerPackageName,
- IPrivilegedCallback callback) {
- installPackageImpl(packageURI, flags, installerPackageName, callback);
- }
-
- @Override
- public void deletePackage(String packageName, int flags, IPrivilegedCallback callback) {
- deletePackageImpl(packageName, flags, callback);
- }
- };
-
- @Override
- public IBinder onBind(Intent intent) {
- return mBinder;
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- // get internal methods via reflection
- try {
- Class>[] installTypes = {
- Uri.class, IPackageInstallObserver.class, int.class,
- String.class
- };
- Class>[] deleteTypes = {
- String.class, IPackageDeleteObserver.class,
- int.class
- };
-
- PackageManager pm = getPackageManager();
- mInstallMethod = pm.getClass().getMethod("installPackage", installTypes);
- mDeleteMethod = pm.getClass().getMethod("deletePackage", deleteTypes);
- } catch (NoSuchMethodException e) {
- Log.e(TAG, "Android not compatible!", e);
- stopSelf();
- }
- }
-
-}
diff --git a/Privileged-F-Droid/src/main/res/drawable-hdpi/ic_launcher.png b/Privileged-F-Droid/src/main/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index 88138a47a..000000000
Binary files a/Privileged-F-Droid/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ
diff --git a/Privileged-F-Droid/src/main/res/drawable-ldpi/ic_launcher.png b/Privileged-F-Droid/src/main/res/drawable-ldpi/ic_launcher.png
deleted file mode 100644
index f1e8bc847..000000000
Binary files a/Privileged-F-Droid/src/main/res/drawable-ldpi/ic_launcher.png and /dev/null differ
diff --git a/Privileged-F-Droid/src/main/res/drawable-mdpi/ic_launcher.png b/Privileged-F-Droid/src/main/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644
index 18ef68deb..000000000
Binary files a/Privileged-F-Droid/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ
diff --git a/Privileged-F-Droid/src/main/res/drawable-xhdpi/ic_launcher.png b/Privileged-F-Droid/src/main/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100644
index 98cb52a3e..000000000
Binary files a/Privileged-F-Droid/src/main/res/drawable-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/Privileged-F-Droid/src/main/res/drawable-xxhdpi/ic_launcher.png b/Privileged-F-Droid/src/main/res/drawable-xxhdpi/ic_launcher.png
deleted file mode 100644
index 9d29cc939..000000000
Binary files a/Privileged-F-Droid/src/main/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/Privileged-F-Droid/src/main/res/drawable-xxxhdpi/ic_launcher.png b/Privileged-F-Droid/src/main/res/drawable-xxxhdpi/ic_launcher.png
deleted file mode 100644
index c012986f5..000000000
Binary files a/Privileged-F-Droid/src/main/res/drawable-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/Privileged-F-Droid/src/main/res/values/strings.xml b/Privileged-F-Droid/src/main/res/values/strings.xml
deleted file mode 100644
index e375b6e4c..000000000
--- a/Privileged-F-Droid/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
- F-Droid Privileged
-
-
diff --git a/privileged-api-lib/build.gradle b/privileged-api-lib/build.gradle
new file mode 100644
index 000000000..392379301
--- /dev/null
+++ b/privileged-api-lib/build.gradle
@@ -0,0 +1,18 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 22
+ buildToolsVersion '23.0.0'
+
+ defaultConfig {
+ minSdkVersion 8
+ targetSdkVersion 22
+ versionCode 1
+ versionName "1.0"
+ }
+
+ // Do not abort build if lint finds errors
+ lintOptions {
+ abortOnError false
+ }
+}
\ No newline at end of file
diff --git a/privileged-api-lib/src/main/AndroidManifest.xml b/privileged-api-lib/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..d1978ceea
--- /dev/null
+++ b/privileged-api-lib/src/main/AndroidManifest.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/F-Droid-Privileged/src/main/aidl/org/fdroid/fdroid/privileged/IPrivilegedCallback.aidl b/privileged-api-lib/src/main/aidl/org/fdroid/fdroid/privileged/IPrivilegedCallback.aidl
similarity index 100%
rename from F-Droid-Privileged/src/main/aidl/org/fdroid/fdroid/privileged/IPrivilegedCallback.aidl
rename to privileged-api-lib/src/main/aidl/org/fdroid/fdroid/privileged/IPrivilegedCallback.aidl
diff --git a/F-Droid-Privileged/src/main/aidl/org/fdroid/fdroid/privileged/IPrivilegedService.aidl b/privileged-api-lib/src/main/aidl/org/fdroid/fdroid/privileged/IPrivilegedService.aidl
similarity index 100%
rename from F-Droid-Privileged/src/main/aidl/org/fdroid/fdroid/privileged/IPrivilegedService.aidl
rename to privileged-api-lib/src/main/aidl/org/fdroid/fdroid/privileged/IPrivilegedService.aidl
diff --git a/settings.gradle b/settings.gradle
index 263753759..b78f89eed 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,4 +1,6 @@
include ':F-Droid'
+include ':F-Droid-Privileged'
+include ':privileged-api-lib'
if ( hasProperty( 'sourceDeps' ) ) {
include ':extern:AndroidPinning'