Merge cherrypicks of [7316389, 7315812, 7315813, 7316457, 7316055, 7315736, 7316390, 7316458, 7316459, 7316460, 7316561, 7316562, 7316563, 7316564, 7316565, 7316566, 7316567, 7316391, 7315814, 7316548] into pi-qpr3-b-release

Change-Id: Iaeeba5247525b45f8eafa378de4cb83f147454df
diff --git a/keystore/Android.bp b/keystore/Android.bp
index 8d095e1..9ce00c2 100644
--- a/keystore/Android.bp
+++ b/keystore/Android.bp
@@ -76,13 +76,6 @@
         pdk: {
             enabled: false,
         },
-        debuggable: {
-            cflags: [
-                // Allow VTS tests running as root to have
-                // additional permissions.
-                "-DGRANT_ROOT_ALL_PERMISSIONS",
-            ],
-        },
     },
 
     required: ["keystore_cli_v2"],
diff --git a/keystore/keystore_client_impl.cpp b/keystore/keystore_client_impl.cpp
index 994e3f2..6d998ad 100644
--- a/keystore/keystore_client_impl.cpp
+++ b/keystore/keystore_client_impl.cpp
@@ -366,7 +366,7 @@
     int32_t result;
     auto binder_result = keystore_->exist(key_name16, kDefaultUID, &result);
     if (!binder_result.isOk()) return false;  // binder error
-    return result == static_cast<int32_t>(ResponseCode::NO_ERROR);
+    return result;
 }
 
 bool KeystoreClientImpl::listKeys(const std::string& prefix,
diff --git a/keystore/permissions.cpp b/keystore/permissions.cpp
index b297c59..1ba91d9 100644
--- a/keystore/permissions.cpp
+++ b/keystore/permissions.cpp
@@ -68,14 +68,7 @@
     {AID_SYSTEM, static_cast<perm_t>((uint32_t)(~0))},
     {AID_VPN, static_cast<perm_t>(P_GET | P_SIGN | P_VERIFY)},
     {AID_WIFI, static_cast<perm_t>(P_GET | P_SIGN | P_VERIFY)},
-    {AID_BLUETOOTH, static_cast<perm_t>(P_GET | P_INSERT | P_DELETE | P_EXIST | P_SIGN | P_VERIFY)},
-
-#ifdef GRANT_ROOT_ALL_PERMISSIONS
-    // Allow VTS tests running as root to perform all operations
-    {AID_ROOT, static_cast<perm_t>((uint32_t)(~0))},
-#else
     {AID_ROOT, static_cast<perm_t>(P_GET)},
-#endif
 };
 
 static const perm_t DEFAULT_PERMS = static_cast<perm_t>(