Loading property_service/libpropertyinfoparser/Android.bp +1 −0 Original line number Original line Diff line number Diff line cc_library_static { cc_library_static { name: "libpropertyinfoparser", name: "libpropertyinfoparser", host_supported: true, host_supported: true, vendor_available: true, srcs: ["property_info_parser.cpp"], srcs: ["property_info_parser.cpp"], cpp_std: "experimental", cpp_std: "experimental", Loading property_service/libpropertyinfoserializer/Android.bp +1 −0 Original line number Original line Diff line number Diff line cc_defaults { cc_defaults { name: "propertyinfoserializer_defaults", name: "propertyinfoserializer_defaults", host_supported: true, host_supported: true, vendor_available: true, cpp_std: "experimental", cpp_std: "experimental", cppflags: [ cppflags: [ "-Wall", "-Wall", Loading shell_and_utilities/README.md +8 −8 Original line number Original line Diff line number Diff line Loading @@ -175,18 +175,18 @@ bzip2: bzcat bzip2 bunzip2 one-true-awk: awk one-true-awk: awk toolbox: getevent newfs\_msdos toolbox: getevent getprop newfs\_msdos toybox: acpi base64 basename blockdev cal cat chcon chgrp chmod chown toybox: acpi base64 basename blockdev cal cat chcon chgrp chmod chown chroot chrt cksum clear cmp comm cp cpio cut date df diff dirname dmesg chroot chrt cksum clear cmp comm cp cpio cut date df diff dirname dmesg dos2unix du echo env expand expr fallocate false file find flock free dos2unix du echo env expand expr fallocate false file find flock free getenforce getprop groups gunzip gzip head hostname hwclock id ifconfig getenforce groups gunzip gzip head hostname hwclock id ifconfig inotifyd inotifyd insmod ionice iorenice kill killall ln load\_policy log logname insmod ionice iorenice kill killall ln load\_policy log logname losetup losetup ls lsmod lsof lspci lsusb md5sum microcom mkdir mkfifo mknod ls lsmod lsof lspci lsusb md5sum microcom mkdir mkfifo mknod mkswap mkswap mktemp modinfo modprobe more mount mountpoint mv netstat nice mktemp modinfo modprobe more mount mountpoint mv netstat nice nl nohup nl nohup od paste patch pgrep pidof pkill pmap printenv printf ps pwd od paste patch pgrep pidof pkill pmap printenv printf ps pwd readlink readlink realpath renice restorecon rm rmdir rmmod runcon sed sendevent realpath renice restorecon rm rmdir rmmod runcon sed sendevent seq seq setenforce setprop setsid sha1sum sha224sum sha256sum sha384sum setenforce setprop setsid sha1sum sha224sum sha256sum sha384sum sha512sum sleep sort split start stat stop strings swapoff swapon sync sha512sum sleep sort split start stat stop strings swapoff swapon sync sysctl tac tail tar taskset tee time timeout top touch tr true truncate sysctl tac tail tar taskset tee time timeout top touch tr true truncate tty ulimit umount uname uniq unix2dos uptime usleep uudecode uuencode tty ulimit umount uname uniq unix2dos uptime usleep uudecode uuencode Loading toolbox/Android.bp +5 −0 Original line number Original line Diff line number Diff line Loading @@ -44,9 +44,11 @@ genrule { cc_defaults { cc_defaults { name: "toolbox_binary_defaults", name: "toolbox_binary_defaults", defaults: ["toolbox_defaults"], defaults: ["toolbox_defaults"], cpp_std: "experimental", srcs: [ srcs: [ "toolbox.c", "toolbox.c", "getevent.c", "getevent.c", "getprop.cpp", "newfs_msdos.c", "newfs_msdos.c", ], ], generated_headers: [ generated_headers: [ Loading @@ -54,12 +56,15 @@ cc_defaults { ], ], whole_static_libs: ["libtoolbox_dd"], whole_static_libs: ["libtoolbox_dd"], shared_libs: [ shared_libs: [ "libbase", "libcutils", "libcutils", ], ], static_libs: ["libpropertyinfoparser"], symlinks: [ symlinks: [ "dd", "dd", "getevent", "getevent", "getprop", "newfs_msdos", "newfs_msdos", ], ], } } Loading toolbox/getprop.cpp 0 → 100644 +127 −0 Original line number Original line Diff line number Diff line // // Copyright (C) 2017 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. // #include <getopt.h> #include <sys/system_properties.h> #include <iostream> #include <string> #include <vector> #include <android-base/properties.h> #include <property_info_parser/property_info_parser.h> using android::base::GetProperty; using android::properties::PropertyInfoAreaFile; PropertyInfoAreaFile property_info_file; void PrintAllProperties(bool print_property_context) { std::vector<std::pair<std::string, std::string>> properties; __system_property_foreach( [](const prop_info* pi, void* cookie) { __system_property_read_callback( pi, [](void* cookie, const char* name, const char* value, unsigned) { auto properties = reinterpret_cast<std::vector<std::pair<std::string, std::string>>*>(cookie); properties->emplace_back(name, value); }, cookie); }, &properties); std::sort(properties.begin(), properties.end()); if (print_property_context) { for (auto& [name, value] : properties) { const char* context = nullptr; property_info_file->GetPropertyInfo(name.c_str(), &context, nullptr); value = context; } } for (const auto& [name, value] : properties) { std::cout << "[" << name << "]: [" << value << "]" << std::endl; } } void PrintProperty(const char* name, const char* default_value, bool print_property_context) { if (print_property_context) { const char* context = nullptr; property_info_file->GetPropertyInfo(name, &context, nullptr); std::cout << context << std::endl; } else { std::cout << GetProperty(name, default_value) << std::endl; } } extern "C" int getprop_main(int argc, char** argv) { bool print_property_context = false; while (true) { static const struct option long_options[] = { {"help", no_argument, nullptr, 'h'}, {nullptr, 0, nullptr, 0}, }; int arg = getopt_long(argc, argv, "Z", long_options, nullptr); if (arg == -1) { break; } switch (arg) { case 'h': std::cout << "usage: getprop [-Z] [NAME [DEFAULT]]\n\n" "Gets an Android system property, or lists them all.\n" "Use -Z to return the property context instead of the property value\n" << std::endl; return 0; case 'Z': print_property_context = true; break; case '?': return -1; default: std::cerr << "getprop: getopt returned invalid result: " << arg << std::endl; return -1; } } if (print_property_context) { property_info_file.LoadDefaultPath(); if (!property_info_file) { std::cerr << "Unable to load property info file" << std::endl; return -1; } } if (optind >= argc) { PrintAllProperties(print_property_context); return 0; } if (optind < argc - 2) { std::cerr << "getprop: Max 2 arguments (see \"getprop --help\")" << std::endl; return -1; } PrintProperty(argv[optind], (optind == argc - 1) ? "" : argv[optind + 1], print_property_context); return 0; } Loading
property_service/libpropertyinfoparser/Android.bp +1 −0 Original line number Original line Diff line number Diff line cc_library_static { cc_library_static { name: "libpropertyinfoparser", name: "libpropertyinfoparser", host_supported: true, host_supported: true, vendor_available: true, srcs: ["property_info_parser.cpp"], srcs: ["property_info_parser.cpp"], cpp_std: "experimental", cpp_std: "experimental", Loading
property_service/libpropertyinfoserializer/Android.bp +1 −0 Original line number Original line Diff line number Diff line cc_defaults { cc_defaults { name: "propertyinfoserializer_defaults", name: "propertyinfoserializer_defaults", host_supported: true, host_supported: true, vendor_available: true, cpp_std: "experimental", cpp_std: "experimental", cppflags: [ cppflags: [ "-Wall", "-Wall", Loading
shell_and_utilities/README.md +8 −8 Original line number Original line Diff line number Diff line Loading @@ -175,18 +175,18 @@ bzip2: bzcat bzip2 bunzip2 one-true-awk: awk one-true-awk: awk toolbox: getevent newfs\_msdos toolbox: getevent getprop newfs\_msdos toybox: acpi base64 basename blockdev cal cat chcon chgrp chmod chown toybox: acpi base64 basename blockdev cal cat chcon chgrp chmod chown chroot chrt cksum clear cmp comm cp cpio cut date df diff dirname dmesg chroot chrt cksum clear cmp comm cp cpio cut date df diff dirname dmesg dos2unix du echo env expand expr fallocate false file find flock free dos2unix du echo env expand expr fallocate false file find flock free getenforce getprop groups gunzip gzip head hostname hwclock id ifconfig getenforce groups gunzip gzip head hostname hwclock id ifconfig inotifyd inotifyd insmod ionice iorenice kill killall ln load\_policy log logname insmod ionice iorenice kill killall ln load\_policy log logname losetup losetup ls lsmod lsof lspci lsusb md5sum microcom mkdir mkfifo mknod ls lsmod lsof lspci lsusb md5sum microcom mkdir mkfifo mknod mkswap mkswap mktemp modinfo modprobe more mount mountpoint mv netstat nice mktemp modinfo modprobe more mount mountpoint mv netstat nice nl nohup nl nohup od paste patch pgrep pidof pkill pmap printenv printf ps pwd od paste patch pgrep pidof pkill pmap printenv printf ps pwd readlink readlink realpath renice restorecon rm rmdir rmmod runcon sed sendevent realpath renice restorecon rm rmdir rmmod runcon sed sendevent seq seq setenforce setprop setsid sha1sum sha224sum sha256sum sha384sum setenforce setprop setsid sha1sum sha224sum sha256sum sha384sum sha512sum sleep sort split start stat stop strings swapoff swapon sync sha512sum sleep sort split start stat stop strings swapoff swapon sync sysctl tac tail tar taskset tee time timeout top touch tr true truncate sysctl tac tail tar taskset tee time timeout top touch tr true truncate tty ulimit umount uname uniq unix2dos uptime usleep uudecode uuencode tty ulimit umount uname uniq unix2dos uptime usleep uudecode uuencode Loading
toolbox/Android.bp +5 −0 Original line number Original line Diff line number Diff line Loading @@ -44,9 +44,11 @@ genrule { cc_defaults { cc_defaults { name: "toolbox_binary_defaults", name: "toolbox_binary_defaults", defaults: ["toolbox_defaults"], defaults: ["toolbox_defaults"], cpp_std: "experimental", srcs: [ srcs: [ "toolbox.c", "toolbox.c", "getevent.c", "getevent.c", "getprop.cpp", "newfs_msdos.c", "newfs_msdos.c", ], ], generated_headers: [ generated_headers: [ Loading @@ -54,12 +56,15 @@ cc_defaults { ], ], whole_static_libs: ["libtoolbox_dd"], whole_static_libs: ["libtoolbox_dd"], shared_libs: [ shared_libs: [ "libbase", "libcutils", "libcutils", ], ], static_libs: ["libpropertyinfoparser"], symlinks: [ symlinks: [ "dd", "dd", "getevent", "getevent", "getprop", "newfs_msdos", "newfs_msdos", ], ], } } Loading
toolbox/getprop.cpp 0 → 100644 +127 −0 Original line number Original line Diff line number Diff line // // Copyright (C) 2017 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. // #include <getopt.h> #include <sys/system_properties.h> #include <iostream> #include <string> #include <vector> #include <android-base/properties.h> #include <property_info_parser/property_info_parser.h> using android::base::GetProperty; using android::properties::PropertyInfoAreaFile; PropertyInfoAreaFile property_info_file; void PrintAllProperties(bool print_property_context) { std::vector<std::pair<std::string, std::string>> properties; __system_property_foreach( [](const prop_info* pi, void* cookie) { __system_property_read_callback( pi, [](void* cookie, const char* name, const char* value, unsigned) { auto properties = reinterpret_cast<std::vector<std::pair<std::string, std::string>>*>(cookie); properties->emplace_back(name, value); }, cookie); }, &properties); std::sort(properties.begin(), properties.end()); if (print_property_context) { for (auto& [name, value] : properties) { const char* context = nullptr; property_info_file->GetPropertyInfo(name.c_str(), &context, nullptr); value = context; } } for (const auto& [name, value] : properties) { std::cout << "[" << name << "]: [" << value << "]" << std::endl; } } void PrintProperty(const char* name, const char* default_value, bool print_property_context) { if (print_property_context) { const char* context = nullptr; property_info_file->GetPropertyInfo(name, &context, nullptr); std::cout << context << std::endl; } else { std::cout << GetProperty(name, default_value) << std::endl; } } extern "C" int getprop_main(int argc, char** argv) { bool print_property_context = false; while (true) { static const struct option long_options[] = { {"help", no_argument, nullptr, 'h'}, {nullptr, 0, nullptr, 0}, }; int arg = getopt_long(argc, argv, "Z", long_options, nullptr); if (arg == -1) { break; } switch (arg) { case 'h': std::cout << "usage: getprop [-Z] [NAME [DEFAULT]]\n\n" "Gets an Android system property, or lists them all.\n" "Use -Z to return the property context instead of the property value\n" << std::endl; return 0; case 'Z': print_property_context = true; break; case '?': return -1; default: std::cerr << "getprop: getopt returned invalid result: " << arg << std::endl; return -1; } } if (print_property_context) { property_info_file.LoadDefaultPath(); if (!property_info_file) { std::cerr << "Unable to load property info file" << std::endl; return -1; } } if (optind >= argc) { PrintAllProperties(print_property_context); return 0; } if (optind < argc - 2) { std::cerr << "getprop: Max 2 arguments (see \"getprop --help\")" << std::endl; return -1; } PrintProperty(argv[optind], (optind == argc - 1) ? "" : argv[optind + 1], print_property_context); return 0; }