├── .gitignore ├── Android.mk ├── CleanSpec.mk ├── README ├── ThirdPartyProject.prop ├── adb ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── OVERVIEW.TXT ├── SERVICES.TXT ├── adb.c ├── adb.h ├── adb_client.c ├── adb_client.h ├── commandline.c ├── console.c ├── fdevent.c ├── fdevent.h ├── file_sync_client.c ├── file_sync_service.c ├── file_sync_service.h ├── framebuffer_service.c ├── get_my_path_darwin.c ├── get_my_path_freebsd.c ├── get_my_path_linux.c ├── get_my_path_windows.c ├── jdwp_service.c ├── log_service.c ├── mutex_list.h ├── protocol.txt ├── remount_service.c ├── services.c ├── sockets.c ├── sockets.dia ├── sysdeps.h ├── sysdeps_win32.c ├── test_track_devices.c ├── test_track_jdwp.c ├── transport.c ├── transport_local.c ├── transport_usb.c ├── usb_libusb.c ├── usb_linux.c ├── usb_linux_client.c ├── usb_osx.c ├── usb_vendors.c ├── usb_vendors.h ├── usb_windows.c ├── utils.c └── utils.h ├── cpio ├── Android.mk └── mkbootfs.c ├── debuggerd ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── arm │ ├── crashglue.S │ ├── machine.c │ ├── pr-support.c │ └── unwind.c ├── crasher.c ├── debuggerd.c ├── debuggerd.h ├── getevent.c ├── symbol_table.c ├── symbol_table.h ├── utility.c ├── utility.h ├── vfp-crasher.c ├── vfp.S └── x86 │ ├── crashglue.S │ ├── machine.c │ ├── unwind.c │ └── x86_utility.h ├── fastboot ├── Android.mk ├── bootimg.c ├── engine.c ├── engineering_key.p12 ├── fastboot.c ├── fastboot.h ├── genkey.sh ├── p12topem.sh ├── protocol.c ├── signfile.sh ├── usb.h ├── usb_linux.c ├── usb_osx.c ├── usb_windows.c ├── usbtest.c ├── util_linux.c ├── util_osx.c └── util_windows.c ├── include ├── acc │ └── acc.h ├── android │ └── log.h ├── arch │ ├── darwin-x86 │ │ └── AndroidConfig.h │ ├── freebsd-x86 │ │ └── AndroidConfig.h │ ├── linux-arm │ │ └── AndroidConfig.h │ ├── linux-ppc │ │ └── AndroidConfig.h │ ├── linux-sh │ │ └── AndroidConfig.h │ ├── linux-x86 │ │ └── AndroidConfig.h │ ├── target_linux-x86 │ │ └── AndroidConfig.h │ └── windows │ │ └── AndroidConfig.h ├── ctest │ └── ctest.h ├── cutils │ ├── abort_socket.h │ ├── array.h │ ├── ashmem.h │ ├── atomic-arm.h │ ├── atomic-inline.h │ ├── atomic-x86.h │ ├── atomic.h │ ├── bitops.h │ ├── compiler.h │ ├── config_utils.h │ ├── cpu_info.h │ ├── dir_hash.h │ ├── event_tag_map.h │ ├── hashmap.h │ ├── iosched_policy.h │ ├── jstring.h │ ├── log.h │ ├── logd.h │ ├── logger.h │ ├── logprint.h │ ├── memory.h │ ├── misc.h │ ├── mq.h │ ├── mspace.h │ ├── native_handle.h │ ├── open_memstream.h │ ├── process_name.h │ ├── properties.h │ ├── qtaguid.h │ ├── record_stream.h │ ├── sched_policy.h │ ├── selector.h │ ├── sockets.h │ ├── str_parms.h │ ├── threads.h │ ├── tztime.h │ ├── uevent.h │ ├── uio.h │ └── zygote.h ├── diskconfig │ └── diskconfig.h ├── mincrypt │ ├── rsa.h │ └── sha.h ├── netutils │ ├── dhcp.h │ └── ifc.h ├── pixelflinger │ ├── format.h │ └── pixelflinger.h ├── private │ ├── android_filesystem_config.h │ └── pixelflinger │ │ ├── ggl_context.h │ │ └── ggl_fixed.h ├── system │ └── audio.h ├── sysutils │ ├── FrameworkClient.h │ ├── FrameworkCommand.h │ ├── FrameworkListener.h │ ├── NetlinkEvent.h │ ├── NetlinkListener.h │ ├── ServiceManager.h │ ├── SocketClient.h │ └── SocketListener.h └── zipfile │ └── zipfile.h ├── init ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── README.BOOTCHART ├── bootchart.c ├── bootchart.h ├── builtins.c ├── devices.c ├── devices.h ├── grab-bootchart.sh ├── init.c ├── init.h ├── init_parser.c ├── init_parser.h ├── keychords.c ├── keychords.h ├── keywords.h ├── list.h ├── log.h ├── logo.c ├── parser.c ├── parser.h ├── property_service.c ├── property_service.h ├── readme.txt ├── signal_handler.c ├── signal_handler.h ├── ueventd.c ├── ueventd.h ├── ueventd_parser.c ├── ueventd_parser.h ├── util.c └── util.h ├── libacc ├── Android.mk ├── FEATURES ├── LICENSE ├── MODULE_LICENSE_BSD_LIKE ├── acc.cpp └── tests │ ├── .gitignore │ ├── Android.mk │ ├── accarm │ ├── armreg.h │ ├── data │ ├── addressOf.c │ ├── array.c │ ├── assignment.c │ ├── assignmentop.c │ ├── b2071670.c │ ├── bellard.otccex.c │ ├── brackets.c │ ├── casts.c │ ├── char.c │ ├── comma.c │ ├── constants.c │ ├── continue.c │ ├── defines.c │ ├── double.c │ ├── error.c │ ├── expr-ansi.c │ ├── expr.c │ ├── expr2.c │ ├── film.c │ ├── float.c │ ├── floatdouble.c │ ├── flops.c │ ├── funcargs.c │ ├── hello.c │ ├── inc.c │ ├── iops.c │ ├── locals.c │ ├── macros.c │ ├── missing-main.c │ ├── otcc-ansi.c │ ├── otcc-noinclude.c │ ├── otcc.c │ ├── pointers.c │ ├── pointers2.c │ ├── returnval-ansi.c │ ├── returnval.c │ ├── rollo3.c │ ├── short.c │ ├── simplest.c │ ├── structs.c │ ├── testStringConcat.c │ └── typedef.c │ ├── disassem.cpp │ ├── disassem.h │ ├── main.cpp │ ├── runtimeTest.cpp │ ├── test │ └── test.py ├── libctest ├── Android.mk ├── NOTICE └── ctest.c ├── libcutils ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── abort_socket.c ├── arch-arm │ └── memset32.S ├── arch-x86 │ ├── android_memset16.S │ ├── android_memset32.S │ ├── cache_wrapper.S │ ├── sse2-memset16-atom.S │ └── sse2-memset32-atom.S ├── array.c ├── ashmem-dev.c ├── ashmem-host.c ├── atomic-android-sh.c ├── atomic.c ├── buffer.c ├── buffer.h ├── config_utils.c ├── cpu_info.c ├── dir_hash.c ├── dlmalloc_stubs.c ├── hashmap.c ├── iosched_policy.c ├── load_file.c ├── loghack.h ├── memory.c ├── mq.c ├── mspace.c ├── native_handle.c ├── open_memstream.c ├── private.h ├── process_name.c ├── properties.c ├── qtaguid.c ├── record_stream.c ├── sched_policy.c ├── selector.c ├── socket_inaddr_any_server.c ├── socket_local.h ├── socket_local_client.c ├── socket_local_server.c ├── socket_loopback_client.c ├── socket_loopback_server.c ├── socket_network_client.c ├── str_parms.c ├── strdup16to8.c ├── strdup8to16.c ├── threads.c ├── tzfile.h ├── tzstrftime.c ├── tztime.c ├── uevent.c ├── uio.c └── zygote.c ├── libdiskconfig ├── Android.mk ├── config_mbr.c ├── diskconfig.c ├── diskutils.c ├── dump_diskconfig.c └── write_lst.c ├── liblinenoise ├── Android.mk ├── MODULE_LICENSE_BSD_LIKE ├── NOTICE ├── linenoise.c └── linenoise.h ├── liblog ├── Android.mk ├── NOTICE ├── event_tag_map.c ├── fake_log_device.c ├── logd_write.c └── logprint.c ├── libmincrypt ├── Android.mk ├── NOTICE ├── rsa.c ├── sha.c └── tools │ ├── Android.mk │ ├── DumpPublicKey.java │ └── DumpPublicKey.mf ├── libnetutils ├── Android.mk ├── NOTICE ├── dhcp_utils.c ├── dhcpclient.c ├── dhcpmsg.c ├── dhcpmsg.h ├── ifc_utils.c ├── packet.c └── packet.h ├── libpixelflinger ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── buffer.cpp ├── buffer.h ├── clear.cpp ├── clear.h ├── codeflinger │ ├── ARMAssembler.cpp │ ├── ARMAssembler.h │ ├── ARMAssemblerInterface.cpp │ ├── ARMAssemblerInterface.h │ ├── ARMAssemblerProxy.cpp │ ├── ARMAssemblerProxy.h │ ├── CodeCache.cpp │ ├── CodeCache.h │ ├── GGLAssembler.cpp │ ├── GGLAssembler.h │ ├── armreg.h │ ├── blending.cpp │ ├── disassem.c │ ├── disassem.h │ ├── load_store.cpp │ └── texturing.cpp ├── col32cb16blend.S ├── col32cb16blend_neon.S ├── fixed.cpp ├── format.cpp ├── picker.cpp ├── picker.h ├── pixelflinger.cpp ├── raster.cpp ├── raster.h ├── rotate90CW_4x4_16v6.S ├── scanline.cpp ├── scanline.h ├── t32cb16blend.S ├── tests │ ├── Android.mk │ └── codegen │ │ ├── Android.mk │ │ └── codegen.cpp ├── tinyutils │ ├── Errors.h │ ├── KeyedVector.h │ ├── SharedBuffer.cpp │ ├── SharedBuffer.h │ ├── SortedVector.h │ ├── TypeHelpers.h │ ├── Vector.h │ ├── VectorImpl.cpp │ ├── VectorImpl.h │ └── smartpointer.h ├── trap.cpp └── trap.h ├── libsysutils ├── Android.mk └── src │ ├── FrameworkClient.cpp │ ├── FrameworkCommand.cpp │ ├── FrameworkListener.cpp │ ├── NetlinkEvent.cpp │ ├── NetlinkListener.cpp │ ├── ServiceManager.cpp │ ├── SocketClient.cpp │ └── SocketListener.cpp ├── libzipfile ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── centraldir.c ├── private.h ├── test_zipfile.c └── zipfile.c ├── logcat ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── event.logtags └── logcat.cpp ├── logwrapper ├── Android.mk ├── NOTICE └── logwrapper.c ├── mkbootimg ├── Android.mk ├── bootimg.h └── mkbootimg.c ├── netcfg ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE └── netcfg.c ├── nexus ├── Android.mk ├── CommandListener.cpp ├── CommandListener.h ├── Controller.cpp ├── Controller.h ├── DhcpClient.cpp ├── DhcpClient.h ├── DhcpEvent.cpp ├── DhcpEvent.h ├── DhcpListener.cpp ├── DhcpListener.h ├── DhcpState.cpp ├── DhcpState.h ├── IControllerHandler.h ├── IDhcpEventHandlers.h ├── ISupplicantEventHandler.h ├── IWifiStatusPollerHandler.h ├── InterfaceConfig.cpp ├── InterfaceConfig.h ├── LoopController.cpp ├── LoopController.h ├── NetworkManager.cpp ├── NetworkManager.h ├── NexusCommand.cpp ├── NexusCommand.h ├── OpenVpnController.cpp ├── OpenVpnController.h ├── Property.cpp ├── Property.h ├── PropertyManager.cpp ├── PropertyManager.h ├── ResponseCode.h ├── ScanResult.cpp ├── ScanResult.h ├── Supplicant.cpp ├── Supplicant.h ├── SupplicantAssociatedEvent.cpp ├── SupplicantAssociatedEvent.h ├── SupplicantAssociatingEvent.cpp ├── SupplicantAssociatingEvent.h ├── SupplicantConnectedEvent.cpp ├── SupplicantConnectedEvent.h ├── SupplicantConnectionTimeoutEvent.cpp ├── SupplicantConnectionTimeoutEvent.h ├── SupplicantDisconnectedEvent.cpp ├── SupplicantDisconnectedEvent.h ├── SupplicantEvent.cpp ├── SupplicantEvent.h ├── SupplicantEventFactory.cpp ├── SupplicantEventFactory.h ├── SupplicantListener.cpp ├── SupplicantListener.h ├── SupplicantScanResultsEvent.cpp ├── SupplicantScanResultsEvent.h ├── SupplicantState.cpp ├── SupplicantState.h ├── SupplicantStateChangeEvent.cpp ├── SupplicantStateChangeEvent.h ├── SupplicantStatus.cpp ├── SupplicantStatus.h ├── TiwlanEventListener.cpp ├── TiwlanEventListener.h ├── TiwlanWifiController.cpp ├── TiwlanWifiController.h ├── VpnController.cpp ├── VpnController.h ├── WifiController.cpp ├── WifiController.h ├── WifiNetwork.cpp ├── WifiNetwork.h ├── WifiScanner.cpp ├── WifiScanner.h ├── WifiStatusPoller.cpp ├── WifiStatusPoller.h ├── main.cpp └── nexctl.c ├── patch.txt ├── rootdir ├── Android.mk ├── etc │ ├── dbus.conf │ ├── hosts │ ├── init.goldfish.rc │ ├── init.goldfish.sh │ ├── init.testmenu │ ├── mountd.conf │ ├── ueventd.goldfish.rc │ └── vold.fstab ├── init.lowmem.rc ├── init.rc ├── init.rc.gonk └── ueventd.rc ├── run-as ├── Android.mk ├── NOTICE ├── package.c ├── package.h └── run-as.c ├── sdcard ├── Android.mk ├── fuse.h └── sdcard.c ├── sh ├── Android.mk ├── MODULE_LICENSE_BSD ├── NOTICE ├── TOUR ├── ThirdPartyProject.prop ├── alias.c ├── alias.h ├── arith.c ├── arith.h ├── arith.y ├── arith_lex.c ├── arith_lex.l ├── bltin │ ├── bltin.h │ ├── echo.1 │ └── echo.c ├── builtins.c ├── builtins.def ├── builtins.h ├── cd.c ├── cd.h ├── error.c ├── error.h ├── eval.c ├── eval.h ├── exec.c ├── exec.h ├── expand.c ├── expand.h ├── funcs │ ├── cmv │ ├── dirs │ ├── kill │ ├── login │ ├── newgrp │ ├── popd │ ├── pushd │ └── suspend ├── histedit.c ├── init.c ├── init.h ├── input.c ├── input.h ├── jobs.c ├── jobs.h ├── machdep.h ├── main.c ├── main.h ├── memalloc.c ├── memalloc.h ├── miscbltin.c ├── miscbltin.h ├── mkbuiltins ├── mkinit.sh ├── mknodes.sh ├── mktokens ├── myhistedit.h ├── mystring.c ├── mystring.h ├── nodes.c ├── nodes.c.pat ├── nodes.h ├── nodetypes ├── options.c ├── options.h ├── output.c ├── output.h ├── parser.c ├── parser.h ├── redir.c ├── redir.h ├── sh.1 ├── shell.h ├── show.c ├── show.h ├── syntax.c ├── syntax.h ├── token.h ├── trap.c ├── trap.h ├── var.c └── var.h └── toolbox ├── Android.mk ├── MODULE_LICENSE_BSD ├── NOTICE ├── alarm.c ├── cat.c ├── chmod.c ├── chown.c ├── cmp.c ├── date.c ├── dd.c ├── dd.h ├── df.c ├── dmesg.c ├── exists.c ├── getevent.c ├── getprop.c ├── hd.c ├── id.c ├── ifconfig.c ├── iftop.c ├── insmod.c ├── ioctl.c ├── ionice.c ├── kill.c ├── ln.c ├── log.c ├── ls.c ├── lsmod.c ├── lsof.c ├── mkdir.c ├── mount.c ├── mv.c ├── nandread.c ├── netstat.c ├── newfs_msdos.c ├── notify.c ├── powerd.c ├── printenv.c ├── ps.c ├── r.c ├── readtty.c ├── reboot.c ├── renice.c ├── rm.c ├── rmdir.c ├── rmmod.c ├── rotatefb.c ├── route.c ├── schedtop.c ├── sendevent.c ├── setconsole.c ├── setkey.c ├── setprop.c ├── sleep.c ├── smd.c ├── start.c ├── stop.c ├── sync.c ├── syren.c ├── toolbox.c ├── top.c ├── umount.c ├── uptime.c ├── vmstat.c ├── watchprops.c └── wipe.c /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2008 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | LOCAL_PATH := $(my-dir) 17 | 18 | ifneq ($(TARGET_SIMULATOR),true) 19 | include $(call first-makefiles-under,$(LOCAL_PATH)) 20 | else 21 | include $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \ 22 | adb \ 23 | libcutils \ 24 | libsysutils \ 25 | liblog \ 26 | libnetutils \ 27 | libpixelflinger \ 28 | libzipfile \ 29 | )) 30 | endif 31 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | The system/ directory is intended for pieces of the world that are the 3 | core of the embedded linux platform at the heart of Android. These 4 | essential bits are required for basic booting, operation, and debugging. 5 | 6 | They should not depend on libraries outside of system/... (some of them 7 | do currently -- they need to be updated or changed) and they should not 8 | be required for the simulator build. 9 | 10 | The license for all these pieces should be clean (Apache2, BSD, or MIT). 11 | 12 | Currently system/bluetooth/... and system/extra/... have some pieces 13 | with GPL/LGPL licensed code. 14 | 15 | Assorted Issues: 16 | 17 | - pppd depends on libutils for logging 18 | - pppd depends on libcrypt/libcrypto 19 | - init, linker, debuggerd, toolbox, usbd depend on libcutils 20 | - should probably rename bionic to libc 21 | -------------------------------------------------------------------------------- /ThirdPartyProject.prop: -------------------------------------------------------------------------------- 1 | # Copyright 2010 Google Inc. All Rights Reserved. 2 | #Fri Jul 16 10:03:09 PDT 2010 3 | currentVersion=2.6.32 4 | version=2.6.32 5 | isNative=true 6 | feedurl=http\://kernel.org/pub/linux/kernel/v2.6/ 7 | name=linux 8 | keywords=linux 9 | onDevice=true 10 | homepage=http\://kernel.org 11 | -------------------------------------------------------------------------------- /adb/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joneschrisg/android-system-core/69c8512061771630bf166394b5567f59a0c2f32d/adb/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /adb/console.c: -------------------------------------------------------------------------------- 1 | #include "sysdeps.h" 2 | #include "adb.h" 3 | #include "adb_client.h" 4 | #include 5 | 6 | static int connect_to_console(void) 7 | { 8 | int fd, port; 9 | 10 | port = adb_get_emulator_console_port(); 11 | if (port < 0) { 12 | if (port == -2) 13 | fprintf(stderr, "error: more than one emulator detected. use -s option\n"); 14 | else 15 | fprintf(stderr, "error: no emulator detected\n"); 16 | return -1; 17 | } 18 | fd = socket_loopback_client( port, SOCK_STREAM ); 19 | if (fd < 0) { 20 | fprintf(stderr, "error: could not connect to TCP port %d\n", port); 21 | return -1; 22 | } 23 | return fd; 24 | } 25 | 26 | 27 | int adb_send_emulator_command(int argc, char** argv) 28 | { 29 | int fd, nn; 30 | 31 | fd = connect_to_console(); 32 | if (fd < 0) 33 | return 1; 34 | 35 | #define QUIT "quit\n" 36 | 37 | for (nn = 1; nn < argc; nn++) { 38 | adb_write( fd, argv[nn], strlen(argv[nn]) ); 39 | adb_write( fd, (nn == argc-1) ? "\n" : " ", 1 ); 40 | } 41 | adb_write( fd, QUIT, sizeof(QUIT)-1 ); 42 | adb_close(fd); 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /adb/get_my_path_darwin.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #import 18 | #include 19 | 20 | void get_my_path(char *s, size_t maxLen) 21 | { 22 | ProcessSerialNumber psn; 23 | GetCurrentProcess(&psn); 24 | CFDictionaryRef dict; 25 | dict = ProcessInformationCopyDictionary(&psn, 0xffffffff); 26 | CFStringRef value = (CFStringRef)CFDictionaryGetValue(dict, 27 | CFSTR("CFBundleExecutable")); 28 | CFStringGetCString(value, s, maxLen, kCFStringEncodingUTF8); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /adb/get_my_path_freebsd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 bsdroid project 3 | * Alexey Tarasov 4 | * 5 | * Copyright (C) 2007 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | void 26 | get_my_path(char *exe, size_t maxLen) 27 | { 28 | char proc[64]; 29 | 30 | snprintf(proc, sizeof(proc), "/proc/%d/file", getpid()); 31 | 32 | int err = readlink(proc, exe, maxLen - 1); 33 | 34 | exe[err > 0 ? err : 0] = '\0'; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /adb/get_my_path_linux.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | void get_my_path(char *exe, size_t maxLen) 23 | { 24 | char proc[64]; 25 | snprintf(proc, sizeof proc, "/proc/%d/exe", getpid()); 26 | int err = readlink(proc, exe, maxLen - 1); 27 | if(err > 0) { 28 | exe[err] = '\0'; 29 | } else { 30 | exe[0] = '\0'; 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /adb/get_my_path_windows.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | void get_my_path(char *exe, size_t maxLen) 22 | { 23 | char *r; 24 | 25 | /* XXX: should be GetModuleFileNameA */ 26 | if (GetModuleFileName(NULL, exe, maxLen) > 0) { 27 | r = strrchr(exe, '\\'); 28 | if (r != NULL) 29 | *r = '\0'; 30 | } else { 31 | exe[0] = '\0'; 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /adb/mutex_list.h: -------------------------------------------------------------------------------- 1 | /* the list of mutexes used by addb */ 2 | #ifndef ADB_MUTEX 3 | #error ADB_MUTEX not defined when including this file 4 | #endif 5 | 6 | ADB_MUTEX(dns_lock) 7 | ADB_MUTEX(socket_list_lock) 8 | ADB_MUTEX(transport_lock) 9 | #if ADB_HOST 10 | ADB_MUTEX(local_transports_lock) 11 | #endif 12 | ADB_MUTEX(usb_lock) 13 | 14 | #undef ADB_MUTEX 15 | -------------------------------------------------------------------------------- /adb/sockets.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joneschrisg/android-system-core/69c8512061771630bf166394b5567f59a0c2f32d/adb/sockets.dia -------------------------------------------------------------------------------- /adb/usb_vendors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __USB_VENDORS_H 18 | #define __USB_VENDORS_H 19 | 20 | extern int vendorIds[]; 21 | extern unsigned vendorIdCount; 22 | 23 | void usb_vendors_init(void); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /cpio/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2005 The Android Open Source Project 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_SRC_FILES := \ 7 | mkbootfs.c 8 | 9 | LOCAL_MODULE := mkbootfs 10 | 11 | include $(BUILD_HOST_EXECUTABLE) 12 | 13 | $(call dist-for-goals,droid,$(LOCAL_BUILT_MODULE)) 14 | -------------------------------------------------------------------------------- /debuggerd/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2005 The Android Open Source Project 2 | 3 | ifneq ($(filter arm x86,$(TARGET_ARCH)),) 4 | 5 | LOCAL_PATH:= $(call my-dir) 6 | include $(CLEAR_VARS) 7 | 8 | LOCAL_SRC_FILES:= debuggerd.c utility.c getevent.c $(TARGET_ARCH)/machine.c $(TARGET_ARCH)/unwind.c symbol_table.c 9 | ifeq ($(TARGET_ARCH),arm) 10 | LOCAL_SRC_FILES += $(TARGET_ARCH)/pr-support.c 11 | endif 12 | 13 | LOCAL_CFLAGS := -Wall 14 | LOCAL_MODULE := debuggerd 15 | 16 | ifeq ($(ARCH_ARM_HAVE_VFP),true) 17 | LOCAL_CFLAGS += -DWITH_VFP 18 | endif # ARCH_ARM_HAVE_VFP 19 | ifeq ($(ARCH_ARM_HAVE_VFP_D32),true) 20 | LOCAL_CFLAGS += -DWITH_VFP_D32 21 | endif # ARCH_ARM_HAVE_VFP_D32 22 | 23 | LOCAL_STATIC_LIBRARIES := libcutils libc 24 | 25 | include $(BUILD_EXECUTABLE) 26 | 27 | include $(CLEAR_VARS) 28 | LOCAL_SRC_FILES := crasher.c 29 | LOCAL_SRC_FILES += $(TARGET_ARCH)/crashglue.S 30 | LOCAL_MODULE := crasher 31 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 32 | LOCAL_MODULE_TAGS := eng 33 | #LOCAL_FORCE_STATIC_EXECUTABLE := true 34 | LOCAL_SHARED_LIBRARIES := libcutils libc 35 | include $(BUILD_EXECUTABLE) 36 | 37 | ifeq ($(ARCH_ARM_HAVE_VFP),true) 38 | include $(CLEAR_VARS) 39 | 40 | LOCAL_CFLAGS += -DWITH_VFP 41 | ifeq ($(ARCH_ARM_HAVE_VFP_D32),true) 42 | LOCAL_CFLAGS += -DWITH_VFP_D32 43 | endif # ARCH_ARM_HAVE_VFP_D32 44 | 45 | LOCAL_SRC_FILES := vfp-crasher.c vfp.S 46 | LOCAL_MODULE := vfp-crasher 47 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 48 | LOCAL_MODULE_TAGS := eng 49 | LOCAL_SHARED_LIBRARIES := libcutils libc 50 | include $(BUILD_EXECUTABLE) 51 | endif # ARCH_ARM_HAVE_VFP == true 52 | 53 | endif # arm or x86 in TARGET_ARCH 54 | -------------------------------------------------------------------------------- /debuggerd/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joneschrisg/android-system-core/69c8512061771630bf166394b5567f59a0c2f32d/debuggerd/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /debuggerd/arm/crashglue.S: -------------------------------------------------------------------------------- 1 | .globl crash1 2 | .type crash1, %function 3 | .globl crashnostack 4 | .type crashnostack, %function 5 | 6 | crash1: 7 | ldr r0, =0xa5a50000 8 | ldr r1, =0xa5a50001 9 | ldr r2, =0xa5a50002 10 | ldr r3, =0xa5a50003 11 | ldr r4, =0xa5a50004 12 | ldr r5, =0xa5a50005 13 | ldr r6, =0xa5a50006 14 | ldr r7, =0xa5a50007 15 | ldr r8, =0xa5a50008 16 | ldr r9, =0xa5a50009 17 | ldr r10, =0xa5a50010 18 | ldr r11, =0xa5a50011 19 | ldr r12, =0xa5a50012 20 | 21 | mov lr, #0 22 | ldr lr, [lr] 23 | b . 24 | 25 | 26 | crashnostack: 27 | mov sp, #0 28 | mov r0, #0 29 | ldr r0, [r0] 30 | b . 31 | -------------------------------------------------------------------------------- /debuggerd/debuggerd.h: -------------------------------------------------------------------------------- 1 | /* system/debuggerd/debuggerd.h 2 | ** 3 | ** Copyright 2006, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "utility.h" 22 | #include "symbol_table.h" 23 | 24 | 25 | /* Main entry point to get the backtrace from the crashing process */ 26 | extern int unwind_backtrace_with_ptrace(int tfd, pid_t pid, mapinfo *map, 27 | unsigned int sp_list[], 28 | int *frame0_pc_sane, 29 | bool at_fault); 30 | 31 | extern void dump_registers(int tfd, int pid, bool at_fault); 32 | 33 | extern int unwind_backtrace_with_ptrace_x86(int tfd, pid_t pid, mapinfo *map, bool at_fault); 34 | 35 | void dump_pc_and_lr(int tfd, int pid, mapinfo *map, int unwound_level, bool at_fault); 36 | 37 | void dump_stack_and_code(int tfd, int pid, mapinfo *map, 38 | int unwind_depth, unsigned int sp_list[], 39 | bool at_fault); 40 | -------------------------------------------------------------------------------- /debuggerd/symbol_table.h: -------------------------------------------------------------------------------- 1 | #ifndef SYMBOL_TABLE_H 2 | #define SYMBOL_TABLE_H 3 | 4 | struct symbol { 5 | unsigned int addr; 6 | unsigned int size; 7 | char *name; 8 | }; 9 | 10 | struct symbol_table { 11 | struct symbol *symbols; 12 | int num_symbols; 13 | char *name; 14 | }; 15 | 16 | struct symbol_table *symbol_table_create(const char *filename); 17 | void symbol_table_free(struct symbol_table *table); 18 | const struct symbol *symbol_table_lookup(struct symbol_table *table, unsigned int addr); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /debuggerd/vfp-crasher.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | extern void crash(void); 4 | 5 | crash(); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /debuggerd/vfp.S: -------------------------------------------------------------------------------- 1 | .text 2 | .align 2 3 | .global crash 4 | .type crash, %function 5 | crash: 6 | fconstd d0, #0 7 | fconstd d1, #1 8 | fconstd d2, #2 9 | fconstd d3, #3 10 | fconstd d4, #4 11 | fconstd d5, #5 12 | fconstd d6, #6 13 | fconstd d7, #7 14 | fconstd d8, #8 15 | fconstd d9, #9 16 | fconstd d10, #10 17 | fconstd d11, #11 18 | fconstd d12, #12 19 | fconstd d13, #13 20 | fconstd d14, #14 21 | fconstd d15, #15 22 | #ifdef WITH_VFP_D32 23 | fconstd d16, #16 24 | fconstd d17, #17 25 | fconstd d18, #18 26 | fconstd d19, #19 27 | fconstd d20, #20 28 | fconstd d21, #21 29 | fconstd d22, #22 30 | fconstd d23, #23 31 | fconstd d24, #24 32 | fconstd d25, #25 33 | fconstd d26, #26 34 | fconstd d27, #27 35 | fconstd d28, #28 36 | fconstd d29, #29 37 | fconstd d30, #30 38 | fconstd d31, #31 39 | #endif 40 | mov r0, #0 41 | str r0, [r0] 42 | bx lr 43 | 44 | -------------------------------------------------------------------------------- /debuggerd/x86/crashglue.S: -------------------------------------------------------------------------------- 1 | .globl crash1 2 | .globl crashnostack 3 | 4 | crash1: 5 | movl $0xa5a50000, %eax 6 | movl $0xa5a50001, %ebx 7 | movl $0xa5a50002, %ecx 8 | 9 | movl $0, %edx 10 | jmp *%edx 11 | 12 | 13 | crashnostack: 14 | movl $0, %ebp 15 | jmp *%ebp 16 | -------------------------------------------------------------------------------- /debuggerd/x86/x86_utility.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** Copyright 2006, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | #define STACK_DEPTH 8 19 | #define STACK_FRAME_DEPTH 64 20 | 21 | typedef struct pt_regs_x86 { 22 | long ebx; 23 | long ecx; 24 | long edx; 25 | long esi; 26 | long edi; 27 | long ebp; 28 | long eax; 29 | int xds; 30 | int xes; 31 | int xfs; 32 | int xgs; 33 | long orig_eax; 34 | long eip; 35 | int xcs; 36 | long eflags; 37 | long esp; 38 | int xss; 39 | }pt_regs_x86; 40 | 41 | -------------------------------------------------------------------------------- /fastboot/engineering_key.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joneschrisg/android-system-core/69c8512061771630bf166394b5567f59a0c2f32d/fastboot/engineering_key.p12 -------------------------------------------------------------------------------- /fastboot/genkey.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -ne 2 ] 4 | then 5 | echo "Usage: $0 alias \"pass phrase\"" 6 | exit -1 7 | fi 8 | 9 | # Generate a 2048 bit RSA key with public exponent 3. 10 | # Encrypt private key with provided password. 11 | openssl genrsa -3 -out $1.pem -passout pass:"$2" 2048 12 | 13 | # Create a self-signed cert for this key. 14 | openssl req -new -x509 -key $1.pem -passin pass:"$2" \ 15 | -out $1-cert.pem \ 16 | -batch -days 10000 17 | 18 | # Create a PKCS12 store containing the generated private key. 19 | # Protect the keystore and the private key with the provided password. 20 | openssl pkcs12 -export -in $1-cert.pem -inkey $1.pem -passin pass:"$2" \ 21 | -out $1.p12 -name $1 -passout pass:"$2" 22 | 23 | rm $1.pem 24 | rm $1-cert.pem 25 | 26 | -------------------------------------------------------------------------------- /fastboot/p12topem.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -ne 2 ] 4 | then 5 | echo "Usage: $0 alias passphrase" 6 | exit -1 7 | fi 8 | 9 | openssl pkcs12 -passin pass:"$2" -passout pass:"$2" -in $1.p12 -out $1.pem 10 | -------------------------------------------------------------------------------- /fastboot/signfile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -ne 3 ] 4 | then 5 | echo "Usage: $0 alias filename passpharse" 6 | exit -1 7 | fi 8 | 9 | openssl dgst -passin pass:"$3" -binary -sha1 -sign $1.pem $2 > $2.sign 10 | 11 | -------------------------------------------------------------------------------- /include/cutils/ashmem.h: -------------------------------------------------------------------------------- 1 | /* cutils/ashmem.h 2 | ** 3 | ** Copyright 2008 The Android Open Source Project 4 | ** 5 | ** This file is dual licensed. It may be redistributed and/or modified 6 | ** under the terms of the Apache 2.0 License OR version 2 of the GNU 7 | ** General Public License. 8 | */ 9 | 10 | #ifndef _CUTILS_ASHMEM_H 11 | #define _CUTILS_ASHMEM_H 12 | 13 | #include 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | int ashmem_create_region(const char *name, size_t size); 20 | int ashmem_set_prot_region(int fd, int prot); 21 | int ashmem_pin_region(int fd, size_t offset, size_t len); 22 | int ashmem_unpin_region(int fd, size_t offset, size_t len); 23 | int ashmem_get_size_region(int fd); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #ifndef __ASHMEMIOC /* in case someone included too */ 30 | 31 | #define ASHMEM_NAME_LEN 256 32 | 33 | #define ASHMEM_NAME_DEF "dev/ashmem" 34 | 35 | /* Return values from ASHMEM_PIN: Was the mapping purged while unpinned? */ 36 | #define ASHMEM_NOT_PURGED 0 37 | #define ASHMEM_WAS_PURGED 1 38 | 39 | /* Return values from ASHMEM_UNPIN: Is the mapping now pinned or unpinned? */ 40 | #define ASHMEM_IS_UNPINNED 0 41 | #define ASHMEM_IS_PINNED 1 42 | 43 | #endif /* ! __ASHMEMIOC */ 44 | 45 | #endif /* _CUTILS_ASHMEM_H */ 46 | -------------------------------------------------------------------------------- /include/cutils/bitops.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_BITOPS_H 18 | #define __CUTILS_BITOPS_H 19 | 20 | #include 21 | 22 | __BEGIN_DECLS 23 | 24 | static inline int popcount(unsigned int x) 25 | { 26 | return __builtin_popcount(x); 27 | } 28 | 29 | static inline int popcountl(unsigned long x) 30 | { 31 | return __builtin_popcountl(x); 32 | } 33 | 34 | static inline int popcountll(unsigned long long x) 35 | { 36 | return __builtin_popcountll(x); 37 | } 38 | 39 | __END_DECLS 40 | 41 | #endif /* __CUTILS_BITOPS_H */ 42 | -------------------------------------------------------------------------------- /include/cutils/compiler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_CUTILS_COMPILER_H 18 | #define ANDROID_CUTILS_COMPILER_H 19 | 20 | /* 21 | * helps the compiler's optimizer predicting branches 22 | */ 23 | 24 | #ifdef __cplusplus 25 | # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true )) 26 | # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false )) 27 | #else 28 | # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 )) 29 | # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 )) 30 | #endif 31 | 32 | #endif // ANDROID_CUTILS_COMPILER_H 33 | -------------------------------------------------------------------------------- /include/cutils/cpu_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_CPU_INFO_H 18 | #define __CUTILS_CPU_INFO_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /* returns a string contiaining an ASCII representation of the CPU serial number, 25 | ** or NULL if cpu info not available. 26 | ** The string is a static variable, so don't call free() on it. 27 | */ 28 | extern const char* get_cpu_serial_number(void); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif /* __CUTILS_CPU_INFO_H */ 35 | -------------------------------------------------------------------------------- /include/cutils/dir_hash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | typedef enum { 18 | SHA_1, 19 | } HashAlgorithm; 20 | 21 | int get_file_hash(HashAlgorithm algorithm, const char *path, 22 | char *output_string, size_t max_output_string); 23 | 24 | int get_recursive_hash_manifest(HashAlgorithm algorithm, 25 | const char *directory_path, 26 | char **output_string); 27 | -------------------------------------------------------------------------------- /include/cutils/event_tag_map.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _LIBS_CUTILS_EVENTTAGMAP_H 18 | #define _LIBS_CUTILS_EVENTTAGMAP_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #define EVENT_TAG_MAP_FILE "/system/etc/event-log-tags" 25 | 26 | struct EventTagMap; 27 | typedef struct EventTagMap EventTagMap; 28 | 29 | /* 30 | * Open the specified file as an event log tag map. 31 | * 32 | * Returns NULL on failure. 33 | */ 34 | EventTagMap* android_openEventTagMap(const char* fileName); 35 | 36 | /* 37 | * Close the map. 38 | */ 39 | void android_closeEventTagMap(EventTagMap* map); 40 | 41 | /* 42 | * Look up a tag by index. Returns the tag string, or NULL if not found. 43 | */ 44 | const char* android_lookupEventTag(const EventTagMap* map, int tag); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /*_LIBS_CUTILS_EVENTTAGMAP_H*/ 51 | -------------------------------------------------------------------------------- /include/cutils/iosched_policy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_IOSCHED_POLICY_H 18 | #define __CUTILS_IOSCHED_POLICY_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef enum { 25 | IoSchedClass_NONE, 26 | IoSchedClass_RT, 27 | IoSchedClass_BE, 28 | IoSchedClass_IDLE, 29 | } IoSchedClass; 30 | 31 | extern int android_set_ioprio(int pid, IoSchedClass clazz, int ioprio); 32 | extern int android_get_ioprio(int pid, IoSchedClass *clazz, int *ioprio); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif /* __CUTILS_IOSCHED_POLICY_H */ 39 | -------------------------------------------------------------------------------- /include/cutils/jstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_STRING16_H 18 | #define __CUTILS_STRING16_H 19 | 20 | #include 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | typedef uint16_t char16_t; 28 | 29 | extern char * strndup16to8 (const char16_t* s, size_t n); 30 | extern size_t strnlen16to8 (const char16_t* s, size_t n); 31 | extern char * strncpy16to8 (char *dest, const char16_t*s, size_t n); 32 | 33 | extern char16_t * strdup8to16 (const char* s, size_t *out_len); 34 | extern size_t strlen8to16 (const char* utf8Str); 35 | extern char16_t * strcpy8to16 (char16_t *dest, const char*s, size_t *out_len); 36 | extern char16_t * strcpylen8to16 (char16_t *dest, const char*s, int length, 37 | size_t *out_len); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif /* __CUTILS_STRING16_H */ 44 | -------------------------------------------------------------------------------- /include/cutils/logd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _ANDROID_CUTILS_LOGD_H 18 | #define _ANDROID_CUTILS_LOGD_H 19 | 20 | /* the stable/frozen log-related definitions have been 21 | * moved to this header, which is exposed by the NDK 22 | */ 23 | #include 24 | 25 | /* the rest is only used internally by the system */ 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #ifdef HAVE_PTHREADS 32 | #include 33 | #endif 34 | #include 35 | #include 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | int __android_log_bwrite(int32_t tag, const void *payload, size_t len); 42 | int __android_log_btwrite(int32_t tag, char type, const void *payload, 43 | size_t len); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif /* _LOGD_H */ 50 | -------------------------------------------------------------------------------- /include/cutils/logger.h: -------------------------------------------------------------------------------- 1 | /* utils/logger.h 2 | ** 3 | ** Copyright 2007, The Android Open Source Project 4 | ** 5 | ** This file is dual licensed. It may be redistributed and/or modified 6 | ** under the terms of the Apache 2.0 License OR version 2 of the GNU 7 | ** General Public License. 8 | */ 9 | 10 | #ifndef _UTILS_LOGGER_H 11 | #define _UTILS_LOGGER_H 12 | 13 | #include 14 | 15 | struct logger_entry { 16 | uint16_t len; /* length of the payload */ 17 | uint16_t __pad; /* no matter what, we get 2 bytes of padding */ 18 | int32_t pid; /* generating process's pid */ 19 | int32_t tid; /* generating process's tid */ 20 | int32_t sec; /* seconds since Epoch */ 21 | int32_t nsec; /* nanoseconds */ 22 | char msg[0]; /* the entry's payload */ 23 | }; 24 | 25 | #define LOGGER_LOG_MAIN "log/main" 26 | #define LOGGER_LOG_RADIO "log/radio" 27 | #define LOGGER_LOG_EVENTS "log/events" 28 | #define LOGGER_LOG_SYSTEM "log/system" 29 | 30 | #define LOGGER_ENTRY_MAX_LEN (4*1024) 31 | #define LOGGER_ENTRY_MAX_PAYLOAD \ 32 | (LOGGER_ENTRY_MAX_LEN - sizeof(struct logger_entry)) 33 | 34 | #ifdef HAVE_IOCTL 35 | 36 | #include 37 | 38 | #define __LOGGERIO 0xAE 39 | 40 | #define LOGGER_GET_LOG_BUF_SIZE _IO(__LOGGERIO, 1) /* size of log */ 41 | #define LOGGER_GET_LOG_LEN _IO(__LOGGERIO, 2) /* used log len */ 42 | #define LOGGER_GET_NEXT_ENTRY_LEN _IO(__LOGGERIO, 3) /* next entry len */ 43 | #define LOGGER_FLUSH_LOG _IO(__LOGGERIO, 4) /* flush log */ 44 | 45 | #endif // HAVE_IOCTL 46 | 47 | #endif /* _UTILS_LOGGER_H */ 48 | -------------------------------------------------------------------------------- /include/cutils/memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_CUTILS_MEMORY_H 18 | #define ANDROID_CUTILS_MEMORY_H 19 | 20 | #include 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* size is given in bytes and must be multiple of 2 */ 28 | void android_memset16(uint16_t* dst, uint16_t value, size_t size); 29 | 30 | /* size is given in bytes and must be multiple of 4 */ 31 | void android_memset32(uint32_t* dst, uint32_t value, size_t size); 32 | 33 | #if !HAVE_STRLCPY 34 | /* Declaration of strlcpy() for platforms that don't already have it. */ 35 | size_t strlcpy(char *dst, const char *src, size_t size); 36 | #endif 37 | 38 | #ifdef __cplusplus 39 | } // extern "C" 40 | #endif 41 | 42 | #endif // ANDROID_CUTILS_MEMORY_H 43 | -------------------------------------------------------------------------------- /include/cutils/misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_MISC_H 18 | #define __CUTILS_MISC_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /* Load an entire file into a malloc'd chunk of memory 25 | * that is length_of_file + 1 (null terminator). If 26 | * sz is non-zero, return the size of the file via sz. 27 | * Returns 0 on failure. 28 | */ 29 | extern void *load_file(const char *fn, unsigned *sz); 30 | 31 | /* Connects your process to the system debugger daemon 32 | * so that on a crash it may be logged or interactively 33 | * debugged (depending on system settings). 34 | */ 35 | extern void debuggerd_connect(void); 36 | 37 | 38 | /* This is the range of UIDs (and GIDs) that are reserved 39 | * for assigning to applications. 40 | */ 41 | #define FIRST_APPLICATION_UID 10000 42 | #define LAST_APPLICATION_UID 99999 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif /* __CUTILS_MISC_H */ 49 | -------------------------------------------------------------------------------- /include/cutils/open_memstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_OPEN_MEMSTREAM_H__ 18 | #define __CUTILS_OPEN_MEMSTREAM_H__ 19 | 20 | #include 21 | 22 | #ifndef HAVE_OPEN_MEMSTREAM 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | FILE* open_memstream(char** bufp, size_t* sizep); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif /*!HAVE_OPEN_MEMSTREAM*/ 35 | 36 | #endif /*__CUTILS_OPEN_MEMSTREAM_H__*/ 37 | -------------------------------------------------------------------------------- /include/cutils/process_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Gives the current process a name. 19 | */ 20 | 21 | #ifndef __PROCESS_NAME_H 22 | #define __PROCESS_NAME_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /** 29 | * Sets the current process name. 30 | * 31 | * Warning: This leaks a string every time you call it. Use judiciously! 32 | */ 33 | void set_process_name(const char* process_name); 34 | 35 | /** Gets the current process name. */ 36 | const char* get_process_name(void); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* __PROCESS_NAME_H */ 43 | -------------------------------------------------------------------------------- /include/cutils/qtaguid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_QTAGUID_H 18 | #define __CUTILS_QTAGUID_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* 29 | * Set tags (and owning UIDs) for network sockets. 30 | */ 31 | extern int qtaguid_tagSocket(int sockfd, int tag, uid_t uid); 32 | 33 | /* 34 | * Untag a network socket before closing. 35 | */ 36 | extern int qtaguid_untagSocket(int sockfd); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* __CUTILS_QTAG_UID_H */ 43 | -------------------------------------------------------------------------------- /include/cutils/record_stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * A simple utility for reading fixed records out of a stream fd 19 | */ 20 | 21 | #ifndef _CUTILS_RECORD_STREAM_H 22 | #define _CUTILS_RECORD_STREAM_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | 29 | typedef struct RecordStream RecordStream; 30 | 31 | extern RecordStream *record_stream_new(int fd, size_t maxRecordLen); 32 | extern void record_stream_free(RecordStream *p_rs); 33 | 34 | extern int record_stream_get_next (RecordStream *p_rs, void ** p_outRecord, 35 | size_t *p_outRecordLen); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | 42 | #endif /*_CUTILS_RECORD_STREAM_H*/ 43 | 44 | -------------------------------------------------------------------------------- /include/cutils/sched_policy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_SCHED_POLICY_H 18 | #define __CUTILS_SCHED_POLICY_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | typedef enum { 25 | SP_BACKGROUND = 0, 26 | SP_FOREGROUND = 1, 27 | } SchedPolicy; 28 | 29 | extern int set_sched_policy(int tid, SchedPolicy policy); 30 | extern int get_sched_policy(int tid, SchedPolicy *policy); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif /* __CUTILS_SCHED_POLICY_H */ 37 | -------------------------------------------------------------------------------- /include/cutils/uevent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_UEVENT_H 18 | #define __CUTILS_UEVENT_H 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | ssize_t uevent_checked_recv(int socket, void *buffer, size_t length); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif /* __CUTILS_UEVENT_H */ 33 | -------------------------------------------------------------------------------- /include/cutils/uio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // 18 | // implementation of sys/uio.h for platforms that don't have it (Win32) 19 | // 20 | #ifndef _LIBS_CUTILS_UIO_H 21 | #define _LIBS_CUTILS_UIO_H 22 | 23 | #ifdef HAVE_SYS_UIO_H 24 | #include 25 | #else 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | #include 32 | 33 | struct iovec { 34 | const void* iov_base; 35 | size_t iov_len; 36 | }; 37 | 38 | extern int readv( int fd, struct iovec* vecs, int count ); 39 | extern int writev( int fd, const struct iovec* vecs, int count ); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif /* !HAVE_SYS_UIO_H */ 46 | 47 | #endif /* _LIBS_UTILS_UIO_H */ 48 | 49 | -------------------------------------------------------------------------------- /include/cutils/zygote.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CUTILS_ZYGOTE_H 18 | #define __CUTILS_ZYGOTE_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | int zygote_run_oneshot(int sendStdio, int argc, const char **argv); 25 | int zygote_run(int argc, const char **argv); 26 | int zygote_run_wait(int argc, const char **argv, void (*post_run_func)(int)); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif /* __CUTILS_ZYGOTE_H */ 33 | -------------------------------------------------------------------------------- /include/netutils/dhcp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010, The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _NETUTILS_DHCP_H_ 18 | #define _NETUTILS_DHCP_H_ 19 | 20 | #include 21 | #include 22 | 23 | __BEGIN_DECLS 24 | 25 | extern int do_dhcp(char *iname); 26 | extern int dhcp_do_request(const char *ifname, 27 | in_addr_t *ipaddr, 28 | in_addr_t *gateway, 29 | in_addr_t *mask, 30 | in_addr_t *dns1, 31 | in_addr_t *dns2, 32 | in_addr_t *server, 33 | uint32_t *lease); 34 | extern int dhcp_stop(const char *ifname); 35 | extern int dhcp_release_lease(const char *ifname); 36 | extern char *dhcp_get_errmsg(); 37 | 38 | __END_DECLS 39 | 40 | #endif /* _NETUTILS_DHCP_H_ */ 41 | -------------------------------------------------------------------------------- /include/sysutils/FrameworkClient.h: -------------------------------------------------------------------------------- 1 | #ifndef _FRAMEWORK_CLIENT_H 2 | #define _FRAMEWORK_CLIENT_H 3 | 4 | #include "../../../frameworks/base/include/utils/List.h" 5 | 6 | #include 7 | 8 | class FrameworkClient { 9 | int mSocket; 10 | pthread_mutex_t mWriteMutex; 11 | 12 | public: 13 | FrameworkClient(int sock); 14 | virtual ~FrameworkClient() {} 15 | 16 | int sendMsg(const char *msg); 17 | int sendMsg(const char *msg, const char *data); 18 | }; 19 | 20 | typedef android::List FrameworkClientCollection; 21 | #endif 22 | -------------------------------------------------------------------------------- /include/sysutils/FrameworkCommand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __FRAMEWORK_CMD_HANDLER_H 17 | #define __FRAMEWORK_CMD_HANDLER_H 18 | 19 | #include "../../../frameworks/base/include/utils/List.h" 20 | 21 | class SocketClient; 22 | 23 | class FrameworkCommand { 24 | private: 25 | const char *mCommand; 26 | 27 | public: 28 | 29 | FrameworkCommand(const char *cmd); 30 | virtual ~FrameworkCommand() { } 31 | 32 | virtual int runCommand(SocketClient *c, int argc, char **argv) = 0; 33 | 34 | const char *getCommand() { return mCommand; } 35 | }; 36 | 37 | typedef android::List FrameworkCommandCollection; 38 | #endif 39 | -------------------------------------------------------------------------------- /include/sysutils/FrameworkListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef _FRAMEWORKSOCKETLISTENER_H 17 | #define _FRAMEWORKSOCKETLISTENER_H 18 | 19 | #include "SocketListener.h" 20 | #include "FrameworkCommand.h" 21 | 22 | class SocketClient; 23 | 24 | class FrameworkListener : public SocketListener { 25 | public: 26 | static const int CMD_ARGS_MAX = 16; 27 | private: 28 | FrameworkCommandCollection *mCommands; 29 | 30 | public: 31 | FrameworkListener(const char *socketName); 32 | virtual ~FrameworkListener() {} 33 | 34 | protected: 35 | void registerCmd(FrameworkCommand *cmd); 36 | virtual bool onDataAvailable(SocketClient *c); 37 | 38 | private: 39 | void dispatchCommand(SocketClient *c, char *data); 40 | }; 41 | #endif 42 | -------------------------------------------------------------------------------- /include/sysutils/NetlinkEvent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef _NETLINKEVENT_H 17 | #define _NETLINKEVENT_H 18 | 19 | #define NL_PARAMS_MAX 32 20 | 21 | class NetlinkEvent { 22 | int mSeq; 23 | char *mPath; 24 | int mAction; 25 | char *mSubsystem; 26 | char *mParams[NL_PARAMS_MAX]; 27 | 28 | public: 29 | const static int NlActionUnknown; 30 | const static int NlActionAdd; 31 | const static int NlActionRemove; 32 | const static int NlActionChange; 33 | 34 | NetlinkEvent(); 35 | virtual ~NetlinkEvent(); 36 | 37 | bool decode(char *buffer, int size); 38 | const char *findParam(const char *paramName); 39 | 40 | const char *getSubsystem() { return mSubsystem; } 41 | int getAction() { return mAction; } 42 | 43 | void dump(); 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /include/sysutils/NetlinkListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef _NETLINKLISTENER_H 17 | #define _NETLINKLISTENER_H 18 | 19 | #include "SocketListener.h" 20 | 21 | class NetlinkEvent; 22 | 23 | class NetlinkListener : public SocketListener { 24 | char mBuffer[64 * 1024]; 25 | 26 | public: 27 | NetlinkListener(int socket); 28 | virtual ~NetlinkListener() {} 29 | 30 | protected: 31 | virtual bool onDataAvailable(SocketClient *cli); 32 | virtual void onEvent(NetlinkEvent *evt) = 0; 33 | }; 34 | #endif 35 | -------------------------------------------------------------------------------- /include/sysutils/ServiceManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _SERVICE_MANAGER_H 18 | #define _SERVICE_MANAGER_H 19 | 20 | class ServiceManager { 21 | public: 22 | ServiceManager(); 23 | virtual ~ServiceManager() {} 24 | 25 | int start(const char *name); 26 | int stop(const char *name); 27 | bool isRunning(const char *name); 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/sysutils/SocketClient.h: -------------------------------------------------------------------------------- 1 | #ifndef _SOCKET_CLIENT_H 2 | #define _SOCKET_CLIENT_H 3 | 4 | #include "../../../frameworks/base/include/utils/List.h" 5 | 6 | #include 7 | #include 8 | 9 | class SocketClient { 10 | int mSocket; 11 | pthread_mutex_t mWriteMutex; 12 | 13 | /* Peer process ID */ 14 | pid_t mPid; 15 | 16 | /* Peer user ID */ 17 | uid_t mUid; 18 | 19 | /* Peer group ID */ 20 | gid_t mGid; 21 | 22 | /* Reference count (starts at 1) */ 23 | pthread_mutex_t mRefCountMutex; 24 | int mRefCount; 25 | 26 | public: 27 | SocketClient(int sock); 28 | virtual ~SocketClient() {} 29 | 30 | int getSocket() { return mSocket; } 31 | pid_t getPid() const { return mPid; } 32 | uid_t getUid() const { return mUid; } 33 | gid_t getGid() const { return mGid; } 34 | 35 | // Send null-terminated C strings: 36 | int sendMsg(int code, const char *msg, bool addErrno); 37 | int sendMsg(const char *msg); 38 | 39 | // Sending binary data: 40 | int sendData(const void *data, int len); 41 | 42 | // Optional reference counting. Reference count starts at 1. If 43 | // it's decremented to 0, it deletes itself. 44 | // SocketListener creates a SocketClient (at refcount 1) and calls 45 | // decRef() when it's done with the client. 46 | void incRef(); 47 | bool decRef(); // returns true at 0 (but note: SocketClient already deleted) 48 | }; 49 | 50 | typedef android::List SocketClientCollection; 51 | #endif 52 | -------------------------------------------------------------------------------- /include/sysutils/SocketListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef _SOCKETLISTENER_H 17 | #define _SOCKETLISTENER_H 18 | 19 | #include 20 | 21 | #include 22 | 23 | class SocketListener { 24 | int mSock; 25 | const char *mSocketName; 26 | SocketClientCollection *mClients; 27 | pthread_mutex_t mClientsLock; 28 | bool mListen; 29 | int mCtrlPipe[2]; 30 | pthread_t mThread; 31 | 32 | public: 33 | SocketListener(const char *socketName, bool listen); 34 | SocketListener(int socketFd, bool listen); 35 | 36 | virtual ~SocketListener(); 37 | int startListener(); 38 | int stopListener(); 39 | 40 | void sendBroadcast(int code, const char *msg, bool addErrno); 41 | void sendBroadcast(const char *msg); 42 | 43 | protected: 44 | virtual bool onDataAvailable(SocketClient *c) = 0; 45 | 46 | private: 47 | static void *threadStart(void *obj); 48 | void runListener(); 49 | }; 50 | #endif 51 | -------------------------------------------------------------------------------- /init/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2005 The Android Open Source Project 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_SRC_FILES:= \ 7 | builtins.c \ 8 | init.c \ 9 | devices.c \ 10 | property_service.c \ 11 | util.c \ 12 | parser.c \ 13 | logo.c \ 14 | keychords.c \ 15 | signal_handler.c \ 16 | init_parser.c \ 17 | ueventd.c \ 18 | ueventd_parser.c 19 | 20 | ifeq ($(strip $(INIT_BOOTCHART)),true) 21 | LOCAL_SRC_FILES += bootchart.c 22 | LOCAL_CFLAGS += -DBOOTCHART=1 23 | endif 24 | 25 | LOCAL_MODULE:= init 26 | 27 | LOCAL_FORCE_STATIC_EXECUTABLE := true 28 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) 29 | LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED) 30 | 31 | LOCAL_STATIC_LIBRARIES := libcutils libc 32 | 33 | include $(BUILD_EXECUTABLE) 34 | 35 | # Make a symlink from /sbin/ueventd to /init 36 | SYMLINKS := $(TARGET_ROOT_OUT)/sbin/ueventd 37 | $(SYMLINKS): INIT_BINARY := $(LOCAL_MODULE) 38 | $(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk 39 | @echo "Symlink: $@ -> ../$(INIT_BINARY)" 40 | @mkdir -p $(dir $@) 41 | @rm -rf $@ 42 | $(hide) ln -sf ../$(INIT_BINARY) $@ 43 | 44 | ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS) 45 | 46 | # We need this so that the installed files could be picked up based on the 47 | # local module name 48 | ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \ 49 | $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS) 50 | -------------------------------------------------------------------------------- /init/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joneschrisg/android-system-core/69c8512061771630bf166394b5567f59a0c2f32d/init/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /init/bootchart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _BOOTCHART_H 18 | #define _BOOTCHART_H 19 | 20 | #ifndef BOOTCHART 21 | # define BOOTCHART 0 22 | #endif 23 | 24 | #if BOOTCHART 25 | 26 | extern int bootchart_init(void); 27 | extern int bootchart_step(void); 28 | extern void bootchart_finish(void); 29 | 30 | # define BOOTCHART_POLLING_MS 200 /* polling period in ms */ 31 | # define BOOTCHART_DEFAULT_TIME_SEC (2*60) /* default polling time in seconds */ 32 | # define BOOTCHART_MAX_TIME_SEC (10*60) /* max polling time in seconds */ 33 | 34 | #endif /* BOOTCHART */ 35 | 36 | #endif /* _BOOTCHART_H */ 37 | -------------------------------------------------------------------------------- /init/devices.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _INIT_DEVICES_H 18 | #define _INIT_DEVICES_H 19 | 20 | #include 21 | 22 | extern void handle_device_fd(); 23 | extern void device_init(void); 24 | extern int add_dev_perms(const char *name, const char *attr, 25 | mode_t perm, unsigned int uid, 26 | unsigned int gid, unsigned short prefix); 27 | int get_device_fd(); 28 | #endif /* _INIT_DEVICES_H */ 29 | -------------------------------------------------------------------------------- /init/grab-bootchart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # this script is used to retrieve the bootchart log generated 4 | # by init when compiled with INIT_BOOTCHART=true. 5 | # 6 | # for all details, see //device/system/init/README.BOOTCHART 7 | # 8 | TMPDIR=/tmp/android-bootchart 9 | rm -rf $TMPDIR 10 | mkdir -p $TMPDIR 11 | 12 | LOGROOT=/data/bootchart 13 | TARBALL=bootchart.tgz 14 | 15 | FILES="header proc_stat.log proc_ps.log proc_diskstats.log kernel_pacct" 16 | 17 | for f in $FILES; do 18 | adb pull $LOGROOT/$f $TMPDIR/$f 2>&1 > /dev/null 19 | done 20 | (cd $TMPDIR && tar -czf $TARBALL $FILES) 21 | cp -f $TMPDIR/$TARBALL ./$TARBALL 22 | echo "look at $TARBALL" 23 | -------------------------------------------------------------------------------- /init/init_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _INIT_INIT_PARSER_H_ 18 | #define _INIT_INIT_PARSER_H_ 19 | 20 | #define INIT_PARSER_MAXARGS 64 21 | 22 | struct action; 23 | 24 | struct action *action_remove_queue_head(void); 25 | void action_add_queue_tail(struct action *act); 26 | void action_for_each_trigger(const char *trigger, 27 | void (*func)(struct action *act)); 28 | int action_queue_empty(void); 29 | void queue_property_triggers(const char *name, const char *value); 30 | void queue_all_property_triggers(); 31 | void queue_builtin_action(int (*func)(int nargs, char **args), char *name); 32 | 33 | int init_parse_config_file(const char *fn); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /init/keychords.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _INIT_KEYCHORDS_H_ 18 | #define _INIT_KEYCHORDS_H_ 19 | 20 | struct service; 21 | 22 | void add_service_keycodes(struct service *svc); 23 | void keychord_init(void); 24 | void handle_keychord(void); 25 | int get_keychord_fd(void); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /init/list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _INIT_LIST_H_ 18 | #define _INIT_LIST_H_ 19 | 20 | struct listnode 21 | { 22 | struct listnode *next; 23 | struct listnode *prev; 24 | }; 25 | 26 | #define node_to_item(node, container, member) \ 27 | (container *) (((char*) (node)) - offsetof(container, member)) 28 | 29 | #define list_declare(name) \ 30 | struct listnode name = { \ 31 | .next = &name, \ 32 | .prev = &name, \ 33 | } 34 | 35 | #define list_for_each(node, list) \ 36 | for (node = (list)->next; node != (list); node = node->next) 37 | 38 | #define list_for_each_reverse(node, list) \ 39 | for (node = (list)->prev; node != (list); node = node->prev) 40 | 41 | void list_init(struct listnode *list); 42 | void list_add_tail(struct listnode *list, struct listnode *item); 43 | void list_remove(struct listnode *item); 44 | 45 | #define list_empty(list) ((list) == (list)->next) 46 | #define list_head(list) ((list)->next) 47 | #define list_tail(list) ((list)->prev) 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /init/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _INIT_LOG_H_ 18 | #define _INIT_LOG_H_ 19 | 20 | void log_init(void); 21 | void log_set_level(int level); 22 | void log_close(void); 23 | void log_write(int level, const char *fmt, ...) 24 | __attribute__ ((format(printf, 2, 3))); 25 | 26 | #define ERROR(x...) log_write(3, "<3>init: " x) 27 | #define NOTICE(x...) log_write(5, "<5>init: " x) 28 | #define INFO(x...) log_write(6, "<6>init: " x) 29 | 30 | #define LOG_DEFAULT_LEVEL 3 /* messages <= this level are logged */ 31 | #define LOG_UEVENTS 0 /* log uevent messages if 1. verbose */ 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /init/parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PARSER_H_ 18 | #define PARSER_H_ 19 | 20 | #define T_EOF 0 21 | #define T_TEXT 1 22 | #define T_NEWLINE 2 23 | 24 | struct parse_state 25 | { 26 | char *ptr; 27 | char *text; 28 | int line; 29 | int nexttoken; 30 | void *context; 31 | void (*parse_line)(struct parse_state *state, int nargs, char **args); 32 | const char *filename; 33 | }; 34 | 35 | int lookup_keyword(const char *s); 36 | void DUMP(void); 37 | int next_token(struct parse_state *state); 38 | void parse_error(struct parse_state *state, const char *fmt, ...); 39 | 40 | #endif /* PARSER_H_ */ 41 | -------------------------------------------------------------------------------- /init/property_service.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _INIT_PROPERTY_H 18 | #define _INIT_PROPERTY_H 19 | 20 | extern void handle_property_set_fd(void); 21 | extern void property_init(void); 22 | extern void start_property_service(void); 23 | void get_property_workspace(int *fd, int *sz); 24 | extern const char* property_get(const char *name); 25 | extern int property_set(const char *name, const char *value); 26 | extern int properties_inited(); 27 | int get_property_set_fd(void); 28 | 29 | #endif /* _INIT_PROPERTY_H */ 30 | -------------------------------------------------------------------------------- /init/signal_handler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _INIT_SIGNAL_HANDLER_H_ 18 | #define _INIT_SIGNAL_HANDLER_H_ 19 | 20 | void signal_init(void); 21 | void handle_signal(void); 22 | int get_signal_fd(void); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /init/ueventd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _INIT_UEVENTD_H_ 18 | #define _INIT_UEVENTD_H_ 19 | 20 | int ueventd_main(int argc, char **argv); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /init/ueventd_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _INIT_UEVENTD_PARSER_H_ 18 | #define _INIT_UEVENTD_PARSER_H_ 19 | 20 | #define UEVENTD_PARSER_MAXARGS 5 21 | 22 | int ueventd_parse_config_file(const char *fn); 23 | void set_device_permission(int nargs, char **args); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /init/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _INIT_UTIL_H_ 18 | #define _INIT_UTIL_H_ 19 | 20 | #include 21 | #include 22 | 23 | #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) 24 | 25 | static const char *coldboot_done = "/dev/.coldboot_done"; 26 | 27 | int mtd_name_to_number(const char *name); 28 | int create_socket(const char *name, int type, mode_t perm, 29 | uid_t uid, gid_t gid); 30 | void *read_file(const char *fn, unsigned *_sz); 31 | time_t gettime(void); 32 | unsigned int decode_uid(const char *s); 33 | 34 | int mkdir_recursive(const char *pathname, mode_t mode); 35 | void sanitize(char *p); 36 | void make_link(const char *oldpath, const char *newpath); 37 | void remove_link(const char *oldpath, const char *newpath); 38 | int wait_for_file(const char *filename, int timeout); 39 | void open_devnull_stdio(void); 40 | void get_hardware_name(char *hardware, unsigned int *revision); 41 | #endif 42 | -------------------------------------------------------------------------------- /libacc/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | # Shared library for target 5 | # ======================================================== 6 | 7 | LOCAL_MODULE:= libacc 8 | LOCAL_SRC_FILES := acc.cpp 9 | 10 | LOCAL_SHARED_LIBRARIES := libdl libcutils 11 | 12 | include $(BUILD_SHARED_LIBRARY) 13 | 14 | # Static library for host 15 | # ======================================================== 16 | 17 | include $(CLEAR_VARS) 18 | LOCAL_MODULE:= libacc 19 | LOCAL_SRC_FILES := acc.cpp 20 | 21 | LOCAL_CFLAGS := -O0 -g 22 | 23 | LOCAL_STATIC_LIBRARIES := libcutils 24 | LOCAL_LDLIBS := -ldl 25 | 26 | include $(BUILD_HOST_STATIC_LIBRARY) 27 | 28 | # Build children 29 | # ======================================================== 30 | 31 | include $(call all-makefiles-under,$(LOCAL_PATH)) 32 | -------------------------------------------------------------------------------- /libacc/LICENSE: -------------------------------------------------------------------------------- 1 | Obfuscated Tiny C Compiler 2 | 3 | Copyright (C) 2001-2003 Fabrice Bellard 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product and its documentation 16 | *is* required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | 21 | 22 | -------------------------------------------------------------------------------- /libacc/MODULE_LICENSE_BSD_LIKE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joneschrisg/android-system-core/69c8512061771630bf166394b5567f59a0c2f32d/libacc/MODULE_LICENSE_BSD_LIKE -------------------------------------------------------------------------------- /libacc/tests/.gitignore: -------------------------------------------------------------------------------- 1 | test-acc 2 | *.out 3 | -------------------------------------------------------------------------------- /libacc/tests/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | # Executable for host 4 | # ======================================================== 5 | include $(CLEAR_VARS) 6 | LOCAL_MODULE:= acc 7 | 8 | LOCAL_SRC_FILES:= \ 9 | main.cpp 10 | 11 | LOCAL_STATIC_LIBRARIES := \ 12 | libacc \ 13 | libcutils 14 | 15 | LOCAL_LDLIBS := -ldl 16 | 17 | 18 | LOCAL_MODULE_TAGS := tests 19 | 20 | include $(BUILD_HOST_EXECUTABLE) 21 | 22 | # Executable for target 23 | # ======================================================== 24 | include $(CLEAR_VARS) 25 | LOCAL_MODULE:= acc 26 | 27 | LOCAL_SRC_FILES:= \ 28 | main.cpp \ 29 | disassem.cpp 30 | 31 | LOCAL_SHARED_LIBRARIES := \ 32 | libacc \ 33 | libdl 34 | 35 | LOCAL_CFLAGS := -O0 -g 36 | 37 | LOCAL_MODULE_TAGS := tests 38 | 39 | include $(BUILD_EXECUTABLE) 40 | 41 | # Runtime tests for host 42 | # ======================================================== 43 | include $(CLEAR_VARS) 44 | LOCAL_MODULE:= accRuntimeTest 45 | 46 | LOCAL_SRC_FILES:= \ 47 | runtimeTest.cpp 48 | 49 | LOCAL_STATIC_LIBRARIES := \ 50 | libacc \ 51 | libcutils 52 | 53 | LOCAL_LDLIBS := -ldl 54 | 55 | LOCAL_MODULE_TAGS := tests 56 | 57 | include $(BUILD_HOST_EXECUTABLE) 58 | 59 | # Runtime tests for target 60 | # ======================================================== 61 | include $(CLEAR_VARS) 62 | LOCAL_MODULE:= accRuntimeTest 63 | 64 | LOCAL_SRC_FILES:= \ 65 | runtimeTest.cpp 66 | 67 | LOCAL_SHARED_LIBRARIES := \ 68 | libacc \ 69 | libdl 70 | 71 | LOCAL_CFLAGS := -O0 -g 72 | 73 | LOCAL_MODULE_TAGS := tests 74 | 75 | include $(BUILD_EXECUTABLE) 76 | -------------------------------------------------------------------------------- /libacc/tests/data/addressOf.c: -------------------------------------------------------------------------------- 1 | void testStruct() { 2 | struct str { 3 | float x; 4 | float y; 5 | }; 6 | 7 | struct str base; 8 | int index = 0; 9 | 10 | base.x = 10.0; 11 | struct str *s = &base; 12 | 13 | float *v = &(*s).x; 14 | float *v2 = &s[index].x; 15 | printf("testStruct: %g %g %g\n",base.x, *v, *v2); 16 | } 17 | 18 | void testArray() { 19 | int a[2]; 20 | a[0] = 1; 21 | a[1] = 2; 22 | int* p = &a[0]; 23 | int* p2 = a; 24 | printf("testArray: %d %d %d\n", a[0], *p, *p2); 25 | } 26 | 27 | int main() { 28 | testStruct(); 29 | testArray(); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /libacc/tests/data/assignment.c: -------------------------------------------------------------------------------- 1 | int main() { 2 | int a = 0; 3 | int b = 1; 4 | a = b = 2; // Test that "b = 2" generates an rvalue. 5 | if (a = 7) { // Test that a = 7 generates an rvalue. 6 | b = 3; 7 | } 8 | return a; 9 | } 10 | -------------------------------------------------------------------------------- /libacc/tests/data/assignmentop.c: -------------------------------------------------------------------------------- 1 | // Test assignment operations 2 | 3 | void testAssignment() { 4 | int a = 2; 5 | a *= 5; 6 | printf("2 *= 5 %d\n", a); 7 | a = 20; 8 | a /= 5; 9 | printf("20 /= 5 %d\n", a); 10 | a = 17; 11 | a %= 5; 12 | printf("17 %%= 5 %d\n", a); 13 | a = 17; 14 | a += 5; 15 | printf("17 += 5 %d\n", a); 16 | a = 17; 17 | a-=5; 18 | printf("17 -= 5 %d\n", a); 19 | a = 17; 20 | a<<=1; 21 | printf("17<<= 1 %d\n", a); 22 | a = 17; 23 | a>>=1; 24 | printf("17>>= 1 %d\n", a); 25 | a = 17; 26 | a&=1; 27 | printf("17&= 1 %d\n", a); 28 | a = 17; 29 | a^=1; 30 | printf("17^= 1 %d\n", a); 31 | a = 16; 32 | a^=1; 33 | printf("16|= 1 %d\n", a); 34 | } 35 | 36 | int a; 37 | 38 | int* f() { 39 | printf("f()\n"); 40 | return &a; 41 | } 42 | 43 | void testEval() { 44 | a = 0; 45 | printf("*f() = *f() + 10;\n"); 46 | *f() = *f() + 10; 47 | printf("a = %d\n", a); 48 | } 49 | 50 | void testOpEval() { 51 | a = 0; 52 | printf("*f() += 10;\n"); 53 | *f() += 10; 54 | printf("a = %d\n", a); 55 | } 56 | 57 | int main() { 58 | testAssignment(); 59 | testEval(); 60 | testOpEval(); 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /libacc/tests/data/b2071670.c: -------------------------------------------------------------------------------- 1 | // See http://b/2071670 2 | 3 | int main() { 4 | float f = 10.0f; 5 | float* floatPointer = &f; 6 | // The following line used to incorrectly error: "Incompatible pointer or array types" 7 | int* buffer = (int*) floatPointer; 8 | return *buffer; 9 | } 10 | -------------------------------------------------------------------------------- /libacc/tests/data/brackets.c: -------------------------------------------------------------------------------- 1 | void testBrackets(int* ar, int len) { 2 | int i; 3 | int errors = 0; 4 | for (i = 0; i < len; i++) { 5 | ar[i] = i; 6 | } 7 | for (i = 0; i < len; i++) { 8 | if (ar[i] != i) { 9 | printf("error: [%d] %d != %d\n", i, ar[i], i); 10 | errors++; 11 | } 12 | } 13 | printf("Errors: %d\n", errors); 14 | } 15 | 16 | void testBrackets2D(int** ar2D, int lenX, int lenY) { 17 | int x, y; 18 | int errors = 0; 19 | for (x = 0; x < lenX; x++) { 20 | for (y = 0; y < lenY; y++) { 21 | ar2D[x][y] = x * lenY + y; 22 | } 23 | } 24 | for (x = 0; x < lenX; x++) { 25 | for (y = 0; y < lenY; y++) { 26 | int expected = x * lenY + y; 27 | int val = ar2D[x][y]; 28 | if (val != expected) { 29 | printf("error: [%d][%d] %d != %d\n", x, y, val, expected); 30 | errors++; 31 | } 32 | } 33 | } 34 | printf("2D Errors: %d\n", errors); 35 | } 36 | 37 | void testHeap() { 38 | int* ar = (int*) malloc(100); 39 | testBrackets(ar, 25); 40 | free(ar); 41 | } 42 | 43 | void testHeap2D() { 44 | int lenX = 10; 45 | int lenY = 5; 46 | int* ar = (int*) malloc(lenX * lenY * 4); 47 | int** ar2D = (int**) malloc(lenX * 4); 48 | int i; 49 | for(i = 0; i < lenX; i++) { 50 | ar2D[i] = ar + lenY * i; 51 | } 52 | testBrackets2D(ar2D, lenX, lenY); 53 | free(ar); 54 | free(ar2D); 55 | } 56 | 57 | int main() { 58 | testHeap(); 59 | testHeap2D(); 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /libacc/tests/data/char.c: -------------------------------------------------------------------------------- 1 | char ga; 2 | char gb; 3 | 4 | int main() { 5 | char a = 'c'; 6 | char b = a * 3; 7 | printf("a = %d, b = %d\n", a, b); 8 | ga = 'd'; 9 | gb = ga * 3; 10 | printf("ga = %d, gb = %d\n", ga, gb); 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /libacc/tests/data/comma.c: -------------------------------------------------------------------------------- 1 | int testReturn() { 2 | return 10, 20, 30; 3 | } 4 | 5 | int testArg(int a) { 6 | return a; 7 | } 8 | 9 | void testComma() { 10 | int a; 11 | 0, a = 10,20; 12 | printf("statement: %d\n", a); 13 | a = 1; 14 | if (a = 0, 1) { 15 | printf("if: a = %d\n", a); 16 | } 17 | int b = 0; 18 | a = 10; 19 | while(b++,a--) {} 20 | printf("while: b = %d\n", b); 21 | b = 0; 22 | for(b++,a = 0;b++, a < 10; b++, a++) {} 23 | printf("for: b = %d\n", b); 24 | b = testReturn(); 25 | printf("return: %d\n", b); 26 | b = testArg((a,12)); 27 | printf("arg: %d\n", b); 28 | } 29 | 30 | 31 | 32 | int main() { 33 | testComma(); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /libacc/tests/data/constants.c: -------------------------------------------------------------------------------- 1 | #define FOO 0x10 2 | 3 | int main() { 4 | printf("0 = %d\n", 0); 5 | printf("010 = %d\n", 010); 6 | printf("0x10 = %d\n", FOO); 7 | printf("'\\a' = %d\n", '\a'); 8 | printf("'\\b' = %d\n", '\b'); 9 | printf("'\\f' = %d\n", '\f'); 10 | printf("'\\n' = %d\n", '\n'); 11 | printf("'\\r' = %d\n", '\r'); 12 | printf("'\\t' = %d\n", '\t'); 13 | printf("'\\v' = %d\n", '\v'); 14 | // Undefined 15 | // printf("'\\z' = %d\n", '\z'); 16 | printf("'\\\\' = %d\n", '\\'); 17 | printf("'\\'' = %d\n", '\''); 18 | printf("'\\\"' = %d\n", '\"'); 19 | printf("'\\?' = %d\n", '\?'); 20 | printf("'\\0' = %d\n", '\0'); 21 | printf("'\\1' = %d\n", '\1'); 22 | printf("'\\12' = %d\n", '\12'); 23 | printf("'\\123' = %d\n", '\123'); 24 | printf("'\\x0' = %d\n", '\x0'); 25 | printf("'\\x1' = %d\n", '\x1'); 26 | printf("'\\x12' = %d\n", '\x12'); 27 | printf("'\\x123' = %d\n", '\x123'); 28 | printf("'\\x1f' = %d\n", '\x1f'); 29 | printf("'\\x1F' = %d\n", '\x1F'); 30 | } 31 | -------------------------------------------------------------------------------- /libacc/tests/data/continue.c: -------------------------------------------------------------------------------- 1 | int main() { 2 | int i, j, sum; 3 | sum = 0; 4 | for (i = 0; i < 10; i++) { 5 | if (i & 1) continue; 6 | for (j = 0; j < 10; j++) { 7 | if (j & 1) continue; 8 | sum += i * j; 9 | } 10 | } 11 | return sum; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /libacc/tests/data/defines.c: -------------------------------------------------------------------------------- 1 | // Simple tests of the C preprocessor 2 | 3 | #define A 1 4 | #define A (4 / 2) 5 | #define B 1 // This is a comment. With a / in it. 6 | 7 | int main() { 8 | return A + B; 9 | } 10 | -------------------------------------------------------------------------------- /libacc/tests/data/double.c: -------------------------------------------------------------------------------- 1 | double atof(char *nptr); 2 | 3 | int main() { 4 | printf("Value = %g\n", atof("10.42")); 5 | return 0; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /libacc/tests/data/error.c: -------------------------------------------------------------------------------- 1 | void foo; 2 | 3 | -------------------------------------------------------------------------------- /libacc/tests/data/expr2.c: -------------------------------------------------------------------------------- 1 | /* Test operators */ 2 | 3 | main() { 4 | int a; 5 | a = a++; 6 | } 7 | -------------------------------------------------------------------------------- /libacc/tests/data/film.c: -------------------------------------------------------------------------------- 1 | // Test logical and bitwise AND and OR 2 | 3 | int test(int x, int y) { 4 | int v = x || y; 5 | return v; 6 | } 7 | 8 | int test2(int x, int y) { 9 | if(x | y) { 10 | return 1; 11 | } else { 12 | return 0; 13 | } 14 | } 15 | 16 | int test3(int x, int y) { 17 | int v = x && y; 18 | return v; 19 | } 20 | 21 | int test4(int x, int y) { 22 | if(x & y) { 23 | return 1; 24 | } else { 25 | return 0; 26 | } 27 | } 28 | 29 | int main(int index) 30 | { 31 | int x,y; 32 | printf("testing...\n"); 33 | int totalBad = 0; 34 | for(y = 0; y < 2; y++) { 35 | for(x = 0; x < 2; x++) { 36 | int a = test(x,y); 37 | int b = test2(x,y); 38 | if (a != b) { 39 | printf("Results differ: OR x=%d y=%d a=%d b=%d\n", x, y, a, b); 40 | totalBad++; 41 | } 42 | a = test3(x,y); 43 | b = test4(x,y); 44 | if (a != b) { 45 | printf("Results differ: AND x=%d y=%d a=%d b=%d\n", x, y, a, b); 46 | totalBad++; 47 | } 48 | } 49 | } 50 | printf("Total bad: %d\n", totalBad); 51 | return 0; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /libacc/tests/data/float.c: -------------------------------------------------------------------------------- 1 | int ftoi(float f) { 2 | return f; 3 | } 4 | 5 | int dtoi(double d) { 6 | return d; 7 | } 8 | 9 | float itof(int i) { 10 | return i; 11 | } 12 | 13 | double itod(int i) { 14 | return i; 15 | } 16 | 17 | float f0, f1; 18 | double d0, d1; 19 | 20 | void testParseConsts() { 21 | printf("Constants: %g %g %g %g %g %g %g %g %g\n", 0e1, 0E1, 0.f, .01f, 22 | .01e0f, 1.0e-1, 1.0e1, 1.0e+1, 23 | .1f); 24 | } 25 | void testVars(float arg0, float arg1, double arg2, double arg3) { 26 | float local0, local1; 27 | double local2, local3; 28 | f0 = arg0; 29 | f1 = arg1; 30 | d0 = arg2; 31 | d1 = arg3; 32 | local0 = arg0; 33 | local1 = arg1; 34 | local2 = arg2; 35 | local3 = arg3; 36 | printf("globals: %g %g %g %g\n", f0, f1, d0, d1); 37 | printf("args: %g %g %g %g\n", arg0, arg1, arg2, arg3); 38 | printf("locals: %g %g %g %g\n", local0, local1, local2, local3); 39 | 40 | 41 | printf("cast rval: %g %g\n", * (float*) & f1, * (double*) & d1); 42 | 43 | * (float*) & f0 = 1.1f; 44 | * (double*) & d0 = 3.3; 45 | printf("cast lval: %g %g %g %g\n", f0, f1, d0, d1); 46 | } 47 | 48 | int main() { 49 | testParseConsts(); 50 | printf("int: %d float: %g double: %g\n", 1, 2.2f, 3.3); 51 | printf(" ftoi(1.4f)=%d\n", ftoi(1.4f)); 52 | printf(" dtoi(2.4)=%d\n", dtoi(2.4)); 53 | printf(" itof(3)=%g\n", itof(3)); 54 | printf(" itod(4)=%g\n", itod(4)); 55 | testVars(1.0f, 2.0f, 3.0, 4.0); 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /libacc/tests/data/floatdouble.c: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | // Test coercing values when storing. 4 | float a = 0.002; 5 | double b = 0.1f; 6 | int c = 10.002; 7 | printf("%g %g %d\n", a, b, c); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /libacc/tests/data/funcargs.c: -------------------------------------------------------------------------------- 1 | int f(int a,int, int c) { 2 | return a + c; 3 | } 4 | 5 | int main() { 6 | return f(1,2,3); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /libacc/tests/data/hello.c: -------------------------------------------------------------------------------- 1 | main(a,b) { 2 | printf("Hello, world\n"); 3 | } 4 | -------------------------------------------------------------------------------- /libacc/tests/data/inc.c: -------------------------------------------------------------------------------- 1 | // Check integer operations 2 | 3 | int main() { 4 | int a = 0; 5 | printf("%d\n", a++); 6 | printf("%d\n", a++); 7 | printf("%d\n", a--); 8 | printf("%d\n", a--); 9 | printf("%d\n", ++a); 10 | printf("%d\n", ++a); 11 | printf("%d\n", --a); 12 | printf("%d\n", --a); 13 | return a; 14 | } 15 | -------------------------------------------------------------------------------- /libacc/tests/data/iops.c: -------------------------------------------------------------------------------- 1 | // Check integer operations 2 | 3 | void loops() { 4 | int y; 5 | printf("++\n"); 6 | for(y = 0; y < 10; y++) { 7 | printf("%d\n", y); 8 | } 9 | printf("--\n"); 10 | for(y = 10; y >= 0; y--) { 11 | printf("%d\n", y); 12 | } 13 | } 14 | 15 | void checkLiterals() { 16 | printf("Literals: %d %d\n", 1, -1); 17 | } 18 | 19 | int main() { 20 | checkLiterals(); 21 | loops(); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /libacc/tests/data/locals.c: -------------------------------------------------------------------------------- 1 | int a; 2 | 3 | int f() { 4 | int a; 5 | // Undefined variable b 6 | // printf("f 0: a = %d b = %d\n", a, b); 7 | printf("f 0: a = %d\n", a); 8 | a = 2; 9 | printf("f 1: a = %d\n", a); 10 | } 11 | 12 | int g(int a) { 13 | printf("g 0: a = %d\n", a); 14 | a = 3; 15 | printf("g 1: a = %d\n", a); 16 | } 17 | 18 | int h(int a) { 19 | // int a; // gcc 4.3 says error: 'a' redeclared as different kind of symbol 20 | 21 | printf("h 0: a = %d\n", a); 22 | a = 4; 23 | printf("h 1: a = %d\n", a); 24 | } 25 | 26 | // Already defined global 27 | // int h() {} 28 | int globCheck() { 29 | fprintf(stdout, "globCheck()\n"); 30 | } 31 | 32 | int fwdCheck() { 33 | b(); 34 | // Undefined forward reference 35 | // c(); 36 | } 37 | 38 | int b() { 39 | printf("b()\n"); 40 | } 41 | 42 | int nested() { 43 | int a; 44 | printf("nested 0: a = %d\n", a); 45 | a = 50; 46 | printf("nested 1: a = %d\n", a); 47 | { 48 | int a; 49 | printf("nested 2: a = %d\n", a); 50 | a = 51; 51 | printf("nested 3: a = %d\n", a); 52 | } 53 | printf("nested 4: a = %d\n", a); 54 | } 55 | 56 | int main() { 57 | globCheck(); 58 | fwdCheck(); 59 | printf("main 0: a = %d\n", a); 60 | a = 5; 61 | printf("main 1: a = %d\n", a); 62 | f(); 63 | printf("main 2: a = %d\n", a); 64 | g(77); 65 | printf("main 3: a = %d\n", a); 66 | h(30); 67 | printf("main 4: a = %d\n", a); 68 | nested(); 69 | printf("main 5: a = %d\n", a); 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /libacc/tests/data/macros.c: -------------------------------------------------------------------------------- 1 | #define A B + B 2 | #define B C 3 | 4 | int main() { 5 | int C = 3; 6 | printf("A = %d\n", A); 7 | #define C 5 8 | printf("A = %d\n", A); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /libacc/tests/data/missing-main.c: -------------------------------------------------------------------------------- 1 | /* No main. */ 2 | 3 | a() { 4 | } -------------------------------------------------------------------------------- /libacc/tests/data/pointers.c: -------------------------------------------------------------------------------- 1 | int main() { 2 | int* pa = (int*) malloc(100); 3 | int* pb = pa + 1; 4 | int* pc = (int*) 0; 5 | *pa = 1; 6 | *pb = 2; 7 | printf("Pointer difference: %d %d\n", pb - pa, ((int) pb) - ((int) pa)); 8 | int c = * (pa + 1); 9 | printf("Pointer addition: %d\n", c); 10 | printf("Pointer comparison to zero: %d %d %d\n", pa == 0, pb == 0, pc == 0); 11 | printf("Pointer comparison: %d %d %d %d %d\n", pa < pb, pa == pb, pa > pb, ! pb, ! pc); 12 | free(pa); 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /libacc/tests/data/pointers2.c: -------------------------------------------------------------------------------- 1 | // Test multiple levels of indirection 2 | 3 | void testsingle() { 4 | int a = 0; 5 | int* pa = &a; 6 | printf("a = %d, *pa = %d\n", a, *pa); 7 | *pa = 2; 8 | printf("a = %d, *pa = %d\n", a, *pa); 9 | } 10 | 11 | void testdouble() { 12 | int a = 0; 13 | int* pa = &a; 14 | int** ppa = &pa; 15 | printf("a = %d, *pa = %d **ppa = %d\n", a, *pa, **ppa); 16 | **ppa = 2; 17 | printf("a = %d, *pa = %d **ppa = %d\n", a, *pa, **ppa); 18 | } 19 | 20 | void testtripple() { 21 | int a = 0; 22 | int* pa = &a; 23 | int** ppa = &pa; 24 | int*** pppa = &ppa; 25 | printf("a = %d, *pa = %d **ppa = %d\n ***pppa = %d", a, *pa, **ppa, ***pppa); 26 | ***pppa = 2; 27 | printf("a = %d, *pa = %d **ppa = %d\n ***pppa = %d", a, *pa, **ppa, ***pppa); 28 | } 29 | 30 | int main() { 31 | testsingle(); 32 | testdouble(); 33 | testdouble(); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /libacc/tests/data/returnval-ansi.c: -------------------------------------------------------------------------------- 1 | 2 | int main(int argc, char** argv) { 3 | return f(); 4 | } 5 | 6 | int f() { 7 | return 42; 8 | } 9 | -------------------------------------------------------------------------------- /libacc/tests/data/returnval.c: -------------------------------------------------------------------------------- 1 | main() { 2 | return 42; 3 | } 4 | 5 | -------------------------------------------------------------------------------- /libacc/tests/data/rollo3.c: -------------------------------------------------------------------------------- 1 | 2 | float fabsf(float); 3 | 4 | int main(void* con, int ft, int launchID) 5 | { 6 | float f = fabsf(-10.0f); 7 | return f; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /libacc/tests/data/short.c: -------------------------------------------------------------------------------- 1 | short a = 3; 2 | int main() { 3 | short* b = &a; 4 | *b = *b - 5; 5 | return a; 6 | } 7 | -------------------------------------------------------------------------------- /libacc/tests/data/simplest.c: -------------------------------------------------------------------------------- 1 | main() {} 2 | -------------------------------------------------------------------------------- /libacc/tests/data/testStringConcat.c: -------------------------------------------------------------------------------- 1 | int main() { 2 | return printf("Hello" "," " world\n"); 3 | } 4 | 5 | -------------------------------------------------------------------------------- /libacc/tests/data/typedef.c: -------------------------------------------------------------------------------- 1 | typedef short COORD; 2 | typedef struct Point { 3 | COORD x; 4 | COORD y; 5 | } Point; 6 | 7 | void add(Point* result, Point* a, Point* b) { 8 | result->x = a->x + b->x; 9 | result->y = a->y + b->y; 10 | } 11 | 12 | void print(Point* p) { 13 | printf("(%d, %d)", p->x, p->y); 14 | } 15 | 16 | void set(Point* p, int x, int y) { 17 | p->x = x; 18 | p->y = y; 19 | } 20 | 21 | int main() { 22 | typedef char* String; 23 | String s = "x = %d\n"; 24 | { 25 | typedef int item; 26 | item x = 3; 27 | printf(s, x); 28 | } 29 | Point a, b, c; 30 | set(&a, 1,2); 31 | set(&b, 3,4); 32 | add(&c, &a, &b); 33 | print(&c); 34 | printf(" = "); 35 | print(&a); 36 | printf(" + "); 37 | print(&b); 38 | printf("\n"); 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /libacc/tests/test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=`dirname $BASH_SOURCE` 4 | cd $SCRIPT_DIR 5 | python test.py "$@" 6 | 7 | -------------------------------------------------------------------------------- /libctest/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_MODULE:= libctest 5 | LOCAL_SRC_FILES := ctest.c 6 | 7 | include $(BUILD_SHARED_LIBRARY) 8 | -------------------------------------------------------------------------------- /libcutils/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joneschrisg/android-system-core/69c8512061771630bf166394b5567f59a0c2f32d/libcutils/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /libcutils/arch-x86/android_memset16.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * Contributed by: Intel Corporation 18 | */ 19 | 20 | #if defined(USE_SSE2) 21 | 22 | # include "cache_wrapper.S" 23 | # undef __i686 24 | # define USE_AS_ANDROID 25 | # define sse2_memset16_atom android_memset16 26 | # include "sse2-memset16-atom.S" 27 | 28 | #else 29 | 30 | # include "memset16.S" 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /libcutils/arch-x86/android_memset32.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * Contributed by: Intel Corporation 18 | */ 19 | 20 | #if defined(USE_SSE2) 21 | 22 | # include "cache_wrapper.S" 23 | # undef __i686 24 | # define USE_AS_ANDROID 25 | # define sse2_memset32_atom android_memset32 26 | # include "sse2-memset32-atom.S" 27 | 28 | #else 29 | 30 | # include "memset32.S" 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /libcutils/arch-x86/cache_wrapper.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * Contributed by: Intel Corporation 18 | */ 19 | 20 | /* Values are optimized for Atom */ 21 | #define SHARED_CACHE_SIZE (512*1024) /* Atom L2 Cache */ 22 | #define DATA_CACHE_SIZE (24*1024) /* Atom L1 Data Cache */ 23 | #define SHARED_CACHE_SIZE_HALF (SHARED_CACHE_SIZE / 2) 24 | #define DATA_CACHE_SIZE_HALF (DATA_CACHE_SIZE / 2) 25 | -------------------------------------------------------------------------------- /libcutils/atomic.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define inline 18 | 19 | #include 20 | -------------------------------------------------------------------------------- /libcutils/dlmalloc_stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* No-op stubs for functions defined in system/bionic/bionic/dlmalloc.c. 18 | */ 19 | void dlmalloc_walk_free_pages() 20 | { 21 | } 22 | 23 | void dlmalloc_walk_heap() 24 | { 25 | } 26 | 27 | void dlmalloc_trim() 28 | { 29 | } 30 | -------------------------------------------------------------------------------- /libcutils/load_file.c: -------------------------------------------------------------------------------- 1 | /* libs/cutils/load_file.c 2 | ** 3 | ** Copyright 2006, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | void *load_file(const char *fn, unsigned *_sz) 23 | { 24 | char *data; 25 | int sz; 26 | int fd; 27 | 28 | data = 0; 29 | fd = open(fn, O_RDONLY); 30 | if(fd < 0) return 0; 31 | 32 | sz = lseek(fd, 0, SEEK_END); 33 | if(sz < 0) goto oops; 34 | 35 | if(lseek(fd, 0, SEEK_SET) != 0) goto oops; 36 | 37 | data = (char*) malloc(sz + 1); 38 | if(data == 0) goto oops; 39 | 40 | if(read(fd, data, sz) != sz) goto oops; 41 | close(fd); 42 | data[sz] = 0; 43 | 44 | if(_sz) *_sz = sz; 45 | return data; 46 | 47 | oops: 48 | close(fd); 49 | if(data != 0) free(data); 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /libcutils/loghack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * This is a temporary hack to enable logging from cutils. 19 | */ 20 | 21 | #ifndef _CUTILS_LOGHACK_H 22 | #define _CUTILS_LOGHACK_H 23 | 24 | #ifdef HAVE_ANDROID_OS 25 | #include 26 | #else 27 | #include 28 | #define LOG(level, ...) \ 29 | ((void)printf("cutils:" level "/" LOG_TAG ": " __VA_ARGS__)) 30 | #define LOGV(...) LOG("V", __VA_ARGS__) 31 | #define LOGD(...) LOG("D", __VA_ARGS__) 32 | #define LOGI(...) LOG("I", __VA_ARGS__) 33 | #define LOGW(...) LOG("W", __VA_ARGS__) 34 | #define LOGE(...) LOG("E", __VA_ARGS__) 35 | #define LOG_ALWAYS_FATAL(...) do { LOGE(__VA_ARGS__); exit(1); } while (0) 36 | #endif 37 | 38 | #endif // _CUTILS_LOGHACK_H 39 | -------------------------------------------------------------------------------- /libcutils/socket_local.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __SOCKET_LOCAL_H 18 | #define __SOCKET_LOCAL_H 19 | 20 | #define FILESYSTEM_SOCKET_PREFIX "/tmp/" 21 | #define ANDROID_RESERVED_SOCKET_PREFIX "/dev/socket/" 22 | 23 | /* 24 | * Set up a given sockaddr_un, to have it refer to the given 25 | * name in the given namespace. The namespace must be one 26 | * of ANDROID_SOCKET_NAMESPACE_ABSTRACT, 27 | * ANDROID_SOCKET_NAMESPACE_RESERVED, or 28 | * ANDROID_SOCKET_NAMESPACE_FILESYSTEM. Upon success, 29 | * the pointed at sockaddr_un is filled in and the pointed at 30 | * socklen_t is set to indicate the final length. This function 31 | * will fail if the namespace is invalid (not one of the indicated 32 | * constants) or if the name is too long. 33 | * 34 | * @return 0 on success or -1 on failure 35 | */ 36 | int socket_make_sockaddr_un(const char *name, int namespaceId, 37 | struct sockaddr_un *p_addr, socklen_t *alen); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libcutils/socket_loopback_client.c: -------------------------------------------------------------------------------- 1 | /* libs/cutils/socket_loopback_client.c 2 | ** 3 | ** Copyright 2006, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #ifndef HAVE_WINSOCK 27 | #include 28 | #include 29 | #include 30 | #include 31 | #endif 32 | 33 | /* Connect to port on the loopback IP interface. type is 34 | * SOCK_STREAM or SOCK_DGRAM. 35 | * return is a file descriptor or -1 on error 36 | */ 37 | int socket_loopback_client(int port, int type) 38 | { 39 | struct sockaddr_in addr; 40 | socklen_t alen; 41 | int s; 42 | 43 | memset(&addr, 0, sizeof(addr)); 44 | addr.sin_family = AF_INET; 45 | addr.sin_port = htons(port); 46 | addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); 47 | 48 | s = socket(AF_INET, type, 0); 49 | if(s < 0) return -1; 50 | 51 | if(connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) { 52 | close(s); 53 | return -1; 54 | } 55 | 56 | return s; 57 | 58 | } 59 | 60 | -------------------------------------------------------------------------------- /libdiskconfig/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | ifneq ($(TARGET_SIMULATOR),true) 5 | 6 | commonSources := \ 7 | diskconfig.c \ 8 | diskutils.c \ 9 | write_lst.c \ 10 | config_mbr.c 11 | 12 | include $(CLEAR_VARS) 13 | LOCAL_SRC_FILES := $(commonSources) 14 | LOCAL_MODULE := libdiskconfig 15 | LOCAL_MODULE_TAGS := optional 16 | LOCAL_SYSTEM_SHARED_LIBRARIES := libcutils liblog libc 17 | include $(BUILD_SHARED_LIBRARY) 18 | 19 | ifeq ($(HOST_OS),linux) 20 | include $(CLEAR_VARS) 21 | LOCAL_SRC_FILES := $(commonSources) 22 | LOCAL_MODULE := libdiskconfig_host 23 | LOCAL_MODULE_TAGS := optional 24 | LOCAL_SYSTEM_SHARED_LIBRARIES := libcutils 25 | LOCAL_CFLAGS := -O2 -g -W -Wall -Werror -D_LARGEFILE64_SOURCE 26 | include $(BUILD_HOST_STATIC_LIBRARY) 27 | endif # HOST_OS == linux 28 | 29 | endif # ! TARGET_SIMULATOR 30 | -------------------------------------------------------------------------------- /libdiskconfig/dump_diskconfig.c: -------------------------------------------------------------------------------- 1 | /* libs/diskconfig/dump_diskconfig.c 2 | * 3 | * Copyright 2008, The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #define LOG_TAG "dump_diskconfig" 19 | #include 20 | 21 | #include 22 | 23 | #include "diskconfig.h" 24 | 25 | int 26 | main(int argc, char *argv[]) 27 | { 28 | struct disk_info *dinfo; 29 | 30 | if (argc < 2) { 31 | LOGE("usage: %s ", argv[0]); 32 | return 1; 33 | } 34 | 35 | if (!(dinfo = load_diskconfig(argv[1], NULL))) 36 | return 1; 37 | 38 | dump_disk_config(dinfo); 39 | 40 | return 0; 41 | } 42 | 43 | -------------------------------------------------------------------------------- /liblinenoise/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | # Static library 5 | # ======================================================== 6 | 7 | include $(CLEAR_VARS) 8 | LOCAL_MODULE:= liblinenoise 9 | LOCAL_SRC_FILES := linenoise.c 10 | 11 | 12 | include $(BUILD_STATIC_LIBRARY) 13 | -------------------------------------------------------------------------------- /liblinenoise/MODULE_LICENSE_BSD_LIKE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joneschrisg/android-system-core/69c8512061771630bf166394b5567f59a0c2f32d/liblinenoise/MODULE_LICENSE_BSD_LIKE -------------------------------------------------------------------------------- /liblinenoise/NOTICE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, Salvatore Sanfilippo 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | * Neither the name of Redis nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without 16 | specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /libmincrypt/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2008 The Android Open Source Project 2 | # 3 | LOCAL_PATH := $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_MODULE := libmincrypt 7 | LOCAL_SRC_FILES := rsa.c sha.c 8 | include $(BUILD_STATIC_LIBRARY) 9 | 10 | include $(CLEAR_VARS) 11 | 12 | LOCAL_MODULE := libmincrypt 13 | LOCAL_SRC_FILES := rsa.c sha.c 14 | include $(BUILD_HOST_STATIC_LIBRARY) 15 | 16 | 17 | # TODO: drop the hyphen once these are checked in 18 | include $(LOCAL_PATH)/tools/Android.mk 19 | -------------------------------------------------------------------------------- /libmincrypt/NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2008, The Android Open Source Project 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | * Redistributions of source code must retain the above copyright 6 | notice, this list of conditions and the following disclaimer. 7 | * Redistributions in binary form must reproduce the above copyright 8 | notice, this list of conditions and the following disclaimer in the 9 | documentation and/or other materials provided with the distribution. 10 | * Neither the name of Google Inc. nor the names of its contributors may 11 | be used to endorse or promote products derived from this software 12 | without specific prior written permission. 13 | 14 | THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR 15 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 | EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 18 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 20 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 22 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 23 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /libmincrypt/tools/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH := $(call my-dir) 16 | include $(CLEAR_VARS) 17 | 18 | LOCAL_MODULE := dumpkey 19 | LOCAL_SRC_FILES := DumpPublicKey.java 20 | LOCAL_JAR_MANIFEST := DumpPublicKey.mf 21 | include $(BUILD_HOST_JAVA_LIBRARY) 22 | -------------------------------------------------------------------------------- /libmincrypt/tools/DumpPublicKey.mf: -------------------------------------------------------------------------------- 1 | Main-Class: com.android.dumpkey.DumpPublicKey 2 | -------------------------------------------------------------------------------- /libnetutils/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_SRC_FILES:= \ 5 | dhcpclient.c \ 6 | dhcpmsg.c \ 7 | dhcp_utils.c \ 8 | ifc_utils.c \ 9 | packet.c 10 | 11 | LOCAL_SHARED_LIBRARIES := \ 12 | libcutils 13 | 14 | # need "-lrt" on Linux simulator to pick up clock_gettime 15 | ifeq ($(TARGET_SIMULATOR),true) 16 | ifeq ($(HOST_OS),linux) 17 | LOCAL_LDLIBS += -lrt -lpthread 18 | endif 19 | endif 20 | 21 | LOCAL_MODULE:= libnetutils 22 | 23 | include $(BUILD_SHARED_LIBRARY) 24 | -------------------------------------------------------------------------------- /libnetutils/packet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008, The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _WIFI_PACKET_H_ 18 | #define _WIFI_PACKET_H_ 19 | 20 | int open_raw_socket(const char *ifname, uint8_t *hwaddr, int if_index); 21 | int send_packet(int s, int if_index, struct dhcp_msg *msg, int size, 22 | uint32_t saddr, uint32_t daddr, uint32_t sport, uint32_t dport); 23 | int receive_packet(int s, struct dhcp_msg *msg); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /libpixelflinger/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joneschrisg/android-system-core/69c8512061771630bf166394b5567f59a0c2f32d/libpixelflinger/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /libpixelflinger/buffer.h: -------------------------------------------------------------------------------- 1 | /* libs/pixelflinger/buffer.h 2 | ** 3 | ** Copyright 2006, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | 19 | #ifndef ANDROID_GGL_TEXTURE_H 20 | #define ANDROID_GGL_TEXTURE_H 21 | 22 | #include 23 | 24 | namespace android { 25 | 26 | void ggl_init_texture(context_t* c); 27 | 28 | void ggl_set_surface(context_t* c, surface_t* dst, const GGLSurface* src); 29 | 30 | void ggl_pick_texture(context_t* c); 31 | void ggl_pick_cb(context_t* c); 32 | 33 | uint32_t ggl_expand(uint32_t v, int sbits, int dbits); 34 | uint32_t ggl_pack_color(context_t* c, int32_t format, 35 | GGLcolor r, GGLcolor g, GGLcolor b, GGLcolor a); 36 | 37 | }; // namespace android 38 | 39 | #endif // ANDROID_GGL_TEXTURE_H 40 | -------------------------------------------------------------------------------- /libpixelflinger/clear.h: -------------------------------------------------------------------------------- 1 | /* libs/pixelflinger/clear.h 2 | ** 3 | ** Copyright 2006, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | #ifndef ANDROID_GGL_CLEAR_H 19 | #define ANDROID_GGL_CLEAR_H 20 | 21 | #include 22 | #include 23 | 24 | namespace android { 25 | 26 | void ggl_init_clear(context_t* c); 27 | 28 | }; // namespace android 29 | 30 | #endif // ANDROID_GGL_CLEAR_H 31 | -------------------------------------------------------------------------------- /libpixelflinger/picker.h: -------------------------------------------------------------------------------- 1 | /* libs/pixelflinger/picker.h 2 | ** 3 | ** Copyright 2006, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | 19 | #ifndef ANDROID_PICKER_H 20 | #define ANDROID_PICKER_H 21 | 22 | #include 23 | 24 | namespace android { 25 | 26 | void ggl_init_picker(context_t* c); 27 | void ggl_pick(context_t* c); 28 | 29 | }; // namespace android 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /libpixelflinger/raster.h: -------------------------------------------------------------------------------- 1 | /* libs/pixelflinger/raster.h 2 | ** 3 | ** Copyright 2006, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | 19 | #ifndef ANDROID_GGL_RASTER_H 20 | #define ANDROID_GGL_RASTER_H 21 | 22 | #include 23 | 24 | namespace android { 25 | 26 | void ggl_init_raster(context_t* c); 27 | 28 | void gglCopyPixels(void* c, GGLint x, GGLint y, GGLsizei width, GGLsizei height, GGLenum type); 29 | void gglRasterPos2d(void* c, GGLint x, GGLint y); 30 | 31 | }; // namespace android 32 | 33 | #endif // ANDROID_GGL_RASTER_H 34 | -------------------------------------------------------------------------------- /libpixelflinger/scanline.h: -------------------------------------------------------------------------------- 1 | /* libs/pixelflinger/scanline.h 2 | ** 3 | ** Copyright 2006, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | 19 | #ifndef ANDROID_SCANLINE_H 20 | #define ANDROID_SCANLINE_H 21 | 22 | #include 23 | 24 | namespace android { 25 | 26 | void ggl_init_scanline(context_t* c); 27 | void ggl_uninit_scanline(context_t* c); 28 | void ggl_pick_scanline(context_t* c); 29 | 30 | }; // namespace android 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /libpixelflinger/tests/Android.mk: -------------------------------------------------------------------------------- 1 | include $(all-subdir-makefiles) 2 | -------------------------------------------------------------------------------- /libpixelflinger/tests/codegen/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_SRC_FILES:= \ 5 | codegen.cpp.arm 6 | 7 | LOCAL_SHARED_LIBRARIES := \ 8 | libcutils \ 9 | libpixelflinger 10 | 11 | LOCAL_C_INCLUDES := \ 12 | system/core/libpixelflinger 13 | 14 | LOCAL_MODULE:= test-opengl-codegen 15 | 16 | LOCAL_MODULE_TAGS := tests 17 | 18 | include $(BUILD_EXECUTABLE) 19 | -------------------------------------------------------------------------------- /libpixelflinger/trap.h: -------------------------------------------------------------------------------- 1 | /* libs/pixelflinger/trap.h 2 | ** 3 | ** Copyright 2006, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | 19 | #ifndef ANDROID_TRAP_H 20 | #define ANDROID_TRAP_H 21 | 22 | #include 23 | 24 | namespace android { 25 | 26 | void ggl_init_trap(context_t* c); 27 | void ggl_state_changed(context_t* c, int flags); 28 | 29 | }; // namespace android 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /libsysutils/Android.mk: -------------------------------------------------------------------------------- 1 | BUILD_LIBSYSUTILS := false 2 | ifneq ($(TARGET_SIMULATOR),true) 3 | BUILD_LIBSYSUTILS := true 4 | endif 5 | 6 | ifeq ($(BUILD_LIBSYSUTILS),true) 7 | 8 | LOCAL_PATH:= $(call my-dir) 9 | 10 | include $(CLEAR_VARS) 11 | 12 | LOCAL_SRC_FILES:= \ 13 | src/SocketListener.cpp \ 14 | src/FrameworkListener.cpp \ 15 | src/NetlinkListener.cpp \ 16 | src/NetlinkEvent.cpp \ 17 | src/FrameworkCommand.cpp \ 18 | src/SocketClient.cpp \ 19 | src/ServiceManager.cpp \ 20 | 21 | LOCAL_MODULE:= libsysutils 22 | 23 | LOCAL_C_INCLUDES := $(KERNEL_HEADERS) 24 | 25 | LOCAL_CFLAGS := 26 | 27 | LOCAL_SHARED_LIBRARIES := libcutils 28 | 29 | ifeq ($(TARGET_SIMULATOR),true) 30 | LOCAL_LDLIBS += -lpthread 31 | endif 32 | 33 | include $(BUILD_SHARED_LIBRARY) 34 | 35 | endif 36 | -------------------------------------------------------------------------------- /libsysutils/src/FrameworkClient.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define LOG_TAG "FrameworkClient" 7 | #include 8 | 9 | #include 10 | 11 | FrameworkClient::FrameworkClient(int socket) { 12 | mSocket = socket; 13 | pthread_mutex_init(&mWriteMutex, NULL); 14 | } 15 | 16 | int FrameworkClient::sendMsg(const char *msg) { 17 | if (mSocket < 0) { 18 | errno = EHOSTUNREACH; 19 | return -1; 20 | } 21 | 22 | pthread_mutex_lock(&mWriteMutex); 23 | if (write(mSocket, msg, strlen(msg) +1) < 0) { 24 | SLOGW("Unable to send msg '%s' (%s)", msg, strerror(errno)); 25 | } 26 | pthread_mutex_unlock(&mWriteMutex); 27 | return 0; 28 | } 29 | 30 | int FrameworkClient::sendMsg(const char *msg, const char *data) { 31 | char *buffer = (char *) alloca(strlen(msg) + strlen(data) + 1); 32 | if (!buffer) { 33 | errno = -ENOMEM; 34 | return -1; 35 | } 36 | strcpy(buffer, msg); 37 | strcat(buffer, data); 38 | return sendMsg(buffer); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /libsysutils/src/FrameworkCommand.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | 18 | #define LOG_TAG "FrameworkCommand" 19 | 20 | #include 21 | 22 | #include 23 | 24 | FrameworkCommand::FrameworkCommand(const char *cmd) { 25 | mCommand = cmd; 26 | } 27 | 28 | int FrameworkCommand::runCommand(SocketClient *c, int argc, char **argv) { 29 | SLOGW("Command %s has no run handler!", getCommand()); 30 | errno = ENOSYS; 31 | return -1; 32 | } 33 | -------------------------------------------------------------------------------- /libzipfile/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | # build host static library 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_SRC_FILES:= \ 7 | centraldir.c \ 8 | zipfile.c 9 | 10 | LOCAL_STATIC_LIBRARIES := \ 11 | libunz 12 | 13 | LOCAL_MODULE:= libzipfile 14 | 15 | LOCAL_C_INCLUDES += external/zlib 16 | 17 | include $(BUILD_HOST_STATIC_LIBRARY) 18 | 19 | # build device static library 20 | include $(CLEAR_VARS) 21 | 22 | LOCAL_SRC_FILES:= \ 23 | centraldir.c \ 24 | zipfile.c 25 | 26 | LOCAL_STATIC_LIBRARIES := \ 27 | libunz 28 | 29 | LOCAL_MODULE:= libzipfile 30 | 31 | LOCAL_C_INCLUDES += external/zlib 32 | 33 | include $(BUILD_STATIC_LIBRARY) 34 | 35 | 36 | # build test_zipfile 37 | include $(CLEAR_VARS) 38 | 39 | LOCAL_SRC_FILES:= \ 40 | test_zipfile.c 41 | 42 | LOCAL_STATIC_LIBRARIES := libzipfile libunz 43 | 44 | LOCAL_MODULE := test_zipfile 45 | 46 | LOCAL_C_INCLUDES += external/zlib 47 | 48 | include $(BUILD_HOST_EXECUTABLE) 49 | -------------------------------------------------------------------------------- /libzipfile/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joneschrisg/android-system-core/69c8512061771630bf166394b5567f59a0c2f32d/libzipfile/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /libzipfile/private.h: -------------------------------------------------------------------------------- 1 | #ifndef PRIVATE_H 2 | #define PRIVATE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | typedef struct Zipentry { 11 | unsigned long fileNameLength; 12 | const unsigned char* fileName; 13 | unsigned short compressionMethod; 14 | unsigned int uncompressedSize; 15 | unsigned int compressedSize; 16 | const unsigned char* data; 17 | 18 | struct Zipentry* next; 19 | } Zipentry; 20 | 21 | typedef struct Zipfile 22 | { 23 | const unsigned char *buf; 24 | ssize_t bufsize; 25 | 26 | // Central directory 27 | unsigned short disknum; //mDiskNumber; 28 | unsigned short diskWithCentralDir; //mDiskWithCentralDir; 29 | unsigned short entryCount; //mNumEntries; 30 | unsigned short totalEntryCount; //mTotalNumEntries; 31 | unsigned int centralDirSize; //mCentralDirSize; 32 | unsigned int centralDirOffest; // offset from first disk //mCentralDirOffset; 33 | unsigned short commentLen; //mCommentLen; 34 | const unsigned char* comment; //mComment; 35 | 36 | Zipentry* entries; 37 | } Zipfile; 38 | 39 | int read_central_dir(Zipfile* file); 40 | 41 | unsigned int read_le_int(const unsigned char* buf); 42 | unsigned int read_le_short(const unsigned char* buf); 43 | 44 | #endif // PRIVATE_H 45 | 46 | -------------------------------------------------------------------------------- /logcat/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2006 The Android Open Source Project 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_SRC_FILES:= logcat.cpp event.logtags 7 | 8 | LOCAL_SHARED_LIBRARIES := liblog 9 | 10 | LOCAL_MODULE:= logcat 11 | 12 | include $(BUILD_EXECUTABLE) 13 | -------------------------------------------------------------------------------- /logcat/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joneschrisg/android-system-core/69c8512061771630bf166394b5567f59a0c2f32d/logcat/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /logwrapper/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_SRC_FILES:= logwrapper.c 5 | LOCAL_MODULE := logwrapper 6 | LOCAL_STATIC_LIBRARIES := liblog 7 | include $(BUILD_EXECUTABLE) 8 | -------------------------------------------------------------------------------- /mkbootimg/Android.mk: -------------------------------------------------------------------------------- 1 | 2 | LOCAL_PATH:= $(call my-dir) 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_SRC_FILES := mkbootimg.c 6 | LOCAL_STATIC_LIBRARIES := libmincrypt 7 | 8 | LOCAL_MODULE := mkbootimg 9 | 10 | include $(BUILD_HOST_EXECUTABLE) 11 | 12 | $(call dist-for-goals,droid,$(LOCAL_BUILT_MODULE)) 13 | -------------------------------------------------------------------------------- /netcfg/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(BUILD_TINY_ANDROID),true) 2 | LOCAL_PATH:= $(call my-dir) 3 | 4 | include $(CLEAR_VARS) 5 | LOCAL_SRC_FILES:= netcfg.c 6 | LOCAL_MODULE:= netcfg 7 | 8 | #LOCAL_FORCE_STATIC_EXECUTABLE := true 9 | #LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN) 10 | #LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED) 11 | #LOCAL_STATIC_LIBRARIES := libcutils libc 12 | 13 | LOCAL_SHARED_LIBRARIES := libc libnetutils 14 | 15 | include $(BUILD_EXECUTABLE) 16 | endif 17 | -------------------------------------------------------------------------------- /netcfg/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joneschrisg/android-system-core/69c8512061771630bf166394b5567f59a0c2f32d/netcfg/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /nexus/DhcpClient.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) 2008 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef _DhcpClient_H 19 | #define _DhcpClient_H 20 | 21 | #include 22 | 23 | class IDhcpEventHandlers; 24 | class ServiceManager; 25 | class DhcpListener; 26 | class Controller; 27 | 28 | class DhcpClient { 29 | public: 30 | static const int STATUS_MONITOR_PORT = 6666; 31 | 32 | private: 33 | int mState; 34 | IDhcpEventHandlers *mHandlers; 35 | ServiceManager *mServiceManager; 36 | DhcpListener *mListener; 37 | int mListenerSocket; 38 | pthread_mutex_t mLock; 39 | Controller *mController; 40 | bool mDoArpProbe; 41 | 42 | public: 43 | DhcpClient(IDhcpEventHandlers *handlers); 44 | virtual ~DhcpClient(); 45 | 46 | int getState() { return mState; } 47 | bool getDoArpProbe() { return mDoArpProbe; } 48 | void setDoArpProbe(bool probe); 49 | 50 | int start(Controller *c); 51 | int stop(); 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /nexus/DhcpEvent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _DHCP_EVENT_H 18 | #define _DHCP_EVENT_H 19 | 20 | class DhcpEvent { 21 | public: 22 | static const int UNKNOWN = 0; 23 | static const int STOP = 1; 24 | static const int RENEW = 2; 25 | static const int RELEASE = 3; 26 | static const int TIMEOUT = 4; 27 | 28 | static char *toString(int val, char *buffer, int max); 29 | 30 | static int parseString(const char *buffer); 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /nexus/DhcpListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _DhcpListener_H 18 | #define _DhcpListener_H 19 | 20 | #include 21 | 22 | class IDhcpEventHandlers; 23 | class Controller; 24 | 25 | class DhcpListener : public SocketListener { 26 | IDhcpEventHandlers *mHandlers; 27 | Controller *mController; 28 | 29 | public: 30 | 31 | DhcpListener(Controller *c, int socket, IDhcpEventHandlers *handlers); 32 | virtual ~DhcpListener(); 33 | 34 | private: 35 | bool onDataAvailable(SocketClient *cli); 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /nexus/DhcpState.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _DHCP_STATE_H 18 | #define _DHCP_STATE_H 19 | 20 | class DhcpState { 21 | public: 22 | static const int INIT = 0; 23 | static const int DISCOVERING = 1; 24 | static const int REQUESTING = 2; 25 | static const int BOUND = 3; 26 | static const int RENEWING = 4; 27 | static const int REBINDING = 5; 28 | static const int REBOOT = 6; 29 | static const int RENEW_REQUESTED = 7; 30 | static const int INIT_IPV4LL = 8; 31 | static const int PROBING = 9; 32 | static const int ANNOUNCING = 10; 33 | 34 | static char *toString(int val, char *buffer, int max); 35 | 36 | static int parseString(const char *buffer); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /nexus/IControllerHandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _ICONTROLLER_HANDLER_H 18 | #define _ICONTROLLER_HANDLER_H 19 | 20 | class Controller; 21 | class InterfaceConfig; 22 | 23 | class IControllerHandler { 24 | public: 25 | virtual ~IControllerHandler() {} 26 | virtual void onInterfaceConnected(Controller *c) = 0; 27 | virtual void onInterfaceDisconnected(Controller *c) = 0; 28 | virtual void onControllerSuspending(Controller *c) = 0; 29 | virtual void onControllerResumed(Controller *c) = 0; 30 | }; 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /nexus/IDhcpEventHandlers.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) 2008 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef _IDhcpEventHandlers_H 19 | #define _IDhcpEventHandlers_H 20 | 21 | class IDhcpEventHandlers { 22 | public: 23 | virtual ~IDhcpEventHandlers() {} 24 | virtual void onDhcpStateChanged(Controller *c, int state) = 0; 25 | virtual void onDhcpEvent(Controller *c, int event) = 0; 26 | virtual void onDhcpLeaseUpdated(Controller *c, 27 | struct in_addr *addr, struct in_addr *net, 28 | struct in_addr *brd, 29 | struct in_addr *gw, struct in_addr *dns1, 30 | struct in_addr *dns2) = 0; 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /nexus/IWifiStatusPollerHandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _IWIFISTATUSPOLLER_HANDLER_H 18 | #define _IWIFISTATUSPOLLER_HANDLER_H 19 | 20 | class IWifiStatusPollerHandler { 21 | public: 22 | virtual ~IWifiStatusPollerHandler() {} 23 | virtual void onStatusPollInterval() = 0; 24 | }; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /nexus/LoopController.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "LoopController.h" 20 | #include "PropertyManager.h" 21 | 22 | LoopController::LoopController(PropertyManager *propmngr, 23 | IControllerHandler *handlers) : 24 | Controller("loop", propmngr, handlers) { 25 | } 26 | -------------------------------------------------------------------------------- /nexus/LoopController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _LOOP_CONTROLLER_H 18 | #define _LOOP_CONTROLLER_H 19 | 20 | #include "Controller.h" 21 | 22 | class ControllerHandler; 23 | 24 | class LoopController : public Controller { 25 | public: 26 | LoopController(PropertyManager *propmngr, IControllerHandler *h); 27 | virtual ~LoopController() {} 28 | 29 | int set(const char *name, const char *value); 30 | const char *get(const char *name, char *buffer, size_t maxsize); 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /nexus/NexusCommand.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "NexusCommand.h" 18 | 19 | NexusCommand::NexusCommand(const char *cmd) : 20 | FrameworkCommand(cmd) { 21 | } 22 | -------------------------------------------------------------------------------- /nexus/NexusCommand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _NEXUS_COMMAND_H 18 | #define _NEXUS_COMMAND_H 19 | 20 | #include 21 | 22 | class NexusCommand : public FrameworkCommand { 23 | public: 24 | NexusCommand(const char *cmd); 25 | virtual ~NexusCommand() {} 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /nexus/OpenVpnController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _OPEN_VPN_CONTROLLER_H 18 | #define _OPEN_VPN_CONTROLLER_H 19 | 20 | #include "PropertyManager.h" 21 | #include "VpnController.h" 22 | 23 | class ServiceManager; 24 | class IControllerHandler; 25 | 26 | class OpenVpnController : public VpnController { 27 | private: 28 | ServiceManager *mServiceManager; 29 | 30 | public: 31 | OpenVpnController(PropertyManager *propmngr, IControllerHandler *handlers); 32 | virtual ~OpenVpnController(); 33 | 34 | int start(); 35 | int stop(); 36 | 37 | private: 38 | int enable(); 39 | int disable(); 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /nexus/PropertyManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _PROPERTY_MANAGER_H 18 | #define _PROPERTY_MANAGER_H 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "Property.h" 26 | 27 | class PropertyManager { 28 | PropertyNamespaceCollection *mNamespaces; 29 | pthread_mutex_t mLock; 30 | 31 | public: 32 | PropertyManager(); 33 | virtual ~PropertyManager(); 34 | int attachProperty(const char *ns, Property *p); 35 | int detachProperty(const char *ns, Property *p); 36 | 37 | android::List *createPropertyList(const char *prefix); 38 | 39 | int set(const char *name, const char *value); 40 | const char *get(const char *name, char *buffer, size_t max); 41 | 42 | private: 43 | PropertyNamespace *lookupNamespace_UNLOCKED(const char *ns); 44 | Property *lookupProperty_UNLOCKED(PropertyNamespace *ns, const char *name); 45 | int doSet(Property *p, int idx, const char *value); 46 | int doGet(Property *p, int idx, char *buffer, size_t max); 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /nexus/ScanResult.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _SCAN_RESULT_H 18 | #define _SCAN_RESULT_H 19 | 20 | #include 21 | 22 | #include 23 | 24 | class ScanResult { 25 | char *mBssid; 26 | uint32_t mFreq; 27 | int mLevel; 28 | char *mFlags; 29 | char *mSsid; 30 | 31 | private: 32 | ScanResult(); 33 | 34 | public: 35 | ScanResult(char *rawResult); 36 | virtual ~ScanResult(); 37 | 38 | ScanResult *clone(); 39 | 40 | const char *getBssid() { return mBssid; } 41 | uint32_t getFreq() { return mFreq; } 42 | int getLevel() { return mLevel; } 43 | const char *getFlags() { return mFlags; } 44 | const char *getSsid() { return mSsid; } 45 | }; 46 | 47 | typedef android::List ScanResultCollection; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /nexus/SupplicantAssociatedEvent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #define LOG_TAG "SupplicantAssociatedEvent" 20 | #include 21 | 22 | #include "SupplicantAssociatedEvent.h" 23 | 24 | SupplicantAssociatedEvent::SupplicantAssociatedEvent(int level, char *event, 25 | size_t len) : 26 | SupplicantEvent(SupplicantEvent::EVENT_ASSOCIATED, 27 | level) { 28 | char *p = event; 29 | 30 | // "00:13:46:40:40:aa" 31 | mBssid = (char *) malloc(18); 32 | strncpy(mBssid, p, 17); 33 | mBssid[17] = '\0'; 34 | } 35 | 36 | SupplicantAssociatedEvent::~SupplicantAssociatedEvent() { 37 | if (mBssid) 38 | free(mBssid); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /nexus/SupplicantAssociatedEvent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _SupplicantAssociatedEvent_H 18 | #define _SupplicantAssociatedEvent_H 19 | 20 | #include "SupplicantEvent.h" 21 | 22 | class SupplicantAssociatedEvent : public SupplicantEvent { 23 | char *mBssid; 24 | char *mSsid; 25 | int mFreq; 26 | 27 | public: 28 | SupplicantAssociatedEvent(int level, char *event, size_t len); 29 | virtual ~SupplicantAssociatedEvent(); 30 | 31 | const char *getBssid() { return mBssid; } 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /nexus/SupplicantAssociatingEvent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _SupplicantAssociatingEvent_H 18 | #define _SupplicantAssociatingEvent_H 19 | 20 | #include "SupplicantEvent.h" 21 | 22 | class SupplicantAssociatingEvent : public SupplicantEvent { 23 | char *mBssid; 24 | char *mSsid; 25 | int mFreq; 26 | 27 | public: 28 | SupplicantAssociatingEvent(int level, char *event, size_t len); 29 | SupplicantAssociatingEvent(const char *bssid, const char *ssid, int freq); 30 | virtual ~SupplicantAssociatingEvent(); 31 | 32 | const char *getBssid() { return mBssid; } 33 | const char *getSsid() { return mSsid; } 34 | int getFreq() { return mFreq;} 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /nexus/SupplicantConnectedEvent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _SupplicantConnectedEvent_H 18 | #define _SupplicantConnectedEvent_H 19 | 20 | #include "SupplicantEvent.h" 21 | 22 | class SupplicantConnectedEvent : public SupplicantEvent { 23 | private: 24 | char *mBssid; 25 | bool mReassociated; 26 | 27 | public: 28 | SupplicantConnectedEvent(int level, char *event, size_t len); 29 | SupplicantConnectedEvent(const char *bssid, bool reassicated); 30 | virtual ~SupplicantConnectedEvent(); 31 | 32 | const char *getBssid() { return mBssid; } 33 | bool getReassociated() { return mReassociated; } 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /nexus/SupplicantConnectionTimeoutEvent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "SupplicantConnectionTimeoutEvent" 18 | #include 19 | 20 | #include "SupplicantConnectionTimeoutEvent.h" 21 | 22 | SupplicantConnectionTimeoutEvent::SupplicantConnectionTimeoutEvent(int level, char *event, 23 | size_t len) : 24 | SupplicantEvent(SupplicantEvent::EVENT_CONNECTIONTIMEOUT, 25 | level) { 26 | // 00:13:46:40:40:aa timed out.' 27 | mBssid = (char *) malloc(18); 28 | strncpy(mBssid, event, 17); 29 | mBssid[17] = '\0'; 30 | } 31 | 32 | SupplicantConnectionTimeoutEvent::~SupplicantConnectionTimeoutEvent() { 33 | if (mBssid) 34 | free(mBssid); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /nexus/SupplicantConnectionTimeoutEvent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _SupplicantConnectionTimeoutEvent_H 18 | #define _SupplicantConnectionTimeoutEvent_H 19 | 20 | #include "SupplicantEvent.h" 21 | 22 | class SupplicantConnectionTimeoutEvent : public SupplicantEvent { 23 | private: 24 | char *mBssid; 25 | bool mReassociated; 26 | 27 | public: 28 | SupplicantConnectionTimeoutEvent(int level, char *event, size_t len); 29 | virtual ~SupplicantConnectionTimeoutEvent(); 30 | 31 | const char *getBssid() { return mBssid; } 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /nexus/SupplicantDisconnectedEvent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "SupplicantDisconnectedEvent" 18 | #include 19 | 20 | #include "SupplicantDisconnectedEvent.h" 21 | 22 | SupplicantDisconnectedEvent::SupplicantDisconnectedEvent(int level, char *event, 23 | size_t len) : 24 | SupplicantEvent(SupplicantEvent::EVENT_DISCONNECTED, 25 | level) { 26 | } 27 | 28 | SupplicantDisconnectedEvent::SupplicantDisconnectedEvent() : 29 | SupplicantEvent(SupplicantEvent::EVENT_DISCONNECTED, -1) { 30 | } 31 | 32 | SupplicantDisconnectedEvent::~SupplicantDisconnectedEvent() { 33 | } 34 | -------------------------------------------------------------------------------- /nexus/SupplicantDisconnectedEvent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _SupplicantDisconnectedEvent_H 18 | #define _SupplicantDisconnectedEvent_H 19 | 20 | #include "SupplicantEvent.h" 21 | 22 | class SupplicantDisconnectedEvent : public SupplicantEvent { 23 | 24 | public: 25 | SupplicantDisconnectedEvent(int level, char *event, size_t len); 26 | SupplicantDisconnectedEvent(); 27 | virtual ~SupplicantDisconnectedEvent(); 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /nexus/SupplicantEvent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #define LOG_TAG "SupplicantEvent" 20 | #include 21 | 22 | #include "SupplicantEvent.h" 23 | 24 | #include "libwpa_client/wpa_ctrl.h" 25 | 26 | SupplicantEvent::SupplicantEvent(int type, int level) { 27 | mType = type; 28 | mLevel = level; 29 | } 30 | -------------------------------------------------------------------------------- /nexus/SupplicantEventFactory.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) 2008 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef _SupplicantEventFactory_H 19 | #define _SupplicantEventFactory_H 20 | 21 | class SupplicantEvent; 22 | 23 | class SupplicantEventFactory { 24 | public: 25 | SupplicantEventFactory(); 26 | virtual ~SupplicantEventFactory() {} 27 | 28 | SupplicantEvent *createEvent(char *event, size_t len); 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /nexus/SupplicantListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _SUPPLICANTLISTENER_H__ 18 | #define _SUPPLICANTLISTENER_H__ 19 | 20 | #include 21 | 22 | struct wpa_ctrl; 23 | class Supplicant; 24 | class SocketClient; 25 | class ISupplicantEventHandler; 26 | class SupplicantEventFactory; 27 | 28 | class SupplicantListener: public SocketListener { 29 | struct wpa_ctrl *mMonitor; 30 | ISupplicantEventHandler *mHandlers; 31 | SupplicantEventFactory *mFactory; 32 | 33 | public: 34 | SupplicantListener(ISupplicantEventHandler *handlers, 35 | struct wpa_ctrl *monitor); 36 | virtual ~SupplicantListener() {} 37 | 38 | struct wpa_ctrl *getMonitor() { return mMonitor; } 39 | 40 | protected: 41 | virtual bool onDataAvailable(SocketClient *c); 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /nexus/SupplicantScanResultsEvent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "SupplicantScanResultsEvent" 18 | #include 19 | 20 | #include "SupplicantScanResultsEvent.h" 21 | 22 | SupplicantScanResultsEvent::SupplicantScanResultsEvent(int level, char *event, 23 | size_t len) : 24 | SupplicantEvent(SupplicantEvent::EVENT_SCAN_RESULTS, 25 | level) { 26 | } 27 | 28 | SupplicantScanResultsEvent::SupplicantScanResultsEvent() : 29 | SupplicantEvent(SupplicantEvent::EVENT_SCAN_RESULTS, -1) { 30 | } 31 | 32 | SupplicantScanResultsEvent::~SupplicantScanResultsEvent() { 33 | } 34 | 35 | -------------------------------------------------------------------------------- /nexus/SupplicantScanResultsEvent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _SupplicantScanResultsEvent_H 18 | #define _SupplicantScanResultsEvent_H 19 | 20 | #include "SupplicantEvent.h" 21 | 22 | class SupplicantScanResultsEvent : public SupplicantEvent { 23 | 24 | public: 25 | SupplicantScanResultsEvent(int level, char *event, size_t len); 26 | SupplicantScanResultsEvent(); 27 | virtual ~SupplicantScanResultsEvent(); 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /nexus/SupplicantState.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _SUPPLICANT_STATE_H 18 | #define _SUPPLICANT_STATE_H 19 | 20 | class SupplicantState { 21 | public: 22 | static const int UNKNOWN = -1; 23 | static const int DISCONNECTED = 0; 24 | static const int INACTIVE = 1; 25 | static const int SCANNING = 2; 26 | static const int ASSOCIATING = 3; 27 | static const int ASSOCIATED = 4; 28 | static const int FOURWAY_HANDSHAKE = 5; 29 | static const int GROUP_HANDSHAKE = 6; 30 | static const int COMPLETED = 7; 31 | static const int IDLE = 8; 32 | 33 | static char *toString(int val, char *buffer, int max); 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /nexus/SupplicantStateChangeEvent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #define LOG_TAG "SupplicantStateChangeEvent" 20 | #include 21 | 22 | #include "SupplicantStateChangeEvent.h" 23 | 24 | SupplicantStateChangeEvent::SupplicantStateChangeEvent(int level, char *event, 25 | size_t len) : 26 | SupplicantEvent(SupplicantEvent::EVENT_STATE_CHANGE, 27 | level) { 28 | // XXX: move this stuff into a static creation method 29 | char *p = index(event, ' '); 30 | if (!p) { 31 | LOGW("Bad event '%s'\n", event); 32 | return; 33 | } 34 | 35 | mState = atoi(p + strlen("state=") + 1); 36 | } 37 | 38 | SupplicantStateChangeEvent::SupplicantStateChangeEvent(int state) : 39 | SupplicantEvent(SupplicantEvent::EVENT_STATE_CHANGE, -1) { 40 | mState = state; 41 | } 42 | 43 | SupplicantStateChangeEvent::~SupplicantStateChangeEvent() { 44 | } 45 | 46 | -------------------------------------------------------------------------------- /nexus/SupplicantStateChangeEvent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _SupplicantStateChangeEvent_H 18 | #define _SupplicantStateChangeEvent_H 19 | 20 | #include "SupplicantEvent.h" 21 | 22 | class SupplicantStateChangeEvent : public SupplicantEvent { 23 | private: 24 | int mState; 25 | 26 | public: 27 | SupplicantStateChangeEvent(int level, char *event, size_t len); 28 | SupplicantStateChangeEvent(int state); 29 | virtual ~SupplicantStateChangeEvent(); 30 | 31 | int getState() { return mState; } 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /nexus/SupplicantStatus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _SupplicantStatus_H 18 | #define _SupplicantStatus_H 19 | 20 | class SupplicantStatus { 21 | private: 22 | int mWpaState; 23 | int mId; 24 | char *mBssid; 25 | char *mSsid; 26 | 27 | private: 28 | SupplicantStatus(); 29 | SupplicantStatus(int state, int id, char *bssid, char *ssid); 30 | 31 | public: 32 | virtual ~SupplicantStatus(); 33 | static SupplicantStatus *createStatus(char *data, int len); 34 | 35 | int getWpaState() { return mWpaState; } 36 | int getId() { return mId; } 37 | const char *getBssid() { return mBssid; } 38 | const char *getSsid() { return mSsid; } 39 | 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /nexus/TiwlanEventListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _TIWLAN_EVENT_LISTENER_H__ 18 | #define _TIWLAN_EVENT_LISTENER_H__ 19 | 20 | #include 21 | 22 | struct wpa_ctrl; 23 | class SocketClient; 24 | class ITiwlanEventHandler; 25 | class TiwlanEventFactory; 26 | 27 | class TiwlanEventListener: public SocketListener { 28 | 29 | public: 30 | TiwlanEventListener(int sock); 31 | virtual ~TiwlanEventListener() {} 32 | 33 | protected: 34 | virtual bool onDataAvailable(SocketClient *c); 35 | }; 36 | 37 | // TODO: Move all this crap into a factory 38 | #define TI_DRIVER_MSG_PORT 9001 39 | 40 | #define IPC_EVENT_LINK_SPEED 2 41 | #define IPC_EVENT_LOW_SNR 13 42 | #define IPC_EVENT_LOW_RSSI 14 43 | 44 | struct ipc_ev_data { 45 | uint32_t event_type; 46 | void *event_id; 47 | uint32_t process_id; 48 | uint32_t delivery_type; 49 | uint32_t user_param; 50 | void *event_callback; 51 | uint32_t bufferSize; 52 | uint8_t buffer[2048]; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /nexus/TiwlanWifiController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _TIWLAN_WIFI_CONTROLLER_H 18 | #define _TIWLAN_WIFI_CONTROLLER_H 19 | 20 | #include "PropertyManager.h" 21 | #include "WifiController.h" 22 | 23 | class IControllerHandler; 24 | class TiwlanEventListener; 25 | 26 | class TiwlanWifiController : public WifiController { 27 | int mListenerSock; 28 | TiwlanEventListener *mEventListener; 29 | 30 | public: 31 | TiwlanWifiController(PropertyManager *propmngr, IControllerHandler *handlers, char *modpath, char *modname, char *modargs); 32 | virtual ~TiwlanWifiController() {} 33 | 34 | virtual int powerUp(); 35 | virtual int powerDown(); 36 | virtual bool isPoweredUp(); 37 | virtual int loadFirmware(); 38 | virtual bool isFirmwareLoaded(); 39 | 40 | private: 41 | int startDriverEventListener(); 42 | }; 43 | #endif 44 | -------------------------------------------------------------------------------- /nexus/WifiScanner.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _WIFISCANNER_H 18 | #define _WIFISCANNER_H 19 | 20 | #include 21 | 22 | class Supplicant; 23 | 24 | class WifiScanner { 25 | pthread_t mThread; 26 | int mCtrlPipe[2]; 27 | Supplicant *mSuppl; 28 | int mPeriod; 29 | bool mActive; 30 | 31 | 32 | public: 33 | WifiScanner(Supplicant *suppl, int period); 34 | virtual ~WifiScanner() {} 35 | 36 | int getPeriod() { return mPeriod; } 37 | 38 | int start(bool active); 39 | int stop(); 40 | 41 | private: 42 | static void *threadStart(void *obj); 43 | 44 | void run(); 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /nexus/WifiStatusPoller.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _WIFI_STATUS_POLLER_H 18 | #define _WIFI_STATUS_POLLER_H 19 | 20 | #include 21 | 22 | class IWifiStatusPollerHandler; 23 | 24 | class WifiStatusPoller { 25 | pthread_t mThread; 26 | int mCtrlPipe[2]; 27 | int mPollingInterval; 28 | IWifiStatusPollerHandler *mHandlers; 29 | bool mStarted; 30 | 31 | public: 32 | WifiStatusPoller(IWifiStatusPollerHandler *handler); 33 | virtual ~WifiStatusPoller() {} 34 | 35 | int start(); 36 | int stop(); 37 | bool isStarted() { return mStarted; } 38 | 39 | void setPollingInterval(int interval); 40 | int getPollingInterval() { return mPollingInterval; } 41 | 42 | private: 43 | static void *threadStart(void *obj); 44 | void run(); 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /patch.txt: -------------------------------------------------------------------------------- 1 | diff --git a/init/util.c b/init/util.c 2 | index 4d98cc2..0667593 100755 3 | --- a/init/util.c 4 | +++ b/init/util.c 5 | @@ -657,8 +657,9 @@ static void get_hardware_name(void) 6 | if (x) { 7 | x += 2; 8 | n = 0; 9 | - while (*x && !isspace(*x)) { 10 | - hardware[n++] = tolower(*x); 11 | + while (*x && *x != '\n') { 12 | + if (!isspace(*x)) 13 | + hardware[n++] = tolower(*x); 14 | x++; 15 | if (n == 31) break; 16 | } 17 | -------------------------------------------------------------------------------- /rootdir/etc/dbus.conf: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | system 7 | 8 | 9 | EXTERNAL 10 | 11 | 15 | unix:path=/dev/socket/dbus 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /rootdir/etc/hosts: -------------------------------------------------------------------------------- 1 | 127.0.0.1 localhost 2 | -------------------------------------------------------------------------------- /rootdir/etc/init.goldfish.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | ifconfig eth0 10.0.2.15 netmask 255.255.255.0 up 4 | route add default gw 10.0.2.2 dev eth0 5 | 6 | qemud=`getprop ro.kernel.android.qemud` 7 | case "$qemud" in 8 | "") 9 | radio_ril=`getprop ro.kernel.android.ril` 10 | case "$radio_ril" in 11 | "") 12 | # no need for the radio interface daemon 13 | # telephony is entirely emulated in Java 14 | setprop ro.radio.noril yes 15 | stop ril-daemon 16 | ;; 17 | esac 18 | ;; 19 | esac 20 | 21 | num_dns=`getprop ro.kernel.android.ndns` 22 | case "$num_dns" in 23 | 2) setprop net.eth0.dns2 10.0.2.4 24 | ;; 25 | 3) setprop net.eth0.dns2 10.0.2.4 26 | setprop net.eth0.dns3 10.0.2.5 27 | ;; 28 | 4) setprop net.eth0.dns2 10.0.2.4 29 | setprop net.eth0.dns3 10.0.2.5 30 | setprop net.eth0.dns4 10.0.2.6 31 | ;; 32 | esac 33 | 34 | # disable boot animation for a faster boot sequence when needed 35 | boot_anim=`getprop ro.kernel.android.bootanim` 36 | case "$boot_anim" in 37 | 0) setprop debug.sf.nobootanimation 1 38 | ;; 39 | esac 40 | 41 | # call 'qemu-props' to set system properties from the emulator. 42 | # 43 | /system/bin/qemu-props 44 | 45 | # this line doesn't really do anything useful. however without it the 46 | # previous setprop doesn't seem to apply for some really odd reason 47 | setprop ro.qemu.init.completed 1 48 | 49 | # set up the second interface (for inter-emulator connections) 50 | # if required 51 | my_ip=`getprop net.shared_net_ip` 52 | case "$my_ip" in 53 | "") 54 | ;; 55 | *) ifconfig eth1 "$my_ip" netmask 255.255.255.0 up 56 | ;; 57 | esac 58 | -------------------------------------------------------------------------------- /rootdir/etc/mountd.conf: -------------------------------------------------------------------------------- 1 | ## mountd configuration file 2 | 3 | ## add a mount entry for each mount point to be managed by mountd 4 | mount { 5 | ## root block device with partition map or raw FAT file system 6 | block_device /dev/block/mmcblk0 7 | 8 | ## mount point for block device 9 | mount_point /sdcard 10 | 11 | ## true if this mount point can be shared via USB mass storage 12 | enable_ums true 13 | 14 | ## path to the UMS driver file for specifying the block device path 15 | ## use this for the mass_storage function driver 16 | driver_store_path /sys/devices/platform/usb_mass_storage/lun0/file 17 | ## use this for android_usb composite gadget driver 18 | ##driver_store_path /sys/devices/platform/msm_hsusb/gadget/lun0/file 19 | } 20 | -------------------------------------------------------------------------------- /rootdir/etc/ueventd.goldfish.rc: -------------------------------------------------------------------------------- 1 | /dev/qemu_trace 0666 system system 2 | /dev/qemu_pipe 0666 system system 3 | -------------------------------------------------------------------------------- /rootdir/etc/vold.fstab: -------------------------------------------------------------------------------- 1 | ## Vold 2.0 Generic fstab 2 | ## - San Mehat (san@android.com) 3 | ## 4 | 5 | ####################### 6 | ## Regular device mount 7 | ## 8 | ## Format: dev_mount