This repository has been archived by the owner on Nov 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
03-packages_apps_Settings-P.patch
121 lines (117 loc) · 5.72 KB
/
03-packages_apps_Settings-P.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
project packages/apps/Settings/
diff --git a/packages/apps/Settings/res/values/strings.xml b/packages/apps/Settings/res/values/strings.xml
index 01ef29b341..fd78667045 100644
--- a/packages/apps/Settings/res/values/strings.xml
+++ b/packages/apps/Settings/res/values/strings.xml
@@ -10087,4 +10087,9 @@
<!-- Title for Connected device shortcut [CHAR LIMIT=30] -->
<string name="devices_title">Devices</string>
+
+ <!-- Allow fake signature checkbox in developer settings -->
+ <string name="allow_signature_fake">Allow signature spoofing</string>
+ <string name="allow_signature_fake_summary">Allow apps to bypass security systems by pretending to be a different app</string>
+ <string name="allow_signature_fake_warning">Allowing apps to bypass security systems can lead to serious security and privacy problems! Check that only benign apps use the corresponding permission when this is active.</string>
</resources>
diff --git a/packages/apps/Settings/res/xml/development_settings.xml b/packages/apps/Settings/res/xml/development_settings.xml
index 8a8d2d4def..abfd8cc637 100644
--- a/packages/apps/Settings/res/xml/development_settings.xml
+++ b/packages/apps/Settings/res/xml/development_settings.xml
@@ -569,6 +569,12 @@
android:key="reset_shortcut_manager_throttling"
android:title="@string/reset_shortcut_manager_throttling" />
+ <SwitchPreference
+ android:key="allow_signature_fake"
+ android:title="@string/allow_signature_fake"
+ android:summary="@string/allow_signature_fake_summary"
+ android:defaultValue="false" />
+
<lineageos.preference.LineageSecureSettingSwitchPreference
android:key="kill_app_longpress_back"
android:title="@string/kill_app_longpress_back"
diff --git a/packages/apps/Settings/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/packages/apps/Settings/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index f2011bc612..0a6bb57367 100644
--- a/packages/apps/Settings/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/packages/apps/Settings/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -497,6 +497,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
controllers.add(new DefaultLaunchPreferenceController(context, "density"));
controllers.add(new DefaultLaunchPreferenceController(context, "background_check"));
controllers.add(new DefaultLaunchPreferenceController(context, "inactive_apps"));
+ controllers.add(new SpoofSignaturePreferenceController(context));
return controllers;
}
diff --git a/packages/apps/Settings/src/com/android/settings/development/SpoofSignaturePreferenceController.java b/packages/apps/Settings/src/com/android/settings/development/SpoofSignaturePreferenceController.java
new file mode 100644
index 0000000000..d0e6a4c52b
--- /dev/null
+++ b/packages/apps/Settings/src/com/android/settings/development/SpoofSignaturePreferenceController.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2019 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.support.annotation.VisibleForTesting;
+import android.support.v14.preference.SwitchPreference;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+
+public class SpoofSignaturePreferenceController extends DeveloperOptionsPreferenceController
+ implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
+
+ private static final String ALLOW_SIGNATURE_FAKE_KEY = "allow_signature_fake";
+
+ @VisibleForTesting
+ static final int SETTING_VALUE_ON = 1;
+ @VisibleForTesting
+ static final int SETTING_VALUE_OFF = 0;
+
+ public SpoofSignaturePreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return ALLOW_SIGNATURE_FAKE_KEY;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final boolean isEnabled = (Boolean) newValue;
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.ALLOW_SIGNATURE_FAKE,
+ isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ final int spoofingMode = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.ALLOW_SIGNATURE_FAKE, SETTING_VALUE_OFF);
+ ((SwitchPreference) mPreference).setChecked(spoofingMode != SETTING_VALUE_OFF);
+ }
+
+ @Override
+ protected void onDeveloperOptionsSwitchDisabled() {
+ super.onDeveloperOptionsSwitchDisabled();
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.ALLOW_SIGNATURE_FAKE, SETTING_VALUE_OFF);
+ ((SwitchPreference) mPreference).setChecked(false);
+ }
+}