diff --git a/.gitignore b/.gitignore index 8c890b1..6272542 100644 --- a/.gitignore +++ b/.gitignore @@ -104,3 +104,4 @@ venv.bak/ # mypy .mypy_cache/ +test.py \ No newline at end of file diff --git a/main.py b/main.py index 729bd18..2f5d5e6 100644 --- a/main.py +++ b/main.py @@ -5,59 +5,75 @@ from stuffs.gapps import Gapps from stuffs.houdini import Houdini from stuffs.magisk import Magisk from stuffs.ndk import Ndk +from stuffs.smartdock import Smartdock from stuffs.widevine import Widevine import tools.helper as helper - - -def main(): - about = """ - WayDroid Helper script v0.3 - Does stuff like installing Gapps, Installing NDK Translation and getting Android ID for device registration. - Use -h flag for help ! - """ - parser = argparse.ArgumentParser(description=about, formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument('-g', '--install-gapps', - dest='gapps', - help='Install OpenGapps to waydroid', - action='store_true') - parser.add_argument('-n', '--install-ndk-translation', - dest='ndk', - help='Install libndk translation for arm translation', - action='store_true') - parser.add_argument('-i', '--get-android-id', dest='getid', - help='Displays your android id for manual registration', - action='store_true') - parser.add_argument('-m', '--install-magisk', dest='magisk', - help='Attempts to install Magisk ( Bootless )', - action='store_true') - parser.add_argument('-l', '--install-libhoudini', dest='houdini', - help='Install libhoudini for arm translation', - action='store_true') - parser.add_argument('-w', '--install-widevine', dest='widevine', - help='Integrate Widevine DRM (L3)', - action='store_true') - args = parser.parse_args() - helper.check_root() - if args.getid: - Android_id().get_id() - if args.gapps: +def install(*args): + if "gapps" in args: Gapps().install() - if args.ndk and not args.houdini: + if "libndk" in args and "houdini" not in args: arch = helper.host()[0] if arch == "x86_64": Ndk().install() else: Logger.warn("libndk is not supported on your CPU") - if args.houdini and not args.ndk: + if "libhoudini" in args and "ndk" not in args: arch = helper.host()[0] if arch == "x86_64": Houdini().install() else: Logger.warn("libhoudini is not supported on your CPU") - if args.magisk: + if "magisk" in args: Magisk().install() - if args.widevine: + if "widevine" in args: Widevine().install() + if "smartdock" in args : + Smartdock().install() + +def uninstall(*args): + pass + +def main(): + about = """ + WayDroid Helper script v0.3 + Does stuff like installing Gapps, installing Magisk, installing NDK Translation and getting Android ID for device registration. + Use -h flag for help! + """ + helper.check_root() + + parser = argparse.ArgumentParser(prog=about) + parser.set_defaults(app="") + + subparsers = parser.add_subparsers(title="subcommands", help="operations") + + google_id_parser=subparsers.add_parser('google', + help='grab device id for unblocking Google Apps') + google_id_parser.set_defaults(func=Android_id().get_id) + # create the parser for the "a" command + + arg_template = { + "dest": "app", + "type": str, + "nargs": '+', + "choices": ["gapps", "libndk","libhoudini","magisk", "smartdock","widevine"], + } + + install_parser = subparsers.add_parser("install", help='install something') + install_parser.set_defaults(func=install) + install_parser.add_argument(**arg_template) + + uninstall_parser = subparsers.add_parser("uninstall", help='uninstall something') + uninstall_parser.set_defaults(func=uninstall) + uninstall_parser.add_argument(**arg_template) + + args = parser.parse_args() + + if args.app: + args.func(*args.app) + else: + args.func() + + if __name__ == "__main__": main() diff --git a/stuffs/android_id.py b/stuffs/android_id.py index 4d52d10..444f8f1 100644 --- a/stuffs/android_id.py +++ b/stuffs/android_id.py @@ -15,4 +15,4 @@ class Android_id: queryout = run(["sqlite3", "/var/lib/waydroid/data/data/com.google.android.gsf/databases/gservices.db", sqs.strip()]) print(queryout.stdout.decode().replace("android_id|", "").strip()) print(" ^----- Open https://google.com/android/uncertified/?pli=1") - print(" Login with your google id then submit the form with id shown above") \ No newline at end of file + print(" Login with your google id then submit the form with id shown above") diff --git a/stuffs/gapps.py b/stuffs/gapps.py index 49457a1..87410b8 100644 --- a/stuffs/gapps.py +++ b/stuffs/gapps.py @@ -27,10 +27,6 @@ class Gapps(General): "setupwizardtablet-x86_64.tar.lz" ] - def download(self): - Logger.info("Downloading OpenGapps now to {} .....".format(self.download_loc)) - super().download() - def copy(self): if not os.path.exists(self.extract_to): os.makedirs(self.extract_to) @@ -56,4 +52,4 @@ class Gapps(General): app_name = os.listdir(os.path.join(self.extract_to, "appunpack"))[0] common_content_dirs = os.listdir(os.path.join(self.extract_to, "appunpack", app_name, "common")) for ccdir in common_content_dirs: - shutil.copytree(os.path.join(self.extract_to, "appunpack", app_name, "common", ccdir), os.path.join(self.copy_dir, self.partition, ccdir), dirs_exist_ok=True) \ No newline at end of file + shutil.copytree(os.path.join(self.extract_to, "appunpack", app_name, "common", ccdir), os.path.join(self.copy_dir, self.partition, ccdir), dirs_exist_ok=True) diff --git a/stuffs/general.py b/stuffs/general.py index 441da30..72d8bbe 100644 --- a/stuffs/general.py +++ b/stuffs/general.py @@ -9,6 +9,10 @@ from tools.container import DBusContainerService from tools.logger import Logger class General: + @property + def skip_extract(self): + return False + @property def download_loc(self): return os.path.join(get_download_dir(), self.dl_file_name) @@ -37,6 +41,7 @@ class General: return False def download(self): + Logger.info("Downloading {} now to {} .....".format(self.dl_file_name, self.download_loc)) loc_md5 = "" if os.path.isfile(self.download_loc): with open(self.download_loc, "rb") as f: @@ -113,21 +118,28 @@ class General: def copy(self): pass + def extra(self): + pass + def install(self): if self.use_overlayfs: self.download() - self.extract() + if not self.skip_extract: + self.extract() self.copy() + self.extra() if hasattr(self, "apply_props"): self.add_props() self.restart() else: self.stop() self.download() - self.extract() + if not self.skip_extract: + self.extract() self.resize() self.mount() self.copy() + self.extra() if hasattr(self, "apply_props"): self.add_props() self.umount() diff --git a/stuffs/houdini.py b/stuffs/houdini.py index 0ac7db2..b784bc0 100644 --- a/stuffs/houdini.py +++ b/stuffs/houdini.py @@ -32,10 +32,6 @@ on property:ro.enable.native.bridge.exec=1 "ro.dalvik.vm.isa.arm64": "x86_64" } - def download(self): - Logger.info("Downloading libhoudini to {}now .....".format(self.download_loc)) - super().download() - def copy(self): run(["chmod", "+x", self.extract_to, "-R"]) Logger.info("Copying libhoudini library files ...") diff --git a/stuffs/magisk.py b/stuffs/magisk.py index 3b918d7..3750342 100644 --- a/stuffs/magisk.py +++ b/stuffs/magisk.py @@ -86,4 +86,4 @@ on property:init.svc.zygote=stopped with gzip.open(gz_filename,'wb') as f_gz: f_gz.write(self.oringinal_bootanim.encode('utf-8')) with open(bootanim_path, "w") as initfile: - initfile.write(self.oringinal_bootanim+self.bootanim_component) \ No newline at end of file + initfile.write(self.oringinal_bootanim+self.bootanim_component) diff --git a/stuffs/ndk.py b/stuffs/ndk.py index 2854133..3c0ced7 100644 --- a/stuffs/ndk.py +++ b/stuffs/ndk.py @@ -31,10 +31,6 @@ on property:ro.enable.native.bridge.exec=1 copy /system/etc/binfmt_misc/arm64_exe /proc/sys/fs/binfmt_misc/register copy /system/etc/binfmt_misc/arm64_dyn /proc/sys/fs/binfmt_misc/register """ - - def download(self): - Logger.info("Downloading libndk to {} now .....".format(self.download_loc)) - super().download() def copy(self): run(["chmod", "+x", self.extract_to, "-R"]) @@ -54,4 +50,4 @@ on property:ro.enable.native.bridge.exec=1 if not path.isfile(init_path): makedirs(path.dirname(init_path), exist_ok=True) with open(init_path, "w") as initfile: - initfile.write(self.init_rc_component) \ No newline at end of file + initfile.write(self.init_rc_component) diff --git a/stuffs/smartdock.py b/stuffs/smartdock.py new file mode 100644 index 0000000..4b21e15 --- /dev/null +++ b/stuffs/smartdock.py @@ -0,0 +1,21 @@ +import os +import shutil +from stuffs.general import General + +class Smartdock(General): + dl_link = "https://github.com/ayasa520/smartdock/releases/download/v1.9.6/smartdock.zip" + partition = "system" + extract_to = "/tmp/smartdockunpack" + dl_file_name = "smartdock.zip" + act_md5 = "ad0cc5e023ac6ee97e7b013b9b0defee" + + def copy(self): + if not os.path.exists(os.path.join(self.copy_dir, self.partition, "priv-app", "SmartDock")): + os.makedirs(os.path.join(self.copy_dir, self.partition, "priv-app", "SmartDock")) + shutil.copyfile(os.path.join(self.extract_to, "app-release.apk"), + os.path.join(self.copy_dir, self.partition, "priv-app", "SmartDock", "smartdock.apk")) + shutil.copyfile(os.path.join(self.extract_to, "permissions_cu.axel.smartdock.xml"), + os.path.join(self.copy_dir, self.partition, "etc", "permissions", "permissions_cu.axel.smartdock.xml")) + + def extra(self): + return super().extra() diff --git a/stuffs/widevine.py b/stuffs/widevine.py index 58899f3..7da3dda 100644 --- a/stuffs/widevine.py +++ b/stuffs/widevine.py @@ -12,12 +12,8 @@ class Widevine(General): extract_to = "/tmp/widevineunpack" act_md5 = "a31f325453c5d239c21ecab8cfdbd878" - def download(self): - Logger.info("Downloading widevine to {} now .....".format(self.download_loc)) - super().download() - def copy(self): run(["chmod", "+x", self.extract_to, "-R"]) Logger.info("Copying widevine library files ...") shutil.copytree(os.path.join(self.extract_to, "vendor_google_proprietary_widevine-prebuilt-94c9ee172e3d78fecc81863f50a59e3646f7a2bd", - "prebuilts"), os.path.join(self.copy_dir, self.partition), dirs_exist_ok=True) \ No newline at end of file + "prebuilts"), os.path.join(self.copy_dir, self.partition), dirs_exist_ok=True) diff --git a/tools/images.py b/tools/images.py index eb7f0d2..b626c37 100644 --- a/tools/images.py +++ b/tools/images.py @@ -44,4 +44,4 @@ def get_image_dir(): if "waydroid" not in cfg: Logger.error("ERROR: Required entry in config was not found, Cannot continue!") #magisk sys.exit(1) - return cfg["waydroid"]["images_path"] \ No newline at end of file + return cfg["waydroid"]["images_path"]