Add preference to opt-out of SystemPermissionInstaller

This commit is contained in:
Dominik Schürmann 2014-05-12 12:55:17 +02:00
parent c65a25524c
commit 2bd686dfe8
5 changed files with 26 additions and 8 deletions

View File

@ -31,6 +31,9 @@
<string name="root_installer">Root access for app installations</string>
<string name="root_installer_on">Root access is used to install/delete/update applications</string>
<string name="root_installer_off">Do not request root access to install/delete/update applications</string>
<string name="system_installer">Use system permissions for app installations</string>
<string name="system_installer_on">F-Droid tries to use system permissions to install/delete/update applications (only possible when installed as system-app)</string>
<string name="system_installer_off">F-Droid does not try to use system permissions to install/delete/update applications (only possible when installed as system-app)</string>
<string name="search_results">Search Results</string>
<string name="app_details">App Details</string>

View File

@ -53,5 +53,8 @@
<CheckBoxPreference android:title="@string/root_installer"
android:defaultValue="false"
android:key="rootInstaller" />
<CheckBoxPreference android:title="@string/system_installer"
android:defaultValue="true"
android:key="systemInstaller" />
</PreferenceCategory>
</PreferenceScreen>

View File

@ -37,11 +37,13 @@ public class Preferences implements SharedPreferences.OnSharedPreferenceChangeLi
public static final String PREF_EXPERT = "expert";
public static final String PREF_UPD_LAST = "lastUpdateCheck";
public static final String PREF_ROOT_INSTALLER = "rootInstaller";
public static final String PREF_SYSTEM_INSTALLER = "systemInstaller";
private static final boolean DEFAULT_COMPACT_LAYOUT = false;
private static final boolean DEFAULT_ROOTED = true;
private static final int DEFAULT_UPD_HISTORY = 14;
private static final boolean DEFAULT_ROOT_INSTALLER = false;
private static final boolean DEFAULT_SYSTEM_INSTALLER = true;
private boolean compactLayout = DEFAULT_COMPACT_LAYOUT;
private boolean filterAppsRequiringRoot = DEFAULT_ROOTED;
@ -64,9 +66,13 @@ public class Preferences implements SharedPreferences.OnSharedPreferenceChangeLi
initialized.put(key, false);
}
public boolean useRootInstaller() {
public boolean isRootInstallerEnabled() {
return preferences.getBoolean(PREF_ROOT_INSTALLER, DEFAULT_ROOT_INSTALLER);
}
public boolean isSystemInstallerEnabled() {
return preferences.getBoolean(PREF_SYSTEM_INSTALLER, DEFAULT_SYSTEM_INSTALLER);
}
public boolean hasCompactLayout() {
if (!isInitialized(PREF_COMPACT_LAYOUT)) {

View File

@ -55,7 +55,8 @@ public class PreferencesActivity extends PreferenceActivity implements
Preferences.PREF_IGN_TOUCH,
Preferences.PREF_CACHE_APK,
Preferences.PREF_EXPERT,
Preferences.PREF_ROOT_INSTALLER
Preferences.PREF_ROOT_INSTALLER,
Preferences.PREF_SYSTEM_INSTALLER
};
@Override
@ -156,6 +157,10 @@ public class PreferencesActivity extends PreferenceActivity implements
onoffSummary(key, R.string.root_installer_on,
R.string.root_installer_off);
} else if (key.equals(Preferences.PREF_SYSTEM_INSTALLER)) {
onoffSummary(key, R.string.system_installer_on,
R.string.system_installer_off);
}
}
@ -164,7 +169,7 @@ public class PreferencesActivity extends PreferenceActivity implements
* when the user grants root access for F-Droid.
*/
protected void initRootInstallerPreference() {
CheckBoxPreference pref = (CheckBoxPreference)findPreference(Preferences.PREF_ROOT_INSTALLER);
CheckBoxPreference pref = (CheckBoxPreference) findPreference(Preferences.PREF_ROOT_INSTALLER);
// we are handling persistence ourself!
pref.setPersistent(false);

View File

@ -107,8 +107,8 @@ abstract public class Installer {
InstallerCallback callback) {
// if root installer has been activated in preferences -> RootInstaller
boolean useRootInstaller = Preferences.get().useRootInstaller();
if (useRootInstaller) {
boolean isRootInstallerEnabled = Preferences.get().isRootInstallerEnabled();
if (isRootInstallerEnabled) {
Log.d(TAG, "root installer preference enabled -> RootInstaller");
try {
@ -118,8 +118,9 @@ abstract public class Installer {
}
}
// system permissions -> SystemPermissionInstaller
if (hasSystemPermissions(activity, pm)) {
// system permissions and pref enabled -> SystemPermissionInstaller
boolean isSystemInstallerEnabled = Preferences.get().isSystemInstallerEnabled();
if (isSystemInstallerEnabled && hasSystemPermissions(activity, pm)) {
Log.d(TAG, "system permissions -> SystemPermissionInstaller");
try {
@ -158,7 +159,7 @@ abstract public class Installer {
InstallerCallback callback) throws AndroidNotCompatibleException {
// if root installer has been activated in preferences -> RootInstaller
boolean useRootInstaller = Preferences.get().useRootInstaller();
boolean useRootInstaller = Preferences.get().isRootInstallerEnabled();
if (useRootInstaller) {
try {
return new RootInstaller(context, pm, callback);