Merge changes from topic 'blockOnProcessingUnsolicited' into nyc-dev
* changes: Tethering: interface updates can be handled again NativeDaemonConnector: add waitForCallbacks method
This commit is contained in:
committed by
Android (Google) Code Review
commit
ff0ff67ecc
@@ -41,6 +41,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
@@ -343,6 +344,30 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
|
|||||||
rawBuilder.append('\0');
|
rawBuilder.append('\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method that waits until all asychronous notifications sent by the native daemon have
|
||||||
|
* been processed. This method must not be called on the notification thread or an
|
||||||
|
* exception will be thrown.
|
||||||
|
*/
|
||||||
|
public void waitForCallbacks() {
|
||||||
|
if (Thread.currentThread() == mLooper.getThread()) {
|
||||||
|
throw new IllegalStateException("Must not call this method on callback thread");
|
||||||
|
}
|
||||||
|
|
||||||
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
mCallbackHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
latch.await();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Slog.wtf(TAG, "Interrupted while waiting for unsolicited response handling", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Issue the given command to the native daemon and return a single expected
|
* Issue the given command to the native daemon and return a single expected
|
||||||
* response.
|
* response.
|
||||||
|
|||||||
@@ -1507,6 +1507,11 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
|||||||
} catch (NativeDaemonConnectorException e) {
|
} catch (NativeDaemonConnectorException e) {
|
||||||
throw e.rethrowAsParcelableException();
|
throw e.rethrowAsParcelableException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that before we return from this command, any asynchronous
|
||||||
|
// notifications generated before the command completed have been
|
||||||
|
// processed by all NetworkManagementEventObservers.
|
||||||
|
mConnector.waitForCallbacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -273,9 +273,6 @@ public class Tethering extends BaseNetworkObserver {
|
|||||||
// ignore usb0 down after enabling RNDIS
|
// ignore usb0 down after enabling RNDIS
|
||||||
// we will handle disconnect in interfaceRemoved instead
|
// we will handle disconnect in interfaceRemoved instead
|
||||||
if (VDBG) Log.d(TAG, "ignore interface down for " + iface);
|
if (VDBG) Log.d(TAG, "ignore interface down for " + iface);
|
||||||
} else if (isWifi(iface)) {
|
|
||||||
// handle disconnect in interfaceRemoved
|
|
||||||
if (VDBG) Log.d(TAG, "ignore interface down for " + iface);
|
|
||||||
} else if (sm != null) {
|
} else if (sm != null) {
|
||||||
sm.sendMessage(TetherInterfaceSM.CMD_INTERFACE_DOWN);
|
sm.sendMessage(TetherInterfaceSM.CMD_INTERFACE_DOWN);
|
||||||
mIfaces.remove(iface);
|
mIfaces.remove(iface);
|
||||||
|
|||||||
Reference in New Issue
Block a user