Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flat-file implementation of property_set / property_get. #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,8 @@ install: all
install -D -m 0755 adb/xdg-adbd $(DESTDIR)$(sbindir)
install -d -m 0755 $(DESTDIR)$(prefix)/lib/systemd/system/
install -D -m 0644 $(top_srcdir)/adbd.service $(DESTDIR)$(prefix)/lib/systemd/system/
install -d -m 0755 $(DESTDIR)$(sysconfdir)
[ -e $(DESTDIR)$(sysconfdir)/adb.properties ] || \
install -D -m 0644 $(top_srcdir)/adb.properties $(DESTDIR)$(sysconfdir)

.PHONY: subdirs
11 changes: 11 additions & 0 deletions adb.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file stores system properties read by the adbd daemon
# Lines beginning with # are ignored. Leading and trailing
# whitespace in the key and value is ignored unless escaped.
# Escapes are:
# \n - newline
# \t - tab
# \xNN - byte in hex
# \<any other character> - that character
#
# Override the default port
#service.adb.tcp.port=5555
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ EOF
if [ "$(pwd)" != "$(cd $top_srcdir && pwd)" ] ; then
cat > Makefile <<EOF
top_srcdir = $top_srcdir
top_builddir = .
include \$(top_srcdir)/Makefile
EOF
fi
Expand Down
2 changes: 2 additions & 0 deletions include.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ mandir ?= $(datadir)/man
sysconfdir ?= $(prefix)/etc
OPT_CFLAGS ?= -O2 -g
OPT_CXXFLAGS ?= -O2 -g

PROPERTIES_PATH=$(sysconfdir)/adb.properties
5 changes: 4 additions & 1 deletion include/cutils/properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

#include <sys/cdefs.h>
#include <stddef.h>
#if !ADB_NON_ANDROID
#if ADB_NON_ANDROID
#define PROP_NAME_MAX 32
#define PROP_VALUE_MAX 92
#else
#include <sys/system_properties.h>
#endif
#include <stdint.h>
Expand Down
3 changes: 2 additions & 1 deletion libcutils/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ commonSources := \
strdup8to16.c \
record_stream.c \
process_name.c \
properties.c \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here was to have either properties.c for Android, or properties_nonandroid.c for the others, providing the same functions. Can we do without the properties.c addition (and changes)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want me to cut-and-paste property_get_bool(), etc. I don't see how to reuse that without some changes to properties.c.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, fair enough. Feel free to ignore that.

properties_nonandroid.c \
threads.c \
sched_policy.c \
Expand Down Expand Up @@ -52,7 +53,7 @@ LOCAL_CFLAGS += $(targetSmpFlag)

OBJS = $(LOCAL_SRC_FILES:.c=.o) $(LOCAL_CXX_SRC_FILES:.cpp=.o)
EXTRA_CFLAGS = $(LOCAL_CFLAGS) -I$(top_srcdir)/include -I$(srcdir) -DHAVE_PTHREADS=1 -DADB_NON_ANDROID=1
EXTRA_CFLAGS += -DPROP_NAME_MAX=32 -DPROP_VALUE_MAX=92
EXTRA_CFLAGS += -DPROP_NAME_MAX=32 -DPROP_VALUE_MAX=92 -DPROPERTIES_PATH=\"$(PROPERTIES_PATH)\"
CFLAGS = $(OPT_CFLAGS) $(EXTRA_CFLAGS)
CXXFLAGS = $(OPT_CXXFLAGS) $(EXTRA_CFLAGS)

Expand Down
4 changes: 4 additions & 0 deletions libcutils/properties.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ int32_t property_get_int32(const char *key, int32_t default_value) {
return (int32_t)property_get_imax(key, INT32_MIN, INT32_MAX, default_value);
}

#ifndef ADB_NON_ANDROID

#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>

Expand Down Expand Up @@ -154,3 +156,5 @@ int property_list(
struct property_list_callback_data data = { propfn, cookie };
return __system_property_foreach(property_list_callback, &data);
}

#endif
Loading