A third possible option would be to add something like this:

on persist.sys.gps.enabled=1
    start gps-daemon

on persist.sys.gps.enabled=0
    stop gps-daemon

and then adding a "disabled" line to the gps-daemon service. That way, GPS
can be enabled/disabled at runtime with `setprop
persist.sys.gps.enabled=<1|0>`. That's probably also something that can be
upstreamed without issues.


On Sun, 5 Mar 2017 at 08:01 Wolfgang Wiedmeyer <w...@wiedmeyer.de> wrote:

Simon Josefsson writes:

> Hi all.
> I noticed that the i9300 /init.target.rc of Replicant 6 deviates from
> upstream wrt gps:
> The commit that introduced this difference said the reason was to reduce
> 'dmesg' spam:
> I have come up with another way to solve the 'dmesg' spam problem,
> without having to deviate from upstream init.target.rc.  How about the
> attached patch?  I have tested it on my phone, both with and without any
> /system/bin/glgps binary, and there is no dmesg spam.
> Thanks,
> /Simon
> From b421692b7da72424decc7ddc0db46956d182dc06 Mon Sep 17 00:00:00 2001
> From: Simon Josefsson <si...@josefsson.org>
> Date: Sat, 4 Mar 2017 17:34:22 +0000
> Subject: [PATCH] Reduce divergance from LineageOS init.target.rc --
>  dmesg spam in another way.
> ---
>  gps_daemon.sh          |  1 +
>  rootdir/init.target.rc | 14 +++++++-------
>  2 files changed, 8 insertions(+), 7 deletions(-)
> diff --git a/gps_daemon.sh b/gps_daemon.sh
> index 7cd6b64..6204974 100644
> --- a/gps_daemon.sh
> +++ b/gps_daemon.sh
> @@ -1,2 +1,3 @@
>  #shellscript as this is the only way selinux will allow this to proceed
>  /system/bin/glgps -c /system/etc/gps.xml
> +sleep 12345678

We already talked about this on irc. This would make the script run for
this amount of time and it would do nothing. This is only to prevent
that the script is immediately run again by init. An alternative would
be to define a property like ro.use.proprietary.gps and only run the script
if the property is set in build.prop.

There may be a solution that doesn't require any change. It's possible
to place a script named userinit.sh in /data/local/ and this script
should be started by sysinit[1][2][3]. Sysinit is started in
init.cm.rc. So it may be enough to move /system/bin/gps_daemon.sh to
/data/local/userinit.sh. I didn't test this, but it would be interesting
in general if it's possible to write a custom init script and run it
this way without a need to modify the ramdisk. It looks like this was
originally intended for being able to run a ssh server.

> diff --git a/rootdir/init.target.rc b/rootdir/init.target.rc
> index 4fcf34d..1652d6d 100644
> --- a/rootdir/init.target.rc
> +++ b/rootdir/init.target.rc
> @@ -93,11 +93,11 @@ on fs
>      # zram
>      swapon_all /fstab.smdk4x12
> -#on boot
> +on boot
>  # Start GPS daemon
> -#service gps-daemon /system/bin/sh /system/bin/gps_daemon.sh
> -#    class main
> -#    socket gps seqpacket 0660 gps system
> -#    user gps
> -#    group system inet sdcard_rw gps
> -#    seclabel u:r:glgps:s0
> +service gps-daemon /system/bin/sh /system/bin/gps_daemon.sh
> +    class main
> +    socket gps seqpacket 0660 gps system
> +    user gps
> +    group system inet sdcard_rw gps
> +    seclabel u:r:glgps:s0

It seems that the userinit.sh script is only started once (sysinit has
"oneshot"). So the a similar behaviour could also be achieved by adding
"oneshot" here to the gps-daemon options. This would likely solve the
problem that init keeps rerunning the script. A disadvantage could be
that the device needs to be restarted in the case that the gps daemon
exits or crashes.

I suggest trying the options I listed before applying the patch with the
sleep command.

Best regards,




Website: https://fossencdi.org
OpenPGP: 0F30 D1A0 2F73 F70A 6FEE  048E 5816 A24C 1075 7FC4
Key download: https://wiedmeyer.de/keys/ww.asc
Replicant mailing list
Replicant mailing list

Reply via email to