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

Commit 2da8e5ef authored by weichinweng's avatar weichinweng
Browse files

NIAP: Add new argument to determine config checksum check result.(2/4)

Bug: 148758680
Test: m
Change-Id: I07eb90a144e172212c7a1a55ef200111efd297e0
Merged-In: I07eb90a144e172212c7a1a55ef200111efd297e0
parent 03b602fa
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ bool is_restricted_mode(void);

/*******************************************************************************
 *
 * Function         is_single_user_mode_
 * Function         is_niap_mode_
 *
 * Description      Checks if BT was enabled in single user mode. In this
 *                  mode, use of keystore for key attestation of LTK is limitee
@@ -114,7 +114,23 @@ bool is_restricted_mode(void);
 * Returns          bool
 *
 ******************************************************************************/
bool is_single_user_mode(void);
bool is_niap_mode(void);

/*******************************************************************************
 *
 * Function         get_niap_config_compare_result
 *
 * Description      Get the niap config compare result for confirming the config
 *                  checksum compare result. When the niap mode doesn't enable,
 *                  it should be all pass (0b11).
 *                  Bit define:
 *                    CONFIG_FILE_COMPARE_PASS = 0b01
 *                    CONFIG_BACKUP_COMPARE_PASS = 0b10
 *
 * Returns          int
 *
 ******************************************************************************/
int get_niap_config_compare_result(void);

/*******************************************************************************
 *
+16 −6
Original line number Diff line number Diff line
@@ -84,7 +84,9 @@ using bluetooth::hearing_aid::HearingAidInterface;

bt_callbacks_t* bt_hal_cbacks = NULL;
bool restricted_mode = false;
bool single_user_mode = false;
bool niap_mode = false;
const int CONFIG_COMPARE_ALL_PASS = 0b11;
int niap_config_compare_result = CONFIG_COMPARE_ALL_PASS;

/*******************************************************************************
 *  Externs
@@ -137,9 +139,10 @@ static bool is_profile(const char* p1, const char* p2) {
 ****************************************************************************/

static int init(bt_callbacks_t* callbacks, bool start_restricted,
                bool is_single_user_mode) {
  LOG_INFO(LOG_TAG, "%s: start restricted = %d ; single user = %d", __func__,
           start_restricted, is_single_user_mode);
                bool is_niap_mode, int config_compare_result) {
  LOG_INFO(LOG_TAG,
           "%s: start restricted = %d ; niap = %d, config compare result = %d",
           __func__, start_restricted, is_niap_mode, config_compare_result);

  if (bluetooth::shim::is_gd_shim_enabled()) {
    LOG_INFO(LOG_TAG, "%s Enable Gd bluetooth functionality", __func__);
@@ -155,7 +158,9 @@ static int init(bt_callbacks_t* callbacks, bool start_restricted,

  bt_hal_cbacks = callbacks;
  restricted_mode = start_restricted;
  single_user_mode = is_single_user_mode;
  niap_mode = is_niap_mode;
  niap_config_compare_result = config_compare_result;

  stack_manager_get_interface()->init_stack();
  btif_debug_init();
  return BT_STATUS_SUCCESS;
@@ -178,7 +183,12 @@ static int disable(void) {
static void cleanup(void) { stack_manager_get_interface()->clean_up_stack(); }

bool is_restricted_mode() { return restricted_mode; }
bool is_single_user_mode() { return single_user_mode; }
bool is_niap_mode() { return niap_mode; }
// if niap mode disable, will always return CONFIG_COMPARE_ALL_PASS(0b11)
// indicate don't check config checksum.
int get_niap_config_compare_result() {
  return niap_mode ? niap_config_compare_result : CONFIG_COMPARE_ALL_PASS;
}

static int get_adapter_properties(void) {
  /* sanity check */
+5 −3
Original line number Diff line number Diff line
@@ -469,10 +469,12 @@ typedef struct {
   * The |start_restricted| flag inits the adapter in restricted mode. In
   * restricted mode, bonds that are created are marked as restricted in the
   * config file. These devices are deleted upon leaving restricted mode.
   * The |is_single_user_mode| flag inits the adapter in NIAP mode.
   * The |is_niap_mode| flag inits the adapter in NIAP mode.
   * The |config_compare_result| flag show the config checksum check result if
   * is in NIAP mode.
   */
  int (*init)(bt_callbacks_t* callbacks, bool guest_mode,
              bool is_single_user_mode);
  int (*init)(bt_callbacks_t* callbacks, bool guest_mode, bool is_niap_mode,
              int config_compare_result);

  /** Enable Bluetooth. */
  int (*enable)();
+1 −1
Original line number Diff line number Diff line
@@ -254,7 +254,7 @@ class BluetoothInterfaceImpl : public BluetoothInterface {

    // Initialize the Bluetooth interface. Set up the adapter (Bluetooth DM) API
    // callbacks.
    status = hal_iface_->init(&bt_callbacks, false, false);
    status = hal_iface_->init(&bt_callbacks, false, false, 0);
    if (status != BT_STATUS_SUCCESS) {
      LOG(ERROR) << "Failed to initialize Bluetooth stack";
      return false;
+1 −1
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@ bt_os_callouts_t bt_os_callouts{
void HeadlessStack::SetUp() {
  LOG(INFO) << __func__ << " Entry";

  int status = bluetoothInterface.init(&bt_callbacks, false, false);
  int status = bluetoothInterface.init(&bt_callbacks, false, false, 0);
  (status == BT_STATUS_SUCCESS)
      ? LOG(INFO) << __func__ << " Initialized bluetooth callbacks"
      : LOG(FATAL) << "Failed to initialize Bluetooth stack";
Loading