Initial commit.
This commit is contained in:
37
.gitignore
vendored
37
.gitignore
vendored
@@ -2,40 +2,5 @@
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Linker files
|
||||
*.ilk
|
||||
|
||||
# Debugger Files
|
||||
*.pdb
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
# debug information files
|
||||
*.dwo
|
||||
*.zip
|
||||
|
||||
20
CMakeLists.txt
Normal file
20
CMakeLists.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
# Copyright 2025 Yağız Zengin
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(disable_watchdog VERSION 1.0)
|
||||
|
||||
add_executable(disable_watchdog disable_watchdog.cpp)
|
||||
target_link_libraries(disable_watchdog PRIVATE log)
|
||||
88
build.sh
Normal file
88
build.sh
Normal file
@@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2025 Yağız Zengin
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
BUILD_64="build_arm64-v8a"
|
||||
BUILD_32="build_armeabi-v7a"
|
||||
THIS="$(basename $0)"
|
||||
|
||||
echo()
|
||||
{
|
||||
command echo "[$THIS]: $@"
|
||||
}
|
||||
|
||||
checks()
|
||||
{
|
||||
if [ -z "$ANDROID_NDK" ]; then
|
||||
echo "Please set ANDROID_NDK variable as your NDK path."
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f /usr/bin/cmake ] && [ ! -f /bin/cmake ]; then
|
||||
echo "Please verify your CMake installation."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
clean()
|
||||
{
|
||||
echo "Cleaning workspace."
|
||||
rm -rf $BUILD_32 $BUILD_64
|
||||
}
|
||||
|
||||
build()
|
||||
{
|
||||
mkdir -p $BUILD_64 $BUILD_32
|
||||
command echo -e "BUILD INFO:
|
||||
ARCHS: arm64-v8a armeabi-v7a
|
||||
ANDROID_PLATFORM: android-21 (android 5.0)
|
||||
ANDROID_TOOLCHAIN_FILE: $ANDROID_NDK/build/cmake/android.toolchain.cmake\n"
|
||||
|
||||
echo "Configuring for arm64-v8a..."
|
||||
cmake -B $BUILD_64 -S . \
|
||||
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
|
||||
-DANDROID_ABI=arm64-v8a \
|
||||
-DANDROID_PLATFORM=android-21
|
||||
|
||||
echo "Configuring for armeabi-v7a..."
|
||||
cmake -B $BUILD_32 -S . \
|
||||
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
|
||||
-DANDROID_ABI=armeabi-v7a \
|
||||
-DANDROID_PLATFORM=android-21
|
||||
|
||||
echo "Building arm64-v8a artifacts..."
|
||||
cmake --build $BUILD_64
|
||||
echo "arm64-v8a build complete, artifacts: $PWD/$BUILD_64"
|
||||
|
||||
echo "Building armeabi-v7a artifacts..."
|
||||
cmake --build $BUILD_32
|
||||
echo "armeabi-v7a build complete, artifacts: $PWD/$BUILD_32"
|
||||
}
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
command echo "Usage: $0 build|rebuild|clean"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
"build") checks; build ;;
|
||||
"clean") clean ;;
|
||||
"rebuild") clean; checks; build ;;
|
||||
*)
|
||||
command echo "$0: Unknown argument: $1"
|
||||
exit 1 ;;
|
||||
esac
|
||||
77
disable_watchdog.cpp
Normal file
77
disable_watchdog.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
Copyright 2025 Yağız Zengin
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
#define LOG_TAG "disable_watchdog"
|
||||
#include <android/log.h>
|
||||
#include <android/log_macros.h>
|
||||
|
||||
bool suspendWatchdog(std::list<const char*> files)
|
||||
{
|
||||
bool suspendOk = false;
|
||||
|
||||
for (const auto& file : files) {
|
||||
int fd = open(file, O_WRONLY);
|
||||
if (fd == -1) {
|
||||
if (errno == ENOENT) {
|
||||
int last = errno;
|
||||
fd = open(file, O_WRONLY | O_CREAT, 644);
|
||||
if (fd == -1) {
|
||||
ALOGW("Cannot create %s: %s\n", file, strerror(errno));
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
ALOGW("Cannot open %s: %s\n", file, strerror(errno));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
char ch = 'V';
|
||||
if (write(fd, &ch, 1) != 1) {
|
||||
ALOGW("Cannot write %s: %s\n", file, strerror(errno));
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
|
||||
suspendOk = true;
|
||||
ALOGI("%s: successfully suspended.\n", file);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
return suspendOk;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
ALOGI("Service started.\n");
|
||||
|
||||
while (1) {
|
||||
if (!suspendWatchdog({"/dev/watchdog1", "/dev/watchdog0", "/dev/watchdog"})) {
|
||||
ALOGE("watchdog suspend fail!\n");
|
||||
break;
|
||||
}
|
||||
sleep(8);
|
||||
}
|
||||
|
||||
ALOGI("Service stopped!\n");
|
||||
return 1;
|
||||
}
|
||||
109
mkmod.sh
Normal file
109
mkmod.sh
Normal file
@@ -0,0 +1,109 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2025 Yağız Zengin
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
BUILD_64="build_arm64-v8a"
|
||||
BUILD_32="build_armeabi-v7a"
|
||||
MOD="watchdog_disabler_$(date +%Y-%M-%d).zip"
|
||||
THIS="$(basename $0)"
|
||||
|
||||
echo() { command echo "[$THIS]: $@"; }
|
||||
|
||||
clean()
|
||||
{
|
||||
rm -rf $MOD \
|
||||
$PWD/module/system/bin/disable_watchdog \
|
||||
$PWD/module/customize.sh
|
||||
touch $PWD/module/system/bin/placeholder
|
||||
}
|
||||
|
||||
prepare()
|
||||
{
|
||||
if [ ! -d $BUILD_32 ] || [ ! -d $BUILD_64 ]; then
|
||||
echo "Missing artifacts. Please build!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f /usr/bin/zip ] && [ ! -f /bin/zip ]; then
|
||||
echo "Please verify your Zip installation!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f $MOD ]; then rm $MOD; fi
|
||||
}
|
||||
|
||||
mk_customize()
|
||||
{
|
||||
if [ $1 -eq 32 ]; then
|
||||
cat <<EOF
|
||||
#!/system/bin/sh
|
||||
|
||||
if ! getprop ro.product.cpu.abi | grep armeabi-v7a &>/dev/null; then
|
||||
echo "This module is compatible with 32-bit devices. Your device running a 64-bit system!"
|
||||
exit 1
|
||||
fi
|
||||
EOF
|
||||
elif [ $1 -eq 64 ]; then
|
||||
cat <<EOF
|
||||
#!/system/bin/sh
|
||||
|
||||
if ! getprop ro.product.cpu.abi | grep arm64-v8a &>/dev/null; then
|
||||
echo "This module is compatible with 64-bit devices. Your device running a 32-bit system!"
|
||||
exit 1
|
||||
fi
|
||||
EOF
|
||||
else
|
||||
cat <<EOF
|
||||
#!/system/bin/sh
|
||||
|
||||
echo "This module not generated correctly. Not usable. Re-generate with mkmod.sh. See https://github.com/YZBruh/watchdog_disabler"
|
||||
exit 1
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
mkzip()
|
||||
{
|
||||
local dir
|
||||
if [ $1 -eq 32 ]; then dir=$BUILD_32; else dir=$BUILD_64; fi
|
||||
|
||||
cd module
|
||||
rm -f $PWD/system/bin/placeholder $PWD/system/bin/disable_watchdog
|
||||
mk_customize $1 > $PWD/customize.sh
|
||||
chmod 755 $PWD/customize.sh
|
||||
cp $dir/disable_watchdog $PWD/system/bin
|
||||
zip -rq $MOD *
|
||||
mv $MOD ..
|
||||
cd ..
|
||||
|
||||
echo "Created module package for $1-bit."
|
||||
}
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
command echo "Usage: $0 32|64|clean"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
"32") prepare; mkzip 32 ;;
|
||||
"64") prepare; mkzip 64 ;;
|
||||
"clean") clean ;;
|
||||
*)
|
||||
command echo "$0: Unknown argument: $1"
|
||||
exit 1 ;;
|
||||
esac
|
||||
33
module/META-INF/com/google/android/update-binary
Normal file
33
module/META-INF/com/google/android/update-binary
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/sbin/sh
|
||||
|
||||
#################
|
||||
# Initialization
|
||||
#################
|
||||
|
||||
umask 022
|
||||
|
||||
# echo before loading util_functions
|
||||
ui_print() { echo "$1"; }
|
||||
|
||||
require_new_magisk() {
|
||||
ui_print "*******************************"
|
||||
ui_print " Please install Magisk v20.4+! "
|
||||
ui_print "*******************************"
|
||||
exit 1
|
||||
}
|
||||
|
||||
#########################
|
||||
# Load util_functions.sh
|
||||
#########################
|
||||
|
||||
OUTFD=$2
|
||||
ZIPFILE=$3
|
||||
|
||||
mount /data 2>/dev/null
|
||||
|
||||
[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
|
||||
. /data/adb/magisk/util_functions.sh
|
||||
[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk
|
||||
|
||||
install_module
|
||||
exit 0
|
||||
1
module/META-INF/com/google/android/updater-script
Normal file
1
module/META-INF/com/google/android/updater-script
Normal file
@@ -0,0 +1 @@
|
||||
#MAGISK
|
||||
6
module/module.prop
Normal file
6
module/module.prop
Normal file
@@ -0,0 +1,6 @@
|
||||
id=watchdog_fix
|
||||
name=Watchdog Fix
|
||||
author=YZBruh
|
||||
version=v1.0
|
||||
versionCode=1
|
||||
description=Disables watchdog
|
||||
3
module/service.sh
Normal file
3
module/service.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
suspend_watchdog &
|
||||
0
module/system/bin/placeholder
Normal file
0
module/system/bin/placeholder
Normal file
Reference in New Issue
Block a user