waydroid_script/stuffs/nodataperm.py

56 lines
2 KiB
Python
Raw Normal View History

2023-01-26 07:23:50 -08:00
import gzip
import os
import shutil
from stuffs.general import General
from tools.helper import run
from tools.logger import Logger
2023-01-26 07:23:50 -08:00
from tools import container
2023-04-29 08:00:42 -07:00
class Nodataperm(General):
2023-04-29 08:00:42 -07:00
id = "nodataperm"
dl_links = {"11": ["https://github.com/ayasa520/hack_full_data_permission/archive/refs/heads/main.zip",
"eafd7b0986f3edaebaf1dd89f19d49bf"]}
dl_file_name = "nodataperm.zip"
extract_to = "/tmp/nodataperm"
2023-04-29 08:00:42 -07:00
dl_link = ...
act_md5 = ...
partition = "system"
2023-01-26 07:23:50 -08:00
files = [
2023-04-29 08:00:42 -07:00
"etc/nodataperm.sh",
"etc/init/nodataperm.rc",
"framework/services.jar"
]
def __init__(self, android_version="11") -> None:
super().__init__()
self.dl_link = self.dl_links[android_version][0]
self.act_md5 = self.dl_links[android_version][1]
def copy(self):
2023-04-29 08:00:42 -07:00
extract_path = os.path.join(
self.extract_to, "hack_full_data_permission-main")
2023-01-26 07:23:50 -08:00
if not container.use_overlayfs():
2023-04-29 08:00:42 -07:00
services_jar = os.path.join(
self.copy_dir, self.partition, "framework", "services.jar")
2023-01-26 07:23:50 -08:00
gz_filename = services_jar+".gz"
2023-04-29 08:00:42 -07:00
with gzip.open(gz_filename, 'wb') as f_gz:
2023-01-26 07:23:50 -08:00
with open(services_jar, "rb") as f:
f_gz.write(f.read())
os.chmod(os.path.join(extract_path, "framework", "services.jar"), 0o644)
os.chmod(os.path.join(extract_path, "etc", "nodataperm.sh"), 0o755)
2023-04-29 08:00:42 -07:00
os.chmod(os.path.join(extract_path, "etc",
"init", "nodataperm.rc"), 0o755)
Logger.info("Copying widevine library files ...")
2023-04-29 08:00:42 -07:00
shutil.copytree(extract_path, os.path.join(
self.copy_dir, self.partition), dirs_exist_ok=True)
2023-01-26 07:23:50 -08:00
2023-04-29 08:00:42 -07:00
def extra2(self):
if not container.use_overlayfs():
services_jar = os.path.join(
self.copy_dir, self.partition, "framework", "services.jar")
gz_filename = services_jar+".gz"
2023-01-26 07:23:50 -08:00
with gzip.GzipFile(gz_filename) as f_gz:
with open(services_jar, "wb") as f:
f.writelines(f_gz)