UPSTREAM: shared/gatt-client: Fix not detecting BT_ATT_SECURITY_AUTO

Using bt_gatt_security cannot detect if BT_ATT_SECURITY_AUTO is enabled
since it actually checks the current level when operating over L2CAP, so
instead use io_sec_level internal field to detect the security level in
which ATT is supposed to be operating.

BUG=chromium:483275,chromium:478308
TEST=Use a BLE keyboard to pair with a chromebook.
The BLE keyboard should be ready to use after successful pairing.

(cherry picked from commit 064f48ad6dd0eb4becb94f5492b6c78218065f19)
Signed-off-by: Joseph Hwang <josephsih@chromium.org>

Change-Id: I406da7440736ada8e4aa22ec4e4635d3b44eee8b
Reviewed-on: https://chromium-review.googlesource.com/331452
Commit-Ready: Shyh-In Hwang <josephsih@chromium.org>
Tested-by: Shyh-In Hwang <josephsih@chromium.org>
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
diff --git a/src/shared/att.c b/src/shared/att.c
index d88169e..d8a49f5 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
@@ -579,10 +579,11 @@
 {
 	int security;
 
-	security = bt_att_get_security(att);
-	if (security != BT_ATT_SECURITY_AUTO)
+	if (att->io_sec_level != BT_ATT_SECURITY_AUTO)
 		return false;
 
+	security = bt_att_get_security(att);
+
 	if (ecode == BT_ATT_ERROR_INSUFFICIENT_ENCRYPTION &&
 					security < BT_ATT_SECURITY_MEDIUM)
 		security = BT_ATT_SECURITY_MEDIUM;
@@ -1002,7 +1003,7 @@
 
 	att->io_on_l2cap = is_io_l2cap_based(att->fd);
 	if (!att->io_on_l2cap)
-		att->io_sec_level = BT_SECURITY_LOW;
+		att->io_sec_level = BT_ATT_SECURITY_LOW;
 
 	return bt_att_ref(att);