question

Nimila Hiranya avatar image
Nimila Hiranya asked Nimila Hiranya edited

Disable Prompting of Sale Amount Screen on Clover Mini after Android 10 Upgrade

While our app is in the CustomerMode, we have added a service to run in the background and suppress the Sale prompt that appears when you dip or swipe a card. This worked fine previously but after the Android 10 upgrade, it seems like the issue has reappeared.

Our service is written as below.

public class IntentSuppressionService extends Service {
    private static final String ACTION_BROADCAST_CARD_INSERTED = "com.clover.intent.action.broadcast.CARD_INSERTED";
    private static final String ACTION_BROADCAST_CARD_SWIPED = "com.clover.intent.action.broadcast.CARD_SWIPED";
    private static final int PRIORITY_INTERCEPT = 200;
    private static String TAG = IntentSuppressionService.class.getName();

    private BroadcastReceiver suppressCardInsertedIntentReceiver = null;

    public static void start(Context context) {
        context.startService(new Intent(context, IntentSuppressionService.class));
    }

    public static void stop(Context context) {
        context.stopService(new Intent(context, IntentSuppressionService.class));
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.d(TAG, "Intent suppression background service is starting");
        return START_STICKY;
    }

    @Override
    public void onCreate() {

        IntentFilter filter = new IntentFilter();
        filter.addAction(ACTION_BROADCAST_CARD_INSERTED);
        filter.addAction(ACTION_BROADCAST_CARD_SWIPED);
        filter.setPriority(PRIORITY_INTERCEPT);

        if (suppressCardInsertedIntentReceiver == null) {
            suppressCardInsertedIntentReceiver = new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    String action = intent != null ? intent.getAction() : null;
                    if (ACTION_BROADCAST_CARD_INSERTED.equals(action) || ACTION_BROADCAST_CARD_SWIPED.equals(action)) {
                        Log.i(TAG, "Intent suppression background service is suppressing intent: " + action);
                        if (isOrderedBroadcast()) {
                            abortBroadcast();
                        }
                    }
                }
            };

            registerReceiver(suppressCardInsertedIntentReceiver, filter);

            Log.d(TAG, "Intent suppression background service broadcast receiver created");
        }
    }

    @Override
    public void onDestroy() {
        if (suppressCardInsertedIntentReceiver != null) {
            unregisterReceiver(suppressCardInsertedIntentReceiver);
            suppressCardInsertedIntentReceiver = null;

            Log.d(TAG, "Intent suppression background service broadcast receiver destroyed");
        }
        super.onDestroy();
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }
}

The sale screen appears intermittently. Are we missing any new intent?

Clover Android SDKClover Miniandroid 10
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community