Coder Social home page Coder Social logo

Comments (10)

TheLastProject avatar TheLastProject commented on July 19, 2024

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

from android.

TheLastProject avatar TheLastProject commented on July 19, 2024

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. 😞

from android.

proletarius101 avatar proletarius101 commented on July 19, 2024

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

from android.

TheLastProject avatar TheLastProject commented on July 19, 2024

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

Screen_recording_20240511_112906.mp4

from android.

proletarius101 avatar proletarius101 commented on July 19, 2024

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

But the activity is exported 🤔

from android.

proletarius101 avatar proletarius101 commented on July 19, 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...

from android.

TheLastProject avatar TheLastProject commented on July 19, 2024

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...

from android.

proletarius101 avatar proletarius101 commented on July 19, 2024

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

from android.

TheLastProject avatar TheLastProject commented on July 19, 2024

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.

from android.

proletarius101 avatar proletarius101 commented on July 19, 2024

I can confirm that single tap work for Google Home

from android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.