Snap for 12680993 from bf416ba9b347f1e9e2ab5c5ab2fe1fdecb60ffe5 to 25Q1-release

Change-Id: I9e42b31744cfe37e793a0a8af62978fad1a6ad58
diff --git a/android/TerminalApp/AndroidManifest.xml b/android/TerminalApp/AndroidManifest.xml
index 6a1ecaf..1af6c8a 100644
--- a/android/TerminalApp/AndroidManifest.xml
+++ b/android/TerminalApp/AndroidManifest.xml
@@ -34,6 +34,7 @@
         android:icon="@mipmap/ic_launcher"
         android:theme="@style/Theme.Material3.DayNight.NoActionBar"
         android:usesCleartextTraffic="true"
+        android:supportsRtl="true"
         android:enabled="false">
         <activity android:name=".MainActivity"
                   android:configChanges="orientation|screenSize|keyboard|keyboardHidden|navigation|uiMode|screenLayout|smallestScreenSize"
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java b/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java
index 10451ec..2f0d301 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java
@@ -289,16 +289,6 @@
         }
     }
 
-    public static File getPartitionFile(Context context, String fileName)
-            throws FileNotFoundException {
-        File file = new File(InstallUtils.getInternalStorageDir(context), fileName);
-        if (!file.exists()) {
-            Log.d(TAG, file.getAbsolutePath() + " - file not found");
-            throw new FileNotFoundException("File not found: " + fileName);
-        }
-        return file;
-    }
-
     private static void allocateSpace(File file, long sizeInBytes) throws IOException {
         try {
             RandomAccessFile raf = new RandomAccessFile(file, "rw");
@@ -536,7 +526,7 @@
 
     private void resizeDiskIfNecessary() {
         try {
-            File file = getPartitionFile(this, "root_part");
+            File file = InstallUtils.getRootfsFile(this);
             SharedPreferences sharedPref = this.getSharedPreferences(
                     getString(R.string.preference_file_key), Context.MODE_PRIVATE);
             SharedPreferences.Editor editor = sharedPref.edit();
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/SettingsActivity.kt b/android/TerminalApp/java/com/android/virtualization/terminal/SettingsActivity.kt
index 03768e9..73bb0b9 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/SettingsActivity.kt
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/SettingsActivity.kt
@@ -30,7 +30,6 @@
 
         val toolbar: MaterialToolbar = findViewById(R.id.settings_toolbar)
         setSupportActionBar(toolbar)
-        supportActionBar?.title = resources.getString(R.string.action_settings)
         val settingsItems = arrayOf(
             SettingsItem(
                 resources.getString(R.string.settings_disk_resize_title),
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/SettingsDiskResizeActivity.kt b/android/TerminalApp/java/com/android/virtualization/terminal/SettingsDiskResizeActivity.kt
index 58be98d..7ccce9c 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/SettingsDiskResizeActivity.kt
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/SettingsDiskResizeActivity.kt
@@ -27,6 +27,7 @@
 import android.widget.TextView
 import androidx.appcompat.app.AppCompatActivity
 import androidx.core.view.isVisible
+import com.android.virtualization.vmlauncher.InstallUtils
 import com.google.android.material.button.MaterialButton
 import com.google.android.material.slider.Slider
 import java.util.regex.Pattern
@@ -55,7 +56,7 @@
                     0
                 )
             ).toFloat();
-        val partition = MainActivity.getPartitionFile(this, "root_part")
+        val partition = InstallUtils.getRootfsFile(this)
         val minDiskSizeMb =
             bytesToMb(MainActivity.getMinFilesystemSize(partition)).toFloat()
                 .coerceAtMost(diskSizeMb)
diff --git a/android/TerminalApp/res/layout/activity_installer.xml b/android/TerminalApp/res/layout/activity_installer.xml
index ce37129..fcd3f1a 100644
--- a/android/TerminalApp/res/layout/activity_installer.xml
+++ b/android/TerminalApp/res/layout/activity_installer.xml
@@ -38,8 +38,7 @@
         android:adjustViewBounds="true"
         android:layout_alignParentStart="true"
         android:layout_marginTop="48dp"
-        android:layout_marginLeft="32dp"
-        android:layout_marginRight="32dp"
+        android:layout_marginHorizontal="32dp"
         app:tint="?attr/colorPrimary" />
 
     <TextView
@@ -49,10 +48,8 @@
         android:singleLine="false"
         android:text="@string/installer_title_text"
         android:layout_below="@id/installer_terminal_icon"
-        android:layout_marginTop="24dp"
-        android:layout_marginBottom="24dp"
-        android:layout_marginLeft="32dp"
-        android:layout_marginRight="32dp"
+        android:layout_marginVertical="24dp"
+        android:layout_marginHorizontal="32dp"
         android:textSize="36sp" />
 
     <TextView
@@ -63,8 +60,7 @@
         android:layout_below="@id/installer_title"
         android:lineSpacingExtra="5dp"
         android:layout_marginTop="24dp"
-        android:layout_marginLeft="32dp"
-        android:layout_marginRight="32dp"
+        android:layout_marginHorizontal="32dp"
         android:textSize="16sp" />
 
     <CheckBox
@@ -72,8 +68,7 @@
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:textSize="16sp"
-        android:layout_marginLeft="42dp"
-        android:layout_marginRight="42dp"
+        android:layout_marginHorizontal="42dp"
         android:layout_above="@id/installer_install_button"
         android:layout_alignParentEnd="true"
         android:text="@string/installer_wait_for_wifi_checkbox_text" />
@@ -85,8 +80,7 @@
         android:layout_alignParentBottom="true"
         android:layout_alignParentEnd="true"
         android:layout_marginBottom="32dp"
-        android:layout_marginLeft="40dp"
-        android:layout_marginRight="40dp"
+        android:layout_marginHorizontal="40dp"
         android:backgroundTint="?attr/colorPrimaryDark"
         android:text="@string/installer_install_button_enabled_text" />
 </RelativeLayout>
diff --git a/android/TerminalApp/res/layout/settings_activity.xml b/android/TerminalApp/res/layout/settings_activity.xml
index 9edfd96..adeff36 100644
--- a/android/TerminalApp/res/layout/settings_activity.xml
+++ b/android/TerminalApp/res/layout/settings_activity.xml
@@ -25,6 +25,7 @@
         android:id="@+id/settings_toolbar"
         android:layout_width="match_parent"
         android:layout_height="?attr/actionBarSize"
+        app:title="@string/action_settings"
         app:layout_constraintTop_toTopOf="parent"/>
     <androidx.recyclerview.widget.RecyclerView
         android:id="@+id/settings_list_recycler_view"
diff --git a/android/TerminalApp/res/layout/settings_list_item.xml b/android/TerminalApp/res/layout/settings_list_item.xml
index 7b27421..b48c5d3 100644
--- a/android/TerminalApp/res/layout/settings_list_item.xml
+++ b/android/TerminalApp/res/layout/settings_list_item.xml
@@ -14,61 +14,56 @@
      limitations under the License.
  -->
 
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<com.google.android.material.card.MaterialCardView
+    xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:gravity="center_vertical"
-    android:layout_height="wrap_content">
+    android:id="@+id/settings_list_item_card"
+    app:strokeWidth="0dp"
+    app:cardCornerRadius="28dp"
+    app:checkedIcon="@null"
+    android:focusable="true"
+    android:checkable="true"
+    android:layout_height="wrap_content"
+    android:layout_width="match_parent">
 
-    <com.google.android.material.card.MaterialCardView
-        android:id="@+id/settings_list_item_card"
-        app:strokeWidth="0dp"
-        app:cardCornerRadius="28dp"
-        app:checkedIcon="@null"
-        android:focusable="true"
-        android:checkable="true"
-        android:layout_height="wrap_content"
-        android:layout_width="match_parent">
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:layout_width="match_parent"
+        android:layout_height="88dp"
+        android:layout_marginStart="24dp"
+        android:layout_marginEnd="16dp">
 
-        <androidx.constraintlayout.widget.ConstraintLayout
-            android:layout_width="match_parent"
-            android:layout_height="88dp"
+        <com.google.android.material.imageview.ShapeableImageView
+            android:id="@+id/settings_list_item_icon"
+            android:layout_width="24dp"
+            android:layout_height="24dp"
+            android:layout_marginEnd="24dp"
+            android:scaleType="centerCrop"
+            app:layout_constraintTop_toTopOf="parent"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintStart_toStartOf="parent" />
+
+        <TextView
+            android:id="@+id/settings_list_item_title"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="20dp"
             android:layout_marginStart="24dp"
-            android:layout_marginEnd="16dp">
+            android:textSize="20sp"
+            app:layout_constraintTop_toTopOf="parent"
+            app:layout_constraintBottom_toTopOf="@+id/settings_list_item_sub_title"
+            app:layout_constraintStart_toEndOf="@id/settings_list_item_icon"
+            app:layout_constraintEnd_toEndOf="parent" />
 
-            <com.google.android.material.imageview.ShapeableImageView
-                android:id="@+id/settings_list_item_icon"
-                android:layout_width="24dp"
-                android:layout_height="24dp"
-                android:layout_marginEnd="24dp"
-                android:scaleType="centerCrop"
-                app:layout_constraintTop_toTopOf="parent"
-                app:layout_constraintBottom_toBottomOf="parent"
-                app:layout_constraintLeft_toLeftOf="parent" />
-
-            <TextView
-                android:id="@+id/settings_list_item_title"
-                android:layout_width="0dp"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="20dp"
-                android:layout_marginStart="24dp"
-                android:textSize="20sp"
-                app:layout_constraintTop_toTopOf="parent"
-                app:layout_constraintBottom_toTopOf="@+id/settings_list_item_sub_title"
-                app:layout_constraintStart_toEndOf="@id/settings_list_item_icon"
-                app:layout_constraintEnd_toEndOf="parent" />
-
-            <TextView
-                android:id="@+id/settings_list_item_sub_title"
-                android:layout_width="0dp"
-                android:layout_height="wrap_content"
-                android:textSize="14sp"
-                android:layout_marginBottom="20dp"
-                android:layout_marginStart="24dp"
-                app:layout_constraintTop_toBottomOf="@+id/settings_list_item_title"
-                app:layout_constraintBottom_toBottomOf="parent"
-                app:layout_constraintStart_toEndOf="@id/settings_list_item_icon"
-                app:layout_constraintEnd_toEndOf="parent" />
-        </androidx.constraintlayout.widget.ConstraintLayout>
-    </com.google.android.material.card.MaterialCardView>
-</FrameLayout>
\ No newline at end of file
+        <TextView
+            android:id="@+id/settings_list_item_sub_title"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:textSize="14sp"
+            android:layout_marginBottom="20dp"
+            android:layout_marginStart="24dp"
+            app:layout_constraintTop_toBottomOf="@+id/settings_list_item_title"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintStart_toEndOf="@id/settings_list_item_icon"
+            app:layout_constraintEnd_toEndOf="parent" />
+    </androidx.constraintlayout.widget.ConstraintLayout>
+</com.google.android.material.card.MaterialCardView>
\ No newline at end of file
diff --git a/android/TerminalApp/res/layout/settings_port_forwarding_item.xml b/android/TerminalApp/res/layout/settings_port_forwarding_item.xml
index 5418bf8..8a57b41 100644
--- a/android/TerminalApp/res/layout/settings_port_forwarding_item.xml
+++ b/android/TerminalApp/res/layout/settings_port_forwarding_item.xml
@@ -14,11 +14,12 @@
      limitations under the License.
  -->
 
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.constraintlayout.widget.ConstraintLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    app:layout_constraintCircleRadius="@dimen/material_emphasis_medium"
-    xmlns:app="http://schemas.android.com/apk/res-auto">
+    app:layout_constraintCircleRadius="@dimen/material_emphasis_medium">
 
     <TextView
         android:id="@+id/settings_port_forwarding_item_port"
@@ -26,13 +27,13 @@
         android:layout_width="match_parent"
         app:layout_constraintTop_toTopOf="parent"
         app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintLeft_toLeftOf="parent"/>
+        app:layout_constraintStart_toStartOf="parent"/>
 
     <com.google.android.material.materialswitch.MaterialSwitch
         android:id="@+id/settings_port_forwarding_item_enabled_switch"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintRight_toRightOf="parent" />
+        app:layout_constraintEnd_toEndOf="parent" />
 
 </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/android/TerminalApp/res/layout/settings_recovery.xml b/android/TerminalApp/res/layout/settings_recovery.xml
index 12344c6..4cce61d 100644
--- a/android/TerminalApp/res/layout/settings_recovery.xml
+++ b/android/TerminalApp/res/layout/settings_recovery.xml
@@ -57,7 +57,7 @@
                 android:text="@string/settings_recovery_reset_title"
                 app:layout_constraintTop_toTopOf="parent"
                 app:layout_constraintBottom_toTopOf="@+id/settings_recovery_reset_sub_title"
-                app:layout_constraintLeft_toLeftOf="parent" />
+                app:layout_constraintStart_toStartOf="parent" />
 
             <TextView
                 android:id="@+id/settings_recovery_reset_sub_title"
@@ -69,7 +69,7 @@
                 android:text="@string/settings_recovery_reset_sub_title"
                 app:layout_constraintTop_toBottomOf="@+id/settings_recovery_reset_title"
                 app:layout_constraintBottom_toBottomOf="parent"
-                app:layout_constraintLeft_toLeftOf="parent" />
+                app:layout_constraintStart_toStartOf="parent" />
         </androidx.constraintlayout.widget.ConstraintLayout>
     </com.google.android.material.card.MaterialCardView>
 </LinearLayout>
\ No newline at end of file
diff --git a/android/TerminalApp/res/values/strings.xml b/android/TerminalApp/res/values/strings.xml
index c89fcfa..4dd33f4 100644
--- a/android/TerminalApp/res/values/strings.xml
+++ b/android/TerminalApp/res/values/strings.xml
@@ -95,6 +95,18 @@
     <string name="settings_recovery_reset_dialog_confirm">Confirm</string>
     <!-- Dialog button cancel for resetting the terminal [CHAR LIMIT=16] -->
     <string name="settings_recovery_reset_dialog_cancel">Cancel</string>
+    <!-- Dialog option to back up previous image(/mnt/backup is the path which is supposed not to be translated) [CHAR LIMIT=none] -->
+    <string name="settings_recovery_reset_dialog_backup_option">Back up data to <xliff:g id="path" example="/mnt/backup">/mnt/backup</xliff:g></string>
+    <!-- Snankbar to indicate recovery error due to backup [CHAR LIMIT=none] -->
+    <string name="settings_recovery_error_due_to_backup">Recovery failed because backup failed</string>
+    <!-- Snankbar to indicate recovery error [CHAR LIMIT=none] -->
+    <string name="settings_recovery_error">Recovery failed</string>
+    <!-- Snankbar to indicate recovery error during removing backup [CHAR LIMIT=none] -->
+    <string name="settings_recovery_error_during_removing_backup">Cannot remove backup file</string>
+    <!-- Settings menu title for removing backup data [CHAR LIMIT=none] -->
+    <string name="settings_recovery_remove_backup_title">Remove backup data</string>
+    <!-- Settings menu sub title for removing backup data(/mnt/backup is the path which is supposed not to be translated) [CHAR LIMIT=none] -->
+    <string name="settings_recovery_remove_backup_sub_title">Clean up <xliff:g id="path" example="/mnt/backup">/mnt/backup</xliff:g></string>
 
     <!-- Notification action button for settings [CHAR LIMIT=20] -->
     <string name="service_notification_settings">Settings</string>
diff --git a/guest/pvmfw/Android.bp b/guest/pvmfw/Android.bp
index 477d0a8..5c767a3 100644
--- a/guest/pvmfw/Android.bp
+++ b/guest/pvmfw/Android.bp
@@ -116,11 +116,12 @@
     rustlibs: [
         "libcbor_util",
         "libciborium",
-        "libdiced_open_dice",
+        "libdiced_open_dice_nostd",
         "libpvmfw_avb_nostd",
         "libzerocopy_nostd",
         "libhex",
     ],
+    static_libs: ["libopen_dice_clear_memory"],
 }
 
 genrule {
@@ -276,6 +277,7 @@
     ],
     static_libs: [
         "libpvmfw",
+        "libvmbase_dice_clear_memory",
     ],
     linker_scripts: [
         "image.ld",
diff --git a/guest/pvmfw/src/dice.rs b/guest/pvmfw/src/dice.rs
index 470711f..f3a2337 100644
--- a/guest/pvmfw/src/dice.rs
+++ b/guest/pvmfw/src/dice.rs
@@ -169,29 +169,6 @@
     }
 }
 
-/// Flushes data caches over the provided address range.
-///
-/// # Safety
-///
-/// The provided address and size must be to an address range that is valid for read and write
-/// (typically on the stack, .bss, .data, or provided BCC) from a single allocation
-/// (e.g. stack array).
-#[no_mangle]
-#[cfg(not(test))]
-unsafe extern "C" fn DiceClearMemory(
-    _ctx: *mut core::ffi::c_void,
-    size: usize,
-    addr: *mut core::ffi::c_void,
-) {
-    use core::slice;
-    use vmbase::memory::flushed_zeroize;
-
-    // SAFETY: We require our caller to provide a valid range within a single object. The open-dice
-    // always calls this on individual stack-allocated arrays which ensures that.
-    let region = unsafe { slice::from_raw_parts_mut(addr as *mut u8, size) };
-    flushed_zeroize(region)
-}
-
 #[cfg(test)]
 mod tests {
     use crate::{
diff --git a/guest/rialto/Android.bp b/guest/rialto/Android.bp
index 8afb8ba..a525168 100644
--- a/guest/rialto/Android.bp
+++ b/guest/rialto/Android.bp
@@ -35,6 +35,7 @@
     ],
     static_libs: [
         "librialto",
+        "libvmbase_dice_clear_memory",
     ],
     linker_scripts: [
         "image.ld",
diff --git a/guest/rialto/src/main.rs b/guest/rialto/src/main.rs
index 244010d..0b79e1e 100644
--- a/guest/rialto/src/main.rs
+++ b/guest/rialto/src/main.rs
@@ -199,28 +199,6 @@
     }
 }
 
-/// Flushes data caches over the provided address range.
-///
-/// # Safety
-///
-/// The provided address and size must be to an address range that is valid for read and write
-/// (typically on the stack, .bss, .data, or provided BCC) from a single allocation
-/// (e.g. stack array).
-#[no_mangle]
-unsafe extern "C" fn DiceClearMemory(
-    _ctx: *mut core::ffi::c_void,
-    size: usize,
-    addr: *mut core::ffi::c_void,
-) {
-    use core::slice;
-    use vmbase::memory::flushed_zeroize;
-
-    // SAFETY: We require our caller to provide a valid range within a single object. The open-dice
-    // always calls this on individual stack-allocated arrays which ensures that.
-    let region = unsafe { slice::from_raw_parts_mut(addr as *mut u8, size) };
-    flushed_zeroize(region)
-}
-
 generate_image_header!();
 main!(main);
 configure_heap!(SIZE_128KB * 2);
diff --git a/guest/trusty/security_vm/launcher/Android.bp b/guest/trusty/security_vm/launcher/Android.bp
index c90d893..38e3e42 100644
--- a/guest/trusty/security_vm/launcher/Android.bp
+++ b/guest/trusty/security_vm/launcher/Android.bp
@@ -57,7 +57,7 @@
     enabled: false,
     arch: {
         x86_64: {
-            src: ":trusty-test-lk.elf",
+            src: ":trusty-lk.elf",
             enabled: true,
         },
         arm64: {
diff --git a/libs/dice/clear_memory/Android.bp b/libs/dice/clear_memory/Android.bp
new file mode 100644
index 0000000..408e931
--- /dev/null
+++ b/libs/dice/clear_memory/Android.bp
@@ -0,0 +1,15 @@
+package {
+    default_visibility: [":__subpackages__"],
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+rust_ffi_static {
+    name: "libvmbase_dice_clear_memory",
+    crate_name: "vmbase_dice_clear_memory",
+    defaults: ["vmbase_ffi_defaults"],
+    srcs: ["src/lib.rs"],
+    rustlibs: ["libvmbase"],
+    visibility: [
+        "//packages/modules/Virtualization:__subpackages__",
+    ],
+}
diff --git a/libs/dice/clear_memory/src/lib.rs b/libs/dice/clear_memory/src/lib.rs
new file mode 100644
index 0000000..2a13396
--- /dev/null
+++ b/libs/dice/clear_memory/src/lib.rs
@@ -0,0 +1,37 @@
+// Copyright 2024, The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+//! Routine for clearing memory containing confidential data, used by the open-dice library.
+//!
+//! Clients should link against this library along the libopen_dice_*_baremetal libraries.
+
+#![no_std]
+
+use core::ffi::c_void;
+use core::slice;
+use vmbase::memory::flushed_zeroize;
+
+/// Zeroes data over the provided address range & flushes data caches.
+///
+/// # Safety
+///
+/// The provided address and size must be to an address range that is valid for read and write
+/// from a single allocation (e.g. stack array).
+#[no_mangle]
+unsafe extern "C" fn DiceClearMemory(_ctx: *mut c_void, size: usize, addr: *mut c_void) {
+    // SAFETY: We require our caller to provide a valid range within a single object. The
+    // open-dice always calls this on individual stack-allocated arrays which ensures that.
+    let region = unsafe { slice::from_raw_parts_mut(addr as *mut u8, size) };
+    flushed_zeroize(region);
+}
diff --git a/libs/dice/sample_inputs/Android.bp b/libs/dice/sample_inputs/Android.bp
index 36fe8c7..c1c4566 100644
--- a/libs/dice/sample_inputs/Android.bp
+++ b/libs/dice/sample_inputs/Android.bp
@@ -78,4 +78,5 @@
         "libdiced_open_dice_nostd",
         "libdiced_sample_inputs_nostd",
     ],
+    static_libs: ["libopen_dice_clear_memory"],
 }
diff --git a/libs/dice/sample_inputs/tests/api_test.rs b/libs/dice/sample_inputs/tests/api_test.rs
index d713168..c627824 100644
--- a/libs/dice/sample_inputs/tests/api_test.rs
+++ b/libs/dice/sample_inputs/tests/api_test.rs
@@ -146,21 +146,3 @@
     let public_key = chain.leaf().subject_public_key();
     public_key.verify(&signature, MESSAGE)
 }
-
-/// Flushes data caches over the provided address range in open-dice.
-///
-/// # Safety
-///
-/// The provided address and size must be to an address range that is valid for read and write
-/// (typically on the stack, .bss, .data, or provided BCC) from a single allocation
-/// (e.g. stack array).
-#[cfg(not(feature = "std"))]
-#[no_mangle]
-unsafe extern "C" fn DiceClearMemory(
-    _ctx: *mut core::ffi::c_void,
-    size: usize,
-    addr: *mut core::ffi::c_void,
-) {
-    // SAFETY: The caller ensures that the address and size are valid for write.
-    unsafe { core::ptr::write_bytes(addr as *mut u8, 0, size) };
-}
diff --git a/libs/vm_launcher_lib/java/com/android/virtualization/vmlauncher/InstallUtils.java b/libs/vm_launcher_lib/java/com/android/virtualization/vmlauncher/InstallUtils.java
index 57691bf..d55d268 100644
--- a/libs/vm_launcher_lib/java/com/android/virtualization/vmlauncher/InstallUtils.java
+++ b/libs/vm_launcher_lib/java/com/android/virtualization/vmlauncher/InstallUtils.java
@@ -28,6 +28,7 @@
 
 import java.io.BufferedInputStream;
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -41,6 +42,7 @@
 
     private static final String VM_CONFIG_FILENAME = "vm_config.json";
     private static final String COMPRESSED_PAYLOAD_FILENAME = "images.tar.gz";
+    private static final String ROOTFS_FILENAME = "root_part";
     private static final String INSTALLATION_COMPLETED_FILENAME = "completed";
     private static final String PAYLOAD_DIR = "linux";
 
@@ -172,4 +174,13 @@
             return false;
         }
     }
+
+    public static File getRootfsFile(Context context) throws FileNotFoundException {
+        File file = new File(getInternalStorageDir(context), ROOTFS_FILENAME);
+        if (!file.exists()) {
+            Log.d(TAG, file.getAbsolutePath() + " - file not found");
+            throw new FileNotFoundException("File not found: " + ROOTFS_FILENAME);
+        }
+        return file;
+    }
 }