-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
Intents on start & exit #2265
Intents on start & exit #2265
Conversation
5fa9fb2
to
9105660
Compare
@rom1v Anything that can be discussed about this already? |
ListIterator<String> iter = list.listIterator(list.size()); | ||
for (String e = iter.previous(); iter.hasPrevious(); e = iter.previous()) { | ||
if(e == null){ | ||
// If there's no value, remove the entry | ||
iter.remove(); | ||
iter.previous(); | ||
iter.remove(); | ||
iter.previous(); | ||
iter.remove(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it's easier to read if just adding all and then remove the unused ones than to just add the ones provided.
Doing the other way is fine too
Sorry, I have no much time to work on scrcpy presently. I'm ok with sending a new intent on start and close, but IMO:
Regards |
Sad but understood. Must be really bad that can't even comment. Thanks for taking the time for that comment.
Updated the top comment with that in mind.
Got it! I'll keep that in mind. Thank you for that commit. It should be enough for what I'm aiming at. I didn't know what could be done. Thank you for giving me what I wanted and needed to make this into |
I still can (and often) answer to comments/issues. About this one, I didn't answer immediately because in my TODO list I wanted to improve the drag&drop behavior by sending an intent after "adb push" a file (the equivalent of |
Ty for clarification. Those things happen. |
9105660
to
fc1e549
Compare
Want me to finish that implementation? |
Thank you for the proposal, but I started implementing it few days ago (i just pushed the WIP: EDIT: Refs #2383 |
It's deprecated but lots of people use older phones. It can still make sense to go forward with it. |
fc1e549
to
6a06f60
Compare
@rom1v |
@@ -188,6 +219,9 @@ private static Options createOptions(String... args) { | |||
boolean powerOffScreenOnClose = Boolean.parseBoolean(args[15]); | |||
options.setPowerOffScreenOnClose(powerOffScreenOnClose); | |||
|
|||
EnumSet<Intents> broadcastIntents = Intents.fromBitSet(BitSet.valueOf(new long[]{Long.parseLong(args[16])})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a roundabout way of translating but it is the way that seemed to be most direct without implementing manually
51122a5
to
6c53b25
Compare
Hi, Thank you for your work. IMO, this feature should be kept simple:
Regards |
Here's my counter-opinions:
|
The STARTED and STOPPED broadcasts could be sent, but the app would only react to STOPPED.
I don't know Tasker, but I guess that the automation tools could probably react to broadcasts without duplicate information in the extras. I don't want custom hacks specific to Tasker (which is not even open source). |
In this case, it would be to hide scrcpy. It's more about apps you don't control than apps you do control.
It's not a feature specific for Tasker, I only mentioned it as an example, but fair enough. |
I'm not sure to understand the problem. IIRC, in your initial version, broadcasts were sent unconditionally. The purpose of the cli option was to disable broadcasts by default because they are not used in 99.9% of users. But if a user needs them, why configuring which broadcasts are sent by scrcpy would help? Scrcpy could just send both STARTED and STOPPED, and apps (or Tasker or whatever) could just do actions on reception of one of them. |
That's because I wanted to confirm implementation direction. Such as:
As I mention in the title, it was code as a base for discussion ;). If I were to do all the cli API by then and you didn't want to accept intent sending, I'd wasted my time on the C code when it would be just thrown away.
I'll try to explain with different words. About selecting which intents to send, my idea is more directed towards apps (most commonly, games but also some bank apps) that try to detect everything and then refuse to work when some parameter is different than expected. If you still insist on a "no" then I can remove the selection part with no hard feelings... |
Given what you mentioned and also not continuing the discussion, I decided my reasons are weak and I'll remove the ability to choose which intents to use completely |
Given the specific needs related to the intent format and their intent extra, maybe a more generic approach would be preferable:
What do you think? |
Even though that approach is flexible, it can lead to any command being run and then will come the need to accommodate for it by what different people want, etc, etc... Then there's the users making typos and then ho to tell there were typos and then check the status code.... Arbitrary code ends up being messy. I'm almost done removing the options :) |
3fb9ac2
to
99b82b4
Compare
Now I just need to test if all is good (later) |
Oh... More conflicts to fix... Maybe next weekend... I'll put in my calendar. |
There are many requests/use cases to execute arbitrary scripts on the device on start/stop: #96 #101 #1413 #1449 …
Maybe not on the command line, but a hook-script:
# yourhook.bash (executed on the device on start/stop)
if [[ "$1" == start ]]
then
# your commands on start
elif [[ "$1" == stop ]]
# your commands on stop
fi |
A hook script from a file is more acceptable than direct text as command line options. However, how can we properly tell the user that the stop is not guaranteed to run? Intents on start and exit don't solve that but I think a solution should be worked on at some point. I have my own proposal with the ServerSocket, which is what I use locally. @rom1v, maybe you can come up with a better solution. |
There is. See |
That one works most of the time... Not even nearly every time. |
If this doesn't work, my understanding is that it's a bug on the device which kills the child process after few hundreds of milliseconds. On a Nexus 5, i have this problem. On a OnePlus 7 Pro, it works 100℅ reliably (even if I had |
@rom1v The easiest way for me to reproduce is to just turn off debug mode automatically. |
It seems to work as expected for me. For example: # enable show touches
scrcpy -t When I turn USB debugging off, show touches is correctly disabled. |
In my phone, if I turn debugging off, everything running as adb is immediately killed (as in |
7e8a942
to
c0de365
Compare
Replaced by #3191 |
Send intents when scrcpy starts and when scrcpy exits
Still missing (will be added if feature accepted)
Extra: video showing a visual use:
https://www.mediafire.com/file/ktcxs0exclvoqha/intent_demo.mp4/file
(I was unable to attach the file in this post)