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

Commit db77169a authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11975806 from b82a27e6 to 24Q3-release

Change-Id: Ia491c8388b85e3f7c55b1fd95f420a2ef4da60dc
parents 9b830c3b b82a27e6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -165,6 +165,9 @@ cc_library_shared {
    ],
    min_sdk_version: "Tiramisu",
    ldflags: ["-Wl,--allow-multiple-definition"],

    // TODO(b/346919576) Workaround LTO build breakage.
    lto_O0: true,
}

cc_library {
+2 −1
Original line number Diff line number Diff line
@@ -2468,10 +2468,11 @@ static void periodicScanCleanupNative(JNIEnv* env, jobject /* object */) {
}

static void scanInitializeNative(JNIEnv* env, jobject object) {
  std::unique_lock<std::shared_mutex> lock(callbacks_mutex);

  sScanner = bluetooth::shim::get_ble_scanner_instance();
  sScanner->RegisterCallbacks(JniScanningCallbacks::GetInstance());

  std::unique_lock<std::shared_mutex> lock(callbacks_mutex);
  if (mScanCallbacksObj != NULL) {
    log::warn("Cleaning up scan callback object");
    env->DeleteGlobalRef(mScanCallbacksObj);
+3 −3
Original line number Diff line number Diff line
@@ -89,16 +89,16 @@ final class DataMigration {

    static int run(Context ctx) {
        if (migrationStatus(ctx) == MIGRATION_STATUS_COMPLETED) {
            Log.d(TAG, "Legacy migration skiped: already completed");
            Log.d(TAG, "Legacy migration skipped: already completed");
            return MIGRATION_STATUS_COMPLETED;
        }
        if (!isMigrationApkInstalled(ctx)) {
            Log.d(TAG, "Legacy migration skiped: no migration app installed");
            Log.d(TAG, "Legacy migration skipped: no migration app installed");
            markMigrationStatus(ctx, MIGRATION_STATUS_MISSING_APK);
            return MIGRATION_STATUS_MISSING_APK;
        }
        if (!incrementeMigrationAttempt(ctx)) {
            Log.d(TAG, "Legacy migration skiped: still failing after too many attempt");
            Log.d(TAG, "Legacy migration skipped: still failing after too many attempt");
            markMigrationStatus(ctx, MIGRATION_STATUS_MAX_ATTEMPT);
            return MIGRATION_STATUS_MAX_ATTEMPT;
        }
+2 −21
Original line number Diff line number Diff line
@@ -72,7 +72,6 @@ public class BluetoothKeystoreService {
    private static final int TRY_MAX = 3;

    private static final String CONFIG_FILE_PREFIX = "bt_config-origin";
    private static final String CONFIG_BACKUP_PREFIX = "bt_config-backup";

    private static final String CONFIG_FILE_HASH = "hash";

@@ -80,17 +79,13 @@ public class BluetoothKeystoreService {
            "/data/misc/bluedroid/bt_config.checksum.encrypted";
    private static final String CONFIG_FILE_ENCRYPTION_PATH =
            "/data/misc/bluedroid/bt_config.conf.encrypted";
    private static final String CONFIG_BACKUP_ENCRYPTION_PATH =
            "/data/misc/bluedroid/bt_config.bak.encrypted";

    private static final String CONFIG_FILE_PATH = "/data/misc/bluedroid/bt_config.conf";
    private static final String CONFIG_BACKUP_PATH = "/data/misc/bluedroid/bt_config.bak";

    private static final int BUFFER_SIZE = 400 * 10;

    private static final int CONFIG_COMPARE_INIT = 0b00;
    private static final int CONFIG_FILE_COMPARE_PASS = 0b01;
    private static final int CONFIG_BACKUP_COMPARE_PASS = 0b10;
    private int mCompareResult;

    private final BluetoothKeystoreNativeInterface mBluetoothKeystoreNativeInterface;
@@ -225,21 +220,13 @@ public class BluetoothKeystoreService {
                    debugLog("bt_config.conf checksum pass.");
                    mCompareResult = mCompareResult | CONFIG_FILE_COMPARE_PASS;
                }
                if (compareFileHash(CONFIG_BACKUP_PATH)) {
                    debugLog("bt_config.bak checksum pass.");
                    mCompareResult = mCompareResult | CONFIG_BACKUP_COMPARE_PASS;
                }
                // Step4: choose which encryption file loads.
                if (doesComparePass(CONFIG_FILE_COMPARE_PASS)) {
                    loadEncryptionFile(CONFIG_FILE_ENCRYPTION_PATH, true);
                } else if (doesComparePass(CONFIG_BACKUP_COMPARE_PASS)) {
                    Files.deleteIfExists(Paths.get(CONFIG_FILE_ENCRYPTION_PATH));
                    mNameEncryptKey.remove(CONFIG_FILE_PREFIX);
                    loadEncryptionFile(CONFIG_BACKUP_ENCRYPTION_PATH, true);
                } else {
                    // if the Common Criteria mode is disable, don't show the log.
                    if (mIsCommonCriteriaMode) {
                        debugLog("Config file conf and bak checksum check fail.");
                        debugLog("Config file conf checksum check fail.");
                    }
                    cleanupAll();
                    return;
@@ -301,8 +288,6 @@ public class BluetoothKeystoreService {
            } else if (decryptedString.equals(CONFIG_FILE_HASH)) {
                readHashFile(CONFIG_FILE_PATH, CONFIG_FILE_PREFIX);
                mPendingEncryptKey.put(CONFIG_FILE_PREFIX);
                readHashFile(CONFIG_BACKUP_PATH, CONFIG_BACKUP_PREFIX);
                mPendingEncryptKey.put(CONFIG_BACKUP_PREFIX);
                saveEncryptedKey();
            }
            return;
@@ -328,7 +313,6 @@ public class BluetoothKeystoreService {
    private void cleanupFile() throws IOException {
        Files.deleteIfExists(Paths.get(CONFIG_CHECKSUM_ENCRYPTION_PATH));
        Files.deleteIfExists(Paths.get(CONFIG_FILE_ENCRYPTION_PATH));
        Files.deleteIfExists(Paths.get(CONFIG_BACKUP_ENCRYPTION_PATH));
    }

    /** Clean up memory. */
@@ -381,7 +365,7 @@ public class BluetoothKeystoreService {
        List<String> configEncryptedLines = new ArrayList<>();
        List<String> keyEncryptedLines = new ArrayList<>();
        for (String key : mNameEncryptKey.keySet()) {
            if (key.equals(CONFIG_FILE_PREFIX) || key.equals(CONFIG_BACKUP_PREFIX)) {
            if (key.equals(CONFIG_FILE_PREFIX)) {
                configEncryptedLines.add(getEncryptedKeyData(key));
            } else {
                keyEncryptedLines.add(getEncryptedKeyData(key));
@@ -395,7 +379,6 @@ public class BluetoothKeystoreService {
            }
            if (!keyEncryptedLines.isEmpty()) {
                Files.write(Paths.get(CONFIG_FILE_ENCRYPTION_PATH), keyEncryptedLines);
                Files.write(Paths.get(CONFIG_BACKUP_ENCRYPTION_PATH), keyEncryptedLines);
            }
        } catch (IOException e) {
            throw new RuntimeException("write encryption file fail");
@@ -441,8 +424,6 @@ public class BluetoothKeystoreService {
        String prefixString = null;
        if (CONFIG_FILE_PATH.equals(hashFilePathString)) {
            prefixString = CONFIG_FILE_PREFIX;
        } else if (CONFIG_BACKUP_PATH.equals(hashFilePathString)) {
            prefixString = CONFIG_BACKUP_PREFIX;
        }
        if (prefixString == null) {
            errorLog("compareFileHash: Unexpected hash file path: " + hashFilePathString);
+0 −5
Original line number Diff line number Diff line
@@ -52,13 +52,10 @@ public final class BluetoothKeystoreServiceTest {

    // Please also check bt_stack string configuration if you want to change the content.
    private static final String CONFIG_FILE_PREFIX = "bt_config-origin";
    private static final String CONFIG_BACKUP_PREFIX = "bt_config-backup";
    private static final String CONFIG_FILE_HASH = "hash";
    private static final String CONFIG_FILE_PATH = "/data/misc/bluedroid/bt_config.conf";
    private static final String CONFIG_FILE_ENCRYPTION_PATH =
            "/data/misc/bluedroid/bt_config.conf.encrypted";
    private static final String CONFIG_BACKUP_ENCRYPTION_PATH =
            "/data/misc/bluedroid/bt_config.bak.encrypted";
    private static final String CONFIG_CHECKSUM_ENCRYPTION_PATH =
            "/data/misc/bluedroid/bt_config.checksum.encrypted";

@@ -271,11 +268,9 @@ public final class BluetoothKeystoreServiceTest {
        // check encryption file clean up.
        Assert.assertFalse(Files.exists(Paths.get(CONFIG_CHECKSUM_ENCRYPTION_PATH)));
        Assert.assertFalse(Files.exists(Paths.get(CONFIG_FILE_ENCRYPTION_PATH)));
        Assert.assertFalse(Files.exists(Paths.get(CONFIG_BACKUP_ENCRYPTION_PATH)));

        // remove hash data avoid interfering result.
        mBluetoothKeystoreService.getNameDecryptKey().remove(CONFIG_FILE_PREFIX);
        mBluetoothKeystoreService.getNameDecryptKey().remove(CONFIG_BACKUP_PREFIX);

        Assert.assertTrue(
                doCompareMap(mNameDecryptKeyResult, mBluetoothKeystoreService.getNameDecryptKey()));
Loading