Skip to content

Commit 9aefa4b

Browse files
committed
Module status fix 😎
Fixed module status keep getting bigger
1 parent 156e600 commit 9aefa4b

File tree

3 files changed

+88
-31
lines changed

3 files changed

+88
-31
lines changed

β€Žmodule.prop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
id=samsung-dex-standalone-mode
22
name=Samsung DeX standalone mode
3-
version=2024.1
4-
versionCode=1
3+
version=2024.2
4+
versionCode=2
55
author=supermarsx
66
description=Patch `floating_feature.xml` to enable Samsung Dex standalone mode, available on devices supporting at least one Dex mode.
77
updateJson=https://raw.githubusercontent.com/supermarsx/magisk-samsung-dex-standalone-mode/main/update.json

β€Žpost-fs-data.sh

Lines changed: 83 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,21 @@ file_is_property_clean() {
151151
fi
152152
}
153153

154-
# file_set_property_direct()
155-
# Set property of a give properties file directly without checks
154+
# file_set_property()
155+
# Set property of a given properties file directly without checks
156156
#
157-
# %usage: file_set_property_direct filepath property value
157+
# %usage: file_set_property filepath property value
158158
# $parameters
159159
# filepath - Path to file
160160
# property - Property to change
161161
# value - Value to set property to
162-
file_set_property_direct() {
163-
fspd_filepath="$1"
164-
fspd_property="$2"
165-
fspd_value="$3"
162+
file_set_property() {
163+
fsp_filepath="$1"
164+
fsp_property="$2"
165+
fsp_value="$3"
166166

167-
echo " [INFO] Setting file '$fspd_filepath' property '$fspd_property' value '$fspd_value' directly now." >> "$logfile"
168-
if sed -i -E "s/$fspd_property=/&$fspd_value/" "$fspd_filepath"
167+
echo " [INFO] Setting file '$fsp_filepath' property '$fsp_property' value '$fsp_value' directly now." >> "$logfile"
168+
if sed -i -E "s/$fsp_property=.^$/$fsp_property=$fsp_value/" "$fsp_filepath"
169169
then
170170
echo " [INFO] File property was set successfully." >> "$logfile"
171171
else
@@ -174,25 +174,82 @@ file_set_property_direct() {
174174
fi
175175
}
176176

177-
# file_set_property()
178-
# Set property of a given properties file
177+
# file_set_property_wrapper()
178+
# Set property of a given properties file with all the checks
179179
#
180-
# %usage: file_set_property filepath property value
180+
# %usage: file_set_property_wrapper filepath property value
181181
# $parameters
182182
# filepath - Path to file
183183
# property - Property to change
184184
# value - Value to set property to
185-
file_set_property() {
186-
fsp_filepath="$1"
187-
fsp_property="$2"
188-
fsp_value="$3"
185+
file_set_property_wrapper() {
186+
fspw_filepath="$1"
187+
fspw_property="$2"
188+
fspw_value="$3"
189+
190+
echo " [INFO] Setting file '$fspw_filepath' property '$fspw_property' value '$fspw_value'." >> "$logfile"
191+
if filepath_exists "$fspw_filepath"; then
192+
file_clear_property "$fspw_filepath" "$fspw_property"
193+
if file_is_property_clean "$fspw_filepath" "$fspw_property"; then
194+
if is_empty "$fspw_value"; then
195+
file_set_property "$fspw_filepath" "$fspw_property" "$fspw_value"
196+
return 0
197+
else
198+
echo " [INFO] No value was set due to parameters." >> "$logfile"
199+
return 0
200+
fi
201+
else
202+
return 1
203+
fi
204+
else
205+
error_add "fileexists"
206+
echo " [ERR!] File '$fspw_filepath' doesn't exist." >> "$logfile"
207+
return 1
208+
fi
209+
}
189210

190-
echo " [INFO] Setting file '$fsp_filepath' property '$fsp_property' value '$fsp_value'." >> "$logfile"
191-
if filepath_exists "$fsp_filepath"; then
192-
file_clear_property "$fsp_filepath" "$fsp_property"
193-
if file_is_property_clean "$fsp_filepath" "$fsp_property"; then
194-
if is_empty "$fsp_value"; then
195-
file_set_property_direct "$fsp_filepath" "$fsp_property" "$fsp_value"
211+
# file_prepend_value_to_property()
212+
# Prepend value to property of a given properties file directly without checks
213+
#
214+
# %usage: file_prepend_value_to_property filepath property value
215+
# $parameters
216+
# filepath - Path to file
217+
# property - Property to change
218+
# value - Value to prepend to property
219+
file_prepend_value_to_property() {
220+
favtp_filepath="$1"
221+
favtp_property="$2"
222+
favtp_value="$3"
223+
224+
echo " [INFO] Setting file '$favtp_filepath' property '$favtp_property' value '$favtp_value' directly now." >> "$logfile"
225+
if sed -i -E "s/$favtp_property=/&$fsp_value/" "$fsp_filepath"
226+
then
227+
echo " [INFO] File property was set successfully." >> "$logfile"
228+
else
229+
error_add "sed.setprop"
230+
echo " [ERR!] File property set failed." >> "$logfile"
231+
fi
232+
}
233+
234+
# file_prepend_value_to_property_wrapper()
235+
# Prepend value to property of a given properties file with all the checks
236+
#
237+
# %usage: file_prepend_value_to_property_wrapper filepath property value
238+
# $parameters
239+
# filepath - Path to file
240+
# property - Property to change
241+
# value - Value to prepend to property
242+
file_prepend_value_to_property_wrapper() {
243+
favtpw_filepath="$1"
244+
favtpw_property="$2"
245+
favtpw_value="$3"
246+
247+
echo " [INFO] Setting file '$favtpw_filepath' property '$favtpw_property' value '$favtpw_value'." >> "$logfile"
248+
if filepath_exists "$favtpw_filepath"; then
249+
file_clear_property "$favtpw_filepath" "$favtpw_property"
250+
if file_is_property_clean "$favtpw_filepath" "$favtpw_property"; then
251+
if is_empty "$favtpw_value"; then
252+
file_prepend_value_to_property "$favtpw_filepath" "$fspw_property" "$favtpw_value"
196253
return 0
197254
else
198255
echo " [INFO] No value was set due to parameters." >> "$logfile"
@@ -203,7 +260,7 @@ file_set_property() {
203260
fi
204261
else
205262
error_add "fileexists"
206-
echo " [ERR!] File '$fsp_filepath' doesn't exist." >> "$logfile"
263+
echo " [ERR!] File '$favtpw_filepath' doesn't exist." >> "$logfile"
207264
return 1
208265
fi
209266
}
@@ -219,7 +276,7 @@ module_set_message() {
219276
msm_property="description"
220277
msm_value="$1"
221278

222-
file_set_property "$msm_filepath" "$msm_property" "$msm_value"
279+
file_set_property_wrapper "$msm_filepath" "$msm_property" "$msm_value"
223280
}
224281

225282
# file_remove_xml_key_value()
@@ -389,9 +446,9 @@ mount_file() {
389446
module_set_status() {
390447
echo " [INFO] Setting module status."
391448
if [ "$error_count" -gt 0 ]; then
392-
module_set_message "βš οΈβ— [WARN/ERROR] - Failed to set standalone mode with ($error_count) error(s): $error_message ||| "
449+
module_set_message "βš οΈβ— [WARN/ERROR] - Failed to set standalone mode with ($error_count) error(s): $error_message."
393450
else
394-
module_set_message "βœ… [OK] - Samsung DeX standalone mode set ||| "
451+
module_set_message "βœ… [OK] - Samsung DeX standalone mode set"
395452
fi
396453
}
397454

β€Župdate.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"version": "2024.1",
3-
"versionCode": "1",
2+
"version": "2024.2",
3+
"versionCode": "2",
44
"zipUrl": "https://github.com/supermarsx/magisk-samsung-dex-standalone-mode/releases/latest/download/magisk-samsung-dex-standalone-mode.zip",
5-
"changelog": "Samsung DeX standalone mode, initial release."
5+
"changelog": "Module status bug fix."
66
}

0 commit comments

Comments
Β (0)