DivestOS/Scripts/LineageOS-11.0/Patch.sh
2017-11-06 15:34:40 -05:00

96 lines
3.7 KiB
Bash
Executable File

#!/bin/bash
#DivestOS: A privacy oriented Android distribution
#Copyright (c) 2017 Spot Communications, Inc.
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <https://www.gnu.org/licenses/>.
#Delete Everything and Sync
#repo forall -c 'git add -A && git reset --hard' && rm -rf out && repo sync -j20 --force-sync
#Apply all of our changes
#source ../../Scripts/LineageOS-11.0/00init.sh && source $scripts/Patch.sh && source $scripts/Deblob.sh && source $scripts/Patch_CVE.sh && source build/envsetup.sh
#Build!
#brunch lineage_nex-userdebug
#
#START OF PREPRATION
#
enter() {
echo "================================================================================================"
dir=$1;
cd $base$dir;
echo "[ENTERING] "$dir;
git add -A && git reset --hard;
}
enhanceLocation() {
cd $base$1;
#Enable GLONASS
sed -i 's/#A_GLONASS_POS_PROTOCOL_SELECT/A_GLONASS_POS_PROTOCOL_SELECT/' gps.conf gps/gps.conf configs/gps.conf &>/dev/null || true;
sed -i 's/A_GLONASS_POS_PROTOCOL_SELECT = 0.*/A_GLONASS_POS_PROTOCOL_SELECT = 15/' gps.conf gps/gps.conf configs/gps.conf &>/dev/null || true;
sed -i 's|A_GLONASS_POS_PROTOCOL_SELECT=0.*</item>|A_GLONASS_POS_PROTOCOL_SELECT=15</item>|' overlay/frameworks/base/core/res/res/values-*/*.xml &>/dev/null || true;
#Recommended reading: https://wwws.nightwatchcybersecurity.com/2016/12/05/cve-2016-5341/
#XTRA: Only use specified URLs
sed -i 's|XTRA_SERVER_QUERY=1|XTRA_SERVER_QUERY=0|' gps.conf gps/gps.conf configs/gps.conf &>/dev/null || true;
sed -i 's|#XTRA_SERVER|XTRA_SERVER|' gps.conf gps/gps.conf configs/gps.conf &>/dev/null || true;
#XTRA: Enable HTTPS
sed -i 's|http://xtra|https://xtra|' overlay/frameworks/base/core/res/res/values-*/*.xml gps.conf gps/gps.conf configs/gps.conf &>/dev/null || true;
#XTRA: Use format version 3 if possible
if grep -sq "XTRA_VERSION_CHECK" gps.conf gps/gps.conf configs/gps.conf; then #Using hardware/qcom/gps OR precompiled blob OR device specific implementation
sed -i 's|XTRA_VERSION_CHECK=0|XTRA_VERSION_CHECK=1|' gps.conf gps/gps.conf configs/gps.conf &>/dev/null || true;
sed -i 's|xtra2.bin|xtra3grc.bin|' gps.conf gps/gps.conf configs/gps.conf &>/dev/null || true;
elif grep -sq "BOARD_VENDOR_QCOM_LOC_PDK_FEATURE_SET := true" BoardConfig.mk boards/*gps.mk; then
if ! grep -sq "USE_DEVICE_SPECIFIC_LOC_API := true" BoardConfig.mk boards/*gps.mk; then
if ! grep -sq "libloc" *proprietary*.txt; then #Using hardware/qcom/gps
sed -i 's|xtra2.bin|xtra3grc.bin|' gps.conf gps/gps.conf configs/gps.conf &>/dev/null || true;
fi;
fi;
fi;
echo "Enhanced location services for $1";
cd $base;
}
export -f enhanceLocation;
#
#END OF PREPRATION
#
#
#START OF ROM CHANGES
#
#None
#
#END OF ROM CHANGES
#
#
#START OF DEVICE CHANGES
#
enter "device/zte/nex"
enableDexPreOpt
patch -p1 < $patches"android_device_zte_nex/Fixes.patch"
patch -p1 < $patches"android_device_zte_nex/Lower_DPI.patch"
enter "kernel/zte/msm8930"
patch -p1 < $patches"android_kernel_zte_msm8930/MDP-Fix.patch"
patch -p1 < $patches"android_kernel_zte_msm8930/Timeconst-Fix.patch"
#Make changes to all devices
cd $base
find "device" -maxdepth 2 -mindepth 2 -type d -exec bash -c 'enhanceLocation "$0"' {} \;
cd $base
#
#END OF DEVICE CHANGES
#