Merge "system mount: unmount system after checking for TWRP app" into android-9.0
diff --git a/Android.mk b/Android.mk
index 1bb421a..26a5227 100755
--- a/Android.mk
+++ b/Android.mk
@@ -151,7 +151,7 @@
LOCAL_SHARED_LIBRARIES += libcrypto
endif
-ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0)
+ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 23; echo $$?),0)
LOCAL_SHARED_LIBRARIES += libbase
endif
@@ -333,6 +333,9 @@
endif
ifneq ($(TW_CRYPTO_USE_SYSTEM_VOLD),)
ifneq ($(TW_CRYPTO_USE_SYSTEM_VOLD),false)
+ ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0)
+ TW_INCLUDE_LIBRESETPROP := true
+ endif
LOCAL_CFLAGS += -DTW_CRYPTO_USE_SYSTEM_VOLD
LOCAL_STATIC_LIBRARIES += libvolddecrypt
endif
@@ -398,6 +401,20 @@
ifneq ($(TW_CLOCK_OFFSET),)
LOCAL_CFLAGS += -DTW_CLOCK_OFFSET=$(TW_CLOCK_OFFSET)
endif
+ifneq ($(TW_OVERRIDE_SYSTEM_PROPS),)
+ TW_INCLUDE_LIBRESETPROP := true
+ LOCAL_CFLAGS += -DTW_OVERRIDE_SYSTEM_PROPS=$(TW_OVERRIDE_SYSTEM_PROPS)
+endif
+ifneq ($(TW_INCLUDE_LIBRESETPROP),)
+ ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0)
+ $(warning libresetprop is not available for android < 7)
+ else
+ LOCAL_SHARED_LIBRARIES += libresetprop
+ LOCAL_C_INCLUDES += external/magisk-prebuilt/include
+ LOCAL_CFLAGS += -DTW_INCLUDE_LIBRESETPROP
+ endif
+endif
+
TWRP_REQUIRED_MODULES += \
dump_image \
erase_image \
@@ -517,15 +534,10 @@
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0)
TWRP_REQUIRED_MODULES += ld.config.txt
- ifeq ($(BOARD_VNDK_RUNTIME_DISABLE),true)
- LOCAL_POST_INSTALL_CMD += \
- sed 's/\(namespace.default.search.paths\)\s\{1,\}=/namespace.default.search.paths = \/sbin\n\1 +=/' \
- $(TARGET_OUT_ETC)/ld.config.vndk_lite.txt > $(TARGET_RECOVERY_ROOT_OUT)/sbin/ld.config.txt;
- else
- LOCAL_POST_INSTALL_CMD += \
- sed 's/\(namespace.default.search.paths\)\s\{1,\}=/namespace.default.search.paths = \/sbin\n\1 +=/' \
- $(TARGET_OUT_ETC)/ld.config.txt > $(TARGET_RECOVERY_ROOT_OUT)/sbin/ld.config.txt;
- endif
+ TWRP_REQUIRED_MODULES += init.recovery.ldconfig.rc
+ LOCAL_POST_INSTALL_CMD += \
+ sed 's/\(namespace.default.search.paths\)\s\{1,\}=/namespace.default.search.paths = \/sbin\n\1 +=/' \
+ $(TARGET_OUT_ETC)/ld.config*.txt > $(TARGET_RECOVERY_ROOT_OUT)/sbin/ld.config.txt;
endif
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 25; echo $$?),0)
diff --git a/crypto/vold_decrypt/Android.mk b/crypto/vold_decrypt/Android.mk
index 860e61f..dc302ad 100644
--- a/crypto/vold_decrypt/Android.mk
+++ b/crypto/vold_decrypt/Android.mk
@@ -107,6 +107,12 @@
endif
endif
+ ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0)
+ ifeq ($(TW_INCLUDE_LIBRESETPROP), true)
+ LOCAL_CFLAGS += -DTW_INCLUDE_LIBRESETPROP
+ endif
+ endif
+
LOCAL_SRC_FILES = vold_decrypt.cpp
LOCAL_SHARED_LIBRARIES := libcutils
include $(BUILD_STATIC_LIBRARY)
diff --git a/crypto/vold_decrypt/vold_decrypt.cpp b/crypto/vold_decrypt/vold_decrypt.cpp
old mode 100644
new mode 100755
index ac872ea..078cd5f
--- a/crypto/vold_decrypt/vold_decrypt.cpp
+++ b/crypto/vold_decrypt/vold_decrypt.cpp
@@ -780,6 +780,128 @@
property_set("vendor.sys.listeners.registered", "false");
}
+void Update_Patch_Level(void) {
+ // On Oreo and above, keymaster requires Android version & patch level to match installed system
+ string sdkverstr = TWFunc::System_Property_Get("ro.build.version.sdk");
+ if (!sdkverstr.empty()) {
+ sdkver = atoi(sdkverstr.c_str());
+ }
+ if (sdkver <= 25) {
+ property_set("vold_decrypt.legacy_system", "true");
+ } else {
+ LOGINFO("Current system is Oreo or above. Setting OS version and security patch level from installed system...\n");
+ property_set("vold_decrypt.legacy_system", "false");
+ }
+
+ char prop_value[PROPERTY_VALUE_MAX];
+ char legacy_system_value[PROPERTY_VALUE_MAX] = "false";
+ property_get("vold_decrypt.legacy_system", prop_value, "");
+
+ // Only set OS ver and patch level if device uses Oreo+ system
+ if (strcmp(prop_value, legacy_system_value) == 0) {
+ property_get("ro.build.version.release", prop_value, "");
+ std::string osver_orig = prop_value;
+ property_set("vold_decrypt.osver_orig", osver_orig.c_str());
+ LOGINFO("Current OS version: %s\n", osver_orig.c_str());
+
+ int error = 0;
+ std::string osver = TWFunc::System_Property_Get("ro.build.version.release");
+ if (!(osver == osver_orig)) {
+ if (!(error = TWFunc::Property_Override("ro.build.version.release", osver))) {
+ LOGINFO("Property override successful! New OS version: %s\n", osver.c_str());
+ } else {
+ LOGERROR("Property override failed, code %d\n", error);
+ return;
+ }
+ // TODO: Confirm whether we actually need to update the props in prop.default
+ std::string sed_osver = "sed -i 's/ro.build.version.release=.*/ro.build.version.release=" + osver + "/g' /prop.default";
+ TWFunc::Exec_Cmd(sed_osver);
+ property_set("vold_decrypt.osver_set", "true");
+ } else {
+ LOGINFO("Current OS version & System OS version already match. Proceeding to next step.\n");
+ property_set("vold_decrypt.osver_set", "false");
+ }
+
+ property_get("ro.build.version.security_patch", prop_value, "");
+ std::string patchlevel_orig = prop_value;
+ property_set("vold_decrypt.patchlevel_orig", patchlevel_orig.c_str());
+ LOGINFO("Current security patch level: %s\n", patchlevel_orig.c_str());
+
+ std::string patchlevel = TWFunc::System_Property_Get("ro.build.version.security_patch");
+ if (!(patchlevel == patchlevel_orig)) {
+ if (!(error = TWFunc::Property_Override("ro.build.version.security_patch", patchlevel))) {
+ LOGINFO("Property override successful! New security patch level: %s\n", patchlevel.c_str());
+ } else {
+ LOGERROR("Property override failed, code %d\n", error);
+ return;
+ }
+ // TODO: Confirm whether we actually need to update the props in prop.default
+ std::string sed_patchlevel = "sed -i 's/ro.build.version.security_patch=.*/ro.build.version.security_patch=" + patchlevel + "/g' /prop.default";
+ TWFunc::Exec_Cmd(sed_patchlevel);
+ property_set("vold_decrypt.patchlevel_set", "true");
+ } else {
+ LOGINFO("Current security patch level & System security patch level already match. Proceeding to next step.\n");
+ property_set("vold_decrypt.patchlevel_set", "false");
+ }
+ return;
+ } else {
+ LOGINFO("Current system is Nougat or older. Skipping OS version and security patch level setting...\n");
+ return;
+ }
+}
+
+void Revert_Patch_Level(void) {
+ char osver_set[PROPERTY_VALUE_MAX];
+ char patchlevel_set[PROPERTY_VALUE_MAX];
+ char osver_patchlevel_set[PROPERTY_VALUE_MAX] = "false";
+
+ property_get("vold_decrypt.osver_set", osver_set, "");
+ property_get("vold_decrypt.patchlevel_set", patchlevel_set, "");
+
+ int osver_result = strcmp(osver_set, osver_patchlevel_set);
+ int patchlevel_result = strcmp(patchlevel_set, osver_patchlevel_set);
+ if (!(osver_result == 0 && patchlevel_result == 0)) {
+ char prop_value[PROPERTY_VALUE_MAX];
+ LOGINFO("Reverting OS version and security patch level to original TWRP values...\n");
+ property_get("vold_decrypt.osver_orig", prop_value, "");
+ std::string osver_orig = prop_value;
+ property_get("ro.build.version.release", prop_value, "");
+ std::string osver = prop_value;
+
+ int error = 0;
+ if (!(osver == osver_orig)) {
+ if (!(error = TWFunc::Property_Override("ro.build.version.release", osver_orig))) {
+ LOGINFO("Property override successful! Original OS version: %s\n", osver_orig.c_str());
+ } else {
+ LOGERROR("Property override failed, code %d\n", error);
+ return;
+ }
+ // TODO: Confirm whether we actually need to update the props in prop.default
+ std::string sed_osver_orig = "sed -i 's/ro.build.version.release=.*/ro.build.version.release=" + osver_orig + "/g' /prop.default";
+ TWFunc::Exec_Cmd(sed_osver_orig);
+ }
+
+ property_get("vold_decrypt.patchlevel_orig", prop_value, "");
+ std::string patchlevel_orig = prop_value;
+ property_get("ro.build.version.security_patch", prop_value, "");
+ std::string patchlevel = prop_value;
+
+ if (!(patchlevel == patchlevel_orig)) {
+ if (!(error = TWFunc::Property_Override("ro.build.version.security_patch", patchlevel_orig))) {
+ LOGINFO("Property override successful! Original security patch level: %s\n", patchlevel_orig.c_str());
+ } else {
+ LOGERROR("Property override failed, code %d\n", error);
+ return;
+ }
+ // TODO: Confirm whether we actually need to update the props in prop.default
+ std::string sed_patchlevel_orig = "sed -i 's/ro.build.version.security_patch=.*/ro.build.version.security_patch=" + patchlevel_orig + "/g' /prop.default";
+ TWFunc::Exec_Cmd(sed_patchlevel_orig);
+ }
+ } else {
+ return;
+ }
+}
+
static unsigned int get_blkdev_size(int fd) {
unsigned long nr_sec;
@@ -1161,6 +1283,9 @@
Symlink_Firmware_Files(is_vendor_symlinked, is_firmware_symlinked);
Set_Needed_Properties();
+#ifdef TW_INCLUDE_LIBRESETPROP
+ Update_Patch_Level();
+#endif
// Start services needed for vold decrypt
LOGINFO("Starting services...\n");
@@ -1225,7 +1350,9 @@
LOGINFO("Failed to start vold\n");
res = VD_ERR_VOLD_FAILED_TO_START;
}
-
+#ifdef TW_INCLUDE_LIBRESETPROP
+ Revert_Patch_Level();
+#endif
// Stop services needed for vold decrypt so /system can be unmounted
LOGINFO("Stopping services...\n");
Stop_Service("sys_vold");
diff --git a/data.cpp b/data.cpp
index 088dbda..b1e8404 100755
--- a/data.cpp
+++ b/data.cpp
@@ -783,6 +783,7 @@
#else
mPersist.SetValue(TW_NO_SHA2, "1");
#endif
+ mPersist.SetValue(TW_UNMOUNT_SYSTEM, "1");
#ifdef TW_NO_SCREEN_TIMEOUT
mConst.SetValue("tw_screen_timeout_secs", "0");
diff --git a/etc/init.rc b/etc/init.rc
index e0889c4..fc32bb8 100644
--- a/etc/init.rc
+++ b/etc/init.rc
@@ -17,6 +17,10 @@
# Set the security context of /postinstall if present.
restorecon /postinstall
+ # ueventd wants to write to /acct
+ mount cgroup none /acct cpuacct
+ mkdir /acct/uid
+
start ueventd
service set_permissive /sbin/permissive.sh
@@ -31,9 +35,6 @@
export ANDROID_DATA /data
export EXTERNAL_STORAGE /sdcard
- mount cgroup none /acct cpuacct
- mkdir /acct/uid
-
mkdir /system
mkdir /data
mkdir /cache
diff --git a/gui/theme/common/landscape.xml b/gui/theme/common/landscape.xml
index 8244c46..230b72f 100755
--- a/gui/theme/common/landscape.xml
+++ b/gui/theme/common/landscape.xml
@@ -2937,6 +2937,9 @@
<condition var1="tw_no_sha2" var2="0"/>
<data variable="tw_use_sha2"/>
</listitem>
+ <listitem name="{@unmount_sys_install=Unmount System before installing a ZIP}">
+ <data variable="tw_unmount_system"/>
+ </listitem>
</listbox>
<checkbox>
diff --git a/gui/theme/common/languages/en.xml b/gui/theme/common/languages/en.xml
index 4a0ac7f..3769da5 100755
--- a/gui/theme/common/languages/en.xml
+++ b/gui/theme/common/languages/en.xml
@@ -719,5 +719,8 @@
<string name="include_kernel_log">Include Kernel Log</string>
<string name="sha2_chk">Use SHA2 for hashing</string>
<string name="unable_set_boot_slot">Error changing bootloader boot slot to {1}</string>
+ <string name="unmount_sys_install">Unmount System before installing a ZIP</string>
+ <string name="unmount_system">Unmounting System...</string>
+ <string name="unmount_system_err">Failed unmounting System</string>
</resources>
</language>
diff --git a/gui/theme/common/languages/tr.xml b/gui/theme/common/languages/tr.xml
index 8e924cb..d86d494 100644
--- a/gui/theme/common/languages/tr.xml
+++ b/gui/theme/common/languages/tr.xml
@@ -98,16 +98,19 @@
<string name="successful">Başarılı</string>
<string name="install_failed">Yükleme Başarısız</string>
<string name="install_successful">Yükleme Başarılı</string>
- <string name="wipe_cache_dalvik_btn">Cache/dalvik temizle</string>
+ <string name="wipe_cache_dalvik_btn">Önbellek/Dalvik Temizle</string>
+ <string name="wipe_dalvik_btn">Dalvik Temizle</string>
<string name="reboot_system_btn">Sistemi Yeniden Başlat</string>
<string name="install_sel_target">Hedef Bölümü Seç</string>
- <string name="flash_image_select">İmajı Flashlamak için Bölüm Seç:</string>
+ <string name="flash_image_select">İmajı Flashlamak için Bölüm Seçin:</string>
<string name="target_partition">Hedef Bölüm:</string>
<string name="flashing_image">İmaj Flashlanıyor...</string>
<string name="image_flashed">İmaj Flashlandı</string>
<string name="wipe_cache_dalvik_confirm">Önbellek ve Dalvik temizlensin mi?</string>
+ <string name="wipe_dalvik_confirm">Dalvik temizlensin mi?</string>
<string name="wiping_cache_dalvik">Önbellek ve Dalvik temizleniyor...</string>
<string name="wipe_cache_dalvik_complete">Önbellek ve Dalvik temizliği tamamlandı</string>
+ <string name="wipe_dalvik_complete">Dalvik Temizliği Tamamlandı</string>
<string name="swipe_wipe">Temizlemek için Kaydır</string>
<string name="swipe_wipe_s"> Temizle</string>
<string name="no_os1">İşletim Sistemi yüklü değil!</string>
@@ -119,9 +122,13 @@
<string name="reboot_install_app_hdr">TWRP Uygulaması yüklensin mi?</string>
<string name="reboot_install_app1">Resmi TWRP Uygulamasını yüklemek ister misiniz?</string>
<string name="reboot_install_app2">Uygulama, yeni TWRP sürümlerini kontrol edebilir.</string>
- <string name="reboot_install_app_prompt_install">Yüklü değilse, TWRP uygulamasını yüklemek için sor</string>
+ <string name="reboot_install_app_prompt_install">Yüklü değilse TWRP uygulamasını yüklemeyi sor</string>
<string name="reboot_install_app_system">Sistem Uygulaması olarak yükle</string>
<string name="reboot_installing_app">Uygulama yükleniyor...</string>
+ <string name="uninstall_twrp_system_app">TWRP Uygulamasını Sistemden kaldır</string>
+ <string name="uninstall_twrp_system_app_confirm">TWRP Uygulaması Sistemden kaldırılsın mı?</string>
+ <string name="uninstalling_twrp_system_app">TWRP Uygulaması Sistemden kaldırılıyor...</string>
+ <string name="uninstall_twrp_system_app_complete">TWRP Uygulamasını Sistemden Kaldırma Tamamlandı</string>
<string name="swipe_to_install_app">TWRP Uygulamasını yüklemek için kaydır</string>
<string name="swipe_flash">Flashlamayı onaylamak için kaydır</string>
<string name="confirm_action">Eylemi Onayla</string>
@@ -130,7 +137,7 @@
<string name="wipe_hdr">Temizle</string>
<string name="factory_reset_hdr">Sıfırla</string>
<string name="factory_reset_btn">Sıfırla</string>
- <string name="factory_reset1">Veriyi, Önbelleği, ve Dalvik'i temizler</string>
+ <string name="factory_reset1">Veriyi, Önbelleği ve Dalvik'i temizler</string>
<string name="factory_reset2">(dahili depolama hariç)</string>
<string name="factory_reset3">Çoğu zaman ihtiyacınız olan</string>
<string name="factory_reset4">tek temizlik budur.</string>
@@ -151,10 +158,10 @@
<string name="format_data_hdr">Veriyi Biçimlendir</string>
<string name="format_data_btn">Veriyi Biçimlendir</string>
<string name="format_data_ptr1">Veriyi biçimlendirmek tüm uygulamalarınızı,</string>
- <string name="format_data_ptr2">yedeklerinizi, resimlerinizi, videolarınızı, medyanızı, temizleyecek ve</string>
+ <string name="format_data_ptr2">yedeklerinizi, resimlerinizi, videolarınızı, medyanızı temizleyecek ve</string>
<string name="format_data_ptr3">dahili depolama üzerindeki şifrelemeyi kaldıracak.</string>
<string name="format_data_adopted">Kabul Edilen Depolama Dahil</string>
- <string name="format_data_lcp1">Veriyi biçimlendirmek tüm uygulamalarınızı, yedeklerinizi, resimlerinizi, videolarınızı, medyanızı, temizleyecek ve</string>
+ <string name="format_data_lcp1">Veriyi biçimlendirmek tüm uygulamalarınızı, yedeklerinizi, resimlerinizi, videolarınızı, medyanızı temizleyecek ve</string>
<string name="format_data_lcp2">dahili depolama üzerindeki şifrelemeyi kaldıracak.</string>
<string name="format_data_wtc1">Veriyi biçimlendirmek tüm uygulamalarınızı,</string>
<string name="format_data_wtc2">yedeklerinizi ve medyanızı temizleyecek. Bu işlem geri alınamaz.</string>
@@ -211,13 +218,13 @@
<string name="encryption_tab">ŞİFRELEME</string>
<string name="encryption">Şifreleme:</string>
<string name="name">Ad:</string>
- <string name="sel_part_backup">Yedeklenecek Bölümleri Seç:</string>
+ <string name="sel_part_backup">Yedeklenecek Bölümleri Seçin:</string>
<string name="storage">Depolama:</string>
<string name="enc_disabled">devre dışı - etkinleştirmek için bir şifre ayarlayın</string>
<string name="enc_enabled">etkin</string>
<string name="enable_backup_comp_chk">Sıkıştırmayı etkinleştir</string>
<string name="skip_digest_backup_chk" version="2">Yedekleme sırasında Digest oluşturmayı geç</string>
- <string name="disable_backup_space_chk" version="2">Yedeklemeden önce boş alan denetimini devre dışı bırak</string>
+ <string name="disable_backup_space_chk" version="2">Yedeklemeden önce boş alan kontrolünü devre dışı bırak</string>
<string name="current_boot_slot">Geçerli Yuva: %tw_active_slot%</string>
<string name="boot_slot_a">A Yuvası</string>
<string name="boot_slot_b">B Yuvası</string>
@@ -228,7 +235,7 @@
<string name="append_date_btn">Tarih Ekle</string>
<string name="backup_name_exists">Bu adda bir yedek zaten var!</string>
<string name="encrypt_backup">Yedeklemeniz şifrelensin mi?</string>
- <string name="enter_pass">Şifre Gir:</string>
+ <string name="enter_pass">Şifreyi Girin:</string>
<string name="enter_pass2">Şifreyi Tekrar Girin:</string>
<string name="pass_not_match">Şifreler eşleşmiyor!</string>
<string name="partitions">Bölümler:</string>
@@ -253,7 +260,7 @@
<string name="restore_try_decrypt">Şifreli Yedek - Çözülmeye Çalışılıyor</string>
<string name="restore_try_decrypt_s">Çözülmeye Çalışılıyor</string>
<string name="restore_backup_date">Yedek tarihi: %tw_restore_file_date%</string>
- <string name="restore_sel_part">Geri Yüklenecek Bölümleri Seç:</string>
+ <string name="restore_sel_part">Geri Yüklenecek Bölümleri Seçin:</string>
<string name="restore_enable_digest_chk" version="2">Yedek Dosyalarının Digest Doğrulamasını etkinleştir</string>
<string name="restore_complete">Geri Yükleme Tamamlandı</string>
<string name="swipe_restore">Geri Yüklemek için Kaydır</string>
@@ -267,7 +274,7 @@
<string name="swipe_rename"> Yeniden Adlandır</string>
<string name="confirm_hdr">Onayla</string>
<string name="mount_hdr">Bağla</string>
- <string name="mount_sel_part">Bağlanacak Bölümleri Seç:</string>
+ <string name="mount_sel_part">Bağlanacak Bölümleri Seçin:</string>
<string name="mount_sys_ro_chk">Sistem bölümünü salt okunur bağla</string>
<string name="mount_sys_ro_s_chk">Sistemi RO Bağla</string>
<string name="decrypt_data_btn">Veri Şifresini Çöz</string>
@@ -319,10 +326,11 @@
<string name="settings_tz_btn">Zaman Dilimi</string>
<string name="settings_screen_btn">Ekran</string>
<string name="settings_screen_bright_btn">Ekran Parlaklığı</string>
+ <string name="vibration_disabled">Bu cihaz için titreşim devre dışı</string>
<string name="settings_vibration_btn">Titreşim</string>
<string name="settings_language_btn">Dil</string>
<string name="time_zone_hdr">Zaman Dilimi</string>
- <string name="sel_tz_list">Zaman Dilimi Seç:</string>
+ <string name="sel_tz_list">Zaman Dilimi Seçin:</string>
<!-- Translator note: if it does not make sense to translate the locations or if it makes more sense,
feel free to change the location listed or drop the location entirely and just call it UTC -6 -->
<string name="utcm11">(UTC -11) Samoa, Midway Adası</string>
@@ -374,7 +382,7 @@
<string name="button_vibration">Düğme Titreşimi:</string>
<string name="kb_vibration">Klavye Titreşimi:</string>
<string name="act_vibration">Eylem Titreşimi:</string>
- <string name="select_language">Dil Seç:</string>
+ <string name="select_language">Dil Seçin:</string>
<string name="sel_lang_btn">Dil Seç</string>
<string name="set_language_btn">Dili Ayarla</string>
<string name="advanced_hdr">Gelişmiş</string>
@@ -424,10 +432,10 @@
<string name="swipe_to_unlock">Kilidi Açmak için Kaydır</string>
<string name="swipe_unlock"> Kilidi Aç</string>
<string name="fm_hdr">Dosya Yöneticisi</string>
- <string name="fm_sel_file">Bir Dosya veya Klasör Seçin</string>
+ <string name="fm_sel_file">Bir Dosya veya Klasör Seç</string>
<string name="fm_type_folder">Klasör</string>
<string name="fm_type_file">Dosya</string>
- <string name="fm_choose_act">Eylem Seçin</string>
+ <string name="fm_choose_act">Eylem Seç</string>
<string name="fm_selected">%tw_fm_type% seçili:</string>
<string name="fm_copy_btn">Kopyala</string>
<string name="fm_copy_file_btn">Dosyayı Kopyala</string>
@@ -444,7 +452,7 @@
<string name="fm_rename_file_btn">Dosyayı Yeniden Adlandır</string>
<string name="fm_rename_folder_btn">Klasörü Yeniden Adlandır</string>
<string name="fm_renaming">Yeniden Adlandır</string>
- <string name="fm_sel_dest">Hedef Klasörü Seçin</string>
+ <string name="fm_sel_dest">Hedef Klasörü Seç</string>
<string name="fm_sel_curr_folder">Geçerli Klasörü Seç</string>
<string name="fm_rename_hdr">Yeniden Adlandır</string>
<string name="fm_set_perms_hdr">İzinleri Ayarla</string>
@@ -481,6 +489,28 @@
<string name="install_cancel">Yükleme</string>
<string name="sel_storage_list">Depolama Seç</string>
<string name="ok_btn">Tamam</string>
+ <string name="install_twrp_ramdisk">Recovery Ramdisk Yükle</string>
+ <string name="install_kernel">Kernel Yükle</string>
+ <string name="repack_kernel_confirm_hdr">Kernel Yükle</string>
+ <string name="repack_ramdisk_confirm_hdr">Recovery Yükle</string>
+ <string name="repack_kernel_confirm">Kernel Yüklensin mi?</string>
+ <string name="repack_ramdisk_confirm">Recovery Yüklensin mi?</string>
+ <string name="repack_backup_first">Önce geçerli imajı yedekle</string>
+ <string name="repack">Yeniden paketle</string>
+ <string name="swipe_to_install">Yüklemek için Kaydır</string>
+ <string name="installing">Yükleniyor...</string>
+ <string name="install_complete">Yükleme Tamamlandı</string>
+ <string name="unpack_error">İmaj açılırken hata oluştu.</string>
+ <string name="repack_error">İmajı yeniden paketleme hatası.</string>
+ <string name="unpacking_image">{1} açılıyor...</string>
+ <string name="repacking_image">{1} yeniden paketleniyor...</string>
+ <string name="repack_image_hdr">İmaj Seç</string>
+ <string name="fix_recovery_loop">Recovery Bootloop'unu Onar</string>
+ <string name="fix_recovery_loop_confirm">Recovery Bootloop'u Onarılsın mı?</string>
+ <string name="fixing_recovery_loop">Recovery Bootloop'u Onarılıyor...</string>
+ <string name="fix_recovery_loop_complete">Recovery Bootloop'unu Onarma Tamamlandı</string>
+ <string name="fixing_recovery_loop_patch">Kernel yamalanıyor...</string>
+ <string name="fix_recovery_loop_patch_error">Kernel yamalama hatası.</string>
<!-- Various console messages - these consist of user displayed messages, oftentimes errors -->
<string name="no_kernel_selinux">Kernel SELinux içeriklerini okuma desteğine sahip değil.</string>
@@ -510,7 +540,7 @@
<string name="backup_folder"> * Yedekleme Klasörü: {1}</string>
<string name="fail_backup_folder">Yedekleme klasörü oluşturulamadı.</string>
<string name="avg_backup_fs">Dosya sistemleri için ortalama yedekleme hızı: {1} MB/sn</string>
- <string name="avg_backup_img">Görüntülü sürücüler için ortalama yedekleme hızı: {1} MB/sn</string>
+ <string name="avg_backup_img">İmajlı sürücüler için ortalama yedekleme hızı: {1} MB/sn</string>
<string name="total_backed_size">[{1} MB YEDEKLENDİ]</string>
<string name="backup_completed">[YEDEKLEME {1} SANİYEDE TAMAMLANDI]</string>
<string name="restore_started">[GERİ YÜKLEME BAŞLATILDI]</string>
@@ -518,7 +548,7 @@
<!-- {1} is the partition display name and {2} is the number of seconds -->
<string name="restore_part_done">[{1} bitti ({2} saniye)]</string>
<string name="verifying_digest" version="2">Digest Doğrulanıyor</string>
- <string name="skip_digest" version="2">Kullanıcı ayarına göre Digest denetimi geçiliyor.</string>
+ <string name="skip_digest" version="2">Kullanıcı ayarına göre Digest kontrolü geçiliyor.</string>
<string name="calc_restore">Geri yükleme ayrıntıları hesaplanıyor...</string>
<string name="restore_read_only">{1} geri yüklenemiyor -- salt okunur bağlanmış.</string>
<string name="restore_unable_locate">Geri yüklemek için \'{1}\' bölümü bulunamıyor.</string>
@@ -533,9 +563,10 @@
<string name="unable_find_part_path">\'{1}\' yolu için bölüm bulunamıyor</string>
<string name="update_part_details">Bölüm ayrıntıları güncelleniyor...</string>
<string name="update_part_details_done">...bitti</string>
- <string name="wiping_dalvik">Dalvik Önbelleği Dizinleri Temizleniyor...</string>
+ <string name="wiping_dalvik">Dalvik Dizinleri Temizleniyor...</string>
<string name="cleaned">Temizlendi: {1}...</string>
- <string name="dalvik_done">-- Dalvik Önbelleği Dizinleri Temizleme Tamamlandı!</string>
+ <string name="cache_dalvik_done">-- Dalvik Önbelleği Dizinleri Temizleme Tamamlandı!</string>
+ <string name="dalvik_done">-- Dalvik Dizinleri Temizleme Tamamlandı!</string>
<string name="no_andsec">Android secure bölümü yok.</string>
<string name="unable_to_locate">{1} bulunamıyor.</string>
<string name="wiping_datamedia">Dahili depolama temizleniyor -- /data/media...</string>
@@ -603,7 +634,7 @@
<string name="backup_folder_set">Yedekleme klasörü '{1}' olarak ayarlandı</string>
<string name="locate_backup_err">'{1}' yedeği bulunamadı</string>
<string name="set_restore_opt">Geri yükleme seçeneklerini ayarlama: '{1}':</string>
- <string name="digest_check_skip" version="2">Digest denetimini atlama açık</string>
+ <string name="digest_check_skip" version="2">Digest kontrolünü atlama açık</string>
<string name="ors_encrypt_restore_err">Şifrelenmiş bir yedeklemeyi geri yüklemek için OpenRecoveryScript kullanılamıyor.</string>
<string name="mounting">Bağlanıyor</string>
<string name="unmounting">Kaldırılıyor</string>
@@ -638,7 +669,7 @@
<string name="verify_zip_fail">Zip imzası doğrulama başarısız oldu!</string>
<string name="verify_zip_done">Zip imzası başarıyla doğrulandı.</string>
<string name="zip_corrupt">Zip dosyası bozuk!</string>
- <string name="no_digest" version="2">Digest denetimi geçiliyor: Digest dosyası bulunamadı</string>
+ <string name="no_digest" version="2">Digest kontrolü geçiliyor: Digest dosyası bulunamadı</string>
<string name="digest_fail" version="2">Digest eşleşmiyor</string>
<string name="digest_match" version="2">Digest eşleşti</string>
<string name="pid_signal">{1} process ended with signal: {2}</string>
diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml
index e014cc5..8370414 100755
--- a/gui/theme/common/portrait.xml
+++ b/gui/theme/common/portrait.xml
@@ -3150,6 +3150,9 @@
<condition var1="tw_no_sha2" var2="0"/>
<data variable="tw_use_sha2"/>
</listitem>
+ <listitem name="{@unmount_sys_install=Unmount System before installing a ZIP}">
+ <data variable="tw_unmount_system"/>
+ </listitem>
</listbox>
<button style="main_button_half_height">
diff --git a/gui/theme/common/watch.xml b/gui/theme/common/watch.xml
index f5d3222..05b7bd2 100755
--- a/gui/theme/common/watch.xml
+++ b/gui/theme/common/watch.xml
@@ -3640,6 +3640,9 @@
<condition var1="tw_no_sha2" var2="0"/>
<data variable="tw_use_sha2"/>
</listitem>
+ <listitem name="{@unmount_sys_install=Unmount System before installing a ZIP}">
+ <data variable="tw_unmount_system"/>
+ </listitem>
</listbox>
<action>
diff --git a/libblkid/Android.mk b/libblkid/Android.mk
index 42762e4..38a192f 100644
--- a/libblkid/Android.mk
+++ b/libblkid/Android.mk
@@ -44,7 +44,7 @@
LOCAL_MODULE := libuuid
LOCAL_MODULE_TAGS := optional
#LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
-LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -DHAVE_LOFF_T -DHAVE_ERR_H -DHAVE_MEMPCPY -DHAVE_FSYNC
+LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64 -DHAVE_LOFF_T -DHAVE_ERR_H -DHAVE_MEMPCPY -DHAVE_FSYNC -DHAVE_SYS_FILE_H
LOCAL_CFLAGS += -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter -Wno-format -Wno-pointer-arith
LOCAL_SRC_FILES = libuuid/src/clear.c \
libuuid/src/copy.c \
diff --git a/openrecoveryscript.cpp b/openrecoveryscript.cpp
index 1de0870..903bc6c 100755
--- a/openrecoveryscript.cpp
+++ b/openrecoveryscript.cpp
@@ -148,8 +148,8 @@
// Wipe
if (strcmp(value, "cache") == 0 || strcmp(value, "/cache") == 0) {
PartitionManager.Wipe_By_Path("/cache");
- } else if (strcmp(value, PartitionManager.Get_Android_Root_Path().c_str()) == 0 || strcmp(value, PartitionManager.Get_Android_Root_Path().c_str()) == 0) {
- PartitionManager.Wipe_By_Path(PartitionManager.Get_Android_Root_Path());
+ } else if (strcmp(value, "system") == 0 || strcmp(value, "/system") == 0 || strcmp(value, PartitionManager.Get_Android_Root_Path().c_str()) == 0) {
+ PartitionManager.Wipe_By_Path("/system");
} else if (strcmp(value, "dalvik") == 0 || strcmp(value, "dalvick") == 0 || strcmp(value, "dalvikcache") == 0 || strcmp(value, "dalvickcache") == 0) {
PartitionManager.Wipe_Dalvik_Cache();
} else if (strcmp(value, "data") == 0 || strcmp(value, "/data") == 0 || strcmp(value, "factory") == 0 || strcmp(value, "factoryreset") == 0) {
@@ -253,8 +253,8 @@
gui_msg(Msg("set_restore_opt=Setting restore options: '{1}':")(value2));
line_len = strlen(value2);
for (i=0; i<line_len; i++) {
- if ((value2[i] == 'S' || value2[i] == 's') && Partition_List.find(PartitionManager.Get_Android_Root_Path() + ';') != string::npos) {
- Restore_List += PartitionManager.Get_Android_Root_Path() + ';';
+ if ((value2[i] == 'S' || value2[i] == 's') && Partition_List.find("/system;") != string::npos) {
+ Restore_List += "/system;";
gui_msg("system=System");
} else if ((value2[i] == 'D' || value2[i] == 'd') && Partition_List.find("/data;") != string::npos) {
Restore_List += "/data;";
@@ -301,6 +301,8 @@
strcat(mount, value);
} else
strcpy(mount, value);
+ if (!strcmp(mount, "/system"))
+ strcpy(mount, PartitionManager.Get_Android_Root_Path().c_str());
if (PartitionManager.Mount_By_Path(mount, true))
gui_msg(Msg("mounted=Mounted '{1}'")(mount));
} else if (strcmp(command, "unmount") == 0 || strcmp(command, "umount") == 0) {
@@ -311,6 +313,8 @@
strcat(mount, value);
} else
strcpy(mount, value);
+ if (!strcmp(mount, "/system"))
+ strcpy(mount, PartitionManager.Get_Android_Root_Path().c_str());
if (PartitionManager.UnMount_By_Path(mount, true))
gui_msg(Msg("unmounted=Unounted '{1}'")(mount));
} else if (strcmp(command, "set") == 0) {
@@ -539,7 +543,7 @@
line_len = Options.size();
for (i=0; i<line_len; i++) {
if (Options.substr(i, 1) == "S" || Options.substr(i, 1) == "s") {
- Backup_List += PartitionManager.Get_Android_Root_Path() + ';';
+ Backup_List += "/system;";
gui_msg("system=System");
} else if (Options.substr(i, 1) == "D" || Options.substr(i, 1) == "d") {
Backup_List += "/data;";
diff --git a/partition.cpp b/partition.cpp
index beb4a81..9ed0ebc 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -272,7 +272,7 @@
// Do nothing
}
-bool TWPartition::Process_Fstab_Line(const char *fstab_line, bool Display_Error, std::map<string, Flags_Map> *twrp_flags) {
+bool TWPartition::Process_Fstab_Line(const char *fstab_line, bool Display_Error, std::map<string, Flags_Map> *twrp_flags, bool Sar_Detect) {
char full_line[MAX_FSTAB_LINE_LENGTH];
char twflags[MAX_FSTAB_LINE_LENGTH] = "";
char* ptr;
@@ -309,11 +309,12 @@
Mount_Point = ptr;
if (fstab_version == 2) {
additional_entry = PartitionManager.Find_Partition_By_Path(Mount_Point);
- if (additional_entry) {
+ if (!Sar_Detect && additional_entry) {
LOGINFO("Found an additional entry for '%s'\n", Mount_Point.c_str());
}
}
- LOGINFO("Processing '%s'\n", Mount_Point.c_str());
+ if(!Sar_Detect)
+ LOGINFO("Processing '%s'\n", Mount_Point.c_str());
Backup_Path = Mount_Point;
Storage_Path = Mount_Point;
Display_Name = ptr + 1;
@@ -410,13 +411,16 @@
if (Primary_Block_Device.find("*") != string::npos)
Wildcard_Block_Device = true;
- if (Mount_Point == "auto") {
- Mount_Point = "/auto";
- char autoi[5];
- sprintf(autoi, "%i", auto_index);
- Mount_Point += autoi;
+ if (Sar_Detect) {
+ if(Is_File_System(Fstab_File_System) && (Mount_Point == "/" || Mount_Point == "/system" || Mount_Point == "/system_root"))
+ Find_Actual_Block_Device();
+ else
+ return true;
+ } else if (Mount_Point == "auto") {
+ Mount_Point = "/auto" + to_string(auto_index);
Backup_Path = Mount_Point;
Storage_Path = Mount_Point;
+ Backup_Name = Mount_Point.substr(1);
auto_index++;
Setup_File_System(Display_Error);
Display_Name = "Storage";
@@ -436,8 +440,10 @@
} else if (Is_File_System(Fstab_File_System)) {
Find_Actual_Block_Device();
Setup_File_System(Display_Error);
- if (Mount_Point == PartitionManager.Get_Android_Root_Path()) {
+ Backup_Name = Display_Name = Mount_Point.substr(1, Mount_Point.size() - 1);
+ if (Mount_Point == "/" || Mount_Point == "/system" || Mount_Point == "/system_root") {
Display_Name = "System";
+ Backup_Name = "system";
Backup_Display_Name = Display_Name;
Storage_Name = Display_Name;
Wipe_Available_in_GUI = true;
@@ -598,6 +604,19 @@
}
}
+ if (Is_File_System(Fstab_File_System) && (Mount_Point == "/" || Mount_Point == "/system" || Mount_Point == "/system_root")) {
+ if (Sar_Detect) {
+ Mount_Point = "/s";
+ Mount_Read_Only = true;
+ Can_Be_Mounted = true;
+ } else {
+ Mount_Point = PartitionManager.Get_Android_Root_Path();
+ Backup_Path = Mount_Point;
+ Storage_Path = Mount_Point;
+ Make_Dir(Mount_Point, Display_Error);
+ }
+ }
+
return true;
}
@@ -1073,8 +1092,6 @@
// Make the mount point folder if it doesn't exist
Make_Dir(Mount_Point, Display_Error);
- Display_Name = Mount_Point.substr(1, Mount_Point.size() - 1);
- Backup_Name = Display_Name;
Backup_Method = BM_FILES;
}
@@ -1525,10 +1542,23 @@
string Command = "mount -o bind '" + Symlink_Path + "' '" + Symlink_Mount_Point + "'";
TWFunc::Exec_Cmd(Command);
}
+
+ if (Mount_Point == "/system_root") {
+ unlink("/system");
+ mkdir("/system", 0755);
+ mount("/system_root/system", "/system", "auto", MS_BIND, NULL);
+ }
+
return true;
}
bool TWPartition::UnMount(bool Display_Error) {
+ if (Mount_Point == "/system_root") {
+ if (umount("/system") == -1)
+ umount2("/system", MNT_DETACH);
+ rmdir("/system");
+ symlink("/system_root/system", "/system");
+ }
if (Is_Mounted()) {
int never_unmount_system;
@@ -2895,7 +2925,7 @@
TWPartition *part = new TWPartition;
char buffer[MAX_FSTAB_LINE_LENGTH];
sprintf(buffer, "%s %s-%i auto defaults defaults", item.c_str(), Mount_Point.c_str(), ++mount_point_index);
- part->Process_Fstab_Line(buffer, false, NULL);
+ part->Process_Fstab_Line(buffer, false, NULL, false);
char display[MAX_FSTAB_LINE_LENGTH];
sprintf(display, "%s %i", Storage_Name.c_str(), mount_point_index);
part->Storage_Name = display;
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index b265469..873b292 100755
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -111,7 +111,7 @@
#endif
}
-int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error) {
+int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error, bool Sar_Detect) {
FILE *fstabFile;
char fstab_line[MAX_FSTAB_LINE_LENGTH];
TWPartition* settings_partition = NULL;
@@ -198,7 +198,7 @@
fstab_line[line_size] = '\n';
TWPartition* partition = new TWPartition();
- if (partition->Process_Fstab_Line(fstab_line, Display_Error, &twrp_flags))
+ if (partition->Process_Fstab_Line(fstab_line, Display_Error, &twrp_flags, Sar_Detect))
Partitions.push_back(partition);
else
delete partition;
@@ -213,7 +213,7 @@
for (std::map<string, Flags_Map>::iterator mapit=twrp_flags.begin(); mapit!=twrp_flags.end(); mapit++) {
if (Find_Partition_By_Path(mapit->first) == NULL) {
TWPartition* partition = new TWPartition();
- if (partition->Process_Fstab_Line(mapit->second.fstab_line, Display_Error, NULL))
+ if (partition->Process_Fstab_Line(mapit->second.fstab_line, Display_Error, NULL, Sar_Detect))
Partitions.push_back(partition);
else
delete partition;
@@ -227,6 +227,13 @@
std::vector<TWPartition*>::iterator iter;
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
+ if (Sar_Detect) {
+ if ((*iter)->Mount_Point == "/s")
+ return true;
+ else
+ continue;
+ }
+
(*iter)->Partition_Post_Processing(Display_Error);
if ((*iter)->Is_Storage) {
@@ -592,6 +599,8 @@
std::vector<TWPartition*>::iterator iter;
string Local_Path = TWFunc::Get_Root_Path(Path);
+ if (Local_Path == "/system")
+ Local_Path = Get_Android_Root_Path();
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
if ((*iter)->Mount_Point == Local_Path || (!(*iter)->Symlink_Mount_Point.empty() && (*iter)->Symlink_Mount_Point == Local_Path))
return (*iter);
@@ -1266,8 +1275,12 @@
Part->Backup_FileName.resize(Part->Backup_FileName.size() - strlen(extn) + 3);
}
- if (!Part->Is_SubPartition)
- Restore_List += Part->Backup_Path + ";";
+ if (!Part->Is_SubPartition) {
+ if (Part->Backup_Path == Get_Android_Root_Path())
+ Restore_List += "/system;";
+ else
+ Restore_List += Part->Backup_Path + ";";
+ }
}
closedir(d);
}
@@ -1285,13 +1298,24 @@
int TWPartitionManager::Wipe_By_Path(string Path) {
std::vector<TWPartition*>::iterator iter;
+ std::vector < TWPartition * >::iterator iter1;
int ret = false;
bool found = false;
string Local_Path = TWFunc::Get_Root_Path(Path);
+ if (Local_Path == "/system")
+ Local_Path = Get_Android_Root_Path();
// Iterate through all partitions
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
if ((*iter)->Mount_Point == Local_Path || (!(*iter)->Symlink_Mount_Point.empty() && (*iter)->Symlink_Mount_Point == Local_Path)) {
+ // iterate through all partitions since some legacy devices uses other partitions as vendor causes issues while wiping
+ (*iter)->Find_Actual_Block_Device();
+ for (iter1 = Partitions.begin (); iter1 != Partitions.end (); iter1++)
+ {
+ (*iter1)->Find_Actual_Block_Device();
+ if ((*iter)->Actual_Block_Device == (*iter1)->Actual_Block_Device && (*iter)->Mount_Point != (*iter1)->Mount_Point)
+ (*iter1)->UnMount(false);
+ }
if (Path == "/and-sec")
ret = (*iter)->Wipe_AndSec();
else
@@ -2831,10 +2855,9 @@
}
string TWPartitionManager::Get_Android_Root_Path() {
- std::string Android_Root = getenv("ANDROID_ROOT");
- if (Android_Root == "")
- Android_Root = "/system";
- return Android_Root;
+ if (property_get_bool("ro.twrp.sar", false))
+ return "/system_root";
+ return "/system";
}
void TWPartitionManager::Remove_Uevent_Devices(const string& Mount_Point) {
diff --git a/partitions.hpp b/partitions.hpp
index 4071b94..92970d9 100644
--- a/partitions.hpp
+++ b/partitions.hpp
@@ -178,7 +178,7 @@
void Setup_Data_Media(); // Sets up a partition as a /data/media emulated storage partition
private:
- bool Process_Fstab_Line(const char *fstab_line, bool Display_Error, std::map<string, Flags_Map> *twrp_flags); // Processes a fstab line
+ bool Process_Fstab_Line(const char *fstab_line, bool Display_Error, std::map<string, Flags_Map> *twrp_flags, bool Sar_Detect); // Processes a fstab line
void Setup_Data_Partition(bool Display_Error); // Setup data partition after fstab processed
void Setup_Cache_Partition(bool Display_Error); // Setup cache partition after fstab processed
bool Find_Wildcard_Block_Devices(const string& Device); // Searches for and finds wildcard block devices
@@ -305,7 +305,7 @@
~TWPartitionManager() {}
public:
- int Process_Fstab(string Fstab_Filename, bool Display_Error); // Parses the fstab and populates the partitions
+ int Process_Fstab(string Fstab_Filename, bool Display_Error, bool Sar_Detect); // Parses the fstab and populates the partitions
int Write_Fstab(); // Creates /etc/fstab file that's used by the command line for mount commands
void Output_Partition_Logging(); // Outputs partition information to the log
void Output_Partition(TWPartition* Part); // Outputs partition details to the log
diff --git a/prebuilt/Android.mk b/prebuilt/Android.mk
index d330799..788068d 100644
--- a/prebuilt/Android.mk
+++ b/prebuilt/Android.mk
@@ -577,9 +577,9 @@
endif
endif
-ifeq ($(TW_INCLUDE_REPACKTOOLS), true)
+ifneq (,$(filter $(TW_INCLUDE_REPACKTOOLS) $(TW_INCLUDE_RESETPROP) $(TW_INCLUDE_LIBRESETPROP), true))
ifeq ($(wildcard external/magisk-prebuilt/Android.mk),)
- $(warning Magisk repacking tools not found!)
+ $(warning Magisk prebuilt tools not found!)
$(warning Please place https://github.com/TeamWin/external_magisk-prebuilt)
$(warning into external/magisk-prebuilt)
$(error magiskboot prebuilts not present; exiting)
diff --git a/twinstall.cpp b/twinstall.cpp
index d659b47..92af497 100755
--- a/twinstall.cpp
+++ b/twinstall.cpp
@@ -339,7 +339,7 @@
}
int TWinstall_zip(const char* path, int* wipe_cache) {
- int ret_val, zip_verify = 1;
+ int ret_val, zip_verify = 1, unmount_system = 1;
if (strcmp(path, "error") == 0) {
LOGERR("Failed to get adb sideload file: '%s'\n", path);
@@ -359,6 +359,8 @@
}
}
+ DataManager::GetValue(TW_UNMOUNT_SYSTEM, unmount_system);
+
#ifndef TW_OEM_BUILD
DataManager::GetValue(TW_SIGNED_ZIP_VERIFY_VAR, zip_verify);
#endif
@@ -410,6 +412,14 @@
return INSTALL_CORRUPT;
}
+ if (unmount_system) {
+ gui_msg("unmount_system=Unmounting System...");
+ if(!PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), true)) {
+ gui_err("unmount_system_err=Failed unmounting System");
+ return -1;
+ }
+ }
+
time_t start, stop;
time(&start);
if (Zip.EntryExists(ASSUMED_UPDATE_BINARY_NAME)) {
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 8203cfa..593ad9d 100755
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -59,6 +59,10 @@
#include "libcrecovery/common.h"
}
+#ifdef TW_INCLUDE_LIBRESETPROP
+ #include <resetprop.h>
+#endif
+
struct selabel_handle *selinux_handle;
/* Execute a command */
@@ -891,19 +895,23 @@
}
string TWFunc::System_Property_Get(string Prop_Name) {
- bool mount_state = PartitionManager.Is_Mounted_By_Path(PartitionManager.Get_Android_Root_Path());
+ return System_Property_Get(Prop_Name, PartitionManager, PartitionManager.Get_Android_Root_Path());
+}
+
+string TWFunc::System_Property_Get(string Prop_Name, TWPartitionManager &PartitionManager, string Mount_Point) {
+ bool mount_state = PartitionManager.Is_Mounted_By_Path(Mount_Point);
std::vector<string> buildprop;
string propvalue;
- if (!PartitionManager.Mount_By_Path(PartitionManager.Get_Android_Root_Path(), true))
+ if (!PartitionManager.Mount_By_Path(Mount_Point, true))
return propvalue;
- string prop_file = "/system/build.prop";
+ string prop_file = Mount_Point + "/build.prop";
if (!TWFunc::Path_Exists(prop_file))
- prop_file = PartitionManager.Get_Android_Root_Path() + "/system/build.prop"; // for devices with system as a root file system (e.g. Pixel)
+ prop_file = Mount_Point + "/system/build.prop"; // for devices with system as a root file system (e.g. Pixel)
if (TWFunc::read_file(prop_file, buildprop) != 0) {
LOGINFO("Unable to open build.prop for getting '%s'.\n", Prop_Name.c_str());
DataManager::SetValue(TW_BACKUP_NAME, Get_Current_Date());
if (!mount_state)
- PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false);
+ PartitionManager.UnMount_By_Path(Mount_Point, false);
return propvalue;
}
int line_count = buildprop.size();
@@ -916,12 +924,12 @@
if (propname == Prop_Name) {
propvalue = buildprop.at(index).substr(end_pos + 1, buildprop.at(index).size());
if (!mount_state)
- PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false);
+ PartitionManager.UnMount_By_Path(Mount_Point, false);
return propvalue;
}
}
if (!mount_state)
- PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false);
+ PartitionManager.UnMount_By_Path(Mount_Point, false);
return propvalue;
}
@@ -1316,4 +1324,13 @@
PartitionManager.UnMount_By_Path(PartitionManager.Get_Android_Root_Path(), false);
return false;
}
+
+int TWFunc::Property_Override(string Prop_Name, string Prop_Value) {
+#ifdef TW_INCLUDE_LIBRESETPROP
+ return setprop(Prop_Name.c_str(), Prop_Value.c_str(), false);
+#else
+ return -2;
+#endif
+}
+
#endif // ndef BUILD_TWRPTAR_MAIN
diff --git a/twrp-functions.hpp b/twrp-functions.hpp
index 8cea321..9d53ab6 100755
--- a/twrp-functions.hpp
+++ b/twrp-functions.hpp
@@ -24,6 +24,10 @@
#include "twrpDigest/twrpDigest.hpp"
+#ifndef BUILD_TWRPTAR_MAIN
+#include "partitions.hpp"
+#endif
+
using namespace std;
#define NON_AB_CACHE_DIR "/cache/"
@@ -90,6 +94,7 @@
static int write_to_file(const string& fn, const string& line); //write to file
static bool Try_Decrypting_Backup(string Restore_Path, string Password); // true for success, false for failed to decrypt
static string System_Property_Get(string Prop_Name); // Returns value of Prop_Name from reading /system/build.prop
+ static string System_Property_Get(string Prop_Name, TWPartitionManager &PartitionManager, string Mount_Point); // Returns value of Prop_Name from reading /system/build.prop
static string Get_Current_Date(void); // Returns the current date in ccyy-m-dd--hh-nn-ss format
static void Auto_Generate_Backup_Name(); // Populates TW_BACKUP_NAME with a backup name based on current date and ro.build.display.id from /system/build.prop
static void Fixup_Time_On_Boot(const string& time_paths = ""); // Fixes time on devices which need it (time_paths is a space separated list of paths to check for ats_* files)
@@ -107,6 +112,7 @@
static std::string get_cache_dir(); // return the cache partition existence
static void check_selinux_support(); // print whether selinux support is enabled to console
static bool Is_TWRP_App_In_System(); // Check if the TWRP app is installed in the system partition
+ static int Property_Override(string Prop_Name, string Prop_Value); // Override properties (including ro. properties)
private:
static void Copy_Log(string Source, string Destination);
diff --git a/twrp.cpp b/twrp.cpp
index dac0093..7689c25 100755
--- a/twrp.cpp
+++ b/twrp.cpp
@@ -43,6 +43,11 @@
#include "twrp-functions.hpp"
#include "data.hpp"
#include "partitions.hpp"
+#ifdef __ANDROID_API_N__
+#include <android-base/strings.h>
+#else
+#include <base/strings.h>
+#endif
#include "openrecoveryscript.hpp"
#include "variables.h"
#include "twrpAdbBuFifo.hpp"
@@ -117,8 +122,78 @@
if (!TWFunc::Path_Exists(fstab_filename)) {
fstab_filename = "/etc/recovery.fstab";
}
+
+ // Begin SAR detection
+ {
+ TWPartitionManager SarPartitionManager;
+ printf("=> Processing %s for SAR-detection\n", fstab_filename.c_str());
+ if (!SarPartitionManager.Process_Fstab(fstab_filename, 1, 1)) {
+ LOGERR("Failing out of recovery due to problem with fstab.\n");
+ return -1;
+ }
+
+ mkdir("/s", 0755);
+
+#if defined(AB_OTA_UPDATER) || defined(__ANDROID_API_Q__)
+ bool fallback_sar = true;
+#else
+ bool fallback_sar = property_get_bool("ro.build.system_root_image", false);
+#endif
+
+ if(SarPartitionManager.Mount_By_Path("/s", false)) {
+ if (TWFunc::Path_Exists("/s/build.prop")) {
+ LOGINFO("SAR-DETECT: Non-SAR System detected\n");
+ property_set("ro.twrp.sar", "0");
+ rmdir("/system_root");
+ } else if (TWFunc::Path_Exists("/s/system/build.prop")) {
+ LOGINFO("SAR-DETECT: SAR System detected\n");
+ property_set("ro.twrp.sar", "1");
+ } else {
+ LOGINFO("SAR-DETECT: No build.prop found, falling back to %s\n", fallback_sar ? "SAR" : "Non-SAR");
+ property_set("ro.twrp.sar", fallback_sar ? "1" : "0");
+ }
+
+// We are doing this here during SAR-detection, since we are mounting the system-partition anyway
+// This way we don't need to remount it later, just for overriding properties
+#if defined(TW_INCLUDE_LIBRESETPROP) && defined(TW_OVERRIDE_SYSTEM_PROPS)
+ stringstream override_props(EXPAND(TW_OVERRIDE_SYSTEM_PROPS));
+ string current_prop;
+ while (getline(override_props, current_prop, ';')) {
+ string other_prop;
+ if (current_prop.find("=") != string::npos) {
+ other_prop = current_prop.substr(current_prop.find("=") + 1);
+ current_prop = current_prop.substr(0, current_prop.find("="));
+ } else {
+ other_prop = current_prop;
+ }
+ other_prop = android::base::Trim(other_prop);
+ current_prop = android::base::Trim(current_prop);
+ string sys_val = TWFunc::System_Property_Get(other_prop, SarPartitionManager, "/s");
+ if (!sys_val.empty()) {
+ LOGINFO("Overriding %s with value: \"%s\" from system property %s\n", current_prop.c_str(), sys_val.c_str(), other_prop.c_str());
+ int error = TWFunc::Property_Override(current_prop, sys_val);
+ if (error) {
+ LOGERR("Failed overriding property %s, error_code: %d\n", current_prop.c_str(), error);
+ }
+ } else {
+ LOGINFO("Not overriding %s with empty value from system property %s\n", current_prop.c_str(), other_prop.c_str());
+ }
+ }
+#endif
+ SarPartitionManager.UnMount_By_Path("/s", false);
+ } else {
+ LOGINFO("SAR-DETECT: Could not mount system partition, falling back to %s\n", fallback_sar ? "SAR":"Non-SAR");
+ property_set("ro.twrp.sar", fallback_sar ? "1" : "0");
+ }
+
+ rmdir("/s");
+
+ TWFunc::check_and_run_script("/sbin/sarsetup.sh", "boot");
+ }
+ // End SAR detection
+
printf("=> Processing %s\n", fstab_filename.c_str());
- if (!PartitionManager.Process_Fstab(fstab_filename, 1)) {
+ if (!PartitionManager.Process_Fstab(fstab_filename, 1, 0)) {
LOGERR("Failing out of recovery due to problem with fstab.\n");
return -1;
}
diff --git a/variables.h b/variables.h
index 76da715..24cde92 100644
--- a/variables.h
+++ b/variables.h
@@ -140,6 +140,7 @@
#define TW_MILITARY_TIME "tw_military_time"
#define TW_USE_SHA2 "tw_use_sha2"
#define TW_NO_SHA2 "tw_no_sha2"
+#define TW_UNMOUNT_SYSTEM "tw_unmount_system"
// Also used:
// tw_boot_is_mountable