From ebce4e713496992b0402ea33cd915cc8c1085fe7 Mon Sep 17 00:00:00 2001 From: Andreea Pavel Date: Thu, 4 Apr 2019 04:28:47 +0300 Subject: [PATCH] Backed out changeset 91b055c0dadb (bug 1533385) for breaking gv-junit at org.mozilla.geckoview.test on a CLOSED TREE --- mobile/android/config/proguard/proguard.cfg | 3 - mobile/android/geckoview/api.txt | 2 - mobile/android/geckoview/build.gradle | 1 - .../org/mozilla/gecko/util/DebugConfig.java | 90 ------------------- .../org/mozilla/geckoview/GeckoRuntime.java | 32 +------ .../geckoview/GeckoRuntimeSettings.java | 29 ------ .../mozilla/geckoview/doc-files/CHANGELOG.md | 9 +- 7 files changed, 3 insertions(+), 163 deletions(-) delete mode 100644 mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/DebugConfig.java diff --git a/mobile/android/config/proguard/proguard.cfg b/mobile/android/config/proguard/proguard.cfg index acbda434cb23..175ec85518d9 100644 --- a/mobile/android/config/proguard/proguard.cfg +++ b/mobile/android/config/proguard/proguard.cfg @@ -170,9 +170,6 @@ -dontwarn java.lang.management.** -dontwarn javax.management.** -# Don't warn when classes referenced by, but not used at runtime by, SnakeYAML are missing. --dontwarn java.beans.** - -include "adjust-keeps.cfg" -include "leakcanary-keeps.cfg" diff --git a/mobile/android/geckoview/api.txt b/mobile/android/geckoview/api.txt index b22f456672eb..c3f2d548beac 100644 --- a/mobile/android/geckoview/api.txt +++ b/mobile/android/geckoview/api.txt @@ -211,7 +211,6 @@ package org.mozilla.geckoview { method @android.support.annotation.NonNull public java.lang.String[] getArguments(); method public boolean getAutomaticFontSizeAdjustment(); method public int getAutoplayDefault(); - method @android.support.annotation.Nullable public java.lang.String getConfigFilePath(); method public boolean getConsoleOutputEnabled(); method @android.support.annotation.NonNull public org.mozilla.geckoview.ContentBlocking.Settings getContentBlocking(); method @android.support.annotation.Nullable public java.lang.Class getCrashHandler(); @@ -253,7 +252,6 @@ package org.mozilla.geckoview { method @android.support.annotation.NonNull public org.mozilla.geckoview.GeckoRuntimeSettings.Builder arguments(@android.support.annotation.NonNull java.lang.String[]); method @android.support.annotation.NonNull public org.mozilla.geckoview.GeckoRuntimeSettings.Builder automaticFontSizeAdjustment(boolean); method @android.support.annotation.NonNull public org.mozilla.geckoview.GeckoRuntimeSettings.Builder autoplayDefault(int); - method @android.support.annotation.NonNull public org.mozilla.geckoview.GeckoRuntimeSettings.Builder configFilePath(@android.support.annotation.Nullable java.lang.String); method @android.support.annotation.NonNull public org.mozilla.geckoview.GeckoRuntimeSettings.Builder consoleOutput(boolean); method @android.support.annotation.NonNull public org.mozilla.geckoview.GeckoRuntimeSettings.Builder contentBlocking(@android.support.annotation.NonNull org.mozilla.geckoview.ContentBlocking.Settings); method @android.support.annotation.NonNull public org.mozilla.geckoview.GeckoRuntimeSettings.Builder crashHandler(java.lang.Class); diff --git a/mobile/android/geckoview/build.gradle b/mobile/android/geckoview/build.gradle index 2d2168205b7c..4b2004bb148f 100644 --- a/mobile/android/geckoview/build.gradle +++ b/mobile/android/geckoview/build.gradle @@ -216,7 +216,6 @@ tasks.withType(Javadoc) { dependencies { implementation "com.android.support:support-v4:$support_library_version" implementation "com.android.support:palette-v7:$support_library_version" - implementation "org.yaml:snakeyaml:1.24" testImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" testImplementation 'junit:junit:4.12' diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/DebugConfig.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/DebugConfig.java deleted file mode 100644 index e670956d6239..000000000000 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/DebugConfig.java +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.gecko.util; - -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.util.Log; - -import org.mozilla.gecko.GeckoThread; -import org.yaml.snakeyaml.TypeDescription; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.Constructor; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class DebugConfig { - private static final String LOGTAG = "GeckoDebugConfig"; - - protected Map prefs; - protected Map env; - protected List args; - - public static @NonNull DebugConfig fromFile(final @NonNull File configFile) throws FileNotFoundException { - final Constructor constructor = new Constructor(DebugConfig.class); - final TypeDescription description = new TypeDescription(DebugConfig.class); - description.putMapPropertyType("prefs", String.class, Object.class); - description.putMapPropertyType("env", String.class, String.class); - description.putListPropertyType("args", String.class); - - final Yaml yaml = new Yaml(constructor); - yaml.addTypeDescription(description); - - final FileInputStream fileInputStream = new FileInputStream(configFile); - try { - return yaml.load(fileInputStream); - } finally { - IOUtils.safeStreamClose(fileInputStream); - } - } - - public void mergeIntoInitInfo(final @NonNull GeckoThread.InitInfo info) { - if (env != null) { - Log.d(LOGTAG, "Adding environment variables from debug config: " + env); - - if (info.extras == null) { - info.extras = new Bundle(); - } - - int c = 0; - while (info.extras.getString("env" + c) != null) { - c += 1; - } - - for (final Map.Entry entry : env.entrySet()) { - info.extras.putString("env" + c, entry.getKey() + "=" + entry.getValue()); - c += 1; - } - } - - if (args != null) { - Log.d(LOGTAG, "Adding arguments from debug config: " + args); - - final ArrayList combinedArgs = new ArrayList<>(); - combinedArgs.addAll(Arrays.asList(info.args)); - combinedArgs.addAll(args); - - info.args = combinedArgs.toArray(new String[combinedArgs.size()]); - } - - if (prefs != null) { - Log.d(LOGTAG, "Adding prefs from debug config: " + prefs); - - final Map combinedPrefs = new HashMap<>(); - combinedPrefs.putAll(info.prefs); - combinedPrefs.putAll(prefs); - info.prefs = Collections.unmodifiableMap(prefs); - } - } -} diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java index 0a278c8b8a49..130cc19d5f6b 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntime.java @@ -8,15 +8,14 @@ package org.mozilla.geckoview; import android.app.ActivityManager; import android.content.ComponentName; -import android.content.Context; import android.content.Intent; -import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ServiceInfo; import android.content.res.Configuration; import android.os.Build; import android.os.Parcel; import android.os.Parcelable; +import android.content.Context; import android.os.Process; import android.support.annotation.AnyThread; import android.support.annotation.NonNull; @@ -26,26 +25,21 @@ import android.util.Log; import org.mozilla.gecko.EventDispatcher; import org.mozilla.gecko.GeckoAppShell; -import org.mozilla.gecko.GeckoScreenOrientation; import org.mozilla.gecko.GeckoSystemStateListener; +import org.mozilla.gecko.GeckoScreenOrientation; import org.mozilla.gecko.GeckoThread; import org.mozilla.gecko.PrefsHelper; import org.mozilla.gecko.util.BundleEventListener; -import org.mozilla.gecko.util.DebugConfig; import org.mozilla.gecko.util.EventCallback; import org.mozilla.gecko.util.GeckoBundle; import org.mozilla.gecko.util.ThreadUtils; -import org.yaml.snakeyaml.error.YAMLException; import java.io.File; -import java.io.FileNotFoundException; public final class GeckoRuntime implements Parcelable { private static final String LOGTAG = "GeckoRuntime"; private static final boolean DEBUG = false; - private static final String CONFIG_FILE_PATH_TEMPLATE = "/data/local/tmp/%s-geckoview-config.yaml"; - /** * Intent action sent to the crash handler when a crash is encountered. * @see GeckoRuntimeSettings.Builder#crashHandler(Class) @@ -221,28 +215,6 @@ public final class GeckoRuntime implements Parcelable { info.flags = flags; info.prefs = settings.getPrefsMap(); - String configFilePath = settings.getConfigFilePath(); - if (configFilePath == null) { - // Default to /data/local/tmp/$PACKAGE-geckoview-config.yaml if android:debuggable="true" - // and to not read configuration from a file if android:debuggable="false". - final ApplicationInfo applicationInfo = context.getApplicationInfo(); - final boolean isPackageDebuggable = (applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; - if (isPackageDebuggable) { - configFilePath = String.format(CONFIG_FILE_PATH_TEMPLATE, applicationInfo.packageName); - } - } - - if (configFilePath != null && !configFilePath.isEmpty()) { - try { - final DebugConfig debugConfig = DebugConfig.fromFile(new File(configFilePath)); - Log.i(LOGTAG, "Adding debug configuration from: " + configFilePath); - debugConfig.mergeIntoInitInfo(info); - } catch (YAMLException e) { - Log.w(LOGTAG, "Failed to add debug configuration from: " + configFilePath, e); - } catch (FileNotFoundException e) { - } - } - if (!GeckoThread.init(info)) { Log.w(LOGTAG, "init failed (could not initiate GeckoThread)"); return false; diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java index 2a978bc5e17e..330f20dc8040 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java @@ -77,19 +77,6 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { return this; } - /** - * Path to configuration file from which GeckoView will read configuration options such as - * Gecko process arguments, environment variables, and preferences. - * - * @param configFilePath Configuration file path to read from, or null to use - * default location /data/local/tmp/$PACKAGE-geckoview-config.yaml. - * @return This Builder instance. - */ - public @NonNull Builder configFilePath(final @Nullable String configFilePath) { - getSettings().mConfigFilePath = configFilePath; - return this; - } - /** * Set whether JavaScript support should be enabled. * @@ -343,7 +330,6 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { /* package */ boolean mUseContentProcess; /* package */ String[] mArgs; /* package */ Bundle mExtras; - /* package */ String mConfigFilePath; /* package */ ContentBlocking.Settings mContentBlocking; @@ -426,7 +412,6 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { mScreenHeightOverride = settings.mScreenHeightOverride; mCrashHandler = settings.mCrashHandler; mRequestedLocales = settings.mRequestedLocales; - mConfigFilePath = settings.mConfigFilePath; } /* package */ void commit() { @@ -461,18 +446,6 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { return mExtras; } - /** - * Path to configuration file from which GeckoView will read configuration options such as - * Gecko process arguments, environment variables, and preferences. - * - * @return Path to configuration file from which GeckoView will read configuration options, - * or null for default location - * /data/local/tmp/$PACKAGE-geckoview-config.yaml. - */ - public @Nullable String getConfigFilePath() { - return mConfigFilePath; - } - /** * Get whether JavaScript support is enabled. * @@ -849,7 +822,6 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { out.writeInt(mScreenHeightOverride); out.writeString(mCrashHandler != null ? mCrashHandler.getName() : null); out.writeStringArray(mRequestedLocales); - out.writeString(mConfigFilePath); } // AIDL code may call readFromParcel even though it's not part of Parcelable. @@ -879,7 +851,6 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { } mRequestedLocales = source.createStringArray(); - mConfigFilePath = source.readString(); } public static final Parcelable.Creator CREATOR diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md index c5b5cecd01d0..dee479e6273a 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md @@ -42,13 +42,6 @@ exclude: true [68.9]: ../GeckoRuntimeSettings.html#setPreferredColorScheme-int- -- Added [`GeckoRuntimeSettings.Builder#configFilePath`][68.10] to set - a path to a configuration file from which GeckoView will read - configuration options such as Gecko process arguments, environment - variables, and preferences. - -[68.10]: ../GeckoRuntimeSettings.Builder.html#configFilePath-java.lang.String- - ## v67 - Added [`setAutomaticFontSizeAdjustment`][67.2] to [`GeckoRuntimeSettings`][67.3] for automatically adjusting font size settings @@ -255,4 +248,4 @@ exclude: true [65.24]: ../CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String- [65.25]: ../GeckoResult.html -[api-version]: affe9cc5dc22f0700867a1ac7f9b55a033a4b88c +[api-version]: 053d9b4164690ff13996be9e7288dd183e2a1db4