brcmwifi: don't use AutoDict

The AutoDict for the AssociatedDeviceList has triggered
a series of issues, described in b/29127321 and b/33414470.
Stop using AutoDict, instead make a dict() of all associated
devices similar to how binwifi.py does it.

Fixes b/33414470

Change-Id: I362005ff57410e7dd0fec958256783ecd74e46f2
diff --git a/dm/brcmwifi.py b/dm/brcmwifi.py
index 3f6ce77..6878800 100644
--- a/dm/brcmwifi.py
+++ b/dm/brcmwifi.py
@@ -556,10 +556,6 @@
                    'X_CATAWAMPUS-ORG_OverrideSSID',
                    'X_CATAWAMPUS-ORG_Suffix24G'])
 
-    self.AssociatedDeviceList = tr.core.AutoDict(
-        'AssociatedDeviceList', iteritems=self.IterAssociations,
-        getitem=self.GetAssociationByIndex)
-
     self.PreSharedKeyList = {}
     for i in range(1, 2):
       # tr-98 spec deviation: spec says 10 PreSharedKeys objects,
@@ -1043,15 +1039,14 @@
       tr.handle.ValidateExports(ad)
     return ad
 
-  def IterAssociations(self):
+  @property
+  def AssociatedDeviceList(self):
     """Retrieves a list of all associated STAs."""
     stations = self.wl.GetAssociatedDevices()
+    associated_device_list = {}
     for idx, mac in enumerate(stations, start=1):
-      yield idx, self.GetAssociation(mac)
-
-  def GetAssociationByIndex(self, index):
-    stations = self.wl.GetAssociatedDevices()
-    return self.GetAssociation(stations[index])
+      associated_device_list[str(idx)] = self.GetAssociation(mac)
+    return associated_device_list
 
 
 class BrcmWlanConfigurationStats(netdev.NetdevStatsLinux26, BASE98WIFI.Stats):
diff --git a/dm/brcmwifi_test.py b/dm/brcmwifi_test.py
index 594c3f4..c112632 100644
--- a/dm/brcmwifi_test.py
+++ b/dm/brcmwifi_test.py
@@ -710,6 +710,12 @@
       seen.add(mac)
     self.assertEqual(len(seen), 3)
 
+  def testAssociatedDeviceUnicodeIndex(self):
+    bw = brcmwifi.BrcmWifiWlanConfiguration('wifi0')
+    al = bw.AssociatedDeviceList
+    h = tr.handle.Handle(al)
+    self.assertTrue(h.GetExport(u'1'))
+
   def testKeyPassphrase(self):
     bw = brcmwifi.BrcmWifiWlanConfiguration('wifi0')
     bw.KeyPassphrase = 'testpassword'