[app] Remove WRITE_SECURE_SETTINGS permission
This commit is contained in:
parent
f1fa90eb38
commit
818f576f25
|
|
@ -23,9 +23,6 @@
|
||||||
package="org.lsposed.manager">
|
package="org.lsposed.manager">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission
|
|
||||||
android:name="android.permission.WRITE_SECURE_SETTINGS"
|
|
||||||
tools:ignore="ProtectedPermissions" />
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".App"
|
android:name=".App"
|
||||||
|
|
|
||||||
|
|
@ -299,4 +299,14 @@ public class ConfigManager {
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean setHiddenIcon(boolean hide) {
|
||||||
|
try {
|
||||||
|
LSPManagerServiceHolder.getService().setHiddenIcon(hide);
|
||||||
|
return true;
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(App.TAG, Log.getStackTraceString(e));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,7 @@
|
||||||
|
|
||||||
package org.lsposed.manager.ui.fragment;
|
package org.lsposed.manager.ui.fragment;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
@ -41,7 +39,6 @@ import androidx.preference.SwitchPreference;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
import com.takisoft.preferencex.PreferenceCategory;
|
|
||||||
import com.takisoft.preferencex.PreferenceFragmentCompat;
|
import com.takisoft.preferencex.PreferenceFragmentCompat;
|
||||||
|
|
||||||
import org.lsposed.manager.App;
|
import org.lsposed.manager.App;
|
||||||
|
|
@ -228,16 +225,15 @@ public class SettingsFragment extends BaseFragment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferenceCategory prefGroupSystem = findPreference("settings_group_system");
|
|
||||||
SwitchPreference prefShowHiddenIcons = findPreference("show_hidden_icon_apps_enabled");
|
SwitchPreference prefShowHiddenIcons = findPreference("show_hidden_icon_apps_enabled");
|
||||||
if (prefGroupSystem != null && prefShowHiddenIcons != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
if (prefShowHiddenIcons != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
&& requireActivity().checkSelfPermission(Manifest.permission.WRITE_SECURE_SETTINGS) == PackageManager.PERMISSION_GRANTED) {
|
if (ConfigManager.isBinderAlive()) {
|
||||||
prefGroupSystem.setVisible(true);
|
prefShowHiddenIcons.setEnabled(true);
|
||||||
prefShowHiddenIcons.setVisible(true);
|
prefShowHiddenIcons.setOnPreferenceChangeListener((preference, newValue) ->
|
||||||
|
ConfigManager.setHiddenIcon(!(boolean) newValue));
|
||||||
|
}
|
||||||
prefShowHiddenIcons.setChecked(Settings.Global.getInt(
|
prefShowHiddenIcons.setChecked(Settings.Global.getInt(
|
||||||
requireActivity().getContentResolver(), "show_hidden_icon_apps_enabled", 1) != 0);
|
requireActivity().getContentResolver(), "show_hidden_icon_apps_enabled", 1) != 0);
|
||||||
prefShowHiddenIcons.setOnPreferenceChangeListener((preference, newValue) -> Settings.Global.putInt(requireActivity().getContentResolver(),
|
|
||||||
"show_hidden_icon_apps_enabled", (boolean) newValue ? 1 : 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SwitchPreference prefFollowSystemAccent = findPreference("follow_system_accent");
|
SwitchPreference prefFollowSystemAccent = findPreference("follow_system_accent");
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
|
android:icon="@drawable/ic_outline_dns_24"
|
||||||
android:key="doh"
|
android:key="doh"
|
||||||
android:summary="@string/dns_over_http_summary"
|
android:summary="@string/dns_over_http_summary"
|
||||||
android:title="@string/dns_over_http"
|
android:title="@string/dns_over_http" />
|
||||||
android:icon="@drawable/ic_outline_dns_24" />
|
|
||||||
</com.takisoft.preferencex.PreferenceCategory>
|
</com.takisoft.preferencex.PreferenceCategory>
|
||||||
|
|
||||||
<com.takisoft.preferencex.PreferenceCategory android:title="@string/settings_group_theme">
|
<com.takisoft.preferencex.PreferenceCategory android:title="@string/settings_group_theme">
|
||||||
|
|
@ -39,45 +39,45 @@
|
||||||
<org.lsposed.manager.util.theme.ThemeColorPreference
|
<org.lsposed.manager.util.theme.ThemeColorPreference
|
||||||
android:defaultValue=""
|
android:defaultValue=""
|
||||||
android:dialogTitle="@string/theme_color"
|
android:dialogTitle="@string/theme_color"
|
||||||
|
android:icon="@drawable/ic_outline_palette_24"
|
||||||
android:key="theme_color"
|
android:key="theme_color"
|
||||||
android:title="@string/theme_color"
|
|
||||||
android:summary="@string/theme_color_summary"
|
android:summary="@string/theme_color_summary"
|
||||||
android:icon="@drawable/ic_outline_palette_24" />
|
android:title="@string/theme_color" />
|
||||||
<rikka.preference.SimpleMenuPreference
|
<rikka.preference.SimpleMenuPreference
|
||||||
android:defaultValue="MODE_NIGHT_FOLLOW_SYSTEM"
|
android:defaultValue="MODE_NIGHT_FOLLOW_SYSTEM"
|
||||||
android:entries="@array/theme_texts"
|
android:entries="@array/theme_texts"
|
||||||
android:entryValues="@array/theme_values"
|
android:entryValues="@array/theme_values"
|
||||||
|
android:icon="@drawable/ic_outline_dark_mode_24"
|
||||||
android:key="dark_theme"
|
android:key="dark_theme"
|
||||||
android:summary="%s"
|
android:summary="%s"
|
||||||
android:title="@string/dark_theme"
|
android:title="@string/dark_theme" />
|
||||||
android:icon="@drawable/ic_outline_dark_mode_24" />
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="black_dark_theme"
|
android:key="black_dark_theme"
|
||||||
android:title="@string/pure_black_dark_theme"
|
android:summary="@string/pure_black_dark_theme_summary"
|
||||||
android:summary="@string/pure_black_dark_theme_summary" />
|
android:title="@string/pure_black_dark_theme" />
|
||||||
</com.takisoft.preferencex.PreferenceCategory>
|
</com.takisoft.preferencex.PreferenceCategory>
|
||||||
|
|
||||||
<com.takisoft.preferencex.PreferenceCategory android:title="@string/settings_group_framework">
|
<com.takisoft.preferencex.PreferenceCategory android:title="@string/settings_group_framework">
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
|
android:icon="@drawable/ic_outline_science_24"
|
||||||
android:key="enable_resources"
|
android:key="enable_resources"
|
||||||
android:summary="@string/settings_enable_resources_summary"
|
|
||||||
android:title="@string/settings_enable_resources"
|
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:icon="@drawable/ic_outline_science_24" />
|
android:summary="@string/settings_enable_resources_summary"
|
||||||
|
android:title="@string/settings_enable_resources" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="disable_verbose_log"
|
android:key="disable_verbose_log"
|
||||||
android:title="@string/pref_title_disable_verbose_log"
|
android:persistent="false"
|
||||||
android:persistent="false" />
|
android:title="@string/pref_title_disable_verbose_log" />
|
||||||
</com.takisoft.preferencex.PreferenceCategory>
|
</com.takisoft.preferencex.PreferenceCategory>
|
||||||
|
|
||||||
<com.takisoft.preferencex.PreferenceCategory
|
<com.takisoft.preferencex.PreferenceCategory
|
||||||
android:title="@string/settings_backup_and_restore"
|
android:icon="@drawable/ic_baseline_settings_backup_restore_24"
|
||||||
android:summary="@string/settings_backup_and_restore_summery"
|
android:summary="@string/settings_backup_and_restore_summery"
|
||||||
android:icon="@drawable/ic_baseline_settings_backup_restore_24">
|
android:title="@string/settings_backup_and_restore">
|
||||||
<Preference
|
<Preference
|
||||||
android:key="backup"
|
android:key="backup"
|
||||||
android:title="@string/settings_backup" />
|
android:title="@string/settings_backup" />
|
||||||
|
|
@ -88,14 +88,13 @@
|
||||||
|
|
||||||
<com.takisoft.preferencex.PreferenceCategory
|
<com.takisoft.preferencex.PreferenceCategory
|
||||||
android:key="settings_group_system"
|
android:key="settings_group_system"
|
||||||
android:title="@string/settings_group_system"
|
android:title="@string/settings_group_system">
|
||||||
app:isPreferenceVisible="false">
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
|
android:enabled="false"
|
||||||
android:key="show_hidden_icon_apps_enabled"
|
android:key="show_hidden_icon_apps_enabled"
|
||||||
android:title="@string/settings_show_hidden_icon_apps_enabled"
|
|
||||||
android:summary="@string/settings_show_hidden_icon_apps_enabled_summary"
|
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
app:isPreferenceVisible="false" />
|
android:summary="@string/settings_show_hidden_icon_apps_enabled_summary"
|
||||||
|
android:title="@string/settings_show_hidden_icon_apps_enabled" />
|
||||||
</com.takisoft.preferencex.PreferenceCategory>
|
</com.takisoft.preferencex.PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import android.content.pm.VersionedPackage;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.os.ResultReceiver;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
@ -265,4 +266,17 @@ public class LSPManagerService extends ILSPManagerService.Stub {
|
||||||
public boolean dex2oatFlagsLoaded() {
|
public boolean dex2oatFlagsLoaded() {
|
||||||
return SystemProperties.get(PROP_NAME).contains(PROP_VALUE);
|
return SystemProperties.get(PROP_NAME).contains(PROP_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHiddenIcon(boolean hide) {
|
||||||
|
var settings = new ServiceShellCommand("settings");
|
||||||
|
var enable = hide ? "0" : "1";
|
||||||
|
var args = new String[]{"put", "global", "show_hidden_icon_apps_enabled", enable};
|
||||||
|
try {
|
||||||
|
settings.shellCommand(FileDescriptor.in, FileDescriptor.out, FileDescriptor.err,
|
||||||
|
args, new ResultReceiver(null));
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.w(TAG, "setHiddenIcon: ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.lsposed.lspd.service;
|
||||||
|
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.RemoteException;
|
||||||
|
import android.os.ResultReceiver;
|
||||||
|
|
||||||
|
import java.io.FileDescriptor;
|
||||||
|
|
||||||
|
class ServiceShellCommand {
|
||||||
|
private static final int SHELL_COMMAND_TRANSACTION = ('_' << 24) | ('C' << 16) | ('M' << 8) | 'D';
|
||||||
|
private final IBinder binder;
|
||||||
|
|
||||||
|
ServiceShellCommand(String name) {
|
||||||
|
binder = android.os.ServiceManager.getService(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void shellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err,
|
||||||
|
String[] args, ResultReceiver resultReceiver) throws RemoteException {
|
||||||
|
Parcel data = Parcel.obtain();
|
||||||
|
Parcel reply = Parcel.obtain();
|
||||||
|
data.writeFileDescriptor(in);
|
||||||
|
data.writeFileDescriptor(out);
|
||||||
|
data.writeFileDescriptor(err);
|
||||||
|
data.writeStringArray(args);
|
||||||
|
data.writeStrongBinder(null);
|
||||||
|
resultReceiver.writeToParcel(data, 0);
|
||||||
|
try {
|
||||||
|
binder.transact(SHELL_COMMAND_TRANSACTION, data, reply, 0);
|
||||||
|
reply.readException();
|
||||||
|
} finally {
|
||||||
|
data.recycle();
|
||||||
|
reply.recycle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -59,4 +59,6 @@ interface ILSPManagerService {
|
||||||
ParceledListSlice<ResolveInfo> queryIntentActivitiesAsUser(in Intent intent, int flags, int userId) = 31;
|
ParceledListSlice<ResolveInfo> queryIntentActivitiesAsUser(in Intent intent, int flags, int userId) = 31;
|
||||||
|
|
||||||
boolean dex2oatFlagsLoaded() = 32;
|
boolean dex2oatFlagsLoaded() = 32;
|
||||||
|
|
||||||
|
void setHiddenIcon(boolean hide) = 33;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue