* limitations under the License.
*/
-package com.android.server;
+package com.android.internal.util.test;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.os.Handler;
import android.os.UserHandle;
-import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.AbstractFuture;
-
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class BroadcastInterceptingContext extends ContextWrapper {
private static final String TAG = "WatchingContext";
- private final List<BroadcastInterceptor> mInterceptors = Lists.newArrayList();
+ private final List<BroadcastInterceptor> mInterceptors = new ArrayList<>();
+
+ public abstract class FutureIntent extends FutureTask<Intent> {
+ public FutureIntent() {
+ super(
+ () -> { throw new IllegalStateException("Cannot happen"); }
+ );
+ }
+ }
- public class BroadcastInterceptor extends AbstractFuture<Intent> {
+ public class BroadcastInterceptor extends FutureIntent {
private final BroadcastReceiver mReceiver;
private final IntentFilter mFilter;
super(base);
}
- public Future<Intent> nextBroadcastIntent(String action) {
+ public FutureIntent nextBroadcastIntent(String action) {
return nextBroadcastIntent(new IntentFilter(action));
}
- public Future<Intent> nextBroadcastIntent(IntentFilter filter) {
+ public FutureIntent nextBroadcastIntent(IntentFilter filter) {
final BroadcastInterceptor interceptor = new BroadcastInterceptor(null, filter);
synchronized (mInterceptors) {
mInterceptors.add(interceptor);