waydroid_script/stuff/nodataperm.py

72 lines
2.5 KiB
Python
Raw Permalink Normal View History

import os
import re
import shutil
2023-05-04 07:51:32 -07:00
from stuff.general import General
from tools.helper import backup, restore
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":
{
"x86_64": [
"https://github.com/ayasa520/hack_full_data_permission/archive/d4beab7780eb792059d33e77d865579c9ee41546.zip",
"b0e3908ffcf5df8ea62f4929aa680f1a"
],
},
"13": {}
2023-04-29 10:36:05 -07:00
}
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",
"framework/services.jar.prof",
"framework/services.jar.bprof",
2023-04-29 08:00:42 -07:00
]
def __init__(self, android_version="11") -> None:
super().__init__()
print("ok")
arch = self.arch[0]
self.dl_link = self.dl_links[android_version][arch][0]
self.act_md5 = self.dl_links[android_version][arch][1]
def copy(self):
name = re.findall("([a-zA-Z0-9]+)\.zip", self.dl_link)[0]
2023-04-29 08:00:42 -07:00
extract_path = os.path.join(
self.extract_to, f"hack_full_data_permission-{name}")
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")
services_jar_prof = os.path.join(
self.copy_dir, self.partition, "framework", "services.jar.prof")
services_jar_bprof = os.path.join(
self.copy_dir, self.partition, "framework", "services.jar.bprof")
backup(services_jar)
backup(services_jar_prof)
backup(services_jar_bprof)
Logger.info(f"Copying {self.id} 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")
services_jar_prof = os.path.join(
self.copy_dir, self.partition, "framework", "services.jar.prof")
services_jar_bprof = os.path.join(
self.copy_dir, self.partition, "framework", "services.jar.bprof")
restore(services_jar)
restore(services_jar_prof)
restore(services_jar_bprof)