Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to open a card from the device control quick settings tile #1881

Open
proletarius101 opened this issue May 11, 2024 · 10 comments
Open
Labels
android: 14 common: frequent Affects or can be seen by most users regularly or impacts most users' first experience severity: major Severely degrades major functionality or product features, with no satisfactory workaround type: bug Something isn't working

Comments

@proletarius101
Copy link

Reproduce steps:

  1. Add a card to catima
  2. Add that card to the device control tile
  3. Quit catima
  4. Open the card from the device control tile by tapping it once
  5. Nothing happens

Expected behavior:
The card opens

Catima version: 2.29.0
Android version: 14

@TheLastProject
Copy link
Member

I can reproduce this by rebooting the emulator as step 3 (for context, I don't know how you define "Quit Catima" here. IIRC a "force stop" is not a reliable test as that causes Android to block delivery of some intents).

Interestingly, this works fine on Android 13, it broke in Android 14. And long-pressing the card in device controls shows it fine, just short pressing doesn't do anything.

Looking at logcat, I do see a message stating "Background activity launch blocked":

2024-05-11 10:36:38.687   558-2278  ActivityTaskManager     system_server                        W  Background activity launch blocked [callingPackage: me.hackerchick.catima.debug; callingUid: 10190; appSwitchState: 2; callingUidHasAnyVisibleWindow: false; callingUidProcState: BOUND_FOREGROUND_SERVICE; isCallingUidPersistentSystemProcess: false; balAllowedByPiSender: BackgroundStartPrivileges[allowsBackgroundActivityStarts=false, allowsBackgroundForegroundServiceStarts=true, originatingToken=null]; realCallingPackage: me.hackerchick.catima.debug; realCallingUid: 10190; realCallingUidHasAnyVisibleWindow: false; realCallingUidProcState: BOUND_FOREGROUND_SERVICE; isRealCallingUidPersistentSystemProcess: false; originatingPendingIntent: null; backgroundStartPrivileges: BackgroundStartPrivileges[allowsBackgroundActivityStarts=false, allowsBackgroundForegroundServiceStarts=false, originatingToken=null]; intent: Intent { flg=0x10000000 cmp=me.hackerchick.catima.debug/protect.card_locker.LoyaltyCardViewActivity (has extras) }; callerApp: ProcessRecord{afd8460 3979:me.hackerchick.catima.debug/u0a190}; inVisibleTask: false]
2024-05-11 10:36:38.688   558-2278  ActivityTaskManager     system_server                        E  Abort background activity starts from 10190
2024-05-11 10:36:38.688   558-2278  ActivityTaskManager     system_server                        I  START u0 {flg=0x10000000 cmp=me.hackerchick.catima.debug/protect.card_locker.LoyaltyCardViewActivity (has extras)} with LAUNCH_MULTIPLE from uid 10190 (BAL_BLOCK) result code=102

@TheLastProject TheLastProject added type: bug Something isn't working severity: major Severely degrades major functionality or product features, with no satisfactory workaround common: frequent Affects or can be seen by most users regularly or impacts most users' first experience android: 14 labels May 11, 2024
@TheLastProject
Copy link
Member

It's quite hard to find documentation on this. My first idea was to just guard the code on Android 14 with a Toast to explain to users to long-press (not perfect, but an okay workaround for now):

    @Override
    public void performControlAction(@NonNull String controlId, @NonNull ControlAction action, @NonNull Consumer<Integer> consumer) {
        consumer.accept(ControlAction.RESPONSE_OK);

        // Android 14 doesn't allow us to start an activity from the background anymore
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
            Toast.makeText(this, R.string.long_press_to_show_card, Toast.LENGTH_LONG).show();
        } else {
            Intent openIntent = new Intent(this, LoyaltyCardViewActivity.class)
                    .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                    .putExtra("id", controlIdToCardId(controlId));
            startActivity(openIntent);


            closePowerScreenOnAndroid11();
        }
    }

But of course, Google has another fun surprise up their sleeve: Suppressing toast from package by user request. (Sure, "by user request"...)

Seems that even telling an user from the background that they need to long-press requires Catima to ask for notification permission even though I currently don't have any other need to ask for notification permissions and this will not make sense to users. 😞

@proletarius101
Copy link
Author

However, long pressing still won't bring up catima from the lock screen 😔

@TheLastProject
Copy link
Member

It seems a bit buggy just after boot but aside from that I can't reproduce that:

Screen_recording_20240511_112906.mp4

@proletarius101
Copy link
Author

proletarius101 commented May 11, 2024

Seems to be relevant to https://developer.android.com/about/versions/14/behavior-changes-14#safer-intents

But the activity is exported 🤔

@proletarius101
Copy link
Author

proletarius101 commented May 11, 2024

Maybe this https://developer.android.com/guide/components/activities/background-starts#exceptions

Note: Starting from Android 14, apps targeting Android 14 or higher must opt in to allow background activity launch when sending a PendingIntent. To opt in, the app should pass an ActivityOptions bundle with setPendingIntentBackgroundActivityStartMode (ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED)

If that's the case, there's a bug in Android...

@TheLastProject
Copy link
Member

I found out today that apparently Samsung's Android skin ("One UI") doesn't have any effect on long-pressing an entry, just moving it around. Given this extra limitation on Samsung devices making the only workaround I could think of not universally possible I think the only logical option that remains is disabling this functionality on Android 14+.

It sucks for those who do prefer to open cards this way but well, our hands seem tied here...

@proletarius101
Copy link
Author

On the other hand, I'm curious how it works for the google home app 🤔

@TheLastProject
Copy link
Member

I don't think Google will let us take a peek into the kitchen :P But it may be worth looking at the Home Assistant Android app, see if the same issues exist there and if not how they do it.

@proletarius101
Copy link
Author

I can confirm that single tap work for Google Home

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android: 14 common: frequent Affects or can be seen by most users regularly or impacts most users' first experience severity: major Severely degrades major functionality or product features, with no satisfactory workaround type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants