Skip to content

Commit

Permalink
Upload v7.0-testing source files
Browse files Browse the repository at this point in the history
  • Loading branch information
InsertX2k authored Sep 2, 2024
1 parent e47b21b commit 79e42fa
Show file tree
Hide file tree
Showing 31 changed files with 25,591 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Config.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[ProgConfig]
version = 6.9.0
version = 7.0.0
rammappath = $DEFAULT
adwclrpath = $DEFAULT
winxpepath = $NONE
Expand Down
5 changes: 5 additions & 0 deletions android_cleaner/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
Initialization script
"""
if __name__ == '__main__':
pass
Binary file not shown.
Binary file not shown.
Binary file added android_cleaner/adb/AdbWinApi.dll
Binary file not shown.
Binary file added android_cleaner/adb/AdbWinUsbApi.dll
Binary file not shown.
21,208 changes: 21,208 additions & 0 deletions android_cleaner/adb/NOTICE.txt

Large diffs are not rendered by default.

Binary file added android_cleaner/adb/adb.exe
Binary file not shown.
Binary file added android_cleaner/adb/etc1tool.exe
Binary file not shown.
Binary file added android_cleaner/adb/fastboot.exe
Binary file not shown.
Binary file added android_cleaner/adb/hprof-conv.exe
Binary file not shown.
Binary file added android_cleaner/adb/libwinpthread-1.dll
Binary file not shown.
Binary file added android_cleaner/adb/make_f2fs.exe
Binary file not shown.
Binary file added android_cleaner/adb/make_f2fs_casefold.exe
Binary file not shown.
53 changes: 53 additions & 0 deletions android_cleaner/adb/mke2fs.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[defaults]
base_features = sparse_super,large_file,filetype,dir_index,ext_attr
default_mntopts = acl,user_xattr
enable_periodic_fsck = 0
blocksize = 4096
inode_size = 256
inode_ratio = 16384
reserved_ratio = 1.0

[fs_types]
ext3 = {
features = has_journal
}
ext4 = {
features = has_journal,extent,huge_file,dir_nlink,extra_isize,uninit_bg
inode_size = 256
}
ext4dev = {
features = has_journal,extent,huge_file,flex_bg,inline_data,64bit,dir_nlink,extra_isize
inode_size = 256
options = test_fs=1
}
small = {
blocksize = 1024
inode_size = 128
inode_ratio = 4096
}
floppy = {
blocksize = 1024
inode_size = 128
inode_ratio = 8192
}
big = {
inode_ratio = 32768
}
huge = {
inode_ratio = 65536
}
news = {
inode_ratio = 4096
}
largefile = {
inode_ratio = 1048576
blocksize = -1
}
largefile4 = {
inode_ratio = 4194304
blocksize = -1
}
hurd = {
blocksize = 4096
inode_size = 128
}
Binary file added android_cleaner/adb/mke2fs.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions android_cleaner/adb/source.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Pkg.UserSrc=false
Pkg.Revision=35.0.1
Binary file added android_cleaner/adb/sqlite3.exe
Binary file not shown.
192 changes: 192 additions & 0 deletions android_cleaner/adb_processor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
"""
Provides normal functions for ADB USB Connectivity to Android smartphones for Temp_Cleaner GUI's Android 7.x+ phones Cleaner.
Copyright (C) 2024 - Ziad Ahmed (Mr.X)
ADB (Android Debug Bridge) is a product of Google, inc. for Android and Android Studio, and is not owned nor is copyrighted by the owner of Temp_Cleaner GUI.
"""
# imports
import os, sys
from subprocess import getoutput
from time import sleep
# initializing a variable containing the path where program executable is stored.
application_path = ''

# a quick check whether if program is a compiled bundle by pyinstaller or a simple python file.
if getattr(sys, 'frozen', False):
# pyinstaller creates a sys attribute frozen=True during startup of pyinstaller bootloader to indicate
# that pyinstaller has compiled (frozen) this program, then it creates a sys constant _MEIPASS containing the path
# where the executable is found.
application_path = f"{sys._MEIPASS}\\android_cleaner"
else: # if program is running as a python script via python terminal
application_path = os.path.dirname(os.path.abspath(__file__))

print(f"[DEBUG]: connection_window module located at: {application_path}")
# fixes for translations module outside of cwd.
sys.path.append(f"{application_path}\\..")
# adb executable path.
adb_exe_path = f'"{application_path}\\adb\\adb.exe"'

def requestADBConnection():
"""
Requests an ADB Connection to the currently connected Android smartphone.
Returns the output of the ADB connection command.
"""
global adb_exe_path
adb_connection_cmd_out = getoutput(f"{adb_exe_path} usb")
return adb_connection_cmd_out

def killADBDaemon():
"""
Requests to kill the currently running ADB Daemon
Returns the output of the kill ADB Daemon command
"""
global adb_exe_path
adb_kill_daemon_cmd = getoutput(f"{adb_exe_path} kill-server")
return adb_kill_daemon_cmd

def listADBDevices():
"""
Returns a list containing all devices connected in USB Debugging mode.
"""
global adb_exe_path
dummy_words = ["daemon", "List", "attached", "started", "successfully", "starting"]
real_devs = []


adb_devices_output = getoutput(f"{adb_exe_path} devices")
adb_devices_output = adb_devices_output.splitlines()
pas = 0
for output in adb_devices_output:
for word in output.split():
if word in dummy_words:
pas = 1
break
if pas == 1:
pas = 0
continue
else:
real_devs.append(output)

# adb_devices_output = adb_devices_output[len(adb_devices_output) -1]
return real_devs

def needToShowInstructionsWindow():
"""
This function returns a boolean, indicating whether the application needs to show the user the instructions
for a proper ADB USB Connection or no.
True means yes, False means No
"""
dev_list = listADBDevices()
if len(dev_list) == 0: # no devices attached
print("[DEBUG] No devices attached that supports ADB Communication.")
return True
else: # we need to check for unauthorization
print("[DEBUG] Found devices that run ADB services.")
for dev in dev_list:
if "unauthorized" in dev:
print(f"[DEBUG]: device:{dev} looks unauthorized")
return True
else:
pass
print("[DEBUG]: Everything seems okay, no need to display anything to user.")
return False

def isMoreThanOneDeviceConnected():
"""
Checks the list of currently supported ADB Devices connected to this PC and returns whether
they are more than one device or no.
True if yes, False if no.
"""
devs_count = len(listADBDevices())
if devs_count == 0:
return False
elif devs_count == 1:
return False
else:
return True
return False


def cleanCachesViaADB(deviceName:str=None) -> str:
"""
The function for clearing all caches stored by 3rd party and system apps on the connected android device.
If multiple devices are connected, you need to pass each device SN as an argument to this function
If no arguments are passed, it will clean the currently connected device.
"""
global adb_exe_path
device_arg = ''

if deviceName == None:
deviceName = ''
device_arg = ''
else:
deviceName = deviceName
device_arg = f"-s {deviceName}"


userpkg_list = []
output_str = ''

for package in getoutput(f"{adb_exe_path} {device_arg} shell pm list packages -3").split("\n"):
pkg = package.replace("package:",'')
userpkg_list.append(pkg)
print(f"query user packages list: \n{userpkg_list}")
output_str = output_str + "\nqueried user packages list"

for package in userpkg_list:
pkgclr = getoutput(f"{adb_exe_path} {device_arg} shell am force-stop {package}")
print(f"[DEBUG]: package: '{package}' has been force stopped!\n{pkgclr}")
output_str = output_str + f"\npackage: {package} has been force stopped!"
print("[DEBUG]: force stopping all user packages has been completed!\n\n")
output_str = output_str + "\nForce stopping all user packages is completed!"

trc = getoutput(f"{adb_exe_path} {device_arg} shell pm trim-caches 10000G")
print(f"trim-caches 10000G command finished with output:\n{trc}\n\n")
output_str = output_str + f"\n[INFO]: Clean caches command finished with output: {trc}\n"

return output_str

def startADBDaemon():
"""
Starts ADB Daemon
Returns the output of the command.
"""
global adb_exe_path
out = getoutput(f"{adb_exe_path} start-server")
return out

def connectViaWiFiDebugging(ip_addr_and_port: str, auth_code=None):
"""
Connects to Android 11+ smartphone via Wi-Fi debugging, if auth_code is given, will request pairing first from adb daemon.
This function returns the output of the adb commands given.
"""
global adb_exe_path
startADBDaemon()
if auth_code == None or auth_code == '': # no pairing is needed.
out = getoutput(f"{adb_exe_path} connect {ip_addr_and_port}")
return out
else: # pairing is needed.
out = getoutput(f"{adb_exe_path} pair {ip_addr_and_port} {auth_code}")

sleep(7) # sleep for 7 seconds between pairing and connecting.
_combine_to_out = getoutput(f"{adb_exe_path} connect {ip_addr_and_port}")
out = out + _combine_to_out

return out

if __name__ == '__main__':
# killADBDaemon()
# requestADBConnection()

# print(f"{listADBDevices()}, len:{len(listADBDevices())}")
# print(needToShowInstructionsWindow())
# print(cleanCachesViaADB())
pass
Binary file added android_cleaner/connect_usb.ico
Binary file not shown.
Binary file added android_cleaner/connect_via_wifi_adb.ico
Binary file not shown.
Loading

0 comments on commit 79e42fa

Please sign in to comment.