Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a629ac2 authored by Ted Bauer's avatar Ted Bauer Committed by Android (Google) Code Review
Browse files

Merge "Write file on boot when migration flag is enabled." into main

parents 0ab4a098 50b8d3f6
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -60,10 +60,12 @@ import libcore.io.IoUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
@@ -161,6 +163,11 @@ final class SettingsState {
    private static final String APEX_DIR = "/apex";
    private static final String APEX_ACONFIG_PATH_SUFFIX = "/etc/aconfig_flags.pb";

    private static final String STORAGE_MIGRATION_FLAG =
            "core_experiments_team_internal/com.android.providers.settings.storage_test_mission_1";
    private static final String STORAGE_MIGRATION_LOG =
            "/metadata/aconfig/flags/storage_migration.log";

    /**
     * This tag is applied to all aconfig default value-loaded flags.
     */
@@ -1439,6 +1446,20 @@ final class SettingsState {
                    }
                }

                if (name != null && name.equals(STORAGE_MIGRATION_FLAG) && value.equals("true")) {
                    File file = new File(STORAGE_MIGRATION_LOG);
                    if (!file.exists()) {
                        try (BufferedWriter writer =
                                new BufferedWriter(new FileWriter(STORAGE_MIGRATION_LOG))) {
                            final long timestamp = System.currentTimeMillis();
                            String entry = String.format("%d | Log init", timestamp);
                            writer.write(entry);
                        } catch (IOException e) {
                            Slog.e(LOG_TAG, "failed to write storage migration file", e);
                        }
                    }
                }

                mSettings.put(name, new Setting(name, value, defaultValue, packageName, tag,
                        fromSystem, id, isPreservedInRestore));

+7 −0
Original line number Diff line number Diff line
@@ -33,3 +33,10 @@ flag {
    bug: "327383546"
    is_fixed_read_only: true
}

flag {
    name: "storage_test_mission_1"
    namespace: "core_experiments_team_internal"
    description: "If this flag is detected as true on boot, writes a logfile to track storage migration correctness."
    bug: "328444881"
}