Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mock location on LineageOS 16/17 with GPS Joystick

Mock location on LineageOS 16/17 with GPS Joystick

Prerequisite

  • A computer (tested on Windows 10, but I don't see any reason it won't work with macOS or Linux).

  • A LineageOS 16/17 compatible phone (LineageOS 16 is recommended, some users reported random crash on LineageOS 17).

  • Download the minimal ADB from XDA Developers Forum and unzip it.

  • Download Unlocked GPS Joystick from here and rename it to base.apk and put it in the ADB folder.

  • 30 minutes of time.

Install LineageOS 16/17

  1. Download LineageOS 16/17 from the offical website.

  2. Download Google App package from here.

  3. Please follow the installation instructions on your device's download page (below the title) to install LinageOS. Please note, you must sideload the Google Apps package BEFORE booting into LineageOS for the first time.

  4. Go through the init setup and install Chrome. Go "Settings" and search for "default", set the Chrome as the default browser app. Otherwise, you won't be able to login to My 11-Seven app.

Install GPS Joystick as a System App

  1. Enable Developer Options in LineageOS. Go "Settings" -> "About phone" and click "Build number" 8 times.

  2. Enable ADB Root Access. Go "Settings" -> "System" -> "Advance" -> "Developer options" -> "Root access" and select "ADB only".

  3. Enable Android debugging. On the "Develop options" page, enable "Android debbuging".

  4. Create a file called "privapp-permissions-com.theappninjas.fakegpsjoystick.xml" in the ADB folder and paste the following into it:

    <privapp-permissions package="com.theappninjas.fakegpsjoystick">
        <permission name="android.permission.INTERNET"/>
        <permission name="android.permission.ACCESS_NETWORK_STATE"/>
        <permission name="android.permission.ACCESS_COARSE_LOCATION"/>
        <permission name="android.permission.ACCESS_FINE_LOCATION"/>
        <permission name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
        <permission name="android.permission.ACCESS_MOCK_LOCATION"/>
        <permission name="android.permission.SYSTEM_ALERT_WINDOW"/>
        <permission name="android.permission.INSTALL_LOCATION_PROVIDER"/>
        <permission name="android.permission.WRITE_SETTINGS"/>
        <permission name="android.permission.WRITE_SECURE_SETTINGS"/>
        <permission name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/>
        <permission name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
        <permission name="com.android.vending.BILLING"/>
        <permission name="android.permission.WAKE_LOCK"/>
        <permission name="com.google.android.c2dm.permission.RECEIVE"/>
        <permission name="com.theappninjas.fakegpsjoystick.permission.C2D_MESSAGE"/>
    </privapp-permissions>
  5. Open Command Prompt/PowerShell/Terminal on you computer and change directory to the ADB folder. Run the following commands:

    # push the GPS Joystick apk and the xml file to your phone, note you must include the trailing slash
    adb push base.apk /sdcard/
    adb push privapp-permissions-com.theappninjas.fakegpsjoystick.xml /sdcard/
    
    # pull the privapp permision file from your phone for editing
    adb pull /system/etc/permissions/privapp-permissions-platform.xml ./privapp-permissions-platform.xml

    Note: If you don't have a file called privapp-permissions-platform.xml in /system/etc/permissions/. The file you need to pull in the second step is /system/etc/permissions/privapp-permissions-xxx.xml (where xxx represents your device name). If you are not sure which file to pull, you can list the all files in /system/etc/permissions directory which filename starts with privapp-permissions and the file should have multiple <privapp-permissions package="..."> sections in it.

    To list all files starts with privapp-permissions:

    adb shell
    
    ls -ltr  /system/etc/permissions/privapp-permissions-*.xml
  6. Edit the privapp-permissions-platform.xml file you just pulled and place the same XML from step 4 between the <permission> </permissions> tags. The file should look like this after this step.

    <?xml version="1.0" encoding="utf-8"?>
    <!--
    ...
    ...
    -->
    <permissions>
        <privapp-permissions package="...">
            <permission name="..." />
        </privapp-permissions>
    
        <privapp-permissions package="...">
            <permission name="..." />
        </privapp-permissions>
    
        ...
    
        <privapp-permissions package="...">
            <permission name="..." />
        </privapp-permissions>
    
        <privapp-permissions package="com.theappninjas.fakegpsjoystick">
            <permission name="android.permission.INTERNET"/>
            <permission name="android.permission.ACCESS_NETWORK_STATE"/>
            <permission name="android.permission.ACCESS_COARSE_LOCATION"/>
            <permission name="android.permission.ACCESS_FINE_LOCATION"/>
            <permission name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
            <permission name="android.permission.ACCESS_MOCK_LOCATION"/>
            <permission name="android.permission.SYSTEM_ALERT_WINDOW"/>
            <permission name="android.permission.INSTALL_LOCATION_PROVIDER"/>
            <permission name="android.permission.WRITE_SETTINGS"/>
            <permission name="android.permission.WRITE_SECURE_SETTINGS"/>
            <permission name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/>
            <permission name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
            <permission name="com.android.vending.BILLING"/>
            <permission name="android.permission.WAKE_LOCK"/>
            <permission name="com.google.android.c2dm.permission.RECEIVE"/>
            <permission name="com.theappninjas.fakegpsjoystick.permission.C2D_MESSAGE"/>
        </privapp-permissions>
    </permissions>
  7. Install GPS Joystick as a system app

    # push the modified permission file
    adb push privapp-permissions-platform.xml /sdcard/
    
    # enable ADB root
    adb root
    
    # enter ADB shell
    adb shell
    
    # remount the system partition with write permission
    mount -o remount,rw /system
    
    # create a directory for GPS Joystick with correct permission
    mkdir /system/priv-app/FakeGPSJoystick
    chown root:root /system/priv-app/FakeGPSJoystick
    chmod 755 /system/priv-app/FakeGPSJoystick
    
    # install GPS Joystick
    cd /system/priv-app/FakeGPSJoystick
    
    mv /sdcard/base.apk ./
    chown root:root base.apk
    chmod 644 base.apk
    
    cd /system/etc/permissions
    
    mv privapp-permissions-platform.xml privapp-permissions-platform.xml.bak
    mv /sdcard/privapp-permissions-platform.xml ./
    chown root:root privapp-permissions-platform.xml
    chmod 644 privapp-permissions-platform.xml
    
    mv /sdcard/privapp-permissions-com.theappninjas.fakegpsjoystick.xml ./
    chown root:root privapp-permissions-com.theappninjas.fakegpsjoystick.xml
    chmod 644 privapp-permissions-com.theappninjas.fakegpsjoystick.xml
    
    # remount the system partition with read-only permission
    mount -o remount,ro /system
    
    # exit
    exit
    adb unroot
  8. Reboot your phone and you should see GPS Joystick in your app drawer. Start the GPS Joystick and go to settings, make sure "Enable System Mode" is enabled (if you don't see this option, double check if you downloaded the UNLOCKED version from App Ninja).

  9. Enjoy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment