diff options
-rw-r--r-- | adb/adb.cpp | 7 | ||||
-rw-r--r-- | adb/adb_auth.cpp | 7 | ||||
-rw-r--r-- | adb/adb_auth.h | 2 | ||||
-rw-r--r-- | adb/adb_auth_client.cpp | 16 | ||||
-rw-r--r-- | adb/adb_auth_host.cpp | 12 | ||||
-rw-r--r-- | adb/adb_client.cpp | 9 | ||||
-rw-r--r-- | adb/adb_io.cpp | 2 | ||||
-rw-r--r-- | adb/adb_main.cpp | 6 | ||||
-rw-r--r-- | adb/commandline.cpp | 7 | ||||
-rw-r--r-- | adb/fdevent.cpp | 20 | ||||
-rw-r--r-- | adb/file_sync_service.cpp | 9 | ||||
-rw-r--r-- | adb/jdwp_service.cpp | 24 | ||||
-rw-r--r-- | adb/remount_service.cpp | 7 | ||||
-rw-r--r-- | adb/services.cpp | 7 | ||||
-rw-r--r-- | adb/set_verity_enable_state_service.cpp | 9 | ||||
-rw-r--r-- | adb/sockets.cpp | 12 | ||||
-rw-r--r-- | adb/sysdeps_win32.c | 26 | ||||
-rw-r--r-- | adb/transport.cpp | 4 | ||||
-rw-r--r-- | adb/transport_local.cpp | 14 | ||||
-rw-r--r-- | adb/transport_usb.cpp | 9 | ||||
-rw-r--r-- | adb/usb_linux.cpp | 7 | ||||
-rw-r--r-- | adb/usb_linux_client.c | 7 | ||||
-rw-r--r-- | adb/usb_osx.c | 7 | ||||
-rw-r--r-- | adb/usb_windows.cpp | 7 | ||||
-rw-r--r-- | init/init.cpp | 69 | ||||
-rw-r--r-- | init/ueventd.cpp | 26 | ||||
-rw-r--r-- | init/util.cpp | 33 | ||||
-rw-r--r-- | init/util.h | 1 |
28 files changed, 201 insertions, 165 deletions
diff --git a/adb/adb.cpp b/adb/adb.cpp index ffa93f4..ca12eb7 100644 --- a/adb/adb.cpp +++ b/adb/adb.cpp @@ -14,7 +14,10 @@ * limitations under the License. */ -#define TRACE_TAG TRACE_ADB +#define TRACE_TAG TRACE_ADB + +#include "sysdeps.h" +#include "adb.h" #include <stdio.h> #include <stdlib.h> @@ -27,8 +30,6 @@ #include <sys/time.h> #include <stdint.h> -#include "sysdeps.h" -#include "adb.h" #include "adb_auth.h" #include "adb_io.h" #include "adb_listeners.h" diff --git a/adb/adb_auth.cpp b/adb/adb_auth.cpp index c236b64..dc01825 100644 --- a/adb/adb_auth.cpp +++ b/adb/adb_auth.cpp @@ -14,7 +14,10 @@ * limitations under the License. */ -#define TRACE_TAG TRACE_ADB +#define TRACE_TAG TRACE_ADB + +#include "sysdeps.h" +#include "adb_auth.h" #include <errno.h> #include <stdio.h> @@ -23,9 +26,7 @@ #include <unistd.h> #include "adb.h" -#include "adb_auth.h" #include "transport.h" -#include "sysdeps.h" int auth_enabled = 0; diff --git a/adb/adb_auth.h b/adb/adb_auth.h index e0425ad..635556e 100644 --- a/adb/adb_auth.h +++ b/adb/adb_auth.h @@ -17,6 +17,8 @@ #ifndef __ADB_AUTH_H #define __ADB_AUTH_H +#include "adb.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/adb/adb_auth_client.cpp b/adb/adb_auth_client.cpp index 5dadcd9..8e7d38b 100644 --- a/adb/adb_auth_client.cpp +++ b/adb/adb_auth_client.cpp @@ -14,23 +14,23 @@ * limitations under the License. */ +#define TRACE_TAG TRACE_AUTH + +#include "sysdeps.h" +#include "adb_auth.h" + #include <resolv.h> #include <stdio.h> #include <string.h> -#include "sysdeps.h" - -#include "adb.h" -#include "adb_auth.h" #include "cutils/list.h" #include "cutils/sockets.h" -#include "fdevent.h" #include "mincrypt/rsa.h" #include "mincrypt/sha.h" -#include "transport.h" - -#define TRACE_TAG TRACE_AUTH +#include "adb.h" +#include "fdevent.h" +#include "transport.h" struct adb_public_key { struct listnode node; diff --git a/adb/adb_auth_host.cpp b/adb/adb_auth_host.cpp index aba23d4..7c2bcfb 100644 --- a/adb/adb_auth_host.cpp +++ b/adb/adb_auth_host.cpp @@ -14,8 +14,14 @@ * limitations under the License. */ +#define TRACE_TAG TRACE_AUTH + +#include "sysdeps.h" +#include "adb_auth.h" + #include <stdio.h> #include <stdlib.h> +#include <string.h> #ifdef _WIN32 # ifndef WIN32_LEAN_AND_MEAN @@ -28,11 +34,8 @@ # include <sys/stat.h> # include <unistd.h> #endif -#include <string.h> -#include "sysdeps.h" #include "adb.h" -#include "adb_auth.h" /* HACK: we need the RSAPublicKey struct * but RSA_verify conflits with openssl */ @@ -52,12 +55,9 @@ #include <openssl/base64.h> #endif -#define TRACE_TAG TRACE_AUTH - #define ANDROID_PATH ".android" #define ADB_KEY_FILE "adbkey" - struct adb_private_key { struct listnode node; RSA *rsa; diff --git a/adb/adb_client.cpp b/adb/adb_client.cpp index a485aa2..4751bff 100644 --- a/adb/adb_client.cpp +++ b/adb/adb_client.cpp @@ -14,6 +14,11 @@ * limitations under the License. */ +#define TRACE_TAG TRACE_ADB + +#include "sysdeps.h" +#include "adb_client.h" + #include <errno.h> #include <limits.h> #include <stdarg.h> @@ -23,10 +28,6 @@ #include <sys/stat.h> #include <sys/types.h> -#include "sysdeps.h" - -#define TRACE_TAG TRACE_ADB -#include "adb_client.h" #include "adb_io.h" static transport_type __adb_transport = kTransportAny; diff --git a/adb/adb_io.cpp b/adb/adb_io.cpp index 1a74688..d89f304 100644 --- a/adb/adb_io.cpp +++ b/adb/adb_io.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#define TRACE_TAG TRACE_RWX +#define TRACE_TAG TRACE_RWX #include "sysdeps.h" #include "adb_io.h" diff --git a/adb/adb_main.cpp b/adb/adb_main.cpp index 1d9cc3b..daec831 100644 --- a/adb/adb_main.cpp +++ b/adb/adb_main.cpp @@ -14,15 +14,15 @@ * limitations under the License. */ -#define TRACE_TAG TRACE_ADB +#define TRACE_TAG TRACE_ADB + +#include "sysdeps.h" #include <errno.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> -#include "sysdeps.h" - #include "adb.h" #include "adb_auth.h" #include "adb_listeners.h" diff --git a/adb/commandline.cpp b/adb/commandline.cpp index 4538b04..c9b1eab 100644 --- a/adb/commandline.cpp +++ b/adb/commandline.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +#define TRACE_TAG TRACE_ADB + +#include "sysdeps.h" + #include <assert.h> #include <ctype.h> #include <errno.h> @@ -31,9 +35,6 @@ #include <unistd.h> #endif -#include "sysdeps.h" - -#define TRACE_TAG TRACE_ADB #include "adb.h" #include "adb_auth.h" #include "adb_client.h" diff --git a/adb/fdevent.cpp b/adb/fdevent.cpp index eeb2a9c..0c43c5e 100644 --- a/adb/fdevent.cpp +++ b/adb/fdevent.cpp @@ -15,25 +15,23 @@ ** limitations under the License. */ -#include <sys/ioctl.h> +#define TRACE_TAG TRACE_FDEVENT -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <errno.h> +#include "sysdeps.h" +#include "fdevent.h" +#include <errno.h> #include <fcntl.h> - #include <stdarg.h> #include <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/ioctl.h> +#include <unistd.h> #include "adb_io.h" #include "adb_trace.h" -#include "fdevent.h" -#include "sysdeps.h" - -#define TRACE_TAG TRACE_FDEVENT /* !!! Do not enable DEBUG for the adb that will run as the server: ** both stdout and stderr are used to communicate between the client diff --git a/adb/file_sync_service.cpp b/adb/file_sync_service.cpp index ac01678..e8e9a0f 100644 --- a/adb/file_sync_service.cpp +++ b/adb/file_sync_service.cpp @@ -14,6 +14,11 @@ * limitations under the License. */ +#define TRACE_TAG TRACE_SYNC + +#include "sysdeps.h" +#include "file_sync_service.h" + #include <dirent.h> #include <errno.h> #include <selinux/android.h> @@ -25,12 +30,8 @@ #include <unistd.h> #include <utime.h> -#include "sysdeps.h" - -#define TRACE_TAG TRACE_SYNC #include "adb.h" #include "adb_io.h" -#include "file_sync_service.h" #include "private/android_filesystem_config.h" static bool should_use_fs_config(const char* path) { diff --git a/adb/jdwp_service.cpp b/adb/jdwp_service.cpp index f0b4ba7..9cf084e 100644 --- a/adb/jdwp_service.cpp +++ b/adb/jdwp_service.cpp @@ -1,12 +1,32 @@ +/* + * Copyright (C) 2015 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. + */ + /* implement the "debug-ports" and "track-debug-ports" device services */ + +#define TRACE_TAG TRACE_JDWP + #include "sysdeps.h" -#define TRACE_TAG TRACE_JDWP -#include "adb.h" + #include <errno.h> #include <stdio.h> #include <string.h> #include <unistd.h> +#include "adb.h" + /* here's how these things work. when adbd starts, it creates a unix server socket diff --git a/adb/remount_service.cpp b/adb/remount_service.cpp index a83d5b1..483ca3d 100644 --- a/adb/remount_service.cpp +++ b/adb/remount_service.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +#define TRACE_TAG TRACE_ADB + +#include "sysdeps.h" + #include <errno.h> #include <fcntl.h> #include <mntent.h> @@ -25,9 +29,6 @@ #include <string> -#include "sysdeps.h" - -#define TRACE_TAG TRACE_ADB #include "adb.h" #include "adb_io.h" #include "cutils/properties.h" diff --git a/adb/services.cpp b/adb/services.cpp index e7bf6b0..abf8ea5 100644 --- a/adb/services.cpp +++ b/adb/services.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +#define TRACE_TAG TRACE_SERVICES + +#include "sysdeps.h" + #include <errno.h> #include <stddef.h> #include <stdio.h> @@ -32,9 +36,6 @@ #include "cutils/properties.h" #endif -#include "sysdeps.h" - -#define TRACE_TAG TRACE_SERVICES #include "adb.h" #include "adb_io.h" #include "file_sync_service.h" diff --git a/adb/set_verity_enable_state_service.cpp b/adb/set_verity_enable_state_service.cpp index 139b074..b75ed4c 100644 --- a/adb/set_verity_enable_state_service.cpp +++ b/adb/set_verity_enable_state_service.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +#define TRACE_TAG TRACE_ADB + +#include "sysdeps.h" + #include <fcntl.h> #include <inttypes.h> #include <stdarg.h> @@ -21,13 +25,12 @@ #include <stdio.h> #include <sys/stat.h> -#define TRACE_TAG TRACE_ADB -#include "adb.h" #include "cutils/properties.h" + +#include "adb.h" #include "ext4_sb.h" #include "fs_mgr.h" #include "remount_service.h" -#include "sysdeps.h" #define FSTAB_PREFIX "/fstab." struct fstab *fstab; diff --git a/adb/sockets.cpp b/adb/sockets.cpp index 12bc8d8..48d02d6 100644 --- a/adb/sockets.cpp +++ b/adb/sockets.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +#define TRACE_TAG TRACE_SOCKETS + +#include "sysdeps.h" + #include <ctype.h> #include <errno.h> #include <stdio.h> @@ -21,14 +25,12 @@ #include <string.h> #include <unistd.h> -#include "sysdeps.h" - -#define TRACE_TAG TRACE_SOCKETS -#include "adb.h" -#include "adb_io.h" #if !ADB_HOST #include "cutils/properties.h" #endif + +#include "adb.h" +#include "adb_io.h" #include "transport.h" ADB_MUTEX_DEFINE( socket_list_lock ); diff --git a/adb/sysdeps_win32.c b/adb/sysdeps_win32.c index f132b8c..c28e031 100644 --- a/adb/sysdeps_win32.c +++ b/adb/sysdeps_win32.c @@ -1,10 +1,30 @@ +/* + * Copyright (C) 2015 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. + */ + +#define TRACE_TAG TRACE_SYSDEPS + #include "sysdeps.h" -#include <winsock2.h> + +#include <winsock2.h> /* winsock.h *must* be included before windows.h. */ #include <windows.h> + +#include <errno.h> #include <stdio.h> #include <stdlib.h> -#include <errno.h> -#define TRACE_TAG TRACE_SYSDEPS + #include "adb.h" extern void fatal(const char *fmt, ...); diff --git a/adb/transport.cpp b/adb/transport.cpp index 1f8ac03..0a960ff 100644 --- a/adb/transport.cpp +++ b/adb/transport.cpp @@ -14,8 +14,9 @@ * limitations under the License. */ -#include "sysdeps.h" +#define TRACE_TAG TRACE_TRANSPORT +#include "sysdeps.h" #include "transport.h" #include <ctype.h> @@ -25,7 +26,6 @@ #include <string.h> #include <unistd.h> -#define TRACE_TAG TRACE_TRANSPORT #include "adb.h" static void transport_unref(atransport *t); diff --git a/adb/transport_local.cpp b/adb/transport_local.cpp index 440d4c5..fe3c87f 100644 --- a/adb/transport_local.cpp +++ b/adb/transport_local.cpp @@ -14,21 +14,23 @@ * limitations under the License. */ +#define TRACE_TAG TRACE_TRANSPORT + +#include "sysdeps.h" +#include "transport.h" + #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> -#include "sysdeps.h" - -#define TRACE_TAG TRACE_TRANSPORT -#include "adb.h" -#include "adb_io.h" #if !ADB_HOST #include "cutils/properties.h" #endif -#include "transport.h" + +#include "adb.h" +#include "adb_io.h" #if ADB_HOST /* we keep a list of opened transports. The atransport struct knows to which diff --git a/adb/transport_usb.cpp b/adb/transport_usb.cpp index 37a8219..cdabffe 100644 --- a/adb/transport_usb.cpp +++ b/adb/transport_usb.cpp @@ -14,15 +14,16 @@ * limitations under the License. */ +#define TRACE_TAG TRACE_TRANSPORT + +#include "sysdeps.h" +#include "transport.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sysdeps.h> - -#define TRACE_TAG TRACE_TRANSPORT #include "adb.h" -#include "transport.h" static int remote_read(apacket *p, atransport *t) { diff --git a/adb/usb_linux.cpp b/adb/usb_linux.cpp index c01ec8c..6fd2b40 100644 --- a/adb/usb_linux.cpp +++ b/adb/usb_linux.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +#define TRACE_TAG TRACE_USB + +#include "sysdeps.h" + #include <ctype.h> #include <dirent.h> #include <errno.h> @@ -33,9 +37,6 @@ #include <linux/usb_ch9.h> #endif -#include "sysdeps.h" - -#define TRACE_TAG TRACE_USB #include "adb.h" #include "transport.h" diff --git a/adb/usb_linux_client.c b/adb/usb_linux_client.c index c88b258..434451c 100644 --- a/adb/usb_linux_client.c +++ b/adb/usb_linux_client.c @@ -14,6 +14,10 @@ * limitations under the License. */ +#define TRACE_TAG TRACE_USB + +#include "sysdeps.h" + #include <dirent.h> #include <errno.h> #include <linux/usb/ch9.h> @@ -25,9 +29,6 @@ #include <sys/types.h> #include <unistd.h> -#include "sysdeps.h" - -#define TRACE_TAG TRACE_USB #include "adb.h" #include "transport.h" diff --git a/adb/usb_osx.c b/adb/usb_osx.c index aa7e1ea..94c8cfe 100644 --- a/adb/usb_osx.c +++ b/adb/usb_osx.c @@ -14,6 +14,10 @@ * limitations under the License. */ +#define TRACE_TAG TRACE_USB + +#include "sysdeps.h" + #include <CoreFoundation/CoreFoundation.h> #include <IOKit/IOKitLib.h> @@ -24,9 +28,6 @@ #include <stdio.h> -#include "sysdeps.h" - -#define TRACE_TAG TRACE_USB #include "adb.h" #include "transport.h" diff --git a/adb/usb_windows.cpp b/adb/usb_windows.cpp index 3c5533b..d2bd58c 100644 --- a/adb/usb_windows.cpp +++ b/adb/usb_windows.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +#define TRACE_TAG TRACE_USB + +#include "sysdeps.h" + #include <winsock2.h> // winsock.h *must* be included before windows.h. #include <adb_api.h> #include <errno.h> @@ -23,9 +27,6 @@ #include <windows.h> #include <winerror.h> -#include "sysdeps.h" - -#define TRACE_TAG TRACE_USB #include "adb.h" #include "transport.h" diff --git a/init/init.cpp b/init/init.cpp index e1c82a4..5a40fd3 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -15,6 +15,7 @@ */ #include <ctype.h> +#include <dirent.h> #include <errno.h> #include <fcntl.h> #include <libgen.h> @@ -40,6 +41,8 @@ #include <selinux/label.h> #include <selinux/android.h> +#include <base/file.h> +#include <base/stringprintf.h> #include <cutils/android_reboot.h> #include <cutils/fs.h> #include <cutils/iosched_policy.h> @@ -47,6 +50,8 @@ #include <cutils/sockets.h> #include <private/android_filesystem_config.h> +#include <memory> + #include "devices.h" #include "init.h" #include "log.h" @@ -66,8 +71,6 @@ static int property_triggers_enabled = 0; static char console[32]; static char bootmode[32]; -static char hardware[32]; -static unsigned revision = 0; static char qemu[32]; static struct action *cur_action = NULL; @@ -773,6 +776,8 @@ static void export_kernel_boot_props(void) { "ro.boot.mode", "ro.bootmode", "unknown", }, { "ro.boot.baseband", "ro.baseband", "unknown", }, { "ro.boot.bootloader", "ro.bootloader", "unknown", }, + { "ro.boot.hardware", "ro.hardware", "unknown", }, + { "ro.boot.revision", "ro.revision", "0", }, }; for (i = 0; i < ARRAY_SIZE(prop_map); i++) { @@ -791,16 +796,6 @@ static void export_kernel_boot_props(void) property_get("ro.bootmode", tmp); strlcpy(bootmode, tmp, sizeof(bootmode)); - /* if this was given on kernel command line, override what we read - * before (e.g. from /proc/cpuinfo), if anything */ - ret = property_get("ro.boot.hardware", tmp); - if (ret) - strlcpy(hardware, tmp, sizeof(hardware)); - property_set("ro.hardware", hardware); - - snprintf(tmp, PROP_VALUE_MAX, "%d", revision); - property_set("ro.revision", tmp); - /* TODO: these are obsolete. We should delete them */ if (!strcmp(bootmode,"factory")) property_set("ro.factorytest", "1"); @@ -810,6 +805,40 @@ static void export_kernel_boot_props(void) property_set("ro.factorytest", "0"); } +static void process_kernel_dt(void) +{ + static const char android_dir[] = "/proc/device-tree/firmware/android"; + + std::string file_name = android::base::StringPrintf("%s/compatible", android_dir); + + std::string dt_file; + android::base::ReadFileToString(file_name, &dt_file); + if (!dt_file.compare("android,firmware")) { + ERROR("firmware/android is not compatible with 'android,firmware'\n"); + return; + } + + std::unique_ptr<DIR, int(*)(DIR*)>dir(opendir(android_dir), closedir); + if (!dir) + return; + + struct dirent *dp; + while ((dp = readdir(dir.get())) != NULL) { + if (dp->d_type != DT_REG || !strcmp(dp->d_name, "compatible")) + continue; + + file_name = android::base::StringPrintf("%s/%s", android_dir, dp->d_name); + + android::base::ReadFileToString(file_name, &dt_file); + std::replace(dt_file.begin(), dt_file.end(), ',', '.'); + + std::string property_name = android::base::StringPrintf("ro.boot.%s", dp->d_name); + if (property_set(property_name.c_str(), dt_file.c_str())) { + ERROR("Could not set property %s to value %s", property_name.c_str(), dt_file.c_str()); + } + } +} + static void process_kernel_cmdline(void) { /* don't expose the raw commandline to nonpriv processes */ @@ -822,11 +851,6 @@ static void process_kernel_cmdline(void) import_kernel_cmdline(0, import_kernel_nv); if (qemu[0]) import_kernel_cmdline(1, import_kernel_nv); - - /* now propogate the info given on command line to internal variables - * used by init as well as the current required properties - */ - export_kernel_boot_props(); } static int property_service_init_action(int nargs, char **args) @@ -1014,10 +1038,17 @@ int main(int argc, char** argv) { klog_init(); property_init(); - get_hardware_name(hardware, &revision); - + process_kernel_dt(); + /* in case one is passing arguments both on the command line and in DT + * Properties set in DT always have priority over the command-line ones + */ process_kernel_cmdline(); + /* now propogate the kernel variables to internal variables + * used by init as well as the current required properties + */ + export_kernel_boot_props(); + selinux_callback cb; cb.func_log = log_callback; selinux_set_callback(SELINUX_CB_LOG, cb); diff --git a/init/ueventd.cpp b/init/ueventd.cpp index d56b91a..5af6e3d 100644 --- a/init/ueventd.cpp +++ b/init/ueventd.cpp @@ -30,28 +30,13 @@ #include "util.h" #include "devices.h" #include "ueventd_parser.h" - -static char hardware[32]; -static unsigned revision = 0; - -static void import_kernel_nv(char *name, int in_qemu) -{ - if (*name != '\0') { - char *value = strchr(name, '='); - if (value != NULL) { - *value++ = 0; - if (!strcmp(name,"androidboot.hardware")) - { - strlcpy(hardware, value, sizeof(hardware)); - } - } - } -} +#include "property_service.h" int ueventd_main(int argc, char **argv) { struct pollfd ufd; int nr; + char hardware[PROP_VALUE_MAX]; char tmp[32]; /* @@ -83,12 +68,7 @@ int ueventd_main(int argc, char **argv) INFO("starting ueventd\n"); - /* Respect hardware passed in through the kernel cmd line. Here we will look - * for androidboot.hardware param in kernel cmdline, and save its value in - * hardware[]. */ - import_kernel_cmdline(0, import_kernel_nv); - - get_hardware_name(hardware, &revision); + property_get("ro.hardware", hardware); ueventd_parse_config_file("/ueventd.rc"); diff --git a/init/util.cpp b/init/util.cpp index c805083..8b238d4 100644 --- a/init/util.cpp +++ b/init/util.cpp @@ -400,39 +400,6 @@ void open_devnull_stdio(void) exit(1); } -void get_hardware_name(char *hardware, unsigned int *revision) { - // Hardware string was provided on kernel command line. - if (hardware[0]) { - return; - } - - FILE* fp = fopen("/proc/cpuinfo", "re"); - if (fp == NULL) { - return; - } - char buf[1024]; - while (fgets(buf, sizeof(buf), fp) != NULL) { - if (strncmp(buf, "Hardware", 8) == 0) { - const char* hw = strstr(buf, ": "); - if (hw) { - hw += 2; - size_t n = 0; - while (*hw) { - if (!isspace(*hw)) { - hardware[n++] = tolower(*hw); - } - hw++; - if (n == 31) break; - } - hardware[n] = 0; - } - } else if (strncmp(buf, "Revision", 8) == 0) { - sscanf(buf, "Revision : %ux", revision); - } - } - fclose(fp); -} - void import_kernel_cmdline(int in_qemu, void (*import_kernel_nv)(char *name, int in_qemu)) { diff --git a/init/util.h b/init/util.h index 77da3ac..e0b3c69 100644 --- a/init/util.h +++ b/init/util.h @@ -42,7 +42,6 @@ void make_link(const char *oldpath, const char *newpath); void remove_link(const char *oldpath, const char *newpath); int wait_for_file(const char *filename, int timeout); void open_devnull_stdio(void); -void get_hardware_name(char *hardware, unsigned int *revision); void import_kernel_cmdline(int in_qemu, void (*import_kernel_nv)(char *name, int in_qemu)); int make_dir(const char *path, mode_t mode); int restorecon(const char *pathname); |