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

Commit 4365c33f authored by weichinweng's avatar weichinweng Committed by Automerger Merge Worker
Browse files

NIAP: Ignore BluetoothKeystoreServiceTest when the User is not primary. am: 59f912b3

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Bluetooth/+/11907827

Change-Id: I91b314272cb10040409d474332c1c3797969d0a3
parents 2a4352ef 59f912b3
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.bluetooth.btservice.bluetoothkeystore;

import android.os.Binder;
import android.os.Process;
import android.util.Log;

import java.io.IOException;
@@ -29,6 +31,7 @@ import java.util.Map;

import org.junit.After;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -116,6 +119,7 @@ public final class BluetoothKeystoreServiceTest {

    @Before
    public void setUp() {
        Assume.assumeTrue("Ignore test when the user is not primary.", isPrimaryUser());
        mBluetoothKeystoreService = new BluetoothKeystoreService(true);
        Assert.assertNotNull(mBluetoothKeystoreService);
        // backup origin config data.
@@ -130,6 +134,9 @@ public final class BluetoothKeystoreServiceTest {

    @After
    public void tearDown() {
        if (!isPrimaryUser()) {
            return;
        }
        try {
            if (!mConfigData.isEmpty()) {
                Files.write(Paths.get(CONFIG_FILE_PATH), mConfigData);
@@ -142,6 +149,10 @@ public final class BluetoothKeystoreServiceTest {
        mBluetoothKeystoreService = null;
    }

    private static boolean isPrimaryUser() {
        return Binder.getCallingUid() == Process.BLUETOOTH_UID;
    }

    private void overwriteConfigFile(List<String> data) {
        try {
            Files.write(Paths.get(CONFIG_FILE_PATH), data);