mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-16 00:30:09 +00:00
Sync source with AOSP
This commit is contained in:
143
native/jni/resetprop/private/_system_properties.h
Normal file
143
native/jni/resetprop/private/_system_properties.h
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
|
||||
#error you should #include <sys/system_properties.h> instead
|
||||
#endif
|
||||
|
||||
#include "system_properties.h"
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define PROP_SERVICE_NAME "property_service"
|
||||
#define PROP_FILENAME "/dev/__properties__"
|
||||
|
||||
#define PROP_MSG_SETPROP 1
|
||||
#define PROP_MSG_SETPROP2 0x00020001
|
||||
|
||||
#define PROP_SUCCESS 0
|
||||
#define PROP_ERROR_READ_CMD 0x0004
|
||||
#define PROP_ERROR_READ_DATA 0x0008
|
||||
#define PROP_ERROR_READ_ONLY_PROPERTY 0x000B
|
||||
#define PROP_ERROR_INVALID_NAME 0x0010
|
||||
#define PROP_ERROR_INVALID_VALUE 0x0014
|
||||
#define PROP_ERROR_PERMISSION_DENIED 0x0018
|
||||
#define PROP_ERROR_INVALID_CMD 0x001B
|
||||
#define PROP_ERROR_HANDLE_CONTROL_MESSAGE 0x0020
|
||||
#define PROP_ERROR_SET_FAILED 0x0024
|
||||
|
||||
/*
|
||||
** Map the property area from the specified filename. This
|
||||
** method is for testing only.
|
||||
*/
|
||||
int __system_property_set_filename(const char *filename);
|
||||
|
||||
/*
|
||||
** Initialize the area to be used to store properties. Can
|
||||
** only be done by a single process that has write access to
|
||||
** the property area.
|
||||
*/
|
||||
int __system_property_area_init();
|
||||
|
||||
/* Read the global serial number of the system properties
|
||||
**
|
||||
** Called to predict if a series of cached __system_property_find
|
||||
** objects will have seen __system_property_serial values change.
|
||||
** But also aids the converse, as changes in the global serial can
|
||||
** also be used to predict if a failed __system_property_find
|
||||
** could in-turn now find a new object; thus preventing the
|
||||
** cycles of effort to poll __system_property_find.
|
||||
**
|
||||
** Typically called at beginning of a cache cycle to signal if _any_ possible
|
||||
** changes have occurred since last. If there is, one may check each individual
|
||||
** __system_property_serial to confirm dirty, or __system_property_find
|
||||
** to check if the property now exists. If a call to __system_property_add
|
||||
** or __system_property_update has completed between two calls to
|
||||
** __system_property_area_serial then the second call will return a larger
|
||||
** value than the first call. Beware of race conditions as changes to the
|
||||
** properties are not atomic, the main value of this call is to determine
|
||||
** whether the expensive __system_property_find is worth retrying to see if
|
||||
** a property now exists.
|
||||
**
|
||||
** Returns the serial number on success, -1 on error.
|
||||
*/
|
||||
uint32_t __system_property_area_serial();
|
||||
|
||||
/* Add a new system property. Can only be done by a single
|
||||
** process that has write access to the property area, and
|
||||
** that process must handle sequencing to ensure the property
|
||||
** does not already exist and that only one property is added
|
||||
** or updated at a time.
|
||||
**
|
||||
** Returns 0 on success, -1 if the property area is full.
|
||||
*/
|
||||
int __system_property_add(const char *name, unsigned int namelen, const char *value, unsigned int valuelen);
|
||||
|
||||
/* Delete a new system property. Added in resetprop
|
||||
**
|
||||
** Returns 0 on success, -1 if the property area is full.
|
||||
*/
|
||||
int __system_property_del(const char *name);
|
||||
|
||||
/* Update the value of a system property returned by
|
||||
** __system_property_find. Can only be done by a single process
|
||||
** that has write access to the property area, and that process
|
||||
** must handle sequencing to ensure that only one property is
|
||||
** updated at a time.
|
||||
**
|
||||
** Returns 0 on success, -1 if the parameters are incorrect.
|
||||
*/
|
||||
int __system_property_update(prop_info *pi, const char *value, unsigned int len);
|
||||
|
||||
/* Read the serial number of a system property returned by
|
||||
** __system_property_find.
|
||||
**
|
||||
** Returns the serial number on success, -1 on error.
|
||||
*/
|
||||
uint32_t __system_property_serial(const prop_info* pi);
|
||||
|
||||
/* Initialize the system properties area in read only mode.
|
||||
* Should be done by all processes that need to read system
|
||||
* properties.
|
||||
*
|
||||
* Returns 0 on success, -1 otherwise.
|
||||
*/
|
||||
int __system_properties_init();
|
||||
|
||||
/* Deprecated: use __system_property_wait instead. */
|
||||
uint32_t __system_property_wait_any(uint32_t old_serial);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
21
native/jni/resetprop/private/redefs.h
Normal file
21
native/jni/resetprop/private/redefs.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef REDEFS_H
|
||||
#define REDEFS_H
|
||||
|
||||
#define __system_property_set _system_property_set2
|
||||
#define __system_property_find _system_property_find2
|
||||
#define __system_property_read_callback _system_property_read_callback2
|
||||
#define __system_property_foreach __system_property_foreach2
|
||||
#define __system_property_wait __system_property_wait2
|
||||
#define __system_property_read __system_property_read2
|
||||
#define __system_property_get __system_property_get2
|
||||
#define __system_property_find_nth __system_property_find_nth2
|
||||
#define __system_property_set_filename __system_property_set_filename2
|
||||
#define __system_property_area_init __system_property_area_init2
|
||||
#define __system_property_area_serial __system_property_area_serial2
|
||||
#define __system_property_add __system_property_add2
|
||||
#define __system_property_update __system_property_update2
|
||||
#define __system_property_serial __system_property_serial2
|
||||
#define __system_properties_init __system_properties_init2
|
||||
#define __system_property_wait_any __system_property_wait_any2
|
||||
|
||||
#endif //REDEFS_H
|
102
native/jni/resetprop/private/system_properties.h
Normal file
102
native/jni/resetprop/private/system_properties.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "redefs.h"
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef struct prop_info prop_info;
|
||||
|
||||
#define PROP_VALUE_MAX 92
|
||||
|
||||
/*
|
||||
* Sets system property `key` to `value`, creating the system property if it doesn't already exist.
|
||||
*/
|
||||
int __system_property_set(const char *key, const char *value);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
const prop_info* __system_property_find(const char *name);
|
||||
|
||||
/*
|
||||
* Calls `callback` with a consistent trio of name, value, and serial number for property `pi`.
|
||||
*/
|
||||
void __system_property_read_callback(const prop_info *pi,
|
||||
void (*callback)(void* cookie, const char *name, const char *value, uint32_t serial),
|
||||
void* cookie);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
int __system_property_foreach(void (*propfn)(const prop_info *pi, void *cookie), void *cookie);
|
||||
|
||||
/*
|
||||
* Waits for the specific system property identified by `pi` to be updated
|
||||
* past `old_serial`. Waits no longer than `relative_timeout`, or forever
|
||||
* if `relaive_timeout` is null.
|
||||
*
|
||||
* 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;
|
||||
bool __system_property_wait(const prop_info *pi,
|
||||
uint32_t old_serial,
|
||||
uint32_t *new_serial_ptr,
|
||||
const struct timespec *relative_timeout);
|
||||
|
||||
/* 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. */
|
||||
int __system_property_read(const prop_info* pi, char* name, char* value);
|
||||
/* Deprecated. Use __system_property_read_callback instead. */
|
||||
int __system_property_get(const char* name, char* value);
|
||||
/* Deprecated. Use __system_property_foreach instead. */
|
||||
const prop_info* __system_property_find_nth(unsigned n);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user