├── .github └── workflows │ └── release.yml ├── API.md ├── README.md └── module ├── META-INF └── com │ └── google │ └── android │ ├── update-binary │ └── updater-script ├── bin ├── arm │ ├── android.hardware.gnss@1.0-impl-openrealgps.so │ ├── android.hardware.gnss@1.1-impl-openrealgps.so │ ├── android.hardware.gnss@2.0-impl-openrealgps.so │ └── android.hardware.gnss@2.1-impl-openrealgps.so ├── arm64 │ ├── android.hardware.gnss@1.0-impl-openrealgps.so │ ├── android.hardware.gnss@1.1-impl-openrealgps.so │ ├── android.hardware.gnss@2.0-impl-openrealgps.so │ └── android.hardware.gnss@2.1-impl-openrealgps.so ├── x64 │ ├── android.hardware.gnss@1.0-impl-openrealgps.so │ ├── android.hardware.gnss@1.1-impl-openrealgps.so │ ├── android.hardware.gnss@2.0-impl-openrealgps.so │ └── android.hardware.gnss@2.1-impl-openrealgps.so └── x86 │ ├── android.hardware.gnss@1.0-impl-openrealgps.so │ ├── android.hardware.gnss@1.1-impl-openrealgps.so │ ├── android.hardware.gnss@2.0-impl-openrealgps.so │ └── android.hardware.gnss@2.1-impl-openrealgps.so ├── customize.sh ├── module.prop ├── post-fs-data.sh └── service.sh /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | on: 3 | workflow_dispatch: 4 | create: 5 | jobs: 6 | release: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - run: zip -r -9 -q -v ../release.zip . 11 | working-directory: ./module 12 | - id: create_release 13 | uses: actions/create-release@v1 14 | env: 15 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 16 | with: 17 | tag_name: ${{ github.ref }} 18 | release_name: ${{ github.ref }} 19 | - uses: actions/upload-release-asset@v1 20 | env: 21 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 22 | with: 23 | upload_url: ${{ steps.create_release.outputs.upload_url }} 24 | asset_path: ./release.zip 25 | asset_name: openrealgps-magisk-${{ github.ref }}.zip 26 | asset_content_type: application/zip -------------------------------------------------------------------------------- /API.md: -------------------------------------------------------------------------------- 1 | # OpenRealGPS API 2 | 3 | ## 调用 API 4 | 5 | OpenRealGPS 会在本地的 9767 端口监听,调用 API 时需要向 http://127.0.0.1:9767/ 发送 HTTP POST 请求。 6 | 7 | 请求体需要包含一个特定格式的 JSON:`["methodName", [], [ parameters... ]]`,返回结果也是一个特定格式的 JSON:`[statusCode, returnValue]`。具体格式与调用的方法有关,详见下文。 8 | 9 | ## API 方法 10 | 11 | ### ping 12 | 该方法用于检测 OpenRealGPS 的工作状态。 13 | 14 | #### Request (sample) 15 | ``` 16 | ["ping", [], []] 17 | ``` 18 | 19 | #### Response (sample) 20 | ``` 21 | [0, 0] 22 | ``` 23 | 24 | ### setDataSource 25 | 该方法用于设置 GNSS 数据来源,参数为 true 时使用模拟数据,参数为 false 时使用真实数据。每次系统重启时该设置都会被重置为 false。 26 | 27 | #### Request (sample) 28 | ``` 29 | ["setDataSource", [], [false]] 30 | ``` 31 | 32 | #### Response (sample) 33 | ``` 34 | [0, null] 35 | ``` 36 | 37 | ### setHardwareEnabled 38 | 该方法用于设置是否启用 GNSS 硬件。若禁用硬件,将无法在使用模拟数据时获取真实数据。每次系统重启时该设置都会被重置为 true。 39 | 40 | #### Request (sample) 41 | ``` 42 | ["setHardwareEnabled", [], [true]] 43 | ``` 44 | 45 | #### Response (sample) 46 | ``` 47 | [0, null] 48 | ``` 49 | 50 | ### updateLocation 51 | 该方法用于更新模拟的位置数据。每次被调用时,OpenRealGPS 驱动都会向系统上层报告最新位置。建议每 1s 调用一次该方法。 52 | 53 | #### Request (sample) 54 | ``` 55 | ["updateLocation", [], [{"latitude": 0.00, "longitude": 0.00, "altitude": 0.00, "speed": 0.0, "bearing": 0.0, "accuracy": 0.0, "timestamp": 0}]] 56 | ``` 57 | 58 | #### Response (sample) 59 | ``` 60 | [0, null] 61 | ``` 62 | 63 | ### updateSatellites 64 | 该方法用于更新模拟的卫星数据。每次被调用时,OpenRealGPS 驱动都会向系统上层报告最新卫星数据。建议每 1s 调用一次该方法。最多包含 64 组卫星数据,超出部分将被忽略。 65 | 66 | #### Request (sample) 67 | ``` 68 | ["updateSatellites", [], [[{"prn": 1, "snr": 20.0, "elv": 0.0, "azm": 0.0}, {"prn": 2, "snr": 20.0, "elv": 0.0, "azm": 0.0}, ...]]] 69 | ``` 70 | 71 | #### Response (sample) 72 | ``` 73 | [0, null] 74 | ``` 75 | 76 | ### getRealLocation 77 | 该方法用于获取真实位置数据。若禁用了 GNSS 硬件将返回无效数据。 78 | 79 | #### Request (sample) 80 | ``` 81 | ["getRealLocation", [], []] 82 | ``` 83 | 84 | #### Response (sample) 85 | ``` 86 | [0, {"latitude": 0.00, "longitude": 0.00, "altitude": 0.00, "speed": 0.0, "bearing": 0.0, "accuracy": 0.0, "timestamp": 0}] 87 | ``` 88 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenRealGPS Core 2 | 3 | ## 使用说明 4 | 5 | 1. 安装 [Magisk](https://github.com/topjohnwu/Magisk) v20.0 或以上版本 6 | 2. 下载并安装 [OpenRealGPS Core Magisk module](https://github.com/OpenRealGPS/magisk-module/releases) 7 | 3. 阅读以下注意事项并激活模块 8 | 9 | ## 注意事项 10 | 11 | 本模块涉及系统底层文件修改,有较高风险导致系统无法启动,本模块不对任何可能造成的后果负责。在安装模块前,请对设备进行完整备份。不建议在常用设备上安装及使用本模块。 12 | 13 | 强烈建议首先安装带有 ADB 和 Shell 功能的第三方 Recovery (如 TWRP)。当系统无法启动时,可通过 Recovery 禁用模块,操作方式为在 Shell 中执行 `touch /data/adb/modules/openrealgps/disable` 14 | 15 | 若已阅读以上事项并接受风险,请在模块目录下创建一个名为 `i_have_read_the_warning` (区分大小写) 的文件以激活模块。模块的激活可在一个具备 root 权限的 shell 中执行:`touch /data/adb/modules/openrealgps/i_have_read_the_warning` 16 | 17 | ## API 18 | 19 | 模块将在本地启动一个 HTTP 端口用于提供 API 交互,详见 [API 文档](API.md) 20 | 21 | ## License 22 | 23 | MIT License 24 | 25 | Copyright (c) 2020 OpenRealGPS Project 26 | 27 | Permission is hereby granted, free of charge, to any person obtaining a copy 28 | of this software and associated documentation files (the "Software"), to deal 29 | in the Software without restriction, including without limitation the rights 30 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 31 | copies of the Software, and to permit persons to whom the Software is 32 | furnished to do so, subject to the following conditions: 33 | 34 | The above copyright notice and this permission notice shall be included in all 35 | copies or substantial portions of the Software. 36 | 37 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 38 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 39 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 40 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 41 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 42 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 43 | SOFTWARE. 44 | -------------------------------------------------------------------------------- /module/META-INF/com/google/android/update-binary: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | 3 | ################# 4 | # Initialization 5 | ################# 6 | 7 | umask 022 8 | 9 | # echo before loading util_functions 10 | ui_print() { echo "$1"; } 11 | 12 | require_new_magisk() { 13 | ui_print "*******************************" 14 | ui_print " Please install Magisk v20.4+! " 15 | ui_print "*******************************" 16 | exit 1 17 | } 18 | 19 | ######################### 20 | # Load util_functions.sh 21 | ######################### 22 | 23 | OUTFD=$2 24 | ZIPFILE=$3 25 | 26 | mount /data 2>/dev/null 27 | 28 | [ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk 29 | . /data/adb/magisk/util_functions.sh 30 | [ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk 31 | 32 | install_module 33 | exit 0 -------------------------------------------------------------------------------- /module/META-INF/com/google/android/updater-script: -------------------------------------------------------------------------------- 1 | #MAGISK -------------------------------------------------------------------------------- /module/bin/arm/android.hardware.gnss@1.0-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/arm/android.hardware.gnss@1.0-impl-openrealgps.so -------------------------------------------------------------------------------- /module/bin/arm/android.hardware.gnss@1.1-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/arm/android.hardware.gnss@1.1-impl-openrealgps.so -------------------------------------------------------------------------------- /module/bin/arm/android.hardware.gnss@2.0-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/arm/android.hardware.gnss@2.0-impl-openrealgps.so -------------------------------------------------------------------------------- /module/bin/arm/android.hardware.gnss@2.1-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/arm/android.hardware.gnss@2.1-impl-openrealgps.so -------------------------------------------------------------------------------- /module/bin/arm64/android.hardware.gnss@1.0-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/arm64/android.hardware.gnss@1.0-impl-openrealgps.so -------------------------------------------------------------------------------- /module/bin/arm64/android.hardware.gnss@1.1-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/arm64/android.hardware.gnss@1.1-impl-openrealgps.so -------------------------------------------------------------------------------- /module/bin/arm64/android.hardware.gnss@2.0-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/arm64/android.hardware.gnss@2.0-impl-openrealgps.so -------------------------------------------------------------------------------- /module/bin/arm64/android.hardware.gnss@2.1-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/arm64/android.hardware.gnss@2.1-impl-openrealgps.so -------------------------------------------------------------------------------- /module/bin/x64/android.hardware.gnss@1.0-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/x64/android.hardware.gnss@1.0-impl-openrealgps.so -------------------------------------------------------------------------------- /module/bin/x64/android.hardware.gnss@1.1-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/x64/android.hardware.gnss@1.1-impl-openrealgps.so -------------------------------------------------------------------------------- /module/bin/x64/android.hardware.gnss@2.0-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/x64/android.hardware.gnss@2.0-impl-openrealgps.so -------------------------------------------------------------------------------- /module/bin/x64/android.hardware.gnss@2.1-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/x64/android.hardware.gnss@2.1-impl-openrealgps.so -------------------------------------------------------------------------------- /module/bin/x86/android.hardware.gnss@1.0-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/x86/android.hardware.gnss@1.0-impl-openrealgps.so -------------------------------------------------------------------------------- /module/bin/x86/android.hardware.gnss@1.1-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/x86/android.hardware.gnss@1.1-impl-openrealgps.so -------------------------------------------------------------------------------- /module/bin/x86/android.hardware.gnss@2.0-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/x86/android.hardware.gnss@2.0-impl-openrealgps.so -------------------------------------------------------------------------------- /module/bin/x86/android.hardware.gnss@2.1-impl-openrealgps.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenRealGPS/magisk-module/1c5887a112951c60d02aa14675052d3515a5b426/module/bin/x86/android.hardware.gnss@2.1-impl-openrealgps.so -------------------------------------------------------------------------------- /module/customize.sh: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | 3 | if [[ -e /data/adb/modules/openrealgps/i_have_read_the_warning ]] 4 | then 5 | ui_print 'Old version detected, preserve i_have_read_the_warning flag' 6 | echo 1 > $MODPATH/i_have_read_the_warning 7 | fi 8 | -------------------------------------------------------------------------------- /module/module.prop: -------------------------------------------------------------------------------- 1 | id=openrealgps 2 | name=OpenRealGPS Core 3 | version=2023.08 4 | versionCode=23080 5 | author=OpenRealGPS Project 6 | description=USE AT YOUR OWN RISK - Read documents at https://github.com/OpenRealGPS/magisk-module -------------------------------------------------------------------------------- /module/post-fs-data.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | MODDIR=${0%/*} 3 | 4 | write_log() { 5 | echo "[`date +'%m-%d %T.%N'`] $1" >> /cache/OpenRealGPS.log 6 | } 7 | 8 | echo -n > /cache/OpenRealGPS.log 9 | chmod 644 /cache/OpenRealGPS.log 10 | write_log 'post-fs-data start' 11 | 12 | write_log 'Cleaning up' 13 | rm -rf $MODDIR/system 14 | rm -rf $MODDIR/vendor 15 | 16 | if [[ ! -e $MODDIR/i_have_read_the_warning ]] 17 | then 18 | write_log 'User have not read the warning, exiting.' 19 | exit 20 | fi 21 | 22 | write_log 'Preparing files' 23 | ABI=`getprop ro.product.cpu.abi` 24 | if [[ ! $ABI ]]; then ABI=`resetprop ro.product.cpu.abi`; fi 25 | case "$ABI" in 26 | *arm64*) ARCH=arm64; LIBPATH=lib64;; 27 | *armeabi*) ARCH=arm; LIBPATH=lib;; 28 | *x86_64*) ARCH=x64; LIBPATH=lib64;; 29 | *x86*) ARCH=x86; LIBPATH=lib;; 30 | *) write_log "Unsupported ABI: $ABI, exiting."; exit;; 31 | esac 32 | write_log "ABI: $ABI, ARCH: $ARCH, LIBPATH: $LIBPATH" 33 | 34 | SOPATH=`find /system/vendor/$LIBPATH/hw -name 'android.hardware.gnss@?.?-impl*.so' | head -n 1` 35 | if [[ ! $SOPATH ]]; then write_log 'Unable to find GNSS library path, exiting.'; exit; fi 36 | SONAME=`basename $SOPATH` 37 | HIDL_VER=`echo $SONAME | sed 's/^.*android.hardware.gnss@\(.*\)-impl.*$/\1/g'` 38 | NEW_SOPATH="$MODDIR/bin/$ARCH/android.hardware.gnss@$HIDL_VER-impl-openrealgps.so" 39 | if [[ ! -e $NEW_SOPATH ]]; then write_log "Unsupported GNSS HIDL version: $HIDL_VER, exiting."; exit; fi 40 | 41 | SVPATH=`find /system/vendor/bin/hw -name '*.gnss*' | head -n 1` 42 | if [[ ! $SVPATH ]]; then write_log 'Unable to find GNSS service path, exiting.'; exit; fi 43 | SVNAME=`basename $SVPATH` 44 | case "$SVNAME" in 45 | vendor.qti.gnss@*-service|android.hardware.gnss@*-service-qti|android.hardware.gnss-aidl-service-qti) write_log "GNSS hardware type: Qualcomm";; 46 | android.hardware.gnss@*-service-mediatek|android.hardware.gnss-service.mediatek) write_log "GNSS hardware type: MediaTek";; 47 | vendor.samsung.hardware.gnss@*-service) write_log "GNSS hardware type: Samsung";; 48 | android.hardware.gnss@*-service-brcm) write_log "GNSS hardware type: Broadcom";; 49 | *) write_log "Unsupported GNSS hardware type: $SVNAME, exiting."; exit;; 50 | esac 51 | 52 | write_log "Original library path: $SOPATH" 53 | write_log "Original service path: $SVPATH" 54 | VENDORDIR=$MODDIR/system/vendor 55 | if [ "$KSU" = true ]; then VENDORDIR=$MODDIR/vendor; fi 56 | mkdir -p $VENDORDIR/$LIBPATH/hw 57 | mkdir -p $VENDORDIR/bin/hw 58 | cp -v -p $SOPATH "$VENDORDIR/$LIBPATH/hw/gnss-original.so" >> /cache/OpenRealGPS.log 2>&1 59 | cp -v $NEW_SOPATH "$VENDORDIR/$LIBPATH/hw/$SONAME" >> /cache/OpenRealGPS.log 2>&1 60 | cp -v -p $SVPATH "$VENDORDIR/bin/hw/$SVNAME" >> /cache/OpenRealGPS.log 2>&1 61 | if [ "$KSU" = true ]; then chcon -v --reference="$SVPATH" "$VENDORDIR/bin/hw/$SVNAME" >> /cache/OpenRealGPS.log 2>&1; fi 62 | 63 | write_log 'post-fs-data done!' 64 | -------------------------------------------------------------------------------- /module/service.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | MODDIR=${0%/*} 3 | 4 | write_log() { 5 | echo "[`date +'%m-%d %T.%N'`] $1" >> /cache/OpenRealGPS.log 6 | /system/bin/log -t 'OpenRealGPS_Service' "$1" 7 | } 8 | 9 | VENDORDIR=$MODDIR/system/vendor 10 | if [ "$KSU" = true ]; then VENDORDIR=$MODDIR/vendor; fi 11 | SVPATH=`find $VENDORDIR/bin/hw/* | head -n 1` 12 | if [[ ! $SVPATH ]]; then write_log 'Service path not found, exiting.'; exit; fi 13 | 14 | SVNAME=`basename $SVPATH` 15 | write_log "Setting permissions for service $SVNAME" 16 | chown root:shell $SVPATH 17 | chmod +s $SVPATH 18 | 19 | SECON=`ls -Z $SVPATH | sed 's/^.*:object_r:\(.*\):.*$/\1/g' | sed 's/^\(.*\)_exec$/\1/g'` 20 | if [[ $SECON ]] 21 | then 22 | write_log "Injecting SELinux policies for service context $SECON" 23 | sepolicy1="allow $SECON * * *" 24 | sepolicy2="allow * $SECON * *" 25 | if command -v magiskpolicy &> /dev/null 26 | then 27 | write_log 'Using magiskpolicy' 28 | magiskpolicy --live "$sepolicy1" 29 | magiskpolicy --live "$sepolicy2" 30 | elif command -v ksud &> /dev/null 31 | then 32 | write_log 'Using ksud' 33 | ksud sepolicy patch "$sepolicy1" 34 | ksud sepolicy patch "$sepolicy2" 35 | else 36 | write_log 'Both magiskpolicy and ksud are not found, what type of SU do you have?' 37 | fi 38 | fi 39 | 40 | write_log "Force restarting service $SVNAME" 41 | pkill -9 -f $SVNAME 42 | 43 | if [[ -w /cache/magisk.log ]] 44 | then 45 | echo '[OpenRealGPS log start]' >> /cache/magisk.log 46 | cat /cache/OpenRealGPS.log >> /cache/magisk.log 47 | echo '[OpenRealGPS log end]' >> /cache/magisk.log 48 | fi 49 | --------------------------------------------------------------------------------