diff --git a/Misc/Features/GrapheneOS.txt b/Misc/Features/GrapheneOS.txt index 2d1e31b3..b8899e65 100644 --- a/Misc/Features/GrapheneOS.txt +++ b/Misc/Features/GrapheneOS.txt @@ -63,6 +63,9 @@ nojit 9 https://github.com/GrapheneOS/platform_build/commit/5b9927197e63593b9220d1a9280021252ef205e9 9 https://github.com/GrapheneOS/platform_build/commit/e36c7aefaa78a1ed5b94c7f51d29277008eea232 +[implemented] captive portal toggle +12 https://github.com/GrapheneOS/platform_packages_apps_Settings/commit/2a0b0b9193195c360260a3ef7094e45c44b79a24 + [implemented] show crash details 12 https://github.com/GrapheneOS/platform_frameworks_base/commit/e740f4b78344c5671d022dfe90bed9e2dacd3db6 diff --git a/Misc/captive_portal_toggle-19.1-err b/Misc/captive_portal_toggle-19.1-err deleted file mode 100644 index 7338a81e..00000000 --- a/Misc/captive_portal_toggle-19.1-err +++ /dev/null @@ -1,55 +0,0 @@ -09-23 11:50:49.155 2227 2227 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.settings/com.android.settings.SubSettings}: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.preference.Preference.setOnPreferenceChangeListener(androidx.preference.Preference$OnPreferenceChangeListener)' on a null object reference -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3707) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3864) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2253) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7870) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1019) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.preference.Preference.setOnPreferenceChangeListener(androidx.preference.Preference$OnPreferenceChangeListener)' on a null object reference -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.settingslib.core.AbstractPreferenceController.displayPreference(AbstractPreferenceController.java:37) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.settings.dashboard.DashboardFragment.lambda$displayResourceTilesToScreen$7(DashboardFragment.java:339) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.settings.dashboard.DashboardFragment.$r8$lambda$7KgqziyHu5rnhM8JHZ4buqOlhzM(Unknown Source:0) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.settings.dashboard.DashboardFragment$$ExternalSyntheticLambda2.accept(Unknown Source:4) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1390) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:604) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:283) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at java.util.Iterator.forEachRemaining(Iterator.java:116) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:475) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:133) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:236) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:435) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.settings.dashboard.DashboardFragment.displayResourceTilesToScreen(DashboardFragment.java:338) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.settings.dashboard.DashboardFragment.displayResourceTiles(DashboardFragment.java:330) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.settings.dashboard.DashboardFragment.refreshAllPreferences(DashboardFragment.java:431) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.settings.dashboard.DashboardFragment.onCreatePreferences(DashboardFragment.java:182) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.settings.network.NetworkDashboardFragment.onCreatePreferences(NetworkDashboardFragment.java:76) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at androidx.preference.PreferenceFragmentCompat.onCreate(PreferenceFragmentCompat.java:161) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.settingslib.core.lifecycle.ObservablePreferenceFragment.onCreate(ObservablePreferenceFragment.java:61) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.settings.SettingsPreferenceFragment.onCreate(SettingsPreferenceFragment.java:126) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.settings.dashboard.DashboardFragment.onCreate(DashboardFragment.java:150) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at androidx.fragment.app.Fragment.performCreate(Fragment.java:2939) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:451) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:254) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2209) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2120) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2022) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at androidx.fragment.app.FragmentManager.executePendingTransactions(FragmentManager.java:603) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.settings.SettingsActivity.switchToFragment(SettingsActivity.java:727) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.settings.SettingsActivity.launchSettingFragment(SettingsActivity.java:509) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at com.android.settings.SettingsActivity.onCreate(SettingsActivity.java:304) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8057) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8037) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1341) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3688) -09-23 11:50:49.155 2227 2227 E AndroidRuntime: ... 12 more diff --git a/Patches/LineageOS-19.1/android_packages_apps_Settings/0001-Captive_Portal_Toggle.patch b/Patches/LineageOS-19.1/android_packages_apps_Settings/0001-Captive_Portal_Toggle.patch deleted file mode 100644 index 3155f516..00000000 --- a/Patches/LineageOS-19.1/android_packages_apps_Settings/0001-Captive_Portal_Toggle.patch +++ /dev/null @@ -1,349 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MSe1969 -Date: Mon, 10 Sep 2018 12:05:40 +0200 -Subject: [PATCH] Network & Internet Settings: Add option to switch off Captive - portal check - - * Option added in Network & Internet Settings, which is equivalent to - the adb shell command 'settings put global captive_portal_mode [1/0]' - * Will be reset to default, if 'Reset network settings' is chosen (menu) - * Warning dialog is shown, when captive portal check is switched off - * Hidden under 'advanced' - -Cherry-picked from lin17-microG repo - -Change-Id: Ibbffdb5f3930df74ca8b4ba93d451f7fad086989 ---- - res/values-de/cm_strings.xml | 3 + - res/values/cm_strings.xml | 5 ++ - res/xml/network_and_internet.xml | 7 ++ - .../android/settings/ResetNetworkConfirm.java | 4 + - ...CaptivePortalModePreferenceController.java | 82 +++++++++++++++++++ - .../network/CaptivePortalWarningDialog.java | 74 +++++++++++++++++ - .../CaptivePortalWarningDialogHost.java | 32 ++++++++ - .../network/NetworkDashboardFragment.java | 17 +++- - 8 files changed, 223 insertions(+), 1 deletion(-) - create mode 100644 src/com/android/settings/network/CaptivePortalModePreferenceController.java - create mode 100644 src/com/android/settings/network/CaptivePortalWarningDialog.java - create mode 100644 src/com/android/settings/network/CaptivePortalWarningDialogHost.java - -diff --git a/res/values-de/cm_strings.xml b/res/values-de/cm_strings.xml -index 1428fbf300..12b4a68a04 100644 ---- a/res/values-de/cm_strings.xml -+++ b/res/values-de/cm_strings.xml -@@ -56,6 +56,9 @@ - Klingelton- und Benachrichtigungslautstärke verknüpfen - Zufällige Anordnung - Bei jedem Entsperrversuch die Ziffernanordnung zufällig neu wählen -+ Captive Portal Erkennung -+ Ein-/Ausschalten der Captive Portal Erkennung (Vorgabe EIN). -+ Nach dem Ausschalten der Captive-Portal-Erkennung empfangen Sie keine Verbindungs-Rückmeldung mehr. Wirklich fortfahren? - Größe des Musters auswählen - Sperrmuster-Fehler anzeigen - Sperrmuster-Punkte anzeigen -diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml -index 2e727640c2..6f14256ebf 100644 ---- a/res/values/cm_strings.xml -+++ b/res/values/cm_strings.xml -@@ -82,6 +82,11 @@ - Scramble layout - Scramble PIN layout when unlocking device - -+ -+ Captive portal mode -+ Enable or disable the captive portal probing for connection attempts (default ON). -+ If you switch off the captive portal, you will not receive connectivity informations any longer. Really switch off? -+ - - Touch fingerprint to unlock - Listens for events while the screen is off -diff --git a/res/xml/network_and_internet.xml b/res/xml/network_and_internet.xml -index d842aad021..7f82235a2b 100644 ---- a/res/xml/network_and_internet.xml -+++ b/res/xml/network_and_internet.xml -@@ -125,4 +125,11 @@ - android:summary="@string/summary_placeholder" - android:order="25" - settings:controller="com.android.settings.network.AdaptiveConnectivityPreferenceController"/> -+ -+ -+ - -diff --git a/src/com/android/settings/ResetNetworkConfirm.java b/src/com/android/settings/ResetNetworkConfirm.java -index f79bdb2e36..58372582e1 100644 ---- a/src/com/android/settings/ResetNetworkConfirm.java -+++ b/src/com/android/settings/ResetNetworkConfirm.java -@@ -37,6 +37,7 @@ import android.os.Looper; - import android.os.RecoverySystem; - import android.os.UserHandle; - import android.os.UserManager; -+import android.provider.Settings; - import android.telephony.SubscriptionManager; - import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener; - import android.telephony.TelephonyManager; -@@ -142,6 +143,9 @@ public class ResetNetworkConfirm extends InstrumentedFragment { - } - } - -+ Settings.Global.putInt(mContext.getContentResolver(), -+ Settings.Global.CAPTIVE_PORTAL_MODE, 1); -+ - restoreDefaultApn(mContext); - Log.d(TAG, "network factoryReset complete. succeeded: " - + String.valueOf(isResetSucceed)); -diff --git a/src/com/android/settings/network/CaptivePortalModePreferenceController.java b/src/com/android/settings/network/CaptivePortalModePreferenceController.java -new file mode 100644 -index 0000000000..ae21b29292 ---- /dev/null -+++ b/src/com/android/settings/network/CaptivePortalModePreferenceController.java -@@ -0,0 +1,82 @@ -+/* -+ * Copyright (C) 2018 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.network; -+ -+import android.content.Context; -+import android.provider.Settings; -+ -+import androidx.fragment.app.Fragment; -+import androidx.preference.Preference; -+import androidx.preference.SwitchPreference; -+ -+import com.android.settings.core.PreferenceControllerMixin; -+import com.android.settingslib.core.AbstractPreferenceController; -+ -+public class CaptivePortalModePreferenceController extends AbstractPreferenceController -+ implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener { -+ -+ private static final String TAG = "CaptivePortalModePreferenceController"; -+ private static final String CAPTIVE_PORTAL_SWITCH_KEY = "captive_portal_switch"; -+ -+ private SwitchPreference mCaptivePortalMode; -+ private Preference mPreference; -+ private final Fragment mFragment; -+ -+ public CaptivePortalModePreferenceController(Context context, Fragment hostFragment) { -+ super(context); -+ -+ mFragment = hostFragment; -+ } -+ -+ @Override -+ public void updateState(Preference preference) { -+ boolean value = (Settings.Global.getInt(mContext.getContentResolver(), -+ Settings.Global.CAPTIVE_PORTAL_MODE, -+ Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT) != 0); -+ ((SwitchPreference) preference).setChecked(value); -+ } -+ -+ @Override -+ public boolean onPreferenceChange(Preference preference, Object newValue) { -+ mPreference = preference; -+ if ((Boolean) newValue) { -+ Settings.Global.putInt(mContext.getContentResolver(), -+ Settings.Global.CAPTIVE_PORTAL_MODE, 1); -+ } else { -+ CaptivePortalWarningDialog.show(mFragment); -+ } -+ return true; -+ } -+ -+ public void onCaptivePortalSwitchOffDialogConfirmed() { -+ Settings.Global.putInt(mContext.getContentResolver(), -+ Settings.Global.CAPTIVE_PORTAL_MODE, 0); -+ } -+ -+ public void onCaptivePortalSwitchOffDialogDismissed() { -+ updateState(mPreference); -+ } -+ -+ @Override -+ public boolean isAvailable() { -+ return true; -+ } -+ -+ @Override -+ public String getPreferenceKey() { -+ return CAPTIVE_PORTAL_SWITCH_KEY; -+ } -+} -diff --git a/src/com/android/settings/network/CaptivePortalWarningDialog.java b/src/com/android/settings/network/CaptivePortalWarningDialog.java -new file mode 100644 -index 0000000000..d27bd7d2f0 ---- /dev/null -+++ b/src/com/android/settings/network/CaptivePortalWarningDialog.java -@@ -0,0 +1,74 @@ -+/* -+ * Copyright (C) 2018 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.network; -+ -+import android.app.Dialog; -+import android.content.DialogInterface; -+import android.os.Bundle; -+ -+import androidx.appcompat.app.AlertDialog; -+import androidx.fragment.app.Fragment; -+import androidx.fragment.app.FragmentManager; -+ -+import com.android.internal.logging.nano.MetricsProto; -+import com.android.settings.R; -+import com.android.settings.core.instrumentation.InstrumentedDialogFragment; -+ -+public class CaptivePortalWarningDialog extends InstrumentedDialogFragment implements -+ DialogInterface.OnClickListener, DialogInterface.OnDismissListener { -+ -+ public static final String TAG = "CaptivePortalWarningDialog"; -+ -+ public static void show(Fragment host) { -+ final FragmentManager manager = host.getActivity().getSupportFragmentManager(); -+ if (manager.findFragmentByTag(TAG) == null) { -+ final CaptivePortalWarningDialog dialog = -+ new CaptivePortalWarningDialog(); -+ dialog.setTargetFragment(host, 0 /* requestCode */); -+ dialog.show(manager, TAG); -+ } -+ } -+ -+ @Override -+ public int getMetricsCategory() { -+ return MetricsProto.MetricsEvent.TYPE_UNKNOWN; -+ } -+ -+ @Override -+ public Dialog onCreateDialog(Bundle savedInstanceState) { -+ return new AlertDialog.Builder(getActivity()) -+ .setTitle(R.string.captive_portal_switch_title) -+ .setMessage(R.string.captive_portal_switch_warning) -+ .setIconAttribute(android.R.attr.alertDialogIcon) -+ .setPositiveButton(android.R.string.yes, this /* onClickListener */) -+ .setNegativeButton(android.R.string.no, this /* onClickListener */) -+ .create(); -+ } -+ -+ @Override -+ public void onClick(DialogInterface dialog, int which) { -+ final CaptivePortalWarningDialogHost host = (CaptivePortalWarningDialogHost) getTargetFragment(); -+ if (host == null) { -+ return; -+ } -+ if (which == DialogInterface.BUTTON_POSITIVE) { -+ host.onCaptivePortalSwitchOffDialogConfirmed(); -+ } else { -+ host.onCaptivePortalSwitchOffDialogDismissed(); -+ } -+ } -+} -diff --git a/src/com/android/settings/network/CaptivePortalWarningDialogHost.java b/src/com/android/settings/network/CaptivePortalWarningDialogHost.java -new file mode 100644 -index 0000000000..7a04d1f831 ---- /dev/null -+++ b/src/com/android/settings/network/CaptivePortalWarningDialogHost.java -@@ -0,0 +1,32 @@ -+/* -+ * Copyright (C) 2018 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.network; -+ -+/** -+ * Interface for CaptivePortalWarningDialogHost callbacks. -+ */ -+public interface CaptivePortalWarningDialogHost { -+ /** -+ * Called when the user presses YES/ok on the warning dialog. -+ */ -+ void onCaptivePortalSwitchOffDialogConfirmed(); -+ -+ /** -+ * Called when the user presses NO/cancel on the warning dialog. -+ */ -+ void onCaptivePortalSwitchOffDialogDismissed(); -+} -diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java -index 286e4e36e5..0eb79c5d4c 100644 ---- a/src/com/android/settings/network/NetworkDashboardFragment.java -+++ b/src/com/android/settings/network/NetworkDashboardFragment.java -@@ -44,7 +44,7 @@ import java.util.List; - - @SearchIndexable - public class NetworkDashboardFragment extends DashboardFragment implements -- MobilePlanPreferenceHost { -+ MobilePlanPreferenceHost, CaptivePortalWarningDialogHost { - - private static final String TAG = "NetworkDashboardFrag"; - -@@ -100,6 +100,8 @@ public class NetworkDashboardFragment extends DashboardFragment implements - new VpnPreferenceController(context); - final PrivateDnsPreferenceController privateDnsPreferenceController = - new PrivateDnsPreferenceController(context); -+ final CaptivePortalModePreferenceController captiveportalModePreferenceController = -+ new CaptivePortalModePreferenceController(context, fragment); - - if (lifecycle != null) { - lifecycle.addObserver(mobilePlanPreferenceController); -@@ -118,10 +120,23 @@ public class NetworkDashboardFragment extends DashboardFragment implements - controllers.add(internetPreferenceController); - } - controllers.add(privateDnsPreferenceController); -+ controllers.add(captiveportalModePreferenceController); - controllers.add(new NetworkProviderCallsSmsController(context, lifecycle)); - return controllers; - } - -+ public void onCaptivePortalSwitchOffDialogConfirmed() { -+ final CaptivePortalModePreferenceController controller = -+ use(CaptivePortalModePreferenceController.class); -+ controller.onCaptivePortalSwitchOffDialogConfirmed(); -+ } -+ -+ public void onCaptivePortalSwitchOffDialogDismissed() { -+ final CaptivePortalModePreferenceController controller = -+ use(CaptivePortalModePreferenceController.class); -+ controller.onCaptivePortalSwitchOffDialogDismissed(); -+ } -+ - @Override - public void showMobilePlanMessageDialog() { - showDialog(MANAGE_MOBILE_PLAN_DIALOG_ID); diff --git a/Patches/LineageOS-19.1/android_packages_apps_Settings/0013-Captive_Portal_Toggle.patch b/Patches/LineageOS-19.1/android_packages_apps_Settings/0013-Captive_Portal_Toggle.patch new file mode 100644 index 00000000..89bb761f --- /dev/null +++ b/Patches/LineageOS-19.1/android_packages_apps_Settings/0013-Captive_Portal_Toggle.patch @@ -0,0 +1,257 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Pratyush +Date: Wed, 20 Oct 2021 05:40:11 +0530 +Subject: [PATCH] add toggle to set captiveportal settings + +Access is disallowed for users that are disallowed from configuring +Private DNS settings. This restriction provides administrative control +over this feature in a way that's compatible with existing device +manager implementations. Private DNS is the closest fit from the +existing user management restrictions that are available. + +Co-authored-by: stuux +Co-authored-by: Renlord +Co-authored-by: Danny Lin +Co-authored-by: anupritaisno1 +Signed-off-by: empratyush +[tad@spotco.us]: removed the option for GrapheneOS servers +Change-Id: I8602bc4be0b896416282b7cf08bcd45b2cc216c6 +--- + res/values/arrays.xml | 10 + + res/values/strings.xml | 3 + + ...ConnectivityCheckPreferenceController.java | 176 ++++++++++++++++++ + .../network/NetworkDashboardFragment.java | 3 + + 4 files changed, 192 insertions(+) + create mode 100644 src/com/android/settings/network/ConnectivityCheckPreferenceController.java + +diff --git a/res/values/arrays.xml b/res/values/arrays.xml +index f50d130936..bb95662047 100644 +--- a/res/values/arrays.xml ++++ b/res/values/arrays.xml +@@ -229,6 +229,16 @@ + 259200000 + + ++ ++ Standard (Google) ++ Disabled ++ ++ ++ ++ 0 ++ 1 ++ ++ + + +diff --git a/res/values/strings.xml b/res/values/strings.xml +index 67c47bc7b3..58b17eeccf 100644 +--- a/res/values/strings.xml ++++ b/res/values/strings.xml +@@ -691,6 +691,9 @@ + Auto reboot + Automatically reboot the device, if the phone hasn\'t been unlocked within the selected number of hours. + ++ Internet connectivity check ++ HTTP endpoints to use for performing internet connectivity checks. ++ + + None + +diff --git a/src/com/android/settings/network/ConnectivityCheckPreferenceController.java b/src/com/android/settings/network/ConnectivityCheckPreferenceController.java +new file mode 100644 +index 0000000000..ae62133141 +--- /dev/null ++++ b/src/com/android/settings/network/ConnectivityCheckPreferenceController.java +@@ -0,0 +1,176 @@ ++/* ++ * Copyright (C) 2020 The Android Open Source 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.network; ++ ++import android.content.ContentResolver; ++import android.content.Context; ++import android.content.res.Resources; ++import android.database.ContentObserver; ++import android.net.LinkProperties; ++import android.net.Network; ++import android.os.Handler; ++import android.os.Looper; ++import android.os.UserHandle; ++import android.os.UserManager; ++import android.provider.Settings; ++import androidx.preference.ListPreference; ++import androidx.preference.Preference; ++import androidx.preference.PreferenceScreen; ++import com.android.internal.util.ArrayUtils; ++import com.android.settings.R; ++import com.android.settings.core.BasePreferenceController; ++import com.android.settings.core.PreferenceControllerMixin; ++import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; ++import com.android.settingslib.RestrictedLockUtilsInternal; ++import com.android.settingslib.core.lifecycle.events.OnResume; ++ ++public class ConnectivityCheckPreferenceController ++ extends BasePreferenceController ++ implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener, ++ OnResume { ++ ++ // imported defaults from AOSP NetworkStack ++ private static final String STANDARD_HTTPS_URL = ++ "https://www.google.com/generate_204"; ++ private static final String STANDARD_HTTP_URL = ++ "http://connectivitycheck.gstatic.com/generate_204"; ++ private static final String STANDARD_FALLBACK_URL = ++ "http://www.google.com/gen_204"; ++ private static final String STANDARD_OTHER_FALLBACK_URLS = ++ "http://play.googleapis.com/generate_204"; ++ ++ private static final int STANDARD_CAPTIVE_PORTAL_HTTP_URL_INTVAL = 0; ++ private static final int DISABLED_CAPTIVE_PORTAL_INTVAL = 1; ++ ++ private static final String KEY_CONNECTIVITY_CHECK_SETTINGS = ++ "connectivity_check_settings"; ++ ++ private ListPreference mConnectivityPreference; ++ ++ public ConnectivityCheckPreferenceController(Context context) { ++ super(context, KEY_CONNECTIVITY_CHECK_SETTINGS); ++ } ++ ++ @Override ++ public int getAvailabilityStatus() { ++ if (isDisabledByAdmin()) { ++ return BasePreferenceController.DISABLED_FOR_USER; ++ } ++ return BasePreferenceController.AVAILABLE; ++ } ++ ++ @Override ++ public void displayPreference(PreferenceScreen screen) { ++ ListPreference captiveList = new ListPreference(screen.getContext()); ++ captiveList.setKey(KEY_CONNECTIVITY_CHECK_SETTINGS); ++ captiveList.setOrder(30); ++ captiveList.setIcon(R.drawable.ic_settings_language); ++ captiveList.setTitle(R.string.connectivity_check_title); ++ captiveList.setSummary(R.string.connectivity_check_summary); ++ captiveList.setEntries(R.array.connectivity_check_entries); ++ captiveList.setEntryValues(R.array.connectivity_check_values); ++ ++ if (mConnectivityPreference == null) { ++ screen.addPreference(captiveList); ++ mConnectivityPreference = captiveList; ++ } ++ super.displayPreference(screen); ++ updatePreferenceState(); ++ } ++ ++ @Override ++ public String getPreferenceKey() { ++ return KEY_CONNECTIVITY_CHECK_SETTINGS; ++ } ++ ++ private void updatePreferenceState() { ++ if (Settings.Global.getInt(mContext.getContentResolver(), ++ Settings.Global.CAPTIVE_PORTAL_MODE, Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT) ++ == Settings.Global.CAPTIVE_PORTAL_MODE_IGNORE) { ++ mConnectivityPreference.setValueIndex(DISABLED_CAPTIVE_PORTAL_INTVAL); ++ return; ++ } ++ ++ String pref = Settings.Global.getString( ++ mContext.getContentResolver(), Settings.Global.CAPTIVE_PORTAL_HTTP_URL); ++ if (STANDARD_HTTP_URL.equals(pref)) { ++ mConnectivityPreference.setValueIndex( ++ STANDARD_CAPTIVE_PORTAL_HTTP_URL_INTVAL); ++ } ++ } ++ ++ @Override ++ public void onResume() { ++ updatePreferenceState(); ++ if (mConnectivityPreference != null) { ++ setCaptivePortalURLs( ++ mContext.getContentResolver(), ++ Integer.parseInt(mConnectivityPreference.getValue())); ++ } ++ } ++ ++ private void setCaptivePortalURLs(ContentResolver cr, int mode) { ++ switch (mode) { ++ case STANDARD_CAPTIVE_PORTAL_HTTP_URL_INTVAL: ++ Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTP_URL, ++ STANDARD_HTTP_URL); ++ Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL, ++ STANDARD_HTTPS_URL); ++ Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL, ++ STANDARD_FALLBACK_URL); ++ Settings.Global.putString( ++ cr, Settings.Global.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS, ++ STANDARD_OTHER_FALLBACK_URLS); ++ Settings.Global.putInt(cr, Settings.Global.CAPTIVE_PORTAL_MODE, ++ Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT); ++ break; ++ default: ++ // Default URLs as placeholder ++ Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTP_URL, ++ STANDARD_HTTP_URL); ++ Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL, ++ STANDARD_HTTPS_URL); ++ Settings.Global.putString(cr, Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL, ++ STANDARD_FALLBACK_URL); ++ Settings.Global.putString( ++ cr, Settings.Global.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS, ++ STANDARD_OTHER_FALLBACK_URLS); ++ Settings.Global.putInt(cr, Settings.Global.CAPTIVE_PORTAL_MODE, ++ Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT); ++ } ++ } ++ ++ @Override ++ public boolean onPreferenceChange(Preference preference, Object value) { ++ final String key = preference.getKey(); ++ if (KEY_CONNECTIVITY_CHECK_SETTINGS.equals(key)) { ++ setCaptivePortalURLs(mContext.getContentResolver(), ++ Integer.parseInt((String)value)); ++ return true; ++ } else { ++ return false; ++ } ++ } ++ ++ private EnforcedAdmin getEnforcedAdmin() { ++ return RestrictedLockUtilsInternal.checkIfRestrictionEnforced( ++ mContext, UserManager.DISALLOW_CONFIG_PRIVATE_DNS, ++ UserHandle.myUserId()); ++ } ++ ++ private boolean isDisabledByAdmin() { return getEnforcedAdmin() != null; } ++} +diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java +index 286e4e36e5..2eb788fbd0 100644 +--- a/src/com/android/settings/network/NetworkDashboardFragment.java ++++ b/src/com/android/settings/network/NetworkDashboardFragment.java +@@ -119,6 +119,9 @@ public class NetworkDashboardFragment extends DashboardFragment implements + } + controllers.add(privateDnsPreferenceController); + controllers.add(new NetworkProviderCallsSmsController(context, lifecycle)); ++ ConnectivityCheckPreferenceController connectivityCheck = ++ new ConnectivityCheckPreferenceController(context); ++ controllers.add(connectivityCheck); + return controllers; + } + diff --git a/Scripts/LineageOS-19.1/Patch.sh b/Scripts/LineageOS-19.1/Patch.sh index c79de95f..5bb13835 100644 --- a/Scripts/LineageOS-19.1/Patch.sh +++ b/Scripts/LineageOS-19.1/Patch.sh @@ -280,7 +280,6 @@ if [ "$DOS_GRAPHENE_CONSTIFY" = true ]; then applyPatch "$DOS_PATCHES/android_pa fi; if enterAndClear "packages/apps/Settings"; then -#applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0001-Captive_Portal_Toggle.patch"; #Add option to disable captive portal checks (MSe1969) #XXX 19REBASE: broken applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0004-Private_DNS.patch"; #More 'Private DNS' options (heavily based off of a CalyxOS patch) applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0005-Automatic_Reboot.patch"; #Timeout for reboot (GrapheneOS) applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0006-Bluetooth_Timeout.patch"; #Timeout for Bluetooth (CalyxOS) @@ -290,6 +289,7 @@ if [ "$DOS_GRAPHENE_EXEC" = true ]; then applyPatch "$DOS_PATCHES/android_packag applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0011-Random_MAC.patch"; #Add option to always randomize MAC (GrapheneOS) applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0009-Install_Restrictions.patch"; #UserManager app installation restrictions (GrapheneOS) applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0012-hosts_toggle.patch"; #Add a toggle to disable /etc/hosts lookup (heavily based off of a GrapheneOS patch) +applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0013-Captive_Portal_Toggle.patch"; #Add option to disable captive portal checks (GrapheneOS) sed -i 's/if (isFullDiskEncrypted()) {/if (false) {/' src/com/android/settings/accessibility/*AccessibilityService*.java; #Never disable secure start-up when enabling an accessibility service fi;