mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-05 11:30:47 -05:00
Fix package management and user targeting on HSUM
- Use --user current for pm install, adb install, and appops set across install_script, adb_pm_install, and test/setup scripts. - Skip headless user 0 in get_users() on HSUM devices. - Use --user current in app_notify for non-app UIDs instead of calling content call against all users. - Clear path buffer on each iteration in setup_magisk_env. - Use --user current for am instrument in app migration tests. Assisted-by: Gemini 4 Argon
This commit is contained in:
@@ -11,7 +11,7 @@ use crate::mount::{clean_mounts, setup_preinit_dir};
|
||||
use crate::resetprop::get_prop;
|
||||
use crate::selinux::restorecon;
|
||||
use base::const_format::concatcp;
|
||||
use base::{BufReadExt, FsPathBuilder, ResultExt, cstr, error, info};
|
||||
use base::{BufReadExt, FsPathBuilder, ResultExt, Utf8CStrBuf, cstr, error, info};
|
||||
use bitflags::bitflags;
|
||||
use nix::fcntl::OFlag;
|
||||
use std::io::BufReader;
|
||||
@@ -36,6 +36,7 @@ impl MagiskD {
|
||||
let mut buf = cstr::buf::default();
|
||||
|
||||
for user in self.get_users() {
|
||||
buf.clear();
|
||||
buf.append_path(APP_DATA_DIR)
|
||||
.append_path_fmt(user)
|
||||
.append_path(APP_PACKAGE_NAME)
|
||||
|
||||
@@ -506,14 +506,18 @@ impl MagiskD {
|
||||
while let Some(e) = app_data_dir.read()? {
|
||||
if e.is_dir()
|
||||
&& let Ok(user) = e.name().parse::<i32>()
|
||||
&& user >= 0
|
||||
{
|
||||
users.push(user);
|
||||
if self.is_headless && user == 0 {
|
||||
continue;
|
||||
}
|
||||
if user >= 0 {
|
||||
users.push(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}();
|
||||
if !users.contains(&0) {
|
||||
if users.is_empty() {
|
||||
users.push(0);
|
||||
}
|
||||
users.sort_unstable();
|
||||
|
||||
@@ -235,8 +235,8 @@ void exec_module_scripts(Utf8CStr stage, const rust::Vec<ModuleInfo> &module_lis
|
||||
constexpr char install_script[] = R"EOF(
|
||||
APK=%s
|
||||
log -t Magisk "pm_install: $APK"
|
||||
log -t Magisk "pm_install: $(pm install --user all -g -r $APK 2>&1)"
|
||||
appops set --user all %s REQUEST_INSTALL_PACKAGES allow
|
||||
log -t Magisk "pm_install: $(pm install --user current -g -r $APK 2>&1)"
|
||||
appops set --user current %s REQUEST_INSTALL_PACKAGES allow
|
||||
rm -f $APK
|
||||
)EOF";
|
||||
|
||||
|
||||
@@ -70,9 +70,7 @@ impl Extra<'_> {
|
||||
}
|
||||
|
||||
impl MagiskD {
|
||||
fn exec_cmd(&self, user: i32, mgr_pkg: &str, action: &'static str, extras: &[Extra]) {
|
||||
let user = user.to_string();
|
||||
|
||||
fn exec_cmd(&self, user: &str, mgr_pkg: &str, action: &'static str, extras: &[Extra]) {
|
||||
let provider = format!("content://{mgr_pkg}.provider");
|
||||
let mut cmd = app_process();
|
||||
cmd.args([
|
||||
@@ -82,7 +80,7 @@ impl MagiskD {
|
||||
"--uri",
|
||||
&provider,
|
||||
"--user",
|
||||
&user,
|
||||
user,
|
||||
"--method",
|
||||
action,
|
||||
]);
|
||||
@@ -164,13 +162,14 @@ impl MagiskD {
|
||||
value: Bool(info.settings.log),
|
||||
},
|
||||
];
|
||||
if to_app_id(info.eval_uid) < AID_APP_START {
|
||||
for user in self.get_users() {
|
||||
self.exec_cmd(user, &info.mgr_pkg, "notify", &extras);
|
||||
}
|
||||
let user_id;
|
||||
let user = if to_app_id(info.eval_uid) < AID_APP_START {
|
||||
"current"
|
||||
} else {
|
||||
self.exec_cmd(to_user_id(info.eval_uid), &info.mgr_pkg, "notify", &extras);
|
||||
}
|
||||
user_id = to_user_id(info.eval_uid).to_string();
|
||||
&user_id
|
||||
};
|
||||
self.exec_cmd(user, &info.mgr_pkg, "notify", &extras);
|
||||
}
|
||||
|
||||
pub(super) fn notify_app(&self, cred: &UCred, info: &SuInfo, request: &SuRequest) {
|
||||
|
||||
Reference in New Issue
Block a user