Handle class and name changed actions with DeviceFound signals.

When the class or name of a device changed, due to name resolution
or otherwise, we  were not updating the cache.
This commit is contained in:
Jaikumar Ganesh
2009-06-19 16:10:50 -07:00
parent ca1db2349e
commit d97daa064b
3 changed files with 77 additions and 52 deletions

View File

@@ -96,7 +96,7 @@ public class LocalBluetoothDevice implements Comparable<LocalBluetoothDevice> {
this.profile = profile;
this.timeSent = 0;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -147,7 +147,7 @@ public class LocalBluetoothDevice implements Comparable<LocalBluetoothDevice> {
}
}
}
private boolean pruneQueue(BluetoothJob job) {
boolean removedStaleItems = false;
long now = System.currentTimeMillis();
@@ -186,7 +186,7 @@ public class LocalBluetoothDevice implements Comparable<LocalBluetoothDevice> {
private boolean processCommand(BluetoothJob job) {
boolean successful = false;
if (job.timeSent == 0) {
job.timeSent = System.currentTimeMillis();
job.timeSent = System.currentTimeMillis();
switch (job.command) {
case CONNECT:
successful = connectInt(job.device, job.profile);
@@ -448,7 +448,7 @@ public class LocalBluetoothDevice implements Comparable<LocalBluetoothDevice> {
public void unpair() {
synchronized (workQueue) {
// Remove any pending commands for this device
boolean processNow = false;
boolean processNow = false;
Iterator<BluetoothJob> it = workQueue.iterator();
while (it.hasNext()) {
BluetoothJob job = it.next();
@@ -494,6 +494,17 @@ public class LocalBluetoothDevice implements Comparable<LocalBluetoothDevice> {
return mName;
}
public void setName(String name) {
if (!mName.equals(name)) {
if (TextUtils.isEmpty(name)) {
mName = mAddress;
} else {
mName = name;
}
dispatchAttributesChanged();
}
}
public void refreshName() {
fetchName();
dispatchAttributesChanged();
@@ -607,6 +618,14 @@ public class LocalBluetoothDevice implements Comparable<LocalBluetoothDevice> {
dispatchAttributesChanged();
}
public void setBtClass(int btClass) {
if (mBtClass != btClass && btClass != BluetoothClass.ERROR) {
mBtClass = btClass;
LocalBluetoothProfileManager.fill(mBtClass, mProfiles);
dispatchAttributesChanged();
}
}
public int getSummary() {
// TODO: clean up
int oneOffSummary = getOneOffSummary();