From 4b63e743bd9fdd430650c84a51a456191cc5fa69 Mon Sep 17 00:00:00 2001 From: althafvly Date: Thu, 11 Jul 2024 11:13:42 +0530 Subject: [PATCH 1/2] Browser: Hide browser settings for parental control --- .gitignore | 1 + ...tings-when-parental-control-is-activ.patch | 118 ++++++++++++++++++ build/e_patches_list.txt | 1 + 3 files changed, 120 insertions(+) create mode 100644 build/e_patches/0053-Browser-Hide-settings-when-parental-control-is-activ.patch diff --git a/.gitignore b/.gitignore index d827dac7..ce24e63b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ _gclient_src*/ .cipd/ .gclient* depot_tools/ +.gcs_entries diff --git a/build/e_patches/0053-Browser-Hide-settings-when-parental-control-is-activ.patch b/build/e_patches/0053-Browser-Hide-settings-when-parental-control-is-activ.patch new file mode 100644 index 00000000..e1de597d --- /dev/null +++ b/build/e_patches/0053-Browser-Hide-settings-when-parental-control-is-activ.patch @@ -0,0 +1,118 @@ +From 8ff36892c33d9d520d2a250998f29ce70f306402 Mon Sep 17 00:00:00 2001 +From: althafvly +Date: Thu, 11 Jul 2024 11:11:15 +0530 +Subject: [PATCH] Browser: Hide settings when parental control is active + +--- + .../chrome/browser/app/ChromeActivity.java | 2 +- + .../AppMenuPropertiesDelegateImpl.java | 5 ++++ + .../browser/app/flags/ChromeCachedFlags.java | 29 +++++++++++++++++++ + .../chrome/browser/settings/MainSettings.java | 4 +++ + 4 files changed, 39 insertions(+), 1 deletion(-) + +diff --git a/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java +index c496be7249fee..ccb1666c7b796 100644 +--- a/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java ++++ b/chrome/android/java/src/org/chromium/chrome/browser/app/ChromeActivity.java +@@ -2498,7 +2498,7 @@ public abstract class ChromeActivity + @BrowserProfileType + int type = Profile.getBrowserProfileTypeFromProfile(getCurrentTabModel().getProfile()); + +- if (id == R.id.preferences_id) { ++ if (id == R.id.preferences_id && !ChromeCachedFlags.isAdminActive()) { + SettingsLauncher settingsLauncher = new SettingsLauncherImpl(); + settingsLauncher.launchSettingsActivity(this); + RecordUserAction.record("MobileMenuSettings"); +diff --git a/chrome/android/java/src/org/chromium/chrome/browser/app/appmenu/AppMenuPropertiesDelegateImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/app/appmenu/AppMenuPropertiesDelegateImpl.java +index 326be6126a152..04a23d4632af4 100644 +--- a/chrome/android/java/src/org/chromium/chrome/browser/app/appmenu/AppMenuPropertiesDelegateImpl.java ++++ b/chrome/android/java/src/org/chromium/chrome/browser/app/appmenu/AppMenuPropertiesDelegateImpl.java +@@ -36,6 +36,7 @@ import org.chromium.base.supplier.ObservableSupplier; + import org.chromium.base.supplier.OneshotSupplier; + import org.chromium.base.supplier.Supplier; + import org.chromium.chrome.R; ++import org.chromium.chrome.browser.app.flags.ChromeCachedFlags; + import org.chromium.chrome.browser.ActivityTabProvider; + import org.chromium.chrome.browser.AlwaysIncognitoLinkInterceptor; + import org.chromium.chrome.browser.bookmarks.BookmarkFeatures; +@@ -668,6 +669,10 @@ public class AppMenuPropertiesDelegateImpl implements AppMenuPropertiesDelegate + item.setEnabled(isIncognitoEnabled() && !isIncognitoReauthShowing); + } + ++ if (item.getItemId() == R.id.preferences_id && item.isVisible()) { ++ item.setEnabled(!ChromeCachedFlags.isAdminActive()); ++ } ++ + if (item.getItemId() == R.id.divider_line_id) { + item.setEnabled(false); + } +diff --git a/chrome/android/java/src/org/chromium/chrome/browser/app/flags/ChromeCachedFlags.java b/chrome/android/java/src/org/chromium/chrome/browser/app/flags/ChromeCachedFlags.java +index 51b65247e38a6..e981722ceecfc 100644 +--- a/chrome/android/java/src/org/chromium/chrome/browser/app/flags/ChromeCachedFlags.java ++++ b/chrome/android/java/src/org/chromium/chrome/browser/app/flags/ChromeCachedFlags.java +@@ -43,6 +43,7 @@ import org.chromium.chrome.browser.tasks.tab_management.TabUiFeatureUtilities; + import org.chromium.chrome.browser.toolbar.ToolbarFeatures; + import org.chromium.chrome.features.start_surface.StartSurfaceConfiguration; + ++import java.lang.reflect.Method; + import java.util.ArrayList; + import java.util.List; + +@@ -215,4 +216,32 @@ public class ChromeCachedFlags { + + return cachedFlag.isEnabled(); + } ++ ++ /** ++ * Retrieves the system property value for the given key. ++ * ++ * @param key The name of the system property. ++ * @return The value of the system property or "0" if not found or an error occurs. ++ */ ++ public static String getSystemProperty(String key) { ++ String value = "0"; ++ try { ++ Class systemProperties = Class.forName("android.os.SystemProperties"); ++ Method get = systemProperties.getMethod("get", String.class); ++ value = (String) get.invoke(null, key); ++ } catch (Exception e) { ++ e.printStackTrace(); ++ } ++ return value; ++ } ++ ++ /** ++ * Checks if the system property value for the hardcoded key "persist.sys.mdm_active" is "1". ++ * ++ * @return true if the property value is "1", false otherwise. ++ */ ++ public static boolean isAdminActive() { ++ String propertyValue = getSystemProperty("persist.sys.mdm_active"); ++ return "1".equals(propertyValue); ++ } + } +diff --git a/chrome/android/java/src/org/chromium/chrome/browser/settings/MainSettings.java b/chrome/android/java/src/org/chromium/chrome/browser/settings/MainSettings.java +index a710f667f3868..b5222372f39af 100644 +--- a/chrome/android/java/src/org/chromium/chrome/browser/settings/MainSettings.java ++++ b/chrome/android/java/src/org/chromium/chrome/browser/settings/MainSettings.java +@@ -20,6 +20,7 @@ import org.chromium.base.BuildInfo; + import org.chromium.base.ContextUtils; + import org.chromium.base.supplier.ObservableSupplier; + import org.chromium.chrome.R; ++import org.chromium.chrome.browser.app.flags.ChromeCachedFlags; + import org.chromium.chrome.browser.autofill.options.AutofillOptionsFragment; + import org.chromium.chrome.browser.autofill.options.AutofillOptionsFragment.AutofillOptionsReferrer; + import org.chromium.chrome.browser.autofill.settings.SettingsLauncherHelper; +@@ -138,6 +139,9 @@ public class MainSettings extends ChromeBaseSettingsFragment + + @Override + public void onStart() { ++ if (ChromeCachedFlags.isAdminActive()) { ++ getActivity().finish(); ++ } + super.onStart(); + SigninManager signinManager = IdentityServicesProvider.get().getSigninManager(getProfile()); + if (signinManager.isSigninSupported(/* requireUpdatedPlayServices= */ false)) { +-- +2.43.0 + diff --git a/build/e_patches_list.txt b/build/e_patches_list.txt index 4f50e999..1ee8a890 100644 --- a/build/e_patches_list.txt +++ b/build/e_patches_list.txt @@ -50,3 +50,4 @@ 0050-Update-app-icon.patch 0051-Update-default-sites.patch 0052-fixup-Add-menu-item-to-bookmark-all-tabs.patch +0053-Browser-Hide-settings-when-parental-control-is-activ.patch \ No newline at end of file -- GitLab From e2fd8b8b8a0daf757f43a90c4f27f5985ae5f987 Mon Sep 17 00:00:00 2001 From: althafvly Date: Thu, 11 Jul 2024 11:23:49 +0530 Subject: [PATCH 2/2] Browser: Set chromium version in docker image --- Dockerfile | 3 ++- build.sh | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0b8341aa..169c7bb9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM ubuntu:20.04 ENV CHROMIUM_DIR "/srv/chromium" +ENV CHROMIUM_VER "123.0.6312.122" RUN dpkg --add-architecture i386 @@ -11,7 +12,7 @@ RUN apt-get update &&\ RUN mkdir ${CHROMIUM_DIR} -RUN curl -s https://raw.githubusercontent.com/chromium/chromium/123.0.6312.122/build/install-build-deps.py \ +RUN curl -s https://raw.githubusercontent.com/chromium/chromium/${CHROMIUM_VER}/build/install-build-deps.py \ | python - --android --lib32 --no-chromeos-fonts --no-prompt RUN git config --global user.name "John Doe" diff --git a/build.sh b/build.sh index 4661b835..4515a94b 100755 --- a/build.sh +++ b/build.sh @@ -2,12 +2,12 @@ set -e -chromium_dir="${chromium_dir:-/srv/chromium}" +chromium_dir="${CHROMIUM_DIR}" root_dir=$(dirname "$(readlink -f "$0")") if [ ! -d "$chromium_dir" ]; then chromium_dir=$root_dir fi -chromium_version="123.0.6312.122" +chromium_version=$(grep 'ENV CHROMIUM_VER' Dockerfile | awk -F'"' '{print $2}') chromium_code=$(echo "$chromium_version" | tr -d '.' | cut -c5-) chromium_url=https://github.com/chromium/chromium.git clean=0 -- GitLab