waydroid_script/stuff/nodataperm.py

54 lines
1.8 KiB
Python
Raw Normal View History

2023-01-26 07:23:50 -08:00
import gzip
import os
import shutil
2023-05-04 07:51:32 -07:00
from stuff.general import General
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"
2023-04-29 10:36:05 -07:00
dl_links = {
"11": ["https://github.com/ayasa520/hack_full_data_permission/archive/refs/heads/main.zip",
"eafd7b0986f3edaebaf1dd89f19d49bf"],
"13": ["", ""]
}
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())
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)