Created
March 25, 2019 14:11
-
-
Save simrat39/32793d5aaa075489e140a3eac6f449f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 7e94274dc8e5415c826d9ee13b1b4199f0e6cd10 Mon Sep 17 00:00:00 2001 | |
From: George G <[email protected]> | |
Date: Sat, 25 Feb 2017 18:24:06 +0200 | |
Subject: [PATCH 1/1] Settings: Introduce Substratum changes. | |
* Add toggle to force bypass of authorisation checks in the | |
SubstratumService. This is only accessible to owner accounts. | |
* Add ApplicationsState filter for Substratum overlays in All | |
apps list. | |
Change-Id: I4d8ca60ead6fe058e7bc2ef8b7613e77457b3f27 | |
[Surge1223: Rewrite to use a PreferenceController class] | |
Signed-off-by: Harsh Shandilya <[email protected]> | |
Signed-off-by: Harsh Shandilya <[email protected]> | |
--- | |
res/menu/manage_apps.xml | 8 +++ | |
res/values/projekt_strings.xml | 27 ++++++++ | |
res/xml/development_settings.xml | 5 ++ | |
.../ManageApplications.java | 31 ++++++++- | |
.../DevelopmentSettingsDashboardFragment.java | 1 + | |
...thorizeSubstratumPreferenceController.java | 69 +++++++++++++++++++ | |
6 files changed, 140 insertions(+), 1 deletion(-) | |
create mode 100644 res/values/projekt_strings.xml | |
create mode 100644 src/com/android/settings/development/ForceAuthorizeSubstratumPreferenceController.java | |
diff --git a/res/menu/manage_apps.xml b/res/menu/manage_apps.xml | |
index 99dba37d3a..a3f79db4fd 100644 | |
--- a/res/menu/manage_apps.xml | |
+++ b/res/menu/manage_apps.xml | |
@@ -29,6 +29,14 @@ | |
android:id="@+id/hide_system" | |
android:title="@string/menu_hide_system" | |
android:showAsAction="never" /> | |
+ <item | |
+ android:id="@+id/show_substratum" | |
+ android:title="@string/menu_show_substratum" | |
+ android:showAsAction="never" /> | |
+ <item | |
+ android:id="@+id/hide_substratum" | |
+ android:title="@string/menu_hide_substratum" | |
+ android:showAsAction="never" /> | |
<item | |
android:id="@+id/sort_order_alpha" | |
android:title="@string/sort_order_alpha" | |
diff --git a/res/values/projekt_strings.xml b/res/values/projekt_strings.xml | |
new file mode 100644 | |
index 0000000000..7b4f8472c4 | |
--- /dev/null | |
+++ b/res/values/projekt_strings.xml | |
@@ -0,0 +1,27 @@ | |
+<?xml version="1.0" encoding="utf-8"?> | |
+<!-- Copyright (c) 2016-2017 Projekt Substratum | |
+ | |
+ 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. | |
+--> | |
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> | |
+ | |
+ <!-- Force authorize substratum packages --> | |
+ <string name="force_authorize_substratum_packages_title">Force authorize every theme app</string> | |
+ <string name="force_authorize_substratum_packages_summary">Allow theme apps from unknown sources</string> | |
+ | |
+ <!-- Manage applications: show substratum overlays --> | |
+ <string name="filter_substratum_apps">Substratum overlays</string> | |
+ <string name="menu_show_substratum">Show overlays</string> | |
+ <string name="menu_hide_substratum">Hide overlays</string> | |
+ | |
+</resources> | |
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml | |
index 7603162e2f..46f18f3a23 100644 | |
--- a/res/xml/development_settings.xml | |
+++ b/res/xml/development_settings.xml | |
@@ -108,6 +108,11 @@ | |
android:summary="@string/show_cpu_info_summary" | |
android:defaultValue="false" /> | |
+ <SwitchPreference | |
+ android:key="force_authorize_substratum_packages" | |
+ android:title="@string/force_authorize_substratum_packages_title" | |
+ android:summary="@string/force_authorize_substratum_packages_summary" /> | |
+ | |
<Preference | |
android:key="demo_mode" | |
android:title="@string/demo_mode"> | |
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java | |
index 04c79e6782..7a58be7e33 100644 | |
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java | |
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java | |
@@ -155,6 +155,7 @@ public class ManageApplications extends InstrumentedFragment | |
private static final String EXTRA_SORT_ORDER = "sortOrder"; | |
private static final String EXTRA_SHOW_SYSTEM = "showSystem"; | |
+ private static final String EXTRA_SHOW_SUBSTRATUM = "showSubstratum"; | |
private static final String EXTRA_HAS_ENTRIES = "hasEntries"; | |
private static final String EXTRA_HAS_BRIDGE = "hasBridge"; | |
@@ -184,6 +185,9 @@ public class ManageApplications extends InstrumentedFragment | |
// whether showing system apps. | |
private boolean mShowSystem; | |
+ // whether showing substratum overlays. | |
+ private boolean mShowSubstratum; | |
+ | |
private ApplicationsState mApplicationsState; | |
public int mListType; | |
@@ -316,6 +320,7 @@ public class ManageApplications extends InstrumentedFragment | |
if (savedInstanceState != null) { | |
mSortOrder = savedInstanceState.getInt(EXTRA_SORT_ORDER, mSortOrder); | |
mShowSystem = savedInstanceState.getBoolean(EXTRA_SHOW_SYSTEM, mShowSystem); | |
+ mShowSubstratum = savedInstanceState.getBoolean(EXTRA_SHOW_SUBSTRATUM, mShowSubstratum); | |
} | |
mInvalidSizeStr = activity.getText(R.string.invalid_size_value); | |
@@ -496,6 +501,7 @@ public class ManageApplications extends InstrumentedFragment | |
mResetAppsHelper.onSaveInstanceState(outState); | |
outState.putInt(EXTRA_SORT_ORDER, mSortOrder); | |
outState.putBoolean(EXTRA_SHOW_SYSTEM, mShowSystem); | |
+ outState.putBoolean(EXTRA_SHOW_SUBSTRATUM, mShowSubstratum); | |
outState.putBoolean(EXTRA_HAS_ENTRIES, mApplications.mHasReceivedLoadEntries); | |
outState.putBoolean(EXTRA_HAS_BRIDGE, mApplications.mHasReceivedBridgeCallback); | |
if (mApplications != null) { | |
@@ -648,6 +654,10 @@ public class ManageApplications extends InstrumentedFragment | |
// Hide notification menu items, because sorting happens when filtering | |
mOptionsMenu.findItem(R.id.sort_order_recent_notification).setVisible(false); | |
mOptionsMenu.findItem(R.id.sort_order_frequent_notification).setVisible(false); | |
+ mOptionsMenu.findItem(R.id.show_substratum).setVisible(!mShowSubstratum | |
+ && mListType != LIST_TYPE_HIGH_POWER); | |
+ mOptionsMenu.findItem(R.id.hide_substratum).setVisible(mShowSubstratum | |
+ && mListType != LIST_TYPE_HIGH_POWER); | |
} | |
@Override | |
@@ -665,6 +675,11 @@ public class ManageApplications extends InstrumentedFragment | |
mShowSystem = !mShowSystem; | |
mApplications.rebuild(); | |
break; | |
+ case R.id.show_substratum: | |
+ case R.id.hide_substratum: | |
+ mShowSubstratum = !mShowSubstratum; | |
+ mApplications.rebuild(); | |
+ break; | |
case R.id.reset_app_preferences: | |
mResetAppsHelper.buildResetDialog(); | |
return true; | |
@@ -1037,7 +1052,7 @@ public class ManageApplications extends InstrumentedFragment | |
if (mCompositeFilter != null) { | |
filterObj = new CompoundFilter(filterObj, mCompositeFilter); | |
} | |
- if (!mManageApplications.mShowSystem) { | |
+ if (!mManageApplications.mShowSystem && !mManageApplications.mShowSubstratum) { | |
if (LIST_TYPES_WITH_INSTANT.contains(mManageApplications.mListType)) { | |
filterObj = new CompoundFilter(filterObj, | |
ApplicationsState.FILTER_DOWNLOADED_AND_LAUNCHER_AND_INSTANT); | |
@@ -1045,7 +1060,21 @@ public class ManageApplications extends InstrumentedFragment | |
filterObj = new CompoundFilter(filterObj, | |
ApplicationsState.FILTER_DOWNLOADED_AND_LAUNCHER); | |
} | |
+ filterObj = new CompoundFilter(filterObj, | |
+ ApplicationsState.FILTER_SUBSTRATUM); | |
+ } else if (!mManageApplications.mShowSystem) { | |
+ if (LIST_TYPES_WITH_INSTANT.contains(mManageApplications.mListType)) { | |
+ filterObj = new CompoundFilter(filterObj, | |
+ ApplicationsState.FILTER_DOWNLOADED_AND_LAUNCHER_AND_INSTANT); | |
+ } else { | |
+ filterObj = new CompoundFilter(filterObj, | |
+ ApplicationsState.FILTER_DOWNLOADED_AND_LAUNCHER); | |
+ } | |
+ } else if (!mManageApplications.mShowSubstratum) { | |
+ filterObj = new CompoundFilter(filterObj, | |
+ ApplicationsState.FILTER_SUBSTRATUM); | |
} | |
+ | |
switch (mLastSortMode) { | |
case R.id.sort_order_size: | |
switch (mWhichSize) { | |
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java | |
index 7bed5728c2..d60ddda56c 100644 | |
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java | |
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java | |
@@ -470,6 +470,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra | |
controllers.add(new FreeformWindowsPreferenceController(context)); | |
controllers.add(new ShortcutManagerThrottlingPreferenceController(context)); | |
controllers.add(new EnableGnssRawMeasFullTrackingPreferenceController(context)); | |
+ controllers.add(new ForceAuthorizeSubstratumPreferenceController(context)); | |
controllers.add(new DefaultLaunchPreferenceController(context, "running_apps")); | |
controllers.add(new DefaultLaunchPreferenceController(context, "demo_mode")); | |
controllers.add(new DefaultLaunchPreferenceController(context, "quick_settings_tiles")); | |
diff --git a/src/com/android/settings/development/ForceAuthorizeSubstratumPreferenceController.java b/src/com/android/settings/development/ForceAuthorizeSubstratumPreferenceController.java | |
new file mode 100644 | |
index 0000000000..e8e3aaaec6 | |
--- /dev/null | |
+++ b/src/com/android/settings/development/ForceAuthorizeSubstratumPreferenceController.java | |
@@ -0,0 +1,69 @@ | |
+/* | |
+ * Copyright (C) 2018 Projekt Substratum | |
+ * | |
+ * 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.v14.preference.SwitchPreference; | |
+import android.support.v7.preference.Preference; | |
+ | |
+import com.android.settings.core.PreferenceControllerMixin; | |
+import com.android.settingslib.development.DeveloperOptionsPreferenceController; | |
+ | |
+public class ForceAuthorizeSubstratumPreferenceController extends | |
+ DeveloperOptionsPreferenceController implements | |
+ Preference.OnPreferenceChangeListener, PreferenceControllerMixin { | |
+ | |
+ private static final String FORCE_AUTHORIZE_SUBSTRATUM_PACKAGES = "force_authorize_substratum_packages"; | |
+ | |
+ final static int DISABLE_FORCE_AUTHORIZE_SUBSTRATUM_PACKAGES = 0; | |
+ final static int ENABLE_FORCE_AUTHORIZE_SUBSTRATUM_PACKAGES = 1; | |
+ | |
+ public ForceAuthorizeSubstratumPreferenceController(Context context) { | |
+ super(context); | |
+ } | |
+ | |
+ @Override | |
+ public String getPreferenceKey() { | |
+ return FORCE_AUTHORIZE_SUBSTRATUM_PACKAGES; | |
+ } | |
+ | |
+ @Override | |
+ public boolean onPreferenceChange(Preference preference, Object newValue) { | |
+ final boolean mForceAuthorizeSubstratumPackages = (Boolean) newValue; | |
+ Settings.Secure.putInt(mContext.getContentResolver(), | |
+ Settings.Secure.FORCE_AUTHORIZE_SUBSTRATUM_PACKAGES, | |
+ mForceAuthorizeSubstratumPackages ? ENABLE_FORCE_AUTHORIZE_SUBSTRATUM_PACKAGES : DISABLE_FORCE_AUTHORIZE_SUBSTRATUM_PACKAGES); | |
+ return true; | |
+ } | |
+ | |
+ @Override | |
+ public void updateState(Preference preference) { | |
+ final int mForceAuthorizeSubstratumPackages = Settings.Secure.getInt(mContext.getContentResolver(), | |
+ Settings.Secure.FORCE_AUTHORIZE_SUBSTRATUM_PACKAGES, 0); | |
+ | |
+ ((SwitchPreference) mPreference).setChecked(mForceAuthorizeSubstratumPackages != DISABLE_FORCE_AUTHORIZE_SUBSTRATUM_PACKAGES); | |
+ } | |
+ | |
+ @Override | |
+ protected void onDeveloperOptionsSwitchDisabled() { | |
+ super.onDeveloperOptionsSwitchDisabled(); | |
+ Settings.Secure.putInt(mContext.getContentResolver(), | |
+ Settings.Secure.FORCE_AUTHORIZE_SUBSTRATUM_PACKAGES, DISABLE_FORCE_AUTHORIZE_SUBSTRATUM_PACKAGES); | |
+ ((SwitchPreference) mPreference).setChecked(false); | |
+ } | |
+} | |
-- | |
2.17.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment