evotor / integration-library

26 stars 34 forks source link

Ошибка при вызове метода process в PrintCorrectionIncomeReceiptCommand #411

Open fallGamlet opened 2 years ago

fallGamlet commented 2 years ago

в классе PrintCorrectionIncomeReceiptCommand возникает ошибка NPE java.lang.NullPointerException: convertImplicitIntentToExplicitIntent(NAME, context.applicationContext) must not be null

fun process(context: Context, callback: IntegrationManagerCallback) {
    IntegrationManagerImpl
        .convertImplicitIntentToExplicitIntent(NAME, context.applicationContext)
        .firstOrNull()
        ?.let { component ->
            IntegrationManagerImpl(context.applicationContext).call(
                NAME,
                component,
                this,
                ActivityStarter(context),
                callback,
                Handler(Looper.getMainLooper())
            )
        }
}

потому что IntegrationManagerImpl.convertImplicitIntentToExplicitIntent(NAME, context.applicationContext) возвращает NULL

const val NAME = "evo.v2.receipt.correction.income.printReceipt"

https://github.com/evotor/integration-library/blob/2e08ffd04f5c7ad69e0b8f88e4195eba8c662204/src/main/java/ru/evotor/framework/core/action/command/print_receipt_command/PrintCorrectionIncomeReceiptCommand.kt

fallGamlet commented 2 years ago

Видать не находит такого сервиса, потому что внутри IntegrationManagerImpl.convertImplicitIntentToExplicitIntent

public static List<ComponentName> convertImplicitIntentToExplicitIntent(String action, Context context) {
    PackageManager pm = context.getPackageManager();
    List<ResolveInfo> resolveInfoList = pm.queryIntentServices(new Intent(action), 0);
    List<ComponentName> intentList = new ArrayList<>();

    if (resolveInfoList == null || resolveInfoList.isEmpty()) {
        return null;
    }
    for (ResolveInfo serviceInfo : resolveInfoList) {
        ComponentName component = new ComponentName(serviceInfo.serviceInfo.packageName, serviceInfo.serviceInfo.name);
        intentList.add(component);
    }

    return intentList;
}

Я думаю, что дело в том, что на моем тестовом терминале Эвотор нет этой службы, потому что он не обновлен до какой-то версии, или у него версия ФФД ниже 1.1

Данные моего терминала Наименование: Эвотор СТ51Ф Версия ОС: 4.3.0 Версия ККТ: 5252 Версия ФФД: 1.05

fallGamlet commented 2 years ago

Если эта ошибка связана с тем, что для использования PrintCorrectionIncomeReceiptCommand нужна версия ФФД выше чем 1.0.5, то лучше выкидывать соответствующее исключение или хотя бы сделать поме нку в документации метода