Merge Android 12

Bug: 202323961
Merged-In: Ia961878214b0f572ff197f23ce4d30bffaddee0e
Change-Id: Ia2deab591dbbd1152ec6507b8c8614b4cf124cf7
diff --git a/Binder.cpp b/Binder.cpp
index d86795c..b90639f 100644
--- a/Binder.cpp
+++ b/Binder.cpp
@@ -16,15 +16,21 @@
 
 #include <hwbinder/Binder.h>
 
-#include <atomic>
-#include <utils/misc.h>
+#include <android-base/macros.h>
+#include <cutils/android_filesystem_config.h>
+#include <cutils/multiuser.h>
 #include <hwbinder/BpHwBinder.h>
 #include <hwbinder/IInterface.h>
+#include <hwbinder/IPCThreadState.h>
 #include <hwbinder/Parcel.h>
+#include <utils/Log.h>
+#include <utils/misc.h>
 
 #include <linux/sched.h>
 #include <stdio.h>
 
+#include <atomic>
+
 namespace android {
 namespace hardware {
 
@@ -114,6 +120,15 @@
         reply->markSensitive();
     }
 
+    // extra comment to try to force running all tests
+    if (UNLIKELY(code == HIDL_DEBUG_TRANSACTION)) {
+        uid_t uid = IPCThreadState::self()->getCallingUid();
+        if (multiuser_get_app_id(uid) >= AID_APP_START) {
+            ALOGE("Can not call IBase::debug from apps");
+            return PERMISSION_DENIED;
+        }
+    }
+
     status_t err = NO_ERROR;
     switch (code) {
         default:
diff --git a/Parcel.cpp b/Parcel.cpp
index 6393bed..98300d0 100644
--- a/Parcel.cpp
+++ b/Parcel.cpp
@@ -1786,7 +1786,7 @@
 
     releaseObjects();
 
-    if (data) {
+    if (data || desired == 0) {
         LOG_ALLOC("Parcel %p: restart from %zu to %zu capacity", this, mDataCapacity, desired);
         if (mDataCapacity > desired) {
             gParcelGlobalAllocSize -= (mDataCapacity - desired);
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 2bd0463..dfede5a 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -2,6 +2,14 @@
   "presubmit": [
     {
       "name": "libbinderthreadstateutils_test"
+    },
+    {
+      "name": "SettingsGoogleUnitTests",
+      "options": [
+        {
+          "exclude-annotation": "androidx.test.filters.FlakyTest"
+        }
+      ]
     }
   ]
 }