diff --git a/F-Droid/res/values/strings.xml b/F-Droid/res/values/strings.xml
index 8c262df2a..3e72acb90 100644
--- a/F-Droid/res/values/strings.xml
+++ b/F-Droid/res/values/strings.xml
@@ -296,23 +296,23 @@
An error occurred while parsing the package
Uninstall error
Failed to uninstall due to an unknown error
- System permissions denied
- This option is only available when F-Droid is installed as a privileged app.
- Install as a privileged app
+ Privileged F-Droid is not available
+ This option is only available when privileged F-Droid is installed.
+ Install privileged F-Droid
Install privileged F-Droid?
Touch for more information.
- Touch to install F-Droid as a privileged app, tightly coupled with the Android operating system. This allows F-Droid to install, upgrade and uninstall apps on its own.\nYou can also do this later from F-Droid\'s preferences.
- Successful installation as a privileged app
- Installation as a privileged app failed
- F-Droid has been successfully installed as a privileged app. This allows F-Droid to install, upgrade and uninstall apps on its own.
- The installation of F-Droid as a privileged app failed. The installation method is not supported by all Android distributions, please consult the F-Droid bug tracker for more information.
+ Touch to install privileged F-Droid, tightly coupled with the Android operating system. This allows F-Droid to install, upgrade and uninstall apps on its own.\nYou can also do this later from F-Droid\'s preferences.
+ Successfully installed privileged F-Droid
+ Installation of privileged F-Droid failed
+ Privileged F-Droid has been successfully installed. This allows F-Droid to install, upgrade and uninstall apps on its own.
+ The installation of privileged F-Droid has failed. The installation method is not supported by all Android distributions, please consult the F-Droid bug tracker for more information.
installing…
uninstalling…
- Do you want to install F-Droid as a privileged app?\nThis takes up to 10 seconds.
- Do you want to install F-Droid as a privileged app?\nThis takes up to 10 seconds and the device will be <b>rebooted</b> afterwards.
- Looks like you have root access on your device. You can now install F-Droid as a privileged app, tightly coupled with the Android operating system. This allows F-Droid to install, upgrade and uninstall apps on its own.
- Do you want to uninstall F-Droid?
- This will uninstall F-Droid completely.
+ Do you want to install privileged F-Droid?\nThis takes up to 10 seconds.
+ Do you want to install privileged F-Droid?\nThis takes up to 10 seconds and the device will be <b>rebooted</b> afterwards.
+ Looks like you have root access on your device. You can now install privileged F-Droid, tightly coupled with the Android operating system. This allows F-Droid to install, upgrade and uninstall apps on its own.
+ Do you want to uninstall privileged F-Droid?
+ This will uninstall privileged F-Droid.
Uninstall
F-Droid is an installable catalogue of FOSS (Free and Open Source Software) applications for the Android platform. The client makes it easy to browse, install, and keep track of updates on your device.
diff --git a/F-Droid/src/org/fdroid/fdroid/AppDetails.java b/F-Droid/src/org/fdroid/fdroid/AppDetails.java
index ee03cb40c..1adc96743 100644
--- a/F-Droid/src/org/fdroid/fdroid/AppDetails.java
+++ b/F-Droid/src/org/fdroid/fdroid/AppDetails.java
@@ -870,7 +870,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
private void installApk(File file) {
try {
- installer.installPackage(file);
+ installer.installPackage(file, app.id);
} catch (AndroidNotCompatibleException e) {
Log.e(TAG, "Android not compatible with this Installer!", e);
}
diff --git a/F-Droid/src/org/fdroid/fdroid/installer/Installer.java b/F-Droid/src/org/fdroid/fdroid/installer/Installer.java
index a6b725b31..295032086 100644
--- a/F-Droid/src/org/fdroid/fdroid/installer/Installer.java
+++ b/F-Droid/src/org/fdroid/fdroid/installer/Installer.java
@@ -27,6 +27,7 @@ import android.util.Log;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.Utils;
+import org.fdroid.fdroid.privileged.install.InstallPrivilegedDialogActivity;
import java.io.File;
import java.util.List;
@@ -146,13 +147,30 @@ abstract public class Installer {
return null;
}
- public void installPackage(File apkFile) throws AndroidNotCompatibleException {
+ public void installPackage(File apkFile, String packageName) throws AndroidNotCompatibleException {
// check if file exists...
if (!apkFile.exists()) {
Log.e(TAG, "Couldn't find file " + apkFile + " to install.");
return;
}
+ // special case: Install F-Droid Privileged
+ if (packageName.equals(PrivilegedInstaller.PRIVILEGED_PACKAGE_NAME)) {
+ Activity activity;
+ try {
+ activity = (Activity) mContext;
+ } catch (ClassCastException e) {
+ Log.d(TAG, "F-Droid Privileged can only be updated using an activity!");
+ return;
+ }
+
+ Intent installIntent = new Intent(activity, InstallPrivilegedDialogActivity.class);
+ installIntent.setAction(InstallPrivilegedDialogActivity.ACTION_INSTALL);
+ installIntent.putExtra(InstallPrivilegedDialogActivity.EXTRA_INSTALL_APK, apkFile.getAbsolutePath());
+ activity.startActivity(installIntent);
+ return;
+ }
+
installPackageInternal(apkFile);
}
diff --git a/F-Droid/src/org/fdroid/fdroid/installer/PrivilegedInstaller.java b/F-Droid/src/org/fdroid/fdroid/installer/PrivilegedInstaller.java
index 23830c26b..132a2e5fe 100644
--- a/F-Droid/src/org/fdroid/fdroid/installer/PrivilegedInstaller.java
+++ b/F-Droid/src/org/fdroid/fdroid/installer/PrivilegedInstaller.java
@@ -74,8 +74,8 @@ public class PrivilegedInstaller extends Installer {
private static final String TAG = "PrivilegedInstaller";
- private static final String PRIVILEGED_INTENT = "org.fdroid.fdroid.privileged.IPrivilegedService";
- private static final String PRIVILEGED_PACKAGE_NAME = "org.fdroid.fdroid.privileged";
+ private static final String PRIVILEGED_SERVICE_INTENT = "org.fdroid.fdroid.privileged.IPrivilegedService";
+ public static final String PRIVILEGED_PACKAGE_NAME = "org.fdroid.fdroid.privileged";
private Activity mActivity;
@@ -119,7 +119,7 @@ public class PrivilegedInstaller extends Installer {
public void onServiceDisconnected(ComponentName name) {
}
};
- Intent serviceIntent = new Intent(PRIVILEGED_INTENT);
+ Intent serviceIntent = new Intent(PRIVILEGED_SERVICE_INTENT);
serviceIntent.setPackage(PRIVILEGED_PACKAGE_NAME);
context.getApplicationContext().bindService(serviceIntent, mServiceConnection,
Context.BIND_AUTO_CREATE);
@@ -210,7 +210,7 @@ public class PrivilegedInstaller extends Installer {
}
};
- Intent serviceIntent = new Intent(PRIVILEGED_INTENT);
+ Intent serviceIntent = new Intent(PRIVILEGED_SERVICE_INTENT);
serviceIntent.setPackage(PRIVILEGED_PACKAGE_NAME);
mContext.getApplicationContext().bindService(serviceIntent, mServiceConnection,
Context.BIND_AUTO_CREATE);
@@ -316,7 +316,7 @@ public class PrivilegedInstaller extends Installer {
}
};
- Intent serviceIntent = new Intent(PRIVILEGED_INTENT);
+ Intent serviceIntent = new Intent(PRIVILEGED_SERVICE_INTENT);
serviceIntent.setPackage(PRIVILEGED_PACKAGE_NAME);
mContext.getApplicationContext().bindService(serviceIntent, mServiceConnection,
Context.BIND_AUTO_CREATE);
diff --git a/F-Droid/src/org/fdroid/fdroid/privileged/install/InstallPrivileged.java b/F-Droid/src/org/fdroid/fdroid/privileged/install/InstallPrivileged.java
index a80c650dd..181244071 100644
--- a/F-Droid/src/org/fdroid/fdroid/privileged/install/InstallPrivileged.java
+++ b/F-Droid/src/org/fdroid/fdroid/privileged/install/InstallPrivileged.java
@@ -24,6 +24,7 @@ import android.os.Build;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.R;
+import org.fdroid.fdroid.installer.PrivilegedInstaller;
import java.util.ArrayList;
import java.util.List;
@@ -39,7 +40,7 @@ abstract class InstallPrivileged {
protected final Context context;
- private static final String PACKAGE_NAME = "org.fdroid.fdroid.privileged";
+ private static final String APK_FILE_NAME = "FDroidPrivileged.apk";
public InstallPrivileged(final Context context) {
this.context = context;
@@ -67,10 +68,10 @@ abstract class InstallPrivileged {
final void runUninstall() {
final String[] commands = {
- "am force-stop " + PACKAGE_NAME,
- "pm clear " + PACKAGE_NAME,
+ "am force-stop " + PrivilegedInstaller.PRIVILEGED_PACKAGE_NAME,
+ "pm clear " + PrivilegedInstaller.PRIVILEGED_PACKAGE_NAME,
"mount -o rw,remount /system",
- "pm uninstall " + PACKAGE_NAME,
+ "pm uninstall " + PrivilegedInstaller.PRIVILEGED_PACKAGE_NAME,
"rm -f " + getInstallPath(),
"sleep 5",
"mount -o ro,remount /system"
@@ -84,19 +85,19 @@ abstract class InstallPrivileged {
}
protected String getInstallPath() {
- return getSystemFolder() + "FDroidPrivileged.apk";
+ return getSystemFolder() + APK_FILE_NAME;
}
private List getInstallCommands(String apkPath) {
final List commands = new ArrayList<>();
commands.add("mount -o rw,remount /system");
commands.addAll(getCopyToSystemCommands(apkPath));
- commands.add("pm uninstall " + PACKAGE_NAME);
+ commands.add("pm uninstall " + PrivilegedInstaller.PRIVILEGED_PACKAGE_NAME);
commands.add("mv " + getInstallPath() + ".tmp " + getInstallPath());
commands.add("pm install -r " + getInstallPath());
commands.add("sleep 5"); // wait until the app is really installed
commands.add("mount -o ro,remount /system");
- commands.add("am force-stop " + PACKAGE_NAME);
+ commands.add("am force-stop " + PrivilegedInstaller.PRIVILEGED_PACKAGE_NAME);
commands.addAll(getPostInstallCommands());
return commands;
}
diff --git a/F-Droid/src/org/fdroid/fdroid/privileged/install/InstallPrivilegedDialogActivity.java b/F-Droid/src/org/fdroid/fdroid/privileged/install/InstallPrivilegedDialogActivity.java
index ece28975a..2fd978546 100644
--- a/F-Droid/src/org/fdroid/fdroid/privileged/install/InstallPrivilegedDialogActivity.java
+++ b/F-Droid/src/org/fdroid/fdroid/privileged/install/InstallPrivilegedDialogActivity.java
@@ -36,12 +36,15 @@ import android.text.Html;
import android.util.Log;
import android.view.ContextThemeWrapper;
+import org.fdroid.fdroid.AppDetails;
import org.fdroid.fdroid.FDroid;
import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.installer.PrivilegedInstaller;
+import java.io.File;
+
import eu.chainfire.libsuperuser.Shell;
/**
@@ -52,11 +55,14 @@ public class InstallPrivilegedDialogActivity extends FragmentActivity {
private static final String TAG = "InstallIntoSystem";
public static final String ACTION_INSTALL = "install";
+ public static final String EXTRA_INSTALL_APK = "apk_file";
+
public static final String ACTION_UNINSTALL = "uninstall";
public static final String ACTION_POST_INSTALL = "post_install";
public static final String ACTION_FIRST_TIME = "first_time";
String action;
+ String apkFile;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -70,6 +76,8 @@ public class InstallPrivilegedDialogActivity extends FragmentActivity {
return;
}
+ apkFile = getIntent().getStringExtra(EXTRA_INSTALL_APK);
+
action = getIntent().getAction();
if (ACTION_UNINSTALL.equals(action)) {
uninstall();
@@ -166,7 +174,11 @@ public class InstallPrivilegedDialogActivity extends FragmentActivity {
.setPositiveButton(R.string.system_permission_install_via_root, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
- installTask.execute();
+ // Open details of F-Droid Privileged
+ Intent intent = new Intent(InstallPrivilegedDialogActivity.this, AppDetails.class);
+ intent.putExtra(AppDetails.EXTRA_APPID,
+ PrivilegedInstaller.PRIVILEGED_PACKAGE_NAME);
+ startActivity(intent);
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@@ -268,7 +280,7 @@ public class InstallPrivilegedDialogActivity extends FragmentActivity {
@Override
protected Void doInBackground(Void... voids) {
- InstallPrivileged.create(getApplicationContext()).runInstall("test"); // TODO
+ InstallPrivileged.create(getApplicationContext()).runInstall(apkFile);
return null;
}
};
@@ -304,9 +316,9 @@ public class InstallPrivilegedDialogActivity extends FragmentActivity {
// hack to get holo design (which is not automatically applied due to activity's Theme.NoDisplay
ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());
- final boolean systemApp = PrivilegedInstaller.isAvailable(this);
+ final boolean isAvailable = PrivilegedInstaller.isAvailable(this);
- if (systemApp) {
+ if (isAvailable) {
AlertDialog.Builder builder = new AlertDialog.Builder(theme)
.setTitle(R.string.system_uninstall)
.setMessage(R.string.system_uninstall_message)
diff --git a/F-Droid/src/org/fdroid/fdroid/views/fragments/PreferencesFragment.java b/F-Droid/src/org/fdroid/fdroid/views/fragments/PreferencesFragment.java
index 69c473651..00226f399 100644
--- a/F-Droid/src/org/fdroid/fdroid/views/fragments/PreferencesFragment.java
+++ b/F-Droid/src/org/fdroid/fdroid/views/fragments/PreferencesFragment.java
@@ -14,6 +14,7 @@ import android.support.v7.app.AlertDialog;
import android.text.Html;
import android.text.TextUtils;
+import org.fdroid.fdroid.AppDetails;
import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.PreferencesActivity;
@@ -221,9 +222,11 @@ public class PreferencesFragment extends PreferenceFragment
alertBuilder.setPositiveButton(R.string.system_permission_install_via_root, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- Intent installIntent = new Intent(getActivity(), InstallPrivilegedDialogActivity.class);
- installIntent.setAction(InstallPrivilegedDialogActivity.ACTION_INSTALL);
- startActivity(installIntent);
+ // Open details of F-Droid Privileged
+ Intent intent = new Intent(getActivity(), AppDetails.class);
+ intent.putExtra(AppDetails.EXTRA_APPID,
+ PrivilegedInstaller.PRIVILEGED_PACKAGE_NAME);
+ startActivity(intent);
}
});
alertBuilder.setNegativeButton(R.string.cancel, null);