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

Commit 12d37c73 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Gerrit Code Review
Browse files

Merge "Remove unused profile manager"

parents 499e8533 096661df
Loading
Loading
Loading
Loading

system/profile/Android.mk

deleted100644 → 0
+0 −44
Original line number Diff line number Diff line
 ##############################################################################
 #
 #  Copyright (C) 2014 Google, Inc.
 #
 #  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.
 #
 ##############################################################################

LOCAL_PATH := $(call my-dir)

# Bluetooth profile static library for target
# ========================================================
include $(CLEAR_VARS)

LOCAL_C_INCLUDES := \
    $(LOCAL_PATH)/.. \
    $(LOCAL_PATH)/include \
    $(LOCAL_PATH)/../btcore/include \
    $(LOCAL_PATH)/../include \
    $(bluetooth_C_INCLUDES)

LOCAL_SRC_FILES := \
    src/manager.c

LOCAL_MODULE := libbtprofile
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := libc liblog
LOCAL_MODULE_CLASS := STATIC_LIBRARIES

LOCAL_CFLAGS += $(bluetooth_CFLAGS)
LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)

include $(BUILD_STATIC_LIBRARY)

system/profile/include/manager.h

deleted100644 → 0
+0 −41
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  Copyright (C) 2014 Google, Inc.
 *
 *  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.
 *
 ******************************************************************************/

#pragma once

static const char PROFILE_MANAGER_MODULE[] = "profile_manager_module";

typedef enum {
  PROFILE_POWER_ACTIVE,
  PROFILE_POWER_HOLD,
  PROFILE_POWER_SNIFF,
  PROFILE_POWER_PARK
} profile_power_level_t;

typedef struct profile_t {
  const char *name;
  profile_power_level_t lowest_acceptable_power_mode;
  bool in_use;
} profile_t;

// Registers a given Bluetooth |profile| with the manager.
void profile_register(const profile_t *profile);

// Looks up a previously registered profile by |name|. If no profile was
// registered by the given |name|, then this function returns NULL.
const profile_t *profile_by_name(const char *name);

system/profile/src/manager.c

deleted100644 → 0
+0 −87
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  Copyright (C) 2014 Google, Inc.
 *
 *  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.
 *
 ******************************************************************************/

#define LOG_TAG "bt_profile_manager"

#include <assert.h>
#include <stdbool.h>

#include "btcore/include/module.h"
#include "profile/include/manager.h"
#include "osi/include/future.h"
#include "osi/include/hash_functions.h"
#include "osi/include/hash_map.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"

static const size_t number_of_profile_buckets = 15;

static bool initialized;
static hash_map_t *profile_map;

// Lifecycle management functions

static future_t *init(void) {
  profile_map = hash_map_new(
    number_of_profile_buckets,
    hash_function_string,
    NULL,
    NULL,
    NULL);

  initialized = true;
  return NULL;
}

static future_t *clean_up(void) {
  initialized = false;

  hash_map_free(profile_map);
  profile_map = NULL;

  return NULL;
}

EXPORT_SYMBOL const module_t profile_manager_module = {
  .name = PROFILE_MANAGER_MODULE,
  .init = init,
  .start_up = NULL,
  .shut_down = NULL,
  .clean_up = clean_up,
  .dependencies = {
    NULL
  }
};

// Interface functions

void profile_register(const profile_t *profile) {
  assert(initialized);
  assert(profile != NULL);
  assert(profile->name != NULL);
  assert(!hash_map_has_key(profile_map, profile->name));

  hash_map_set(profile_map, profile->name, (void *) profile);
}

const profile_t *profile_by_name(const char *name) {
  assert(initialized);
  assert(name != NULL);

  return (profile_t *)hash_map_get(profile_map, name);
}