1

I'm running rooted stock Android 13.

I use the LINE Messenger app, but that app seems to behave badly under Android. After the app has been idle for a while, it doesn't respond to incoming messages until the LINE client is explicitly launched and brought to the foreground. This means that I often miss incoming messages until much later than when they are originally sent. I don't have this problem with any other messaging apps.

I'm trying to figure out a way to wake up the LINE app periodically, and I came up with the following possibility ... but it doesn't work:

/system/bin/su -c /system/bin/am set-inactive jp.naver.line.android false

The command always comes back with this error:

cmd: Failure calling service activity: Failed transaction (2147483646)

I get the same error without the /system/bin/su -c

Is there perhaps some other way in Android 13 to accomplish this?

PS: To be clear, by "wake up", I do not mean for the LINE app to visibly launch. What I want is for LINE to properly respond to incoming messages, even when that app is not open on the screen. This is how other messaging apps behave, and I consider LINE to be "badly behaved", because LINE does not respond to incoming messages if it has not been visibly open on the screen for a while.

Also to be clear, I always have LINE running with "Unrestricted" battery behavior (as opposed to the other two choices, "Optimized" or "Restricted"), but it still does not respond to incoming messages if it has not been open on the screen for a while.

Is there some way to force /system/bin/am set-inactive ... to properly function? If so, periodically running this command for LINE might cause LINE to become aware of incoming messages every time that the command runs, even when LINE isn't open on the screen.

Or perhaps is there an alternative to /system/bin/am which will accomplish what I desire?

4
  • I don't know how Line works, but most messenger apps use for receiving messages Google Firebase Push Messages, su the delay might also be caused by Google Play Services. What are the battery settings of Line? Note that a lot of manufacturer modify Android TK save even more power which has the side effect that apps wake up or too late.
    – Robert
    Apr 6 at 21:10
  • Well, all the other messaging apps I use do not have this problem, so I don't think it's related to Play Services. My OS doesn't even offer the "battery optimization" settings, so this can't be changed on an "app" basis. It's "OS 2.0.3" for the Nothing 2 device. I also thought that "am set-inactive ... false" would affect the Firebase Push behavior. Also, if I remember correctly, LINE had the same problem on my old Pixel 5, even when I had "battery optimization" turned off for it. This is why I say that LINE is "badly behaved". Is there any way I can force an app like LINE to "wake up"?
    – HippoMan
    Apr 7 at 0:45
  • If by "wake up" you mean "launch the app", you can try automation with Tasker etc
    – beeshyams
    Apr 7 at 3:23
  • Launching the app is not acceptable, because I don't want it popping up on the screen. I already had Tasker doing that, but it's too disruptive of my Android usage to have it periodically launching visibly. And I have a small correction: I had forgotten that on my A13 implementation, battery behavior is controlled on the Settings=>Apps=>[appname] screen. But I already always have been running it with "Unrestricted" there. By "wake up", I mean for the app to still respond to incoming messages when it's in the background, just like all the other messaging apps do.
    – HippoMan
    Apr 7 at 14:30

1 Answer 1

2

Well, it turns out that I figured out how to get this to work, after all!

Earlier, I wrote the original "Answer" here and then modified it a little later to say that it doesn't actually work, because the am set-inactive jp.naver.line.android false command that I'm using was causing my device to never go to sleep.

But later I realized that this am set-inactive ... command only caused device sleep to get disabled because I also ran AutoInput Unlock Screen in my Tasker device-startup task instantly after this am ... command was invoked, and this caused them to somehow badly interact with each other and to prevent my device from ever going to sleep again.

Once I set up the AutoInput Unlock Screen command to run many seconds earlier than the am ... command in that Tasker device-startup script, my device was once again able to properly go to sleep, and LINE Messenger is now actually functioning properly.

Here's exactly how I did it:

(1) I created a Tasker task called LineForceActive which runs this command via Code=>Run Shell, using the Use Root option ...

/system/bin/am set-inactive jp.naver.line.android.false 0</dev/null 1>/dev/null 2>&1

The /dev/null redirections are needed, because the "am" command fails unless it's running with stdin, stdout, and stderr pointing to either /dev/tty or /dev/null.

(2) I created a Tasker Code=>Run Shell task called LineRenice which checks whether LINE Messenger is running, and if so, it runs renice on it to set it to the highest priority possible (priority -20). This is the LineRenice Tasker task ...

Task: LineRenice
Settings: Run Both Together

A1: Run Shell [
     Command: /system/bin/pgrep line
     Timeout (Seconds): 1
     Use Root: On
     Store Output In: %XXOUT
     Use Global Namespace: On
     Continue Task After Error:On ]

A2: Variable Set [
     Name: %XXEXIT
     To: %err
     Do Maths: On
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On
     Continue Task After Error:On ]

A3: Stop [ ]
    If  [ %XXEXIT != 0 ]

A4: Run Shell [
 Command: /system/bin/renice -p -n -20 %XXOUT
 Timeout (Seconds): 1
 Use Root: On
 Use Global Namespace: On ]

I'm not sure whether doing renice to set LINE Messenger to a very high priority is really needed, but it doesn't seem to hurt. I'll decide later if I might want to stop using LineRenice altogether.

(3) Near the end of my Tasker device-startup script, I do the following. It launches LINE Messenger, waits a short time, and then runs the LineRenice and LineForceActive Tasker tasks ...

Launch App [
Package/App Name: LINE
Exclude From Recent Apps: On
Always Start New Copy: On
Continue Task After Error:On ]

Wait [
MS: 0
Seconds: 3
Minutes: 0
Hours: 0
Days: 0 ]

Perform Task [
Name: LineRenice
Priority: 0
Structure Output (JSON, etc): On
Continue Task After Error:On ]

Perform Task [
Name: LineForceActive
Priority: 0
Structure Output (JSON, etc): On ]

(4) I set up a Tasker profile which uses Tasker's logcat monitor to detect when LINE Messenger has been force-closed. In this case, I cause the same code to be invoked that's in item 3. This restarts LINE Messenger.

(5) I also set up a Tasker profile to run the LineRenice and LineForceActive tasks every 2 minutes. This might not actually be necessary, and I'll decide later if I really want to continue to run these repeated calls.

Running Tasker and AutoInput on a rooted device is of course necessary for all this to work. One of the main reasons I always want to root my Android devices and use Tasker and Tasker plugins is to enable me to install these kinds of fixes and modifications.

1
  • Since I installed and posted my Answer, there have been two LINE Messenger updates in the Play Store, and I installed each of them. I then decided to test by disabling my LineRenice and LineForceActive Tasker tasks, and now it looks like LINE Messenger is actually working properly on its own!! But it seems like LINE Messenger still stops responding to messages after it's been force-closed, so now, I'm only performing item 4 in my Answer (but without LineRenice and LineForceActive), and this seems to be all I need. I hope this behavior continues, and I'll report.
    – HippoMan
    Apr 13 at 2:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .