Merge "system/core: remove methods returning SharedBuffer in String8, String16"
diff --git a/adb/adb.cpp b/adb/adb.cpp
index e973603..0e1859c 100644
--- a/adb/adb.cpp
+++ b/adb/adb.cpp
@@ -239,6 +239,10 @@
     // "device::ro.product.name=x;ro.product.model=y;ro.product.device=z;".
     std::vector<std::string> pieces = android::base::Split(banner, ":");
 
+    // Reset the features list or else if the server sends no features we may
+    // keep the existing feature set (http://b/24405971).
+    t->SetFeatures("");
+
     if (pieces.size() > 2) {
         const std::string& props = pieces[2];
         for (auto& prop : android::base::Split(props, ";")) {
diff --git a/adb/adb.h b/adb/adb.h
index 037c010..a20b345 100644
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -50,7 +50,7 @@
 std::string adb_version();
 
 // Increment this when we want to force users to start a new adb server.
-#define ADB_SERVER_VERSION 32
+#define ADB_SERVER_VERSION 33
 
 class atransport;
 struct usb_handle;
diff --git a/adb/transport.cpp b/adb/transport.cpp
index ffbb107..2a2fac7 100644
--- a/adb/transport.cpp
+++ b/adb/transport.cpp
@@ -786,6 +786,9 @@
     // Local static allocation to avoid global non-POD variables.
     static const FeatureSet* features = new FeatureSet{
         kFeatureShell2
+        // Increment ADB_SERVER_VERSION whenever the feature list changes to
+        // make sure that the adb client and server features stay in sync
+        // (http://b/24370690).
     };
 
     return *features;
@@ -796,6 +799,10 @@
 }
 
 FeatureSet StringToFeatureSet(const std::string& features_string) {
+    if (features_string.empty()) {
+        return FeatureSet();
+    }
+
     auto names = android::base::Split(features_string,
                                       {kFeatureStringDelimiter});
     return FeatureSet(names.begin(), names.end());
diff --git a/adb/transport_test.cpp b/adb/transport_test.cpp
index 7d69c3e..97fc069 100644
--- a/adb/transport_test.cpp
+++ b/adb/transport_test.cpp
@@ -167,6 +167,9 @@
     ASSERT_FALSE(t.has_feature("foo"));
     ASSERT_TRUE(t.has_feature("bar"));
     ASSERT_TRUE(t.has_feature("baz"));
+
+    t.SetFeatures("");
+    ASSERT_EQ(0U, t.features().size());
 }
 
 TEST(transport, parse_banner_no_features) {
diff --git a/crash_reporter/Android.mk b/crash_reporter/Android.mk
index 6cd34ab..e797022 100644
--- a/crash_reporter/Android.mk
+++ b/crash_reporter/Android.mk
@@ -14,8 +14,6 @@
 
 LOCAL_PATH := $(call my-dir)
 
-ifeq ($(HOST_OS),linux)
-
 crash_reporter_cpp_extension := .cc
 
 crash_reporter_src := crash_collector.cc \
@@ -62,8 +60,8 @@
 LOCAL_REQUIRED_MODULES := core2md \
     crash_reporter_logs.conf \
     crash_sender \
-    dbus-send \
-    init.crash_reporter.rc
+    dbus-send
+LOCAL_INIT_RC := crash_reporter.rc
 LOCAL_RTTI_FLAG := -frtti
 LOCAL_SHARED_LIBRARIES := libchrome \
     libchromeos \
@@ -94,17 +92,6 @@
 LOCAL_SRC_FILES := $(warn_collector_src)
 include $(BUILD_EXECUTABLE)
 
-# Crash reporter init script.
-# ========================================================
-ifdef TARGET_COPY_OUT_INITRCD
-include $(CLEAR_VARS)
-LOCAL_MODULE := init.crash_reporter.rc
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_PATH := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_INITRCD)
-LOCAL_SRC_FILES := init.crash_reporter.rc
-include $(BUILD_PREBUILT)
-endif
-
 # Crash reporter logs conf file.
 # ========================================================
 include $(CLEAR_VARS)
@@ -135,5 +122,3 @@
 LOCAL_SRC_FILES := $(crash_reporter_test_src)
 LOCAL_STATIC_LIBRARIES := libcrash libgmock
 include $(BUILD_NATIVE_TEST)
-
-endif # HOST_OS == linux
diff --git a/crash_reporter/init.crash_reporter.rc b/crash_reporter/crash_reporter.rc
similarity index 100%
rename from crash_reporter/init.crash_reporter.rc
rename to crash_reporter/crash_reporter.rc
diff --git a/crash_reporter/crash_sender b/crash_reporter/crash_sender
index 29a1229..8a422dd 100755
--- a/crash_reporter/crash_sender
+++ b/crash_reporter/crash_sender
@@ -128,7 +128,11 @@
 
 is_official_image() {
   [ ${FORCE_OFFICIAL} -ne 0 ] && return 0
-  getprop ro.product.description | grep -q Official
+  if [ "$(getprop ro.secure)" = "1" ]; then
+    return 0
+  else
+    return 1
+  fi
 }
 
 # Returns 0 if the a crash test is currently running.  NOTE: Mirrors
@@ -165,7 +169,7 @@
   # If we're testing crash reporter itself, we don't want to special-case
   # for developer mode.
   is_crash_test_in_progress && return 1
-  if [ "$(getprop ro.build.type)" = "eng" ]; then
+  if [ "$(getprop ro.debuggable)" = "1" ]; then
     return 0
   else
     return 1
diff --git a/include/utils/Compat.h b/include/utils/Compat.h
index c5f9d6a..b2ba55e 100644
--- a/include/utils/Compat.h
+++ b/include/utils/Compat.h
@@ -33,6 +33,10 @@
     return pread(fd, buf, nbytes, offset);
 }
 
+static inline ssize_t pwrite64(int fd, const void* buf, size_t nbytes, off64_t offset) {
+    return pwrite(fd, buf, nbytes, offset);
+}
+
 #endif /* __APPLE__ */
 
 #if defined(_WIN32)
diff --git a/include/utils/LruCache.h b/include/utils/LruCache.h
index cd9d7f9..7818b4e 100644
--- a/include/utils/LruCache.h
+++ b/include/utils/LruCache.h
@@ -17,8 +17,11 @@
 #ifndef ANDROID_UTILS_LRU_CACHE_H
 #define ANDROID_UTILS_LRU_CACHE_H
 
+#include <unordered_set>
+
 #include <UniquePtr.h>
-#include <utils/BasicHashtable.h>
+
+#include "utils/TypeHelpers.h"  // hash_t
 
 namespace android {
 
@@ -36,6 +39,7 @@
 class LruCache {
 public:
     explicit LruCache(uint32_t maxCapacity);
+    virtual ~LruCache();
 
     enum Capacity {
         kUnlimitedCapacity,
@@ -50,32 +54,6 @@
     void clear();
     const TValue& peekOldestValue();
 
-    class Iterator {
-    public:
-        Iterator(const LruCache<TKey, TValue>& cache): mCache(cache), mIndex(-1) {
-        }
-
-        bool next() {
-            mIndex = mCache.mTable->next(mIndex);
-            return (ssize_t)mIndex != -1;
-        }
-
-        size_t index() const {
-            return mIndex;
-        }
-
-        const TValue& value() const {
-            return mCache.mTable->entryAt(mIndex).value;
-        }
-
-        const TKey& key() const {
-            return mCache.mTable->entryAt(mIndex).key;
-        }
-    private:
-        const LruCache<TKey, TValue>& mCache;
-        size_t mIndex;
-    };
-
 private:
     LruCache(const LruCache& that);  // disallow copy constructor
 
@@ -90,27 +68,79 @@
         const TKey& getKey() const { return key; }
     };
 
+    struct HashForEntry : public std::unary_function<Entry*, hash_t> {
+        size_t operator() (const Entry* entry) const {
+            return hash_type(entry->key);
+        };
+    };
+
+    struct EqualityForHashedEntries : public std::unary_function<Entry*, hash_t> {
+        bool operator() (const Entry* lhs, const Entry* rhs) const {
+            return lhs->key == rhs->key;
+        };
+    };
+
+    typedef std::unordered_set<Entry*, HashForEntry, EqualityForHashedEntries> LruCacheSet;
+
     void attachToCache(Entry& entry);
     void detachFromCache(Entry& entry);
-    void rehash(size_t newCapacity);
 
-    UniquePtr<BasicHashtable<TKey, Entry> > mTable;
+    typename LruCacheSet::iterator findByKey(const TKey& key) {
+        Entry entryForSearch(key, mNullValue);
+        typename LruCacheSet::iterator result = mSet->find(&entryForSearch);
+        return result;
+    }
+
+    UniquePtr<LruCacheSet> mSet;
     OnEntryRemoved<TKey, TValue>* mListener;
     Entry* mOldest;
     Entry* mYoungest;
     uint32_t mMaxCapacity;
     TValue mNullValue;
+
+public:
+    class Iterator {
+    public:
+        Iterator(const LruCache<TKey, TValue>& cache): mCache(cache), mIterator(mCache.mSet->begin()) {
+        }
+
+        bool next() {
+            if (mIterator == mCache.mSet->end()) {
+                return false;
+            }
+            std::advance(mIterator, 1);
+            return mIterator != mCache.mSet->end();
+        }
+
+        const TValue& value() const {
+            return (*mIterator)->value;
+        }
+
+        const TKey& key() const {
+            return (*mIterator)->key;
+        }
+    private:
+        const LruCache<TKey, TValue>& mCache;
+        typename LruCacheSet::iterator mIterator;
+    };
 };
 
 // Implementation is here, because it's fully templated
 template <typename TKey, typename TValue>
 LruCache<TKey, TValue>::LruCache(uint32_t maxCapacity)
-    : mTable(new BasicHashtable<TKey, Entry>)
+    : mSet(new LruCacheSet())
     , mListener(NULL)
     , mOldest(NULL)
     , mYoungest(NULL)
     , mMaxCapacity(maxCapacity)
     , mNullValue(NULL) {
+    mSet->max_load_factor(1.0);
+};
+
+template <typename TKey, typename TValue>
+LruCache<TKey, TValue>::~LruCache() {
+    // Need to delete created entries.
+    clear();
 };
 
 template<typename K, typename V>
@@ -120,20 +150,19 @@
 
 template <typename TKey, typename TValue>
 size_t LruCache<TKey, TValue>::size() const {
-    return mTable->size();
+    return mSet->size();
 }
 
 template <typename TKey, typename TValue>
 const TValue& LruCache<TKey, TValue>::get(const TKey& key) {
-    hash_t hash = hash_type(key);
-    ssize_t index = mTable->find(-1, hash, key);
-    if (index == -1) {
+    typename LruCacheSet::const_iterator find_result = findByKey(key);
+    if (find_result == mSet->end()) {
         return mNullValue;
     }
-    Entry& entry = mTable->editEntryAt(index);
-    detachFromCache(entry);
-    attachToCache(entry);
-    return entry.value;
+    Entry *entry = *find_result;
+    detachFromCache(*entry);
+    attachToCache(*entry);
+    return entry->value;
 }
 
 template <typename TKey, typename TValue>
@@ -142,36 +171,29 @@
         removeOldest();
     }
 
-    hash_t hash = hash_type(key);
-    ssize_t index = mTable->find(-1, hash, key);
-    if (index >= 0) {
+    if (findByKey(key) != mSet->end()) {
         return false;
     }
-    if (!mTable->hasMoreRoom()) {
-        rehash(mTable->capacity() * 2);
-    }
 
-    // Would it be better to initialize a blank entry and assign key, value?
-    Entry initEntry(key, value);
-    index = mTable->add(hash, initEntry);
-    Entry& entry = mTable->editEntryAt(index);
-    attachToCache(entry);
+    Entry* newEntry = new Entry(key, value);
+    mSet->insert(newEntry);
+    attachToCache(*newEntry);
     return true;
 }
 
 template <typename TKey, typename TValue>
 bool LruCache<TKey, TValue>::remove(const TKey& key) {
-    hash_t hash = hash_type(key);
-    ssize_t index = mTable->find(-1, hash, key);
-    if (index < 0) {
+    typename LruCacheSet::const_iterator find_result = findByKey(key);
+    if (find_result == mSet->end()) {
         return false;
     }
-    Entry& entry = mTable->editEntryAt(index);
+    Entry* entry = *find_result;
     if (mListener) {
-        (*mListener)(entry.key, entry.value);
+        (*mListener)(entry->key, entry->value);
     }
-    detachFromCache(entry);
-    mTable->removeAt(index);
+    detachFromCache(*entry);
+    mSet->erase(entry);
+    delete entry;
     return true;
 }
 
@@ -201,7 +223,10 @@
     }
     mYoungest = NULL;
     mOldest = NULL;
-    mTable->clear();
+    for (auto entry : *mSet.get()) {
+        delete entry;
+    }
+    mSet->clear();
 }
 
 template <typename TKey, typename TValue>
@@ -232,19 +257,5 @@
     entry.child = NULL;
 }
 
-template <typename TKey, typename TValue>
-void LruCache<TKey, TValue>::rehash(size_t newCapacity) {
-    UniquePtr<BasicHashtable<TKey, Entry> > oldTable(mTable.release());
-    Entry* oldest = mOldest;
-
-    mOldest = NULL;
-    mYoungest = NULL;
-    mTable.reset(new BasicHashtable<TKey, Entry>(newCapacity));
-    for (Entry* p = oldest; p != NULL; p = p->child) {
-        put(p->key, p->value);
-    }
 }
-
-}
-
 #endif // ANDROID_UTILS_LRU_CACHE_H
diff --git a/liblog/Android.bp b/liblog/Android.bp
index ee394fd..34e7f92 100644
--- a/liblog/Android.bp
+++ b/liblog/Android.bp
@@ -47,7 +47,7 @@
             sanitize: ["never"],
         },
         android_arm: {
-            // TODO: This is to work around b/19059885. Remove after root cause is fixed
+            // TODO: This is to work around b/24465209. Remove after root cause is fixed
             ldflags: ["-Wl,--hash-style=both"],
         },
         windows: {
diff --git a/liblog/Android.mk b/liblog/Android.mk
index 271c6f9..a183db8 100644
--- a/liblog/Android.mk
+++ b/liblog/Android.mk
@@ -69,7 +69,7 @@
 LOCAL_WHOLE_STATIC_LIBRARIES := liblog
 LOCAL_CFLAGS := -Werror $(liblog_cflags)
 
-# TODO: This is to work around b/19059885. Remove after root cause is fixed
+# TODO: This is to work around b/24465209. Remove after root cause is fixed
 LOCAL_LDFLAGS_arm := -Wl,--hash-style=both
 
 LOCAL_SANITIZE := never
diff --git a/libutils/tests/LruCache_test.cpp b/libutils/tests/LruCache_test.cpp
index 6155def..2ed84d7 100644
--- a/libutils/tests/LruCache_test.cpp
+++ b/libutils/tests/LruCache_test.cpp
@@ -221,7 +221,7 @@
     cache.put(ComplexKey(0), ComplexValue(0));
     cache.put(ComplexKey(1), ComplexValue(1));
     EXPECT_EQ(2U, cache.size());
-    assertInstanceCount(2, 3);  // the null value counts as an instance
+    assertInstanceCount(2, 3);  // the member mNullValue counts as an instance
 }
 
 TEST_F(LruCacheTest, Clear) {
diff --git a/logd/LogKlog.cpp b/logd/LogKlog.cpp
index febf775..c6109f5 100644
--- a/logd/LogKlog.cpp
+++ b/logd/LogKlog.cpp
@@ -388,6 +388,16 @@
     return ANDROID_LOG_INFO;
 }
 
+static const char *strnrchr(const char *s, size_t len, char c) {
+  const char *save = NULL;
+  for (;len; ++s, len--) {
+    if (*s == c) {
+      save = s;
+    }
+  }
+  return save;
+}
+
 //
 // log a message into the kernel log buffer
 //
@@ -584,11 +594,11 @@
     //   eg: [143:healthd]healthd -> [143:healthd]
     size_t taglen = etag - tag;
     // Mediatek-special printk induced stutter
-    char *np = strrchr(tag, ']');
-    if (np && (++np < etag)) {
-        size_t s = etag - np;
-        if (((s + s) < taglen) && !strncmp(np, np - 1 - s, s)) {
-            taglen = np - tag;
+    const char *mp = strnrchr(tag, ']', taglen);
+    if (mp && (++mp < etag)) {
+        size_t s = etag - mp;
+        if (((s + s) < taglen) && !memcmp(mp, mp - 1 - s, s)) {
+            taglen = mp - tag;
         }
     }
     // skip leading space
@@ -606,15 +616,19 @@
         b = 1;
     }
     size_t n = 1 + taglen + 1 + b + 1;
+    int rc = n;
+    if ((taglen > n) || (b > n)) { // Can not happen ...
+        rc = -EINVAL;
+        return rc;
+    }
 
     // Allocate a buffer to hold the interpreted log message
-    int rc = n;
     char *newstr = reinterpret_cast<char *>(malloc(n));
     if (!newstr) {
         rc = -ENOMEM;
         return rc;
     }
-    np = newstr;
+    char *np = newstr;
 
     // Convert priority into single-byte Android logger priority
     *np = convertKernelPrioToAndroidPrio(pri);
diff --git a/logd/main.cpp b/logd/main.cpp
index 9b88983..f90da37 100644
--- a/logd/main.cpp
+++ b/logd/main.cpp
@@ -422,7 +422,7 @@
 
     LogListener *swl = new LogListener(logBuf, reader);
     // Backlog and /proc/sys/net/unix/max_dgram_qlen set to large value
-    if (swl->startListener(300)) {
+    if (swl->startListener(600)) {
         exit(1);
     }
 
diff --git a/metricsd/Android.mk b/metricsd/Android.mk
index c35f4e8..03b5739 100644
--- a/metricsd/Android.mk
+++ b/metricsd/Android.mk
@@ -14,10 +14,6 @@
 
 LOCAL_PATH := $(call my-dir)
 
-ifeq ($(HOST_OS),linux)
-
-LOCAL_INIT_SERVICE := metrics_daemon
-
 metrics_cpp_extension := .cc
 libmetrics_sources := \
   c_metrics_library.cc \
@@ -124,13 +120,13 @@
 # metrics daemon.
 # ========================================================
 include $(CLEAR_VARS)
-LOCAL_MODULE := $(LOCAL_INIT_SERVICE)
+LOCAL_MODULE := metrics_daemon
 LOCAL_C_INCLUDES := $(metrics_includes) \
   external/libchromeos
 LOCAL_CFLAGS := $(metrics_CFLAGS)
 LOCAL_CPP_EXTENSION := $(metrics_cpp_extension)
 LOCAL_CPPFLAGS := $(metrics_CPPFLAGS)
-LOCAL_REQUIRED_MODULES := init.$(LOCAL_INIT_SERVICE).rc
+LOCAL_INIT_RC := metrics_daemon.rc
 LOCAL_RTTI_FLAG := -frtti
 LOCAL_SHARED_LIBRARIES := $(metrics_shared_libraries) \
   libmetrics \
@@ -146,15 +142,6 @@
 LOCAL_STATIC_LIBRARIES := metrics_daemon_protos
 include $(BUILD_EXECUTABLE)
 
-ifdef INITRC_TEMPLATE
-include $(CLEAR_VARS)
-LOCAL_MODULE := init.$(LOCAL_INIT_SERVICE).rc
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_PATH := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_INITRCD)
-LOCAL_SRC_FILES := init.$(LOCAL_INIT_SERVICE).rc
-include $(BUILD_PREBUILT)
-endif # INITRC_TEMPLATE
-
 # Unit tests for metrics.
 # ========================================================
 include $(CLEAR_VARS)
@@ -175,5 +162,3 @@
 LOCAL_STATIC_LIBRARIES := libBionicGtestMain libgmock metrics_daemon_protos
 
 include $(BUILD_NATIVE_TEST)
-
-endif # HOST_OS == linux
diff --git a/metricsd/include/metrics/metrics_library.h b/metricsd/include/metrics/metrics_library.h
index 26df2f4..5556e57 100644
--- a/metricsd/include/metrics/metrics_library.h
+++ b/metricsd/include/metrics/metrics_library.h
@@ -142,10 +142,10 @@
                        bool* result);
 
   // Time at which we last checked if metrics were enabled.
-  static time_t cached_enabled_time_;
+  time_t cached_enabled_time_;
 
   // Cached state of whether or not metrics were enabled.
-  static bool cached_enabled_;
+  bool cached_enabled_;
 
   base::FilePath uma_events_file_;
   base::FilePath consent_file_;
diff --git a/metricsd/metrics_daemon.cc b/metricsd/metrics_daemon.cc
index b63be46..3b81cf8 100644
--- a/metricsd/metrics_daemon.cc
+++ b/metricsd/metrics_daemon.cc
@@ -239,7 +239,7 @@
   ticks_per_second_ = sysconf(_SC_CLK_TCK);
 
   daily_active_use_.reset(
-      new PersistentInteger("Platform.DailyUseTime"));
+      new PersistentInteger("Platform.UseTime.PerDay"));
   version_cumulative_active_use_.reset(
       new PersistentInteger("Platform.CumulativeUseTime"));
   version_cumulative_cpu_use_.reset(
@@ -253,23 +253,23 @@
       new PersistentInteger("Platform.UserCrashInterval"));
 
   any_crashes_daily_count_.reset(
-      new PersistentInteger("Platform.AnyCrashesDaily"));
+      new PersistentInteger("Platform.AnyCrashes.PerDay"));
   any_crashes_weekly_count_.reset(
-      new PersistentInteger("Platform.AnyCrashesWeekly"));
+      new PersistentInteger("Platform.AnyCrashes.PerWeek"));
   user_crashes_daily_count_.reset(
-      new PersistentInteger("Platform.UserCrashesDaily"));
+      new PersistentInteger("Platform.UserCrashes.PerDay"));
   user_crashes_weekly_count_.reset(
-      new PersistentInteger("Platform.UserCrashesWeekly"));
+      new PersistentInteger("Platform.UserCrashes.PerWeek"));
   kernel_crashes_daily_count_.reset(
-      new PersistentInteger("Platform.KernelCrashesDaily"));
+      new PersistentInteger("Platform.KernelCrashes.PerDay"));
   kernel_crashes_weekly_count_.reset(
-      new PersistentInteger("Platform.KernelCrashesWeekly"));
+      new PersistentInteger("Platform.KernelCrashes.PerWeek"));
   kernel_crashes_version_count_.reset(
       new PersistentInteger("Platform.KernelCrashesSinceUpdate"));
   unclean_shutdowns_daily_count_.reset(
-      new PersistentInteger("Platform.UncleanShutdownsDaily"));
+      new PersistentInteger("Platform.UncleanShutdown.PerDay"));
   unclean_shutdowns_weekly_count_.reset(
-      new PersistentInteger("Platform.UncleanShutdownsWeekly"));
+      new PersistentInteger("Platform.UncleanShutdowns.PerWeek"));
 
   daily_cycle_.reset(new PersistentInteger("daily.cycle"));
   weekly_cycle_.reset(new PersistentInteger("weekly.cycle"));
diff --git a/metricsd/init.metrics_daemon.rc b/metricsd/metrics_daemon.rc
similarity index 100%
rename from metricsd/init.metrics_daemon.rc
rename to metricsd/metrics_daemon.rc
diff --git a/metricsd/metrics_library.cc b/metricsd/metrics_library.cc
index 6449a24..3109704 100644
--- a/metricsd/metrics_library.cc
+++ b/metricsd/metrics_library.cc
@@ -53,9 +53,6 @@
   "TPM.EarlyResetDuringCommand",  // 12
 };
 
-time_t MetricsLibrary::cached_enabled_time_ = 0;
-bool MetricsLibrary::cached_enabled_ = false;
-
 MetricsLibrary::MetricsLibrary() {}
 MetricsLibrary::~MetricsLibrary() {}
 
@@ -140,11 +137,15 @@
   base::FilePath dir = base::FilePath(metrics::kMetricsDirectory);
   uma_events_file_ = dir.Append(metrics::kMetricsEventsFileName);
   consent_file_ = dir.Append(metrics::kConsentFileName);
+  cached_enabled_ = false;
+  cached_enabled_time_ = 0;
 }
 
 void MetricsLibrary::InitForTest(const base::FilePath& metrics_directory) {
   uma_events_file_ = metrics_directory.Append(metrics::kMetricsEventsFileName);
   consent_file_ = metrics_directory.Append(metrics::kConsentFileName);
+  cached_enabled_ = false;
+  cached_enabled_time_ = 0;
 }
 
 bool MetricsLibrary::SendToUMA(const std::string& name,
diff --git a/metricsd/uploader/upload_service_test.cc b/metricsd/uploader/upload_service_test.cc
index 0dd7db6..305fd0c 100644
--- a/metricsd/uploader/upload_service_test.cc
+++ b/metricsd/uploader/upload_service_test.cc
@@ -42,6 +42,8 @@
     chromeos_metrics::PersistentInteger::SetMetricsDirectory(
         dir_.path().value());
     metrics_lib_.InitForTest(dir_.path());
+    ASSERT_EQ(0, base::WriteFile(
+        dir_.path().Append(metrics::kConsentFileName), "", 0));
     upload_service_.reset(new UploadService(new MockSystemProfileSetter(),
                                             &metrics_lib_, "", true));
 
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 5f1169d..dc85d98 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -86,7 +86,7 @@
     write /proc/sys/kernel/kptr_restrict 2
     write /proc/sys/vm/mmap_min_addr 32768
     write /proc/sys/net/ipv4/ping_group_range "0 2147483647"
-    write /proc/sys/net/unix/max_dgram_qlen 300
+    write /proc/sys/net/unix/max_dgram_qlen 600
     write /proc/sys/kernel/sched_rt_runtime_us 950000
     write /proc/sys/kernel/sched_rt_period_us 1000000