Skip to content

Commit

Permalink
v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
yukkerike committed Apr 22, 2024
1 parent e2ce935 commit 2cf60c2
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 41 deletions.
70 changes: 39 additions & 31 deletions customize.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,58 @@
set_perm_recursive $MODPATH 0 0 0755 0755
ui_print
floating_feature_path="/system/etc/floating_feature.xml"
floating_feature_key="SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE"

set_perm_recursive $MODPATH 0 0 0755 0755

print_done_message () {
ui_print "Requirements met, avoiding abortion."
ui_print "We won't patch XML right now, patch will apply during each boot."
ui_print "Reinstalling this module after firmware updates won't be needed."
installation_completed() {
ui_print
ui_print "Requirements met."
ui_print "The patch to $floating_feature_path"
ui_print "will be applied on each boot."
ui_print "No need for reinstall after firmware updates."
ui_print
ui_print "[DONE]"
exit 0
}

abort_installation() {
ui_print
ui_print "Installation process was cancelled."
touch $MODPATH/remove
exit 1
}

if [ -e $(magisk --path)/.magisk/modules/dex_feature_enabler/floating_feature.xml.patched ]; then
ui_print "Seems, it's not a fresh install."
ui_print "Seems like it's not a fresh install."
ui_print "Bypassing checks and inflating new files."
ui_print "If you're experiencing problems, try a clean install."
ui_print
print_done_message
exit 0
ui_print "If you're experiencing problems, try a fresh install."
installation_completed
fi

ui_print "Is /system/etc/floating_feature.xml in place?"
if [ ! -f /system/etc/floating_feature.xml ]; then
ui_print "[FAIL] Installation process was cancelled, this path seems not to exist: /system/etc/floating_feature.xml"
touch $MODPATH/remove
exit 1
ui_print "Is $floating_feature_path in place?"
if [ ! -f "$floating_feature_path" ]; then
ui_print "This file seems not to exist."
ui_print "Nothing to patch."
abort_installation
fi
ui_print "PASS"
ui_print

ui_print "Does it have SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE key?"
if ! grep -q SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE /system/etc/floating_feature.xml; then
ui_print "[UNSUPPORTED] Highly likely, Samsung DEX is unsupported on your platform,"
ui_print "or file can't be opened due to other related problems..."
ui_print "Installation process was cancelled."
touch $MODPATH/remove
exit 1
ui_print
ui_print "Does it have $floating_feature_key key?"
if ! grep -q $floating_feature_key "$floating_feature_path"; then
ui_print "[UNSUPPORTED] Highly likely, Samsung DeX"
ui_print "is unsupported on your device."
abort_installation
fi
ui_print "PASS"
ui_print

ui_print "Is standalone feature already enabled?"
if grep -q '<SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE>.*standalone.*</SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE>' /system/etc/floating_feature.xml; then
ui_print "[SKIP] Installation process was cancelled, due to persistance of 'standalone' feature flag.\nNo need for using this module!"
touch $MODPATH/remove
exit 1
ui_print
ui_print "Is the standalone feature already enabled?"
if grep -q "<$floating_feature_key>.*standalone.*</$floating_feature_key>" "$floating_feature_path"; then
ui_print "[SKIP] Standalone mode of Samsung DeX is already enabled."
ui_print "No need to use this module!"
abort_installation
fi
ui_print "PASS"
ui_print

print_done_message
installation_completed
4 changes: 2 additions & 2 deletions module.prop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id=dex_feature_enabler
name=DeX Feature Enabler
version=1.0
versionCode=1
version=1.1
versionCode=2
author=yukkerike
description=Patches floating_feature.xml to enable Samsung DeX mode on inner display.
updateJson=https://raw.githubusercontent.com/yukkerike/dex_feature_enabler/main/update.json
23 changes: 18 additions & 5 deletions post-fs-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@
MODDIR=${0%/*}
PATCHED_XML=$MODDIR/floating_feature.xml.patched
ORIGINAL_XML=/system/etc/floating_feature.xml
MODULE_PROP=$MODDIR/module.prop

sed '/<SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE>/s/, *standalone//; /<SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE>/s/<SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE>\(.*\)<\/SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE>/<SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE>\1,standalone<\/SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE>/' $ORIGINAL_XML > $PATCHED_XML
sed -i -E "s/description=(\[.+\] )?/description=/" $MODULE_PROP

chown root:root $PATCHED_XML
chmod 0644 $PATCHED_XML
chcon -v u:object_r:system_file:s0 $PATCHED_XML
set_success() {
sed -i "s/description=/description=\[DONE\] /" $MODULE_PROP
}

mount -o bind $PATCHED_XML $ORIGINAL_XML
set_failed() {
sed -i "s/description=/description=\[FAILED: $1\] /" $MODULE_PROP
}

sed "/<SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE>/s/, *standalone//; /<SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE>/s/<SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE>\(.*\)<\/SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE>/<SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE>\1,standalone<\/SEC_FLOATING_FEATURE_COMMON_CONFIG_DEX_MODE>/" $ORIGINAL_XML > $PATCHED_XML || set_failed patch

chown root:root $PATCHED_XML || set_failed chown
chmod 0644 $PATCHED_XML || set_failed chmod
chcon -v u:object_r:system_file:s0 $PATCHED_XML || set_failed chcon

mount -o bind $PATCHED_XML $ORIGINAL_XML || set_failed mount

grep -q "FAILED" $MODULE_PROP || set_success
6 changes: 3 additions & 3 deletions update.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "1.0",
"versionCode": "1",
"version": "1.1",
"versionCode": "2",
"changelog": "Initial release of DeX Feature Enabler.",
"zipUrl": "https://github.com/yukkerike/dex_feature_enabler/releases/download/latest/dex_feature_enabler.zip"
"zipUrl": "https://github.com/yukkerike/dex_feature_enabler/releases/latest/download/dex_feature_enabler.zip"
}

0 comments on commit 2cf60c2

Please sign in to comment.