Merge "Clear names from externally supplied WorkSources to WifiManager (b/10733757)" into klp-dev

This commit is contained in:
David Christie
2013-09-20 20:04:04 +00:00
committed by Android (Google) Code Review
2 changed files with 24 additions and 7 deletions

View File

@@ -103,7 +103,21 @@ public class WorkSource implements Parcelable {
* @hide
*/
public void clearNames() {
mNames = null;
if (mNames != null) {
mNames = null;
// Clear out any duplicate uids now that we don't have names to disambiguate them.
int destIndex = 1;
int newNum = mNum;
for (int sourceIndex = 1; sourceIndex < mNum; sourceIndex++) {
if (mUids[sourceIndex] == mUids[sourceIndex - 1]) {
newNum--;
} else {
mUids[destIndex] = mUids[sourceIndex];
destIndex++;
}
}
mNum = newNum;
}
}
/**

View File

@@ -1867,13 +1867,16 @@ public class WifiManager {
boolean changed = true;
if (ws == null) {
mWorkSource = null;
} else if (mWorkSource == null) {
changed = mWorkSource != null;
mWorkSource = new WorkSource(ws);
} else {
changed = mWorkSource.diff(ws);
if (changed) {
mWorkSource.set(ws);
ws.clearNames();
if (mWorkSource == null) {
changed = mWorkSource != null;
mWorkSource = new WorkSource(ws);
} else {
changed = mWorkSource.diff(ws);
if (changed) {
mWorkSource.set(ws);
}
}
}
if (changed && mHeld) {