Skip to content

Commit fa170bd

Browse files
MarqleMarqle
authored andcommitted
zsh adapt && remote unused permissions
1 parent 6099467 commit fa170bd

5 files changed

Lines changed: 80 additions & 48 deletions

File tree

‎src/apps/vcoder/entry/src/main/ets/entryability/EntryAbility.ets‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export default class EntryAbility extends RustAbility {
126126
});
127127
setTimeout(() => {
128128
windowStage.getMainWindow((err, data) => {
129-
data.setWindowDecorHeight(32)
129+
data.setWindowDecorHeight(44)
130130
data.setWindowDecorVisible(false);
131131
})
132132
}, 40)

‎src/apps/vcoder/entry/src/main/module.json5‎

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,45 +34,15 @@
3434
}
3535
],
3636
"requestPermissions": [
37-
{
38-
"name": "ohos.permission.PREPARE_APP_TERMINATE"
39-
},
4037
{
4138
"name": "ohos.permission.INTERNET"
4239
},
43-
// {
44-
// "name": "ohos.permission.GET_ALL_PROCESSES"
45-
// },
4640
{
4741
"name": "ohos.permission.READ_WRITE_USER_FILE"
4842
},
49-
// {
50-
// "name": "ohos.permission.SECURE_PASTE"
51-
// },
5243
{
5344
"name": "ohos.permission.CUSTOM_SANDBOX"
5445
},
55-
// {
56-
// "name": "ohos.permission.MANAGE_USER_IDM"
57-
// },
58-
// {
59-
// "name": "ohos.permission.ACCESS_PIN_AUTH"
60-
// },
61-
// {
62-
// "name": "ohos.permission.ACCESS_USER_AUTH_INTERNAL"
63-
// },
64-
// {
65-
// "name": "ohos.permission.DUMP"
66-
// },
67-
// {
68-
// "name": "ohos.permission.READ_DIAGNOSTIC_LOGS"
69-
// },
70-
// {
71-
// "name": "ohos.permission.READ_DFX_SYSEVENT"
72-
// },
73-
// {
74-
// "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
75-
// },
7646
{
7747
"name": "ohos.permission.READ_CALENDAR",
7848
"reason": "$string:module_desc",
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
{
2-
"string": [
3-
{
4-
"name": "module_desc",
5-
"value": "module description"
6-
},
7-
{
8-
"name": "EntryAbility_desc",
9-
"value": "description"
10-
},
11-
{
12-
"name": "EntryAbility_label",
13-
"value": "label"
14-
}
15-
]
2+
"string": [{
3+
"name": "module_desc",
4+
"value": "module description"
5+
},
6+
{
7+
"name": "EntryAbility_desc",
8+
"value": "description"
9+
},
10+
{
11+
"name": "EntryAbility_label",
12+
"value": "Bitfun"
13+
}
14+
]
1615
}

‎src/crates/core/src/service/terminal/src/shell/detection.rs‎

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,22 @@ impl ShellDetector {
8282

8383
#[cfg(not(windows))]
8484
{
85-
if let Some(bash_path) = Self::find_bash_with_which() {
85+
if let Some(zsh_path) = Self::find_zsh_with_which() {
86+
return DetectedShell {
87+
shell_type: ShellType::Zsh,
88+
path: zsh_path.clone(),
89+
version: Self::get_shell_version(zsh_path.to_str().unwrap_or_default()),
90+
display_name: "zsh".to_string(),
91+
};
92+
} else if let Some(bash_path) = Self::find_bash_with_which() {
8693
return DetectedShell {
8794
shell_type: ShellType::Bash,
8895
path: bash_path.clone(),
8996
version: Self::get_shell_version(bash_path.to_str().unwrap_or_default()),
9097
display_name: "bash".to_string(),
9198
};
92-
} else {
99+
}
100+
{
93101
log::error!("bash not found");
94102
}
95103
// Try to use $SHELL environment variable
@@ -313,6 +321,35 @@ impl ShellDetector {
313321
None
314322
}
315323

324+
#[cfg(not(windows))]
325+
fn find_zsh_with_which() -> Option<PathBuf> {
326+
let output = std::process::Command::new("which").arg("zsh").output();
327+
match output {
328+
Ok(output) => {
329+
if output.status.success() {
330+
let path_str = String::from_utf8_lossy(&output.stdout).trim().to_string();
331+
if !path_str.is_empty() {
332+
let path = PathBuf::from(path_str);
333+
if path.exists() {
334+
return Some(path);
335+
} else {
336+
log::warn!("zsh path not exist");
337+
}
338+
} else {
339+
log::warn!("zsh not exist");
340+
}
341+
} else {
342+
let stderr = String::from_utf8_lossy(&output.stderr);
343+
log::error!("which zsh error: {}", stderr.trim());
344+
}
345+
}
346+
Err(e) => {
347+
log::error!("which zsh error: {}", e);
348+
}
349+
};
350+
None
351+
}
352+
316353
#[cfg(not(windows))]
317354
fn find_bash_with_which() -> Option<PathBuf> {
318355
let output = std::process::Command::new("which").arg("bash").output();

‎src/crates/core/src/service/terminal/src/shell/scripts/shellIntegration-rc.zsh‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
11
# ---------------------------------------------------------------------------------------------
22
# Shell Integration for Zsh
33
# ---------------------------------------------------------------------------------------------
4-
builtin autoload -Uz add-zsh-hook is-at-least
4+
5+
add-zsh-hook() {
6+
local hook_name = "$1"
7+
local func_name = "$2"
8+
local -a hook_array
9+
10+
case "${hook_name}" in
11+
precmd)
12+
hook_array=("${(@)}precmd_functions[@]}")
13+
precmd_functions+=("${func_name}")
14+
;;
15+
preexec)
16+
preexec_functions+=("${func_name}")
17+
;;
18+
*)
19+
return 1
20+
;;
21+
esac
22+
}
23+
24+
if ! builtin type is-at-least >/dev/null 2>&1' then
25+
is-at-least() {
26+
local required="$1"
27+
local current="${ZSH_VERSION}"
28+
[[ "${current}" == $(echo -e "${required}\n${current}" sort -v | head -n1) ]]
29+
}
30+
fi
531
632
# Prevent the script recursing when setting up
733
if [ -n "$TERMINAL_SHELL_INTEGRATION" ]; then

0 commit comments

Comments
 (0)