You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.3 KiB
72 lines
2.3 KiB
/*
|
|
* Copyright 2019 The Android Open Source Project
|
|
*
|
|
* 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
|
|
|
|
#include <functional>
|
|
#include <list>
|
|
#include <string>
|
|
|
|
#define LOG_DUMPSYS(fd, fmt, args...) \
|
|
do { \
|
|
dprintf(fd, "%s " fmt "\n", DUMPSYS_TAG, ##args); \
|
|
} while (false)
|
|
|
|
#define LOG_DUMPSYS_TITLE(fd, title) \
|
|
do { \
|
|
dprintf(fd, " ----- %s -----\n", title); \
|
|
} while (false)
|
|
|
|
constexpr char kPrivateAddressPrefix[] = "xx:xx:xx:xx";
|
|
#define PRIVATE_ADDRESS(addr) \
|
|
(addr.ToString() \
|
|
.replace(0, strlen(kPrivateAddressPrefix), kPrivateAddressPrefix) \
|
|
.c_str())
|
|
|
|
#define PRIVATE_CELL(number) \
|
|
(number \
|
|
.replace(0, (number.size() > 2) ? number.size() - 2 : 0, \
|
|
(number.size() > 2) ? number.size() - 2 : 0, '*') \
|
|
.c_str())
|
|
|
|
inline double ticks_to_seconds(uint16_t ticks) {
|
|
return (static_cast<double>(ticks) * 0.625 * 0.001);
|
|
}
|
|
|
|
inline double supervision_timeout_to_seconds(uint16_t timeout) {
|
|
return (static_cast<double>(timeout) * 0.01);
|
|
}
|
|
|
|
namespace bluetooth {
|
|
namespace shim {
|
|
|
|
using DumpsysFunction = std::function<void(int fd)>;
|
|
|
|
/**
|
|
* Entrypoint from legacy stack to provide dumpsys functionality
|
|
* for both the legacy shim and the Gabeldorsche stack.
|
|
*/
|
|
void Dump(int fd, const char** args);
|
|
|
|
/**
|
|
* Dumpsys access for legacy shim modules.
|
|
*/
|
|
void RegisterDumpsysFunction(const void* token, DumpsysFunction func);
|
|
void UnregisterDumpsysFunction(const void* token);
|
|
|
|
} // namespace shim
|
|
} // namespace bluetooth
|