use of com.android.dialer.phonelookup.consolidator.PhoneLookupInfoConsolidator in project android_packages_apps_Dialer by LineageOS.
the class BlockingCommand method run.
@Override
public ListenableFuture<String> run(Arguments args) throws IllegalCommandLineArgumentException {
if (args.getPositionals().isEmpty()) {
return Futures.immediateFuture(getUsage());
}
String command = args.getPositionals().get(0);
if ("block".equals(command)) {
String number = args.getPositionals().get(1);
return Futures.transform(Blocking.block(appContext, ImmutableList.of(number), null), (unused) -> "blocked " + number, MoreExecutors.directExecutor());
}
if ("unblock".equals(command)) {
String number = args.getPositionals().get(1);
return Futures.transform(Blocking.unblock(appContext, ImmutableList.of(number), null), (unused) -> "unblocked " + number, MoreExecutors.directExecutor());
}
if ("isblocked".equals(command)) {
String number = args.getPositionals().get(1);
ListenableFuture<DialerPhoneNumber> dialerPhoneNumberFuture = executorService.submit(() -> new DialerPhoneNumberUtil().parse(number, null));
ListenableFuture<PhoneLookupInfo> lookupFuture = Futures.transformAsync(dialerPhoneNumberFuture, (dialerPhoneNumber) -> PhoneLookupComponent.get(appContext).compositePhoneLookup().lookup(dialerPhoneNumber), executorService);
return Futures.transform(lookupFuture, (info) -> new PhoneLookupInfoConsolidator(info).isBlocked() ? "true" : "false", MoreExecutors.directExecutor());
}
return Futures.immediateFuture(getUsage());
}
Aggregations