Merge branch 'fix-817--info-why-priv-extension-disabled' into master

Remove Privileged Installer preference when appropriate

See merge request !430
This commit is contained in:
Hans-Christoph Steiner 2017-02-24 15:56:32 +01:00
commit e27ce21b65

View File

@ -166,7 +166,11 @@ public class PreferencesFragment extends PreferenceFragment
break; break;
case Preferences.PREF_PRIVILEGED_INSTALLER: case Preferences.PREF_PRIVILEGED_INSTALLER:
// We may have removed this preference if it is not suitable to show the user. So lets check it is here first.
final CheckBoxPreference pref = (CheckBoxPreference) findPreference(Preferences.PREF_PRIVILEGED_INSTALLER);
if (pref != null) {
checkSummary(key, R.string.system_installer_on); checkSummary(key, R.string.system_installer_on);
}
break; break;
case Preferences.PREF_ENABLE_PROXY: case Preferences.PREF_ENABLE_PROXY:
@ -214,6 +218,16 @@ public class PreferencesFragment extends PreferenceFragment
boolean enabled = p.isPrivilegedInstallerEnabled(); boolean enabled = p.isPrivilegedInstallerEnabled();
boolean installed = PrivilegedInstaller.isExtensionInstalledCorrectly(getActivity()) boolean installed = PrivilegedInstaller.isExtensionInstalledCorrectly(getActivity())
== PrivilegedInstaller.IS_EXTENSION_INSTALLED_YES; == PrivilegedInstaller.IS_EXTENSION_INSTALLED_YES;
// On later versions of Android the privileged installer needs to be installed
// via flashing an update.zip or building into a rom. As such, if it isn't installed
// by the time the user boots, opens F-Droid, and views this settings page, then there
// is no benefit showing it to them (it will only be disabled and we can't offer any
// way to easily install from here.
if (Build.VERSION.SDK_INT > 19 && !installed) {
PreferenceCategory other = (PreferenceCategory) findPreference("pref_category_other");
other.removePreference(pref);
} else {
pref.setEnabled(installed); pref.setEnabled(installed);
pref.setDefaultValue(installed); pref.setDefaultValue(installed);
pref.setChecked(enabled && installed); pref.setChecked(enabled && installed);
@ -232,6 +246,7 @@ public class PreferencesFragment extends PreferenceFragment
} }
}); });
} }
}
private void initUpdatePrivilegedExtensionPreference() { private void initUpdatePrivilegedExtensionPreference() {
if (Build.VERSION.SDK_INT > 19) { if (Build.VERSION.SDK_INT > 19) {