2009-03-04 04:28:35 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE_SYS_SYSTEM_PROPERTIES_H
|
|
|
|
#define _INCLUDE_SYS_SYSTEM_PROPERTIES_H
|
|
|
|
|
2010-02-09 23:05:43 +01:00
|
|
|
#include <sys/cdefs.h>
|
2017-02-17 00:34:21 +01:00
|
|
|
#include <stdbool.h>
|
2017-01-24 21:43:29 +01:00
|
|
|
#include <stddef.h>
|
2017-02-11 03:13:46 +01:00
|
|
|
#include <stdint.h>
|
2010-02-09 23:05:43 +01:00
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
2009-03-04 04:28:35 +01:00
|
|
|
typedef struct prop_info prop_info;
|
|
|
|
|
|
|
|
#define PROP_VALUE_MAX 92
|
|
|
|
|
2017-02-11 03:13:46 +01:00
|
|
|
/*
|
2017-08-18 00:34:21 +02:00
|
|
|
* Sets system property `name` to `value`, creating the system property if it doesn't already exist.
|
2017-02-11 03:13:46 +01:00
|
|
|
*/
|
2023-05-17 02:20:12 +02:00
|
|
|
int __system_property_set(const char* _Nonnull __name, const char* _Nonnull __value);
|
2011-03-11 00:52:49 +01:00
|
|
|
|
2017-02-11 03:13:46 +01:00
|
|
|
/*
|
|
|
|
* Returns a `prop_info` corresponding system property `name`, or nullptr if it doesn't exist.
|
|
|
|
* Use __system_property_read_callback to query the current value.
|
|
|
|
*
|
|
|
|
* Property lookup is expensive, so it can be useful to cache the result of this function.
|
|
|
|
*/
|
2023-05-17 02:20:12 +02:00
|
|
|
const prop_info* _Nullable __system_property_find(const char* _Nonnull __name);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2017-02-11 03:13:46 +01:00
|
|
|
/*
|
|
|
|
* Calls `callback` with a consistent trio of name, value, and serial number for property `pi`.
|
|
|
|
*/
|
2023-05-17 02:20:12 +02:00
|
|
|
void __system_property_read_callback(const prop_info* _Nonnull __pi,
|
|
|
|
void (* _Nonnull __callback)(void* _Nullable __cookie, const char* _Nonnull __name, const char* _Nonnull __value, uint32_t __serial),
|
|
|
|
void* _Nullable __cookie) __INTRODUCED_IN(26);
|
2013-02-13 01:39:31 +01:00
|
|
|
|
2017-02-11 03:13:46 +01:00
|
|
|
/*
|
|
|
|
* Passes a `prop_info` for each system property to the provided
|
|
|
|
* callback. Use __system_property_read_callback() to read the value.
|
|
|
|
*
|
|
|
|
* This method is for inspecting and debugging the property system, and not generally useful.
|
|
|
|
*/
|
2023-05-17 02:20:12 +02:00
|
|
|
int __system_property_foreach(void (* _Nonnull __callback)(const prop_info* _Nonnull __pi, void* _Nullable __cookie), void* _Nullable __cookie)
|
2016-05-27 20:14:16 +02:00
|
|
|
__INTRODUCED_IN(19);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2017-02-17 00:34:21 +01:00
|
|
|
/*
|
|
|
|
* Waits for the specific system property identified by `pi` to be updated
|
|
|
|
* past `old_serial`. Waits no longer than `relative_timeout`, or forever
|
2023-05-17 02:20:12 +02:00
|
|
|
* if `relative_timeout` is null.
|
2017-02-17 00:34:21 +01:00
|
|
|
*
|
|
|
|
* If `pi` is null, waits for the global serial number instead.
|
|
|
|
*
|
|
|
|
* If you don't know the current serial, use 0.
|
|
|
|
*
|
|
|
|
* Returns true and updates `*new_serial_ptr` on success, or false if the call
|
|
|
|
* timed out.
|
|
|
|
*/
|
|
|
|
struct timespec;
|
2023-05-17 02:20:12 +02:00
|
|
|
bool __system_property_wait(const prop_info* _Nullable __pi, uint32_t __old_serial, uint32_t* _Nonnull __new_serial_ptr, const struct timespec* _Nullable __relative_timeout)
|
2017-04-20 21:58:31 +02:00
|
|
|
__INTRODUCED_IN(26);
|
2017-02-17 00:34:21 +01:00
|
|
|
|
2017-02-11 03:13:46 +01:00
|
|
|
/* Deprecated. In Android O and above, there's no limit on property name length. */
|
|
|
|
#define PROP_NAME_MAX 32
|
|
|
|
/* Deprecated. Use __system_property_read_callback instead. */
|
2023-05-17 02:20:12 +02:00
|
|
|
int __system_property_read(const prop_info* _Nonnull __pi, char* _Nullable __name, char* _Nonnull __value);
|
2017-02-11 03:13:46 +01:00
|
|
|
/* Deprecated. Use __system_property_read_callback instead. */
|
2023-05-17 02:20:12 +02:00
|
|
|
int __system_property_get(const char* _Nonnull __name, char* _Nonnull __value);
|
2017-04-17 23:53:07 +02:00
|
|
|
/* Deprecated. Use __system_property_foreach instead. */
|
2023-05-17 02:20:12 +02:00
|
|
|
const prop_info* _Nullable __system_property_find_nth(unsigned __n);
|
2017-02-11 03:13:46 +01:00
|
|
|
|
2010-02-09 23:05:43 +01:00
|
|
|
__END_DECLS
|
|
|
|
|
2009-03-04 04:28:35 +01:00
|
|
|
#endif
|