Mark M. | has entered the room |
Mark M. | turned on guest access |
Sep 21 | 9:20 AM |
Susheel | has entered the room |
Mark M. |
hello, Susheel!
|
Mark M. |
how can I help you today?
|
Susheel |
Hi Mark. How are you doing?
|
Mark M. |
slightly sleep-deprived, but otherwise OK -- and you?
|
Susheel |
I got just the right amount of sleep so I'm good. Thank you!
|
Sep 21 | 9:25 AM |
Susheel |
I have a horizontal recyclerview I am using this as a viewpager. But now I'm having to implement my own viewpager indicator equivalent.
|
Susheel |
Shouldn't be terribly hard as I could just use shape drawables because I am in need of circle page indicator.
|
Susheel |
I know there's nothing in stock recyclerview that provides this functionality
|
Susheel |
What do you think or suggest?
|
Mark M. |
in terms of... what?
|
Dimitris | has entered the room |
Mark M. |
(BTW, hello, Dmitris -- I will be with you shortly!)
|
Susheel |
about my solution. with the shape drawables
|
Dimitris |
Hello!
|
Susheel |
is there a simpler, cleaner or elegant way?
|
Mark M. |
::shrug::
|
Mark M. |
that seems fine
|
Mark M. |
you might look at how an equivalent ViewPager indicator is implemented
|
Mark M. |
the principle difference is in the event listener for finding out when to change the indicator, and to what state
|
Mark M. |
(er, principal)
|
Susheel |
Right.
|
Susheel |
Okay
|
Mark M. |
everything else about the indicator would not need to change
|
Mark M. |
barring some unexpected dependency of the indicator on the pager
|
Susheel |
True. You can get to Dimitris now.
|
Mark M. |
OK
|
Mark M. |
Dmitris: your turn! do you have a question?
|
Dimitris |
So in case we are using a "bad" library that creates some thread using C++ and its not properly mapped to java so when the device sleeps and come back the c++ created thread is either killed or sleeping but we need to restart it, what do we do :P
|
Mark M. |
we ask that question of somebody who has done a lot more NDK work than I have
|
Dimitris |
(library is handed by the manufacturer and its obfuscated)
|
Sep 21 | 9:30 AM |
Mark M. |
as I haven't the foggiest notion
|
Sep 21 | 9:30 AM |
Mark M. |
though if it's the manufacturer's own library, they ought to know about their own hardware sleeping, and so this is clearly a bug
|
Dimitris |
I guess if I dont see any memory leaks I should just restart it manually without fear right ?
|
Mark M. |
ideally, yes
|
Mark M. |
it is possible that there is some global state outside the scope of the thread that will not like that, though
|
Dimitris |
and what is the "best" way of getting notified that the device goes to sleep
|
Mark M. |
AFAIK, the closest thing is watching for ACTION_SCREEN_OFF and ACTION_SCREEN_ON broadcasts
|
Mark M. |
but, I have not researched this area in years
|
Dimitris |
thats not really reliable
|
Mark M. |
that would not surprise me
|
Mark M. |
but I am not aware of anything better
|
Dimitris |
cause this definitely does't seem to recognize the user pressing the power button
|
Mark M. |
it should
|
Dimitris |
what about recognizing the power button click
|
Dimitris |
maybe I should override the keys pressed
|
Mark M. |
AFAIK, people do that via ACTION_SCREEN_OFF and ACTION_SCREEN_ON
|
Dimitris |
hmm then I guess I should check if I have some mistake in my code
|
Mark M. |
I do not think that the power button triggers a KeyEvent, though I may be wrong, and that would also imply that your activity is in the foreground
|
Mark M. |
again, this is not an area that I work in much, so my knowledge is fuzzy and may be out of date
|
Mark M. |
IOW, YMMV, FYI :-)
|
Dimitris |
:D
|
Sep 21 | 9:35 AM |
Dimitris |
adb shell input keyevent 26 is the power button :P
|
Mark M. |
however, if your code cannot detect it, that will be of limited utility
|
Dimitris |
hmm
|
Mark M. |
for example, HOME button presses do not result in KeyEvents, last I checked
|
Dimitris |
maybe I can use this onWindowFocusChanged
|
Dimitris |
im not sure if on screen on this gets triggered
|
Dimitris |
if it does I can assume the device wakes up
|
Mark M. |
it would get triggered in other cases, though, such as when another activity takes over the focus
|
Dimitris |
hmm
|
Dimitris |
if I could at least consistently get the screen off event
|
Dimitris |
the combination would work
|
Dimitris |
but I need at least one of the events in a consistent way
|
Mark M. |
pressing the POWER button should trigger ACTION_SCREEN_OFF, AFAIK
|
Mark M. |
if it is not doing that on your hardware, ask the manufacturer
|
Dimitris |
thank you Mark !
|
Mark M. |
for stuff like this, you might run some tests on a more "official" environment (e.g., Google Pixel), to determine whether your problem is in your logic or in the manufacturer's device
|
Dimitris |
this makes sense !
|
Mark M. |
let me switch back to Susheel, and I will return to you in a bit
|
Mark M. |
Susheel: back to you! do you have another question?
|
Dimitris |
(at least allows me to complain to the manufacturer)
|
Sep 21 | 9:40 AM |
Mark M. |
OK, if either of you have a question, go right ahead
|
Dimitris |
What is your opinion of global shared preferences and the fact that its deprecated, wasn't it a decent feature for people having a set of applications with sharedUserId?
|
Mark M. |
I don't think it was ever really safe for multiple processes
|
Dimitris |
Do you know if an app has System permissions (signed with a system key and so on) can it read shared prefs from every app on the device
|
Mark M. |
I doubt it
|
Mark M. |
that should require root
|
Dimitris |
what if two apps are both system apps
|
Mark M. |
that should not change the situation
|
Dimitris |
can they access each others shared prefs ?
|
Mark M. |
a device manufacturer/ROM developer might set up a pre-installed app in some Linux user group that allows for broader read access
|
Mark M. |
not by default
|
Mark M. |
as Google recommends, use a real IPC solution
|
Sep 21 | 9:45 AM |
Dimitris |
but they also mention this
|
Dimitris |
The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID. However, if this attribute is set to the same value for two or more applications, they will all share the same ID — provided that their certificate sets are identical. Applications with the same user ID can access each other's data and, if desired, run in the same process.
|
Dimitris |
each other's data means shared prefs too ?
|
Mark M. |
yes
|
Dimitris |
so if the sharedUserId = System
|
Dimitris |
then it might be possible that they both access the same
|
Mark M. |
by "system apps", I assumed that you mean installed on the privileged partition
|
Dimitris |
shareduserid='android.uid.system’
|
Mark M. |
are you signing the firmware?
|
Mark M. |
if not, then what you want will not work, as your apps will not be signed with the signing key that signed the firmware
|
Dimitris |
no but I can sign my app with the OS key
|
Mark M. |
OK
|
Mark M. |
then in principle what you describe should be possible
|
Dimitris |
so I do have a real System app
|
Dimitris |
thank you !
|
Dimitris |
is there a section on IPC in the book ?
|
Mark M. |
startActivity(), startService(), bindService(), sendBroadcast() are your main IPC solutions
|
Mark M. |
(plus ContentProvider)
|
Mark M. |
(and its related classes, like ContentObserver)
|
Mark M. |
so I would have one app be the "owner" of the preferences, and expose an API to other apps via a provider or perhaps a bound service
|
Dimitris |
bad question but is the ContentProvider staying intact when an app gets uninstalled
|
Sep 21 | 9:50 AM |
Mark M. |
no, as the ContentProvider implementation is being uninstalled
|
Susheel | has left the room |
Dimitris |
that makes sense
|
Mark M. |
IMHO, if you have two apps that are that tightly coupled, they should be one app, not two
|
Dimitris |
I guess the provider or bound service implementations are the way to go for me
|
Dimitris |
they need to be two unfortunately
|
Dimitris |
so I need to decide how they will communicate
|
Dimitris |
maybe broadcasting some intents will be enough
|
Dimitris |
but thank you for mentioning all the options
|
Dimitris |
have a nice day Mark thanks again
|
Mark M. |
you're welcome!
|
Dimitris | has left the room |
Sep 21 | 10:00 AM |
Mark M. | turned off guest access |