Search in sources :

Example 1 with PhoneLookupInfoConsolidator

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());
}
Also used : PhoneLookupInfoConsolidator(com.android.dialer.phonelookup.consolidator.PhoneLookupInfoConsolidator) PhoneLookupInfo(com.android.dialer.phonelookup.PhoneLookupInfo) DialerPhoneNumber(com.android.dialer.DialerPhoneNumber) DialerPhoneNumberUtil(com.android.dialer.phonenumberproto.DialerPhoneNumberUtil)

Aggregations

DialerPhoneNumber (com.android.dialer.DialerPhoneNumber)1 PhoneLookupInfo (com.android.dialer.phonelookup.PhoneLookupInfo)1 PhoneLookupInfoConsolidator (com.android.dialer.phonelookup.consolidator.PhoneLookupInfoConsolidator)1 DialerPhoneNumberUtil (com.android.dialer.phonenumberproto.DialerPhoneNumberUtil)1