16 Commits

Author SHA1 Message Date
d3d8ed8255 leo: update initrd and gps
* removed prebuilt initrd.gz
* added related stuff so that the ramdisk is compiled by CM
* updated libgps to 2.1 NMEA (credits to tytung)

Change-Id: I777a872c112f7c9852478a296ef592688526a04f
2011-09-28 01:53:48 +01:00
Steve Kondik
68347ad03d Merge "leo: update some mk files to include TARGET_BOOTLOADER_BOARD_NAME" into gingerbread 2011-08-30 10:44:42 +04:00
95b720a985 leo: Fix BOARD_NAME test in Android.mk to be htcleo
Change-Id: If7e9eaca1db08c02460bf794a5f3aa5be9388bf8
2011-08-16 11:03:13 +01:00
905c306371 leo: update some mk files to include TARGET_BOOTLOADER_BOARD_NAME
Change-Id: I27e9d8af0c0b7b4a2b86e91d36ed5b9490db645c
2011-08-15 10:38:20 +01:00
Ricardo Cerqueira
b8e67364ce leo: Add build barrier for other devices
This was breaking the normal builds on other devices...

Change-Id: Ic8ffa68ac432640433c6083b3a9774c59204df8c
2011-08-15 03:02:53 +01:00
115162ec01 leo: gps, and some overlay config updates
* Updated libgps to v2.0 NMEA (tytung)
* Fixed leo.mk, so that custom gps.conf is included
* removed duplicate entry in frameworks config.xml
* enabled allow_in_call_touch_ui in the phone app

Change-Id: I07bb3512954a6457d46a2d63a35498bfd08ed57b
2011-08-13 00:00:52 +01:00
2629ed2783 leo: update to latest
* Added tytung libgps 1.9 NMEA
* Added cedesmith libhtc_ril_wrapper 0.8b4
* Added tablet tweaks
* Added various changes to config.xml for framework core
* removed recovery.fstab.magldr, as it is not required
* Fixed permissiond of /dev/smd27 for gps

Change-Id: I6afc963134a19b759f1a43d81b5e8b7d01c5553c
2011-08-05 09:45:42 +01:00
982245879f leo: fixed postrecovery & and led notifications
Change-Id: I9f9327ac7abb0a4a3e659ba08cff844ed09f36d0
2011-05-25 01:04:17 +01:00
Steve Kondik
8044589cc2 Merge "leo: add postrecoveryboot to change recovery.fstab" into gingerbread 2011-05-20 09:39:47 +04:00
Steve Kondik
c374a5d94c Merge "leo: initrd fix" into gingerbread 2011-05-20 09:39:22 +04:00
11a691afac leo: initrd fix
removed the insmod of msm_rmnet in the init.htcleo.rc, this can
cause issues in cLK. amended init.htcleo.rc to do dhcpd_eth0 rather
than dhcpd as the wireless wasn't working 2.3.4

Change-Id: Iba5dd9776b244be8dbc464f43f28da4ea9c47395
2011-05-13 13:42:26 +01:00
a711c66fde leo: add postrecoveryboot to change recovery.fstab
Added the postrecoveryboot.sh script to change the recovery.fstab
so that it is comapitable for both cLK and magldr

Change-Id: I04eb1e5230e7fbc2f2e0b117d9086ec700b17c19
2011-05-09 21:44:33 +01:00
05b4e6e8d2 new recovery kernel, revert size of recovery to 5M, and recovery.fstab for magldr as an option
Change-Id: I277374bcffd9139d27aacde78c2238143bea39bc
2011-04-29 14:58:47 +01:00
Koushik Dutta
9c2791c193 Merge "ppp tethering fix" into gingerbread 2011-04-29 03:55:14 +04:00
f0199bc841 leo: board kernel base
changed back to 0x11800000, as the new value doesn't work, and
breaks creation of recovery image. This would of also broken in
creation of cLK boot.img

Change-Id: I8c81dddefcabe7cd91c064e02ebd0792d1fe2f0a
2011-04-25 15:53:16 +01:00
cedesmith
3c3077c603 ppp tethering fix
Change-Id: I438d1059aca8d367ae92249f63b418bf142314bf
2011-04-20 18:38:56 +03:00
25 changed files with 4539 additions and 22 deletions

View File

@@ -12,10 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
ifeq ($(TARGET_BOOTLOADER_BOARD_NAME),htcleo)
LOCAL_PATH := $(my-dir)
subdir_makefiles := \
$(LOCAL_PATH)/libreference-ril/Android.mk \
$(LOCAL_PATH)/libsensors/Android.mk \
$(LOCAL_PATH)/liblights/Android.mk
$(LOCAL_PATH)/liblights/Android.mk \
$(LOCAL_PATH)/libgps/Android.mk \
$(LOCAL_PATH)/libhtc_ril_wrapper/Android.mk
include $(subdir_makefiles)
endif

View File

@@ -25,5 +25,12 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
ALL_PREBUILT += $(INSTALLED_KERNEL_TARGET)
file := $(TARGET_RECOVERY_ROOT_OUT)/sbin/postrecoveryboot.sh
ALL_PREBUILT += $(file)
$(file) : $(LOCAL_PATH)/postrecoveryboot.sh | $(ACP)
$(transform-prebuilt-to-target)
# include the non-open-source counterpart to this file
-include vendor/htc/leo/AndroidBoardVendor.mk

View File

@@ -52,7 +52,7 @@ WIFI_DRIVER_MODULE_NAME := "bcm4329"
BOARD_KERNEL_CMDLINE := no_console_suspend=1 wire.search_count=5
BOARD_USES_GENERIC_AUDIO := false
BOARD_KERNEL_BASE := 0x20000000
BOARD_KERNEL_BASE := 0x11800000
BOARD_KERNEL_NEW_PPPOX := true
BOARD_HAVE_BLUETOOTH := true
@@ -83,14 +83,14 @@ TARGET_USES_LEOUPDATE := true
# # cat /proc/mtd
# dev: size erasesize name
#mtd0: 00100000 00020000 "misc"
#mtd1: 003e0000 00020000 "recovery"
#mtd1: 00500000 00020000 "recovery"
#mtd2: 00500000 00020000 "boot"
#mtd3: 09600000 00020000 "system"
#mtd4: 02c00000 00020000 "cache"
#mtd5: 0d900000 00020000 "userdata"
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x00500000
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x003e0000
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x00500000
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 0x09600000 # limited so we enforce room to grow
BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x0d900000
BOARD_FLASH_BLOCK_SIZE := 131072
@@ -107,3 +107,5 @@ BOARD_VENDOR_QCOM_GPS_LOC_API_AMSS_VERSION := 3200
TARGET_PREBUILT_RECOVERY_KERNEL := device/htc/leo/recovery_kernel
BOARD_USES_RECOVERY_CHARGEMODE := true
TARGET_PROVIDES_INIT_RC := true

View File

@@ -15,3 +15,37 @@ SUPL_HOST=FQDN
SUPL_PORT=7275
SUPL_TLS_HOST=FQDN
SUPL_TLS_CERT=/etc/SuplRootCert
###########################################
# Enable/disable automatic (periodic) #
# download requests of gpsOneXTRA #
# assistance data to client #
# Range: 0 to 1 #
# Default: 0 (Disabled) #
###########################################
GPS1_XTRA_AUTO_DOWNLOAD_ENABLED=0
###########################################
# Time (in hours) between automatic #
# download requests of gpsOneXTRA #
# assistance data to client #
# Range: 1 to 168 (168 = hr in a week) #
# Default: 24 hr #
###########################################
GPS1_XTRA_DOWNLOAD_INTERVAL=24
###########################################
# Enable/disable to shutdown the gpsOne #
# engine properly on GPS off #
# Range: 0 to 1 #
# Default: 1 (Enabled) #
###########################################
GPS1_CLEANUP_ENABLED=1
###########################################
# Time (in seconds) between invoking #
# pdsm_get_position() #
# Range: 2 to 120 #
# Default: 2 seconds #
###########################################
GPS1_SESSION_TIMEOUT=2

51
gps_eu.conf Normal file
View File

@@ -0,0 +1,51 @@
NTP_SERVER=europe.pool.ntp.org
XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin
NTP_SERVER=0.europe.pool.ntp.org
NTP_SERVER=1.europe.pool.ntp.org
NTP_SERVER=2.europe.pool.ntp.org
NTP_SERVER=3.europe.pool.ntp.org
XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin
SUPL_HOST=supl.google.com
SUPL_PORT=7276
SUPL_HOST=FQDN
SUPL_PORT=7275
SUPL_TLS_HOST=FQDN
SUPL_TLS_CERT=/etc/SuplRootCert
###########################################
# Enable/disable automatic (periodic) #
# download requests of gpsOneXTRA #
# assistance data to client #
# Range: 0 to 1 #
# Default: 0 (Disabled) #
###########################################
GPS1_XTRA_AUTO_DOWNLOAD_ENABLED=0
###########################################
# Time (in hours) between automatic #
# download requests of gpsOneXTRA #
# assistance data to client #
# Range: 1 to 168 (168 = hr in a week) #
# Default: 24 hr #
###########################################
GPS1_XTRA_DOWNLOAD_INTERVAL=24
###########################################
# Enable/disable to shutdown the gpsOne #
# engine properly on GPS off #
# Range: 0 to 1 #
# Default: 1 (Enabled) #
###########################################
GPS1_CLEANUP_ENABLED=1
###########################################
# Time (in seconds) between invoking #
# pdsm_get_position() #
# Range: 2 to 120 #
# Default: 2 seconds #
###########################################
GPS1_SESSION_TIMEOUT=2

142
init.htcleo.rc Normal file
View File

@@ -0,0 +1,142 @@
on boot
mount debugfs /sys/kernel/debug /sys/kernel/debug
mkdir /data/misc/wifi 0770 wifi wifi
mkdir /data/misc/wifi/sockets 0770 wifi wifi
mkdir /data/misc/dhcp 0770 dhcp dhcp
chown dhcp dhcp /data/misc/dhcp
# bluetooth power up/down interface
chown bluetooth bluetooth /sys/class/rfkill/rfkill0/type
chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state
chmod 0660 /sys/class/rfkill/rfkill0/state
chown radio radio /sys/module/pm/parameters/idle_sleep_mode
# Set error receiver
setprop ro.error.receiver.htc.apps com.android.updater
# ruu
write /data/misc/screen_lock_status 0
chown system system /data/misc/screen_lock_status
chmod 644 /data/misc/screen_lock_status
# for wireless modem
chown system system /sys/module/serial/parameters/modem_enabled
chown system system /dev/ttyHSUSB0
chown system system /dev/smd9
chown media media /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# Power Management
write /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate 40000
# Overwrite framework low memory killer minfree setting
write /sys/module/lowmemorykiller/parameters/minfree 3584,4096,6144,7168,7680,8192
# Enable low memory killer to check file pages
write /sys/module/lowmemorykiller/parameters/minfile 0,0,0,5120,5632,6144
write /sys/module/lowmemorykiller/parameters/check_filepages
service hciattach /system/bin/brcm_patchram_plus --enable_hci\
--baudrate 3000000 --patchram /etc/firmware/bcm4329.hcd /dev/ttyHS0
user bluetooth
group bluetooth net_bt_admin
disabled
#service btld /system/bin/logwrapper /system/bin/btld -lpm 1 -hb 3000000
# user root
# group bluetooth net_bt_admin
# disabled
# oneshot
# compass/accelerometer daemon
service akmd /system/bin/akmd
user compass
group compass misc input
service wpa_supplicant /system/bin/wpa_supplicant \
-Dwext -ieth0 -c/data/misc/wifi/wpa_supplicant.conf
#user wifi
#group wifi inet
socket wpa_eth0 dgram 660 wifi wifi
disabled
oneshot
service dhcpcd_eth0 /system/bin/dhcpcd -ABKL
disabled
oneshot
service iprenew_eth0 /system/bin/dhcpcd -n
disabled
oneshot
# for USB internet sharing
service udhcpd /system/bin/udhcpd
disabled
oneshot
#service netsharing_on /system/bin/netsharing net on
# disabled
# oneshot
#service netsharing_off /system/bin/netsharing net off
# disabled
# oneshot
#service netsharing_pass /system/bin/netsharing net_pass on
# disabled
# oneshot
#service modem /system/xbin/wireless_modem
# user system
# group system
# disabled
#service zchgd /system/bin/zchgd
# user root
# group root graphics
# oneshot
service dumpstate /system/bin/dumpstate -s
socket dumpstate stream 0660 shell log
disabled
oneshot
#on property:dev.bootcomplete=1
# start bootcomplete
#service bootcomplete /system/bin/bootcomplete
# user root
# group root
# disabled
# oneshot
#service shutdown /system/bin/shutdown
# user root
# group root
# disabled
# oneshot
#service ipd /system/bin/ipd
# socket ipd stream 666 root inet
# Execute files in /etc/init.d before booting
service sysinit /system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d
disabled
oneshot
#on property:service.modem.enable=1
# start modem
#on property:service.modem.enable=0
# stop modem
#service srv_ser2net /system/bin/ser2net -n
# disabled
#on property:service.ser2net.enable=1
# start srv_ser2net
#on property:service.ser2net.enable=0
# stop srv_ser2net

451
init.rc Normal file
View File

@@ -0,0 +1,451 @@
on early-init
start ueventd
on init
sysclktz 0
loglevel 3
# setup the global environment
export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
export LD_LIBRARY_PATH /vendor/lib:/system/lib
export ANDROID_BOOTLOGO 1
export ANDROID_CACHE /cache
export ANDROID_ROOT /system
export ANDROID_ASSETS /system/app
export ANDROID_DATA /data
export DOWNLOAD_CACHE /cache/download
export EXTERNAL_STORAGE /mnt/sdcard
export ASEC_MOUNTPOINT /mnt/asec
export LOOP_MOUNTPOINT /mnt/obb
export SD_EXT_DIRECTORY /sd-ext
export BOOTCLASSPATH /system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar
# Backward compatibility
symlink /system/etc /etc
symlink /sys/kernel/debug /d
# Right now vendor lives on the same filesystem as system,
# but someday that may change.
symlink /system/vendor /vendor
# create mountpoints
mkdir /mnt 0775 root system
mkdir /mnt/sdcard 0000 system system
# Create cgroup mount point for cpu accounting
mkdir /acct
mount cgroup none /acct cpuacct
mkdir /acct/uid
# Backwards Compat - XXX: Going away in G*
symlink /mnt/sdcard /sdcard
mkdir /system
mkdir /data 0771 system system
mkdir /cache 0771 system cache
mkdir /config 0500 root root
# Directory for putting things only root should see.
mkdir /mnt/secure 0700 root root
# Directory for staging bindmounts
mkdir /mnt/secure/staging 0700 root root
# Directory-target for where the secure container
# imagefile directory will be bind-mounted
mkdir /mnt/secure/asec 0700 root root
# Secure container public mount points.
mkdir /mnt/asec 0700 root system
mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
# Filesystem image public mount points.
mkdir /mnt/obb 0700 root system
mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000
mkdir /sd-ext 0771 system system
write /proc/sys/kernel/panic_on_oops 1
write /proc/sys/kernel/hung_task_timeout_secs 0
write /proc/cpu/alignment 4
write /proc/sys/kernel/sched_latency_ns 10000000
write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
write /proc/sys/kernel/sched_compat_yield 1
write /proc/sys/kernel/sched_child_runs_first 0
# Create cgroup mount points for process groups
mkdir /dev/cpuctl
mount cgroup none /dev/cpuctl cpu
chown system system /dev/cpuctl
chown system system /dev/cpuctl/tasks
chmod 0777 /dev/cpuctl/tasks
write /dev/cpuctl/cpu.shares 1024
mkdir /dev/cpuctl/fg_boost
chown system system /dev/cpuctl/fg_boost/tasks
chmod 0777 /dev/cpuctl/fg_boost/tasks
write /dev/cpuctl/fg_boost/cpu.shares 1024
mkdir /dev/cpuctl/bg_non_interactive
chown system system /dev/cpuctl/bg_non_interactive/tasks
chmod 0777 /dev/cpuctl/bg_non_interactive/tasks
# 5.0 %
write /dev/cpuctl/bg_non_interactive/cpu.shares 52
on fs
# mount mtd partitions
# Mount /system rw first to give the filesystem a chance to save a checkpoint
mount yaffs2 mtd@system /system
mount yaffs2 mtd@system /system ro remount
mount yaffs2 mtd@userdata /data nosuid nodev
# leo specific for the purpose of RM and unlimited download space
if [ ! -d /data/cachemnt ] ; then
mkdir /data/cachemnt
chown system:system /data/cachemnt
chmod 777 /data/cachemnt
fi
symlink /data/cachemnt /cache
chown system:system /data/cachemnt
on post-fs
# once everything is setup, no need to modify /
mount rootfs rootfs / ro remount
# We chown/chmod /data again so because mount is run as root + defaults
chown system system /data
chmod 0771 /data
# Mount compressed filesystems
mount squashfs loop@/system/lib/modules/modules.sqf /system/lib/modules ro
mount squashfs loop@/system/xbin/xbin.sqf /system/xbin ro
# Create dump dir and collect dumps.
# Do this before we mount cache so eventually we can use cache for
# storing dumps on platforms which do not have a dedicated dump partition.
mkdir /data/dontpanic
chown root log /data/dontpanic
chmod 0750 /data/dontpanic
# Collect apanic data, free resources and re-arm trigger
copy /proc/apanic_console /data/dontpanic/apanic_console
chown root log /data/dontpanic/apanic_console
chmod 0640 /data/dontpanic/apanic_console
copy /proc/apanic_threads /data/dontpanic/apanic_threads
chown root log /data/dontpanic/apanic_threads
chmod 0640 /data/dontpanic/apanic_threads
write /proc/apanic_console 1
# Same reason as /data above
chown system cache /cache
chmod 0771 /cache
# This may have been created by the recovery system with odd permissions
chown system cache /cache/recovery
chmod 0770 /cache/recovery
#change permissions on vmallocinfo so we can grab it from bugreports
chown root log /proc/vmallocinfo
chmod 0440 /proc/vmallocinfo
#change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
chown root system /proc/kmsg
chmod 0440 /proc/kmsg
chown root system /proc/sysrq-trigger
chmod 0220 /proc/sysrq-trigger
# create basic filesystem structure
mkdir /data/misc 01771 system misc
mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
mkdir /data/misc/bluetooth 0770 system system
mkdir /data/misc/keystore 0700 keystore keystore
mkdir /data/misc/vpn 0770 system system
mkdir /data/misc/systemkeys 0700 system system
mkdir /data/misc/vpn/profiles 0770 system system
# give system access to wpa_supplicant.conf for backup and restore
mkdir /data/misc/wifi 0770 wifi wifi
chmod 0770 /data/misc/wifi
chmod 0660 /data/misc/wifi/wpa_supplicant.conf
mkdir /data/local 0771 shell shell
mkdir /data/local/tmp 0771 shell shell
mkdir /data/local/download 0771 system cache
mkdir /data/data 0771 system system
mkdir /data/app-private 0771 system system
mkdir /data/app 0771 system system
mkdir /data/property 0700 root root
mkdir /cache/download 0771 system cache
# create dalvik-cache and double-check the perms
mkdir /data/dalvik-cache 0771 system system
chown system system /data/dalvik-cache
chmod 0771 /data/dalvik-cache
mkdir /cache/dalvik-cache 0771 system system
chown system system /cache/dalvik-cache
chmod 0771 /cache/dalvik-cache
# create the lost+found directories, so as to enforce our permissions
mkdir /data/lost+found 0770
mkdir /cache/lost+found 0770
# double check the perms, in case lost+found already exists, and set owner
chown root root /data/lost+found
chmod 0770 /data/lost+found
chown root root /cache/lost+found
chmod 0770 /cache/lost+found
# allow net_raw to have access to /dev/socket directory
chown root net_raw /dev/socket
chmod 0775 /dev/socket
# allow system to modify cpufreq control files
chown root system /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
chown root system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
chown root system /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
chmod 0664 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
on boot
# basic network init
ifup lo
hostname localhost
domainname localdomain
# set RLIMIT_NICE to allow priorities from 19 to -20
setrlimit 13 40 40
# Define the oom_adj values for the classes of processes that can be
# killed by the kernel. These are used in ActivityManagerService.
setprop ro.FOREGROUND_APP_ADJ 0
setprop ro.VISIBLE_APP_ADJ 1
setprop ro.PERCEPTIBLE_APP_ADJ 2
setprop ro.HEAVY_WEIGHT_APP_ADJ 3
setprop ro.SECONDARY_SERVER_ADJ 4
setprop ro.BACKUP_APP_ADJ 5
setprop ro.HOME_APP_ADJ 6
setprop ro.HIDDEN_APP_MIN_ADJ 7
setprop ro.EMPTY_APP_ADJ 15
# Define the memory thresholds at which the above process classes will
# be killed. These numbers are in pages (4k).
setprop ro.FOREGROUND_APP_MEM 2048
setprop ro.VISIBLE_APP_MEM 3072
setprop ro.PERCEPTIBLE_APP_MEM 4096
setprop ro.HEAVY_WEIGHT_APP_MEM 4096
setprop ro.SECONDARY_SERVER_MEM 6144
setprop ro.BACKUP_APP_MEM 6144
setprop ro.HOME_APP_MEM 6144
setprop ro.HIDDEN_APP_MEM 7168
setprop ro.EMPTY_APP_MEM 8192
# Write value must be consistent with the above properties.
# Note that the driver only supports 6 slots, so we have combined some of
# the classes into the same memory level; the associated processes of higher
# classes will still be killed first.
write /sys/module/lowmemorykiller/parameters/adj 0,1,2,4,7,15
write /proc/sys/vm/overcommit_memory 1
write /proc/sys/vm/min_free_order_shift 4
write /sys/module/lowmemorykiller/parameters/minfree 2048,3072,4096,6144,7168,8192
# Set init its forked children's oom_adj.
write /proc/1/oom_adj -16
# Tweak background writeout
write /proc/sys/vm/dirty_expire_centisecs 200
write /proc/sys/vm/dirty_background_ratio 5
# Permissions for System Server and daemons.
chown radio system /sys/android_power/state
chown radio system /sys/android_power/request_state
chown radio system /sys/android_power/acquire_full_wake_lock
chown radio system /sys/android_power/acquire_partial_wake_lock
chown radio system /sys/android_power/release_wake_lock
chown radio system /sys/power/state
chown radio system /sys/power/wake_lock
chown radio system /sys/power/wake_unlock
chmod 0660 /sys/power/state
chmod 0660 /sys/power/wake_lock
chmod 0660 /sys/power/wake_unlock
chown system system /sys/class/timed_output/vibrator/enable
chown system system /sys/class/leds/keyboard-backlight/brightness
chown system system /sys/class/leds/lcd-backlight/brightness
chown system system /sys/class/leds/button-backlight/brightness
chown system system /sys/class/leds/jogball-backlight/brightness
chown system system /sys/class/leds/red/brightness
chown system system /sys/class/leds/green/brightness
chown system system /sys/class/leds/blue/brightness
chown system system /sys/class/leds/red/device/grpfreq
chown system system /sys/class/leds/red/device/grppwm
chown system system /sys/class/leds/red/device/blink
chown system system /sys/class/leds/red/brightness
chown system system /sys/class/leds/green/brightness
chown system system /sys/class/leds/blue/brightness
chown system system /sys/class/leds/red/device/grpfreq
chown system system /sys/class/leds/red/device/grppwm
chown system system /sys/class/leds/red/device/blink
chown system system /sys/class/timed_output/vibrator/enable
chown system system /sys/module/sco/parameters/disable_esco
chown system system /sys/kernel/ipv4/tcp_wmem_min
chown system system /sys/kernel/ipv4/tcp_wmem_def
chown system system /sys/kernel/ipv4/tcp_wmem_max
chown system system /sys/kernel/ipv4/tcp_rmem_min
chown system system /sys/kernel/ipv4/tcp_rmem_def
chown system system /sys/kernel/ipv4/tcp_rmem_max
chown root radio /proc/cmdline
# Define TCP buffer sizes for various networks
# ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208
setprop net.tcp.buffersize.wifi 4095,87380,110208,4096,16384,110208
setprop net.tcp.buffersize.umts 4094,87380,110208,4096,16384,110208
setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040
setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680
# Include extra init file
import /system/etc/init.local.rc
# Run sysinit
exec /system/bin/sysinit
class_start default
## Daemon processes to be run by init.
##
service ueventd /sbin/ueventd
critical
service console /system/bin/sh
console
disabled
user shell
group log
on property:ro.secure=0
start console
# adbd is controlled by the persist.service.adb.enable system property
service adbd /sbin/adbd
disabled
# adbd on at boot in emulator
on property:ro.kernel.qemu=1
start adbd
on property:persist.service.adb.enable=1
start adbd
on property:persist.service.adb.enable=0
stop adbd
service servicemanager /system/bin/servicemanager
user system
critical
onrestart restart zygote
onrestart restart media
service vold /system/bin/vold
socket vold stream 0660 root mount
ioprio be 2
service netd /system/bin/netd
socket netd stream 0660 root system
socket dnsproxyd stream 0660 root inet
service debuggerd /system/bin/debuggerd
service ril-daemon /system/bin/rild -l /system/lib/libhtc_ril_wrapper.so -- -d /dev/smd0 nand_init rmnet_mode
socket rild stream 660 root radio
socket rild-debug stream 660 radio system
user root
group radio cache inet misc audio sdcard_rw net_admin net_raw
service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
socket zygote stream 666
onrestart write /sys/android_power/request_state wake
onrestart write /sys/power/state on
onrestart restart media
onrestart restart netd
service media /system/bin/mediaserver
user media
group system audio camera graphics inet net_bt net_bt_admin net_raw
ioprio rt 4
service bootanim /system/bin/bootanimation
user graphics
group graphics
disabled
oneshot
service dbus /system/bin/dbus-daemon --system --nofork
socket dbus stream 660 bluetooth bluetooth
user bluetooth
group bluetooth net_bt_admin
service bluetoothd /system/bin/bluetoothd -n
socket bluetooth stream 660 bluetooth bluetooth
socket dbus_bluetooth stream 660 bluetooth bluetooth
# init.rc does not yet support applying capabilities, so run as root and
# let bluetoothd drop uid to bluetooth with the right linux capabilities
group bluetooth net_bt_admin misc
disabled
service hfag /system/bin/sdptool add --channel=10 HFAG
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
service hsag /system/bin/sdptool add --channel=11 HSAG
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
service opush /system/bin/sdptool add --channel=12 OPUSH
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
service pbap /system/bin/sdptool add --channel=19 PBAP
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
service installd /system/bin/installd
socket installd stream 600 system system
service racoon /system/bin/racoon
socket racoon stream 600 system system
# racoon will setuid to vpn after getting necessary resources.
group net_admin
disabled
oneshot
service mtpd /system/bin/mtpd
socket mtpd stream 600 system system
user vpn
group vpn net_admin net_raw
disabled
oneshot
service keystore /system/bin/keystore /data/misc/keystore
user keystore
group keystore
socket keystore stream 666
service dumpstate /system/bin/dumpstate -s
socket dumpstate stream 0660 shell log
disabled
oneshot

BIN
initrd.gz

Binary file not shown.

17
leo.mk
View File

@@ -23,7 +23,8 @@
## (1) First, the most specific values, i.e. the aspects that are specific to GSM
PRODUCT_COPY_FILES += \
device/htc/leo/init.leo.rc:root/init.leo.rc \
device/htc/leo/init.htcleo.rc:root/init.htcleo.rc \
device/htc/leo/init.rc:root/init.rc \
PRODUCT_PROPERTY_OVERRIDES += \
ro.sf.lcd_density=240 \
@@ -34,12 +35,12 @@ PRODUCT_PROPERTY_OVERRIDES += \
ro.ril.enable.a53.HTC-ITA=1 \
ro.ril.enable.a52=0 \
ro.ril.enable.a53=1 \
ro.ril.enable.dtm = 1 \
ro.ril.gprsclass = 12 \
ro.ril.enable.dtm=1 \
ro.ril.gprsclass=12 \
ro.ril.hsdpa.category=8 \
ro.ril.hsupa.category=5 \
ro.ril.hsxpa=2 \
mobiledata.interfaces=rmnet0,rmnet1,rmnet2,ppp \
mobiledata.interfaces=rmnet0,rmnet1,rmnet2,ppp0 \
wifi.interface=eth0 \
wifi.supplicant_scan_interval=15
@@ -101,7 +102,9 @@ PRODUCT_PACKAGES += \
gralloc.qsd8k \
copybit.qsd8k \
leo-reference-ril \
gps.leo
gps.htcleo \
libgps \
libhtc_ril_wrapper
@@ -137,7 +140,6 @@ PRODUCT_COPY_FILES += \
PRODUCT_COPY_FILES += \
device/htc/leo/kernel:boot/zImage \
device/htc/leo/initrd.gz:boot/initrd.gz \
ifeq ($(TARGET_PREBUILT_KERNEL),)
LOCAL_KERNEL := device/htc/leo/kernel
@@ -146,7 +148,8 @@ LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL)
endif
# The gps config appropriate for this device
$(call inherit-product, device/common/gps/gps_as_supl.mk)
PRODUCT_COPY_FILES += \
device/htc/leo/gps.conf:system/etc/gps.conf
PRODUCT_COPY_FILES += \
$(LOCAL_KERNEL):kernel

View File

@@ -20,7 +20,9 @@
#
# The gps config appropriate for this device
$(call inherit-product, device/common/gps/gps_eu_supl.mk)
PRODUCT_COPY_FILES += \
device/htc/leo/gps_eu.conf:system/etc/gps.conf
# The rest of the configuration is inherited from a generic config
$(call inherit-product, device/htc/leo/leo.mk)

25
libgps/Android.mk Normal file
View File

@@ -0,0 +1,25 @@
LOCAL_PATH:= $(call my-dir)
ifneq ($(TARGET_SIMULATOR),true)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libgps
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
LOCAL_SHARED_LIBRARIES := libutils libcutils librpc
LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/librpc
LOCAL_SRC_FILES := \
leo-gps.c \
leo-gps-rpc.c \
time.cpp \
include $(BUILD_SHARED_LIBRARY)
endif # !TARGET_SIMULATOR

358
libgps/gps.h Normal file
View File

@@ -0,0 +1,358 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _HARDWARE_GPS_H
#define _HARDWARE_GPS_H
#include <stdint.h>
#include <stdlib.h>
#if __cplusplus
extern "C" {
#endif
/** Milliseconds since January 1, 1970 */
typedef int64_t GpsUtcTime;
/** Maximum number of SVs for gps_sv_status_callback(). */
#define GPS_MAX_SVS 32
/** Requested mode for GPS operation. */
typedef uint16_t GpsPositionMode;
// IMPORTANT: Note that the following values must match
// constants in GpsLocationProvider.java.
/** Mode for running GPS standalone (no assistance). */
#define GPS_POSITION_MODE_STANDALONE 0
/** AGPS MS-Based mode. */
#define GPS_POSITION_MODE_MS_BASED 1
/** AGPS MS-Assisted mode. */
#define GPS_POSITION_MODE_MS_ASSISTED 2
/** GPS status event values. */
typedef uint16_t GpsStatusValue;
// IMPORTANT: Note that the following values must match
// constants in GpsLocationProvider.java.
/** GPS status unknown. */
#define GPS_STATUS_NONE 0
/** GPS has begun navigating. */
#define GPS_STATUS_SESSION_BEGIN 1
/** GPS has stopped navigating. */
#define GPS_STATUS_SESSION_END 2
/** GPS has powered on but is not navigating. */
#define GPS_STATUS_ENGINE_ON 3
/** GPS is powered off. */
#define GPS_STATUS_ENGINE_OFF 4
/** Flags to indicate which values are valid in a GpsLocation. */
typedef uint16_t GpsLocationFlags;
// IMPORTANT: Note that the following values must match
// constants in GpsLocationProvider.java.
/** GpsLocation has valid latitude and longitude. */
#define GPS_LOCATION_HAS_LAT_LONG 0x0001
/** GpsLocation has valid altitude. */
#define GPS_LOCATION_HAS_ALTITUDE 0x0002
/** GpsLocation has valid speed. */
#define GPS_LOCATION_HAS_SPEED 0x0004
/** GpsLocation has valid bearing. */
#define GPS_LOCATION_HAS_BEARING 0x0008
/** GpsLocation has valid accuracy. */
#define GPS_LOCATION_HAS_ACCURACY 0x0010
/** Flags used to specify which aiding data to delete
when calling delete_aiding_data(). */
typedef uint16_t GpsAidingData;
// IMPORTANT: Note that the following values must match
// constants in GpsLocationProvider.java.
#define GPS_DELETE_EPHEMERIS 0x0001
#define GPS_DELETE_ALMANAC 0x0002
#define GPS_DELETE_POSITION 0x0004
#define GPS_DELETE_TIME 0x0008
#define GPS_DELETE_IONO 0x0010
#define GPS_DELETE_UTC 0x0020
#define GPS_DELETE_HEALTH 0x0040
#define GPS_DELETE_SVDIR 0x0080
#define GPS_DELETE_SVSTEER 0x0100
#define GPS_DELETE_SADATA 0x0200
#define GPS_DELETE_RTI 0x0400
#define GPS_DELETE_CELLDB_INFO 0x8000
#define GPS_DELETE_ALL 0xFFFF
/** AGPS type */
typedef uint16_t AGpsType;
#define AGPS_TYPE_SUPL 1
#define AGPS_TYPE_C2K 2
/** AGPS status event values. */
typedef uint16_t AGpsStatusValue;
/** GPS requests data connection for AGPS. */
#define GPS_REQUEST_AGPS_DATA_CONN 1
/** GPS releases the AGPS data connection. */
#define GPS_RELEASE_AGPS_DATA_CONN 2
/** AGPS data connection initiated */
#define GPS_AGPS_DATA_CONNECTED 3
/** AGPS data connection completed */
#define GPS_AGPS_DATA_CONN_DONE 4
/** AGPS data connection failed */
#define GPS_AGPS_DATA_CONN_FAILED 5
/**
* Name for the GPS XTRA interface.
*/
#define GPS_XTRA_INTERFACE "gps-xtra"
/**
* Name for the GPS DEBUG interface.
*/
#define GPS_DEBUG_INTERFACE "gps-debug"
/**
* Name for the AGPS interface.
*/
#define AGPS_INTERFACE "agps"
/**
* Name for the GPS privacy interface.
*/
#define GPS_PRIVACY_INTERFACE "privacy"
/** Represents a location. */
typedef struct {
/** Contains GpsLocationFlags bits. */
uint16_t flags;
/** Represents latitude in degrees. */
double latitude;
/** Represents longitude in degrees. */
double longitude;
/** Represents altitude in meters above the WGS 84 reference
* ellipsoid. */
double altitude;
/** Represents speed in meters per second. */
float speed;
/** Represents heading in degrees. */
float bearing;
/** Represents expected accuracy in meters. */
float accuracy;
/** Timestamp for the location fix. */
GpsUtcTime timestamp;
} GpsLocation;
/** Represents the status. */
typedef struct {
GpsStatusValue status;
} GpsStatus;
/** Represents SV information. */
typedef struct {
/** Pseudo-random number for the SV. */
int prn;
/** Signal to noise ratio. */
float snr;
/** Elevation of SV in degrees. */
float elevation;
/** Azimuth of SV in degrees. */
float azimuth;
} GpsSvInfo;
/** Represents SV status. */
typedef struct {
/** Number of SVs currently visible. */
int num_svs;
/** Contains an array of SV information. */
GpsSvInfo sv_list[GPS_MAX_SVS];
/** Represents a bit mask indicating which SVs
* have ephemeris data.
*/
uint32_t ephemeris_mask;
/** Represents a bit mask indicating which SVs
* have almanac data.
*/
uint32_t almanac_mask;
/**
* Represents a bit mask indicating which SVs
* were used for computing the most recent position fix.
*/
uint32_t used_in_fix_mask;
} GpsSvStatus;
/** Callback with location information. */
typedef void (* gps_location_callback)(GpsLocation* location);
/** Callback with status information. */
typedef void (* gps_status_callback)(GpsStatus* status);
/** Callback with SV status information. */
typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info);
/** Callback for reporting NMEA sentences. */
typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length);
/** GPS callback structure. */
typedef struct {
gps_location_callback location_cb;
gps_status_callback status_cb;
gps_sv_status_callback sv_status_cb;
gps_nmea_callback nmea_cb;
} GpsCallbacks;
/** Represents the standard GPS interface. */
typedef struct {
/**
* Opens the interface and provides the callback routines
* to the implemenation of this interface.
*/
int (*init)( GpsCallbacks* callbacks );
/** Starts navigating. */
int (*start)( void );
/** Stops navigating. */
int (*stop)( void );
/** Closes the interface. */
void (*cleanup)( void );
/** Injects the current time. */
int (*inject_time)(GpsUtcTime time, int64_t timeReference,
int uncertainty);
/** Injects current location from another location provider
* (typically cell ID).
* latitude and longitude are measured in degrees
* expected accuracy is measured in meters
*/
int (*inject_location)(double latitude, double longitude, float accuracy);
/**
* Specifies that the next call to start will not use the
* information defined in the flags. GPS_DELETE_ALL is passed for
* a cold start.
*/
void (*delete_aiding_data)(GpsAidingData flags);
/**
* fix_frequency represents the time between fixes in seconds.
* Set fix_frequency to zero for a single-shot fix.
*/
int (*set_position_mode)(GpsPositionMode mode, int fix_frequency);
/** Get a pointer to extension information. */
const void* (*get_extension)(const char* name);
} GpsInterface;
/** Callback to request the client to download XTRA data.
The client should download XTRA data and inject it by calling
inject_xtra_data(). */
typedef void (* gps_xtra_download_request)();
/** Callback structure for the XTRA interface. */
typedef struct {
gps_xtra_download_request download_request_cb;
} GpsXtraCallbacks;
/** Extended interface for XTRA support. */
typedef struct {
/**
* Opens the XTRA interface and provides the callback routines
* to the implemenation of this interface.
*/
int (*init)( GpsXtraCallbacks* callbacks );
/** Injects XTRA data into the GPS. */
int (*inject_xtra_data)( char* data, int length );
} GpsXtraInterface;
/** Extended interface for DEBUG support. */
typedef struct {
/**
* This function should return any information that the native
* implementation wishes to include in a bugreport.
*/
size_t (*get_internal_state)(char* buffer, size_t bufferSize);
} GpsDebugInterface;
/** Represents the status of AGPS. */
typedef struct {
AGpsType type;
AGpsStatusValue status;
} AGpsStatus;
/** Callback with AGPS status information. */
typedef void (* agps_status_callback)(AGpsStatus* status);
/** Callback structure for the AGPS interface. */
typedef struct {
agps_status_callback status_cb;
} AGpsCallbacks;
/** Extended interface for AGPS support. */
typedef struct {
/**
* Opens the AGPS interface and provides the callback routines
* to the implemenation of this interface.
*/
void (*init)( AGpsCallbacks* callbacks );
/**
* Notifies that a data connection is available and sets
* the name of the APN to be used for SUPL.
*/
int (*data_conn_open)( const char* apn );
/**
* Notifies that the AGPS data connection has been closed.
*/
int (*data_conn_closed)();
/**
* Notifies that a data connection is not available for AGPS.
*/
int (*data_conn_failed)();
/**
* Sets the hostname and port for the AGPS server.
*/
int (*set_server)( AGpsType type, const char* hostname, int port );
} AGpsInterface;
/** Extended interface for GPS privacy support. */
typedef struct {
/**
* Opens the AGPS interface and provides the callback routines
* to the implemenation of this interface.
*/
void (*set_privacy_lock)( int enable_lock );
} GpsPrivacyInterface;
/** Returns the hardware GPS interface. */
const GpsInterface* gps_get_hardware_interface();
/**
* Returns the qemu emulated GPS interface.
*/
const GpsInterface* gps_get_qemu_interface();
/**
* Returns the default GPS interface.
*/
const GpsInterface* gps_get_interface();
#if __cplusplus
} // extern "C"
#endif
#endif // _HARDWARE_GPS_H

1084
libgps/leo-gps-rpc.c Normal file

File diff suppressed because it is too large Load Diff

1357
libgps/leo-gps.c Normal file

File diff suppressed because it is too large Load Diff

8
libgps/time.cpp Normal file
View File

@@ -0,0 +1,8 @@
#include <utils/SystemClock.h>
extern "C" int64_t elapsed_realtime() {
int64_t realtime = android::elapsedRealtime();
return realtime;
}

View File

@@ -0,0 +1,21 @@
LOCAL_PATH:= $(call my-dir)
ifneq ($(TARGET_SIMULATOR),true)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := libhtc_ril_wrapper.c
LOCAL_SHARED_LIBRARIES := liblog libdl libnetutils libcutils
LOCAL_CFLAGS := -std=c99
LOCAL_CFLAGS += -DRIL_SHLIB
#build shared library
LOCAL_MODULE:= libhtc_ril_wrapper
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
LOCAL_MODULE_TAGS := eng
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
endif # !TARGET_SIMULATOR

190
libhtc_ril_wrapper/NOTICE Normal file
View File

@@ -0,0 +1,190 @@
Copyright (c) 2005-2008, The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View File

@@ -0,0 +1,763 @@
/*
* Credits go to LeTama for the data connection code and phh for the wrapper code
* Copyright (C) 2010 Sebastian Heinecke (gauner1986)
*
* 0.8 by cedesmith
*/
#include <telephony/ril.h>
#include <dlfcn.h>
#include <utils/Log.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <pthread.h>
#include <sys/wait.h>
#include <termios.h>
#include <time.h>
#include <poll.h>
#include <cutils/properties.h>
#include <arpa/inet.h>
#undef LOG_TAG
#define LOG_TAG "RIL_WRAP"
#define RIL_onRequestComplete(t, e, response, responselen) s_rilenv->OnRequestComplete(t,e, response, responselen)
#define msleep(x) usleep(x*1000);
static const struct RIL_Env *s_rilenv;
static struct RIL_Env htcril_env;
static void *ril_handler=NULL;
static int rmnet_mode = 1;
static int nand_init = 0;
static volatile int pppd_pid;
static volatile int delayedNetworkReady=0;
static volatile RIL_Token request_registration_state_token = NULL;
char current_apn[80];
char current_user[80];
char current_addr[16];
static volatile int registrationState=0;
static volatile int gprsRegistrationState=0;
static volatile RIL_LastDataCallActivateFailCause lastDataError=PDP_FAIL_ERROR_UNSPECIFIED;
char* logtime()
{
static char sTime[10];
time_t t = time(NULL);
strftime(sTime, sizeof(sTime), "%H:%M:%S", localtime(&t));
return sTime;
}
typedef enum {
DATA_STATE_DISCONNECTED=0,
DATA_STATE_DISCONNECTING,
DATA_STATE_PPP_DIED,
DATA_STATE_CONNECTING,
DATA_STATE_CONNECTED,
DATA_STATE_CONNECTION_KILL,
} Wrap_DataCallState;
static volatile Wrap_DataCallState dataConnectionState=DATA_STATE_DISCONNECTED;
static volatile int fd_smd=-1;
int open_modem()
{
if(fd_smd!=-1) return fd_smd;
fd_smd = open ("/dev/smd0", O_RDWR);
if(fd_smd == -1) {
LOGE("%s: send_modem: Error opening smd0", logtime());
return -1; //AT_ERROR_GENERIC;
}
struct termios ios;
tcgetattr( fd_smd, &ios );
ios.c_lflag = 0; /* disable ECHO, ICANON, etc... */
tcsetattr( fd_smd, TCSANOW, &ios );
//fcntl(fd_smd, F_SETFL, O_NONBLOCK | fcntl(fd_smd, F_GETFL, 0));
return fd_smd;
}
void close_modem(){
if(fd_smd!=-1) {
close(fd_smd);
fd_smd=-1;
}
}
int send_modem(const char * cmd)
{
int err = 0;
size_t cur = 0;
ssize_t written;
size_t len = strlen(cmd);
if(open_modem() == -1) return -1; //AT_ERROR_GENERIC;
LOGD("%s: AT> %s", logtime(), cmd);
/* the main string */
while (cur < len) {
do {
written = write (fd_smd, cmd + cur, len - cur);
} while (written < 0 && errno == EINTR);
if (written < 0) return -1;// AT_ERROR_GENERIC;
cur += written;
}
/* the \r */
do {
written = write (fd_smd, "\r" , 1);
} while ((written < 0 && errno == EINTR) || (written == 0));
if (written < 0) {
LOGE("%s: send_modem: write failure", logtime());
return -1; //AT_ERROR_GENERIC;
}
return written;
}
int read_modem(char* response, size_t responseLen)
{
if(open_modem() == -1) return -1;
char *pread=response;
while( pread<response+responseLen){
if(read(fd_smd, pread, 1)<=0) break;
if((*pread=='\n' || *pread=='\r') && pread==response) continue;
if(*pread=='\r') break;
pread++;
}
*pread=0;
if(pread!=response) LOGD("%s: MODEM> %s", logtime(), response);
else LOGD("%s MODEM>", logtime());
return pread-response;
}
const char* requestToString(int request)
{
switch(request) {
case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS";
case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN";
case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK";
case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2";
case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2";
case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN";
case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2";
case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION";
case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS";
case RIL_REQUEST_DIAL: return "DIAL";
case RIL_REQUEST_GET_IMSI: return "GET_IMSI";
case RIL_REQUEST_HANGUP: return "HANGUP";
case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND";
case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND";
case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
case RIL_REQUEST_CONFERENCE: return "CONFERENCE";
case RIL_REQUEST_UDUB: return "UDUB";
case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE";
case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH";
case RIL_REQUEST_REGISTRATION_STATE: return "REGISTRATION_STATE";
case RIL_REQUEST_GPRS_REGISTRATION_STATE: return "GPRS_REGISTRATION_STATE";
case RIL_REQUEST_OPERATOR: return "OPERATOR";
case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER";
case RIL_REQUEST_DTMF: return "DTMF";
case RIL_REQUEST_SEND_SMS: return "SEND_SMS";
case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE";
case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL";
case RIL_REQUEST_SIM_IO: return "SIM_IO";
case RIL_REQUEST_SEND_USSD: return "SEND_USSD";
case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD";
case RIL_REQUEST_GET_CLIR: return "GET_CLIR";
case RIL_REQUEST_SET_CLIR: return "SET_CLIR";
case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS";
case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD";
case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING";
case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING";
case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE";
case RIL_REQUEST_GET_IMEI: return "GET_IMEI";
case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV";
case RIL_REQUEST_ANSWER: return "ANSWER";
case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL";
case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK";
case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK";
case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD";
case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE";
case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC";
case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL";
case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS ";
case RIL_REQUEST_DTMF_START: return "DTMF_START";
case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP";
case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION";
case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION";
case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE";
case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE";
case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "GET_NEIGHBORING_CELL_IDS";
case RIL_REQUEST_SET_MUTE: return "SET_MUTE";
case RIL_REQUEST_GET_MUTE: return "GET_MUTE";
case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP";
case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE";
case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST";
case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO";
case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW";
case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS";
case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE";
case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE";
case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE";
case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE";
case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND";
case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE";
case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE";
case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER";
case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES";
case RIL_REQUEST_CDMA_SET_SUBSCRIPTION:return"CDMA_SET_SUBSCRIPTION";
case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE";
case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE";
case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE";
case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE";
case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH";
case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF";
case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS";
case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE";
case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"GSM_GET_BROADCAST_SMS_CONFIG";
case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"GSM_SET_BROADCAST_SMS_CONFIG";
case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "CDMA_GET_BROADCAST_SMS_CONFIG";
case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "CDMA_SET_BROADCAST_SMS_CONFIG";
case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "CDMA_SMS_BROADCAST_ACTIVATION";
case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"CDMA_VALIDATE_AND_WRITE_AKEY";
case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION";
case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM";
case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM";
case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY";
case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE";
case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS";
case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS";
case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS";
case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
case RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_NETWORK_STATE_CHANGED";
case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS";
case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM";
case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD";
case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST(obsolete)";
case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED";
case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH";
case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END";
case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND";
case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY";
case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP";
case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL";
case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH";
case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED";
case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING";
case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED";
case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS";
case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS";
case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED";
case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING";
case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS";
case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC";
case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW";
case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE";
case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE";
default: return "<unknown request>";
}
}
struct RequestInfo
{
RIL_Token token;
int request;
time_t startTime;
};
struct RequestInfo pendingRequests[200];
void requestStarted(RIL_Token t, int request)
{
LOGD("%s: Request Received %p %s", logtime(), t, requestToString(request));
for(size_t i=0; i<sizeof(pendingRequests)/sizeof(struct RequestInfo); i++) {
if(pendingRequests[i].token==NULL) {
pendingRequests[i].token=t;
pendingRequests[i].request=request;
pendingRequests[i].startTime=clock();
return;
}
}
LOGD("%s: Request list full", logtime());
}
void requestRemoveAt(int idx)
{
size_t i;
for(i=idx+1; i<sizeof(pendingRequests)/sizeof(struct RequestInfo) && pendingRequests[i].token!=NULL; i++)
pendingRequests[i-1]=pendingRequests[i];
pendingRequests[i-1].token=NULL;
pendingRequests[i-1].request=0;
pendingRequests[i-1].startTime=0;
}
struct RequestInfo requestCompleted(RIL_Token t)
{
struct RequestInfo r = { .token=NULL, .request=0, .startTime=0};
for(size_t i=0; i<sizeof(pendingRequests)/sizeof(struct RequestInfo) && pendingRequests[i].token!=NULL; i++) {
if(pendingRequests[i].token==t) {
r=pendingRequests[i];
LOGD("%s: Request Complete %p %s after %d ms", logtime(), r.token, requestToString(r.request), (unsigned int)(clock()-r.startTime)/(CLOCKS_PER_SEC/1000));
requestRemoveAt(i);
return r;
}
}
LOGD("%s: Request Complete %p not found in started list", logtime(),t);
return r;
}
unsigned requestsPending()
{
unsigned count=0;
for(size_t i=0; i<sizeof(pendingRequests)/sizeof(struct RequestInfo) && pendingRequests[i].token!=NULL; i++) {
if(pendingRequests[i].token!=NULL) {
if((clock()-pendingRequests[i].startTime)/CLOCKS_PER_SEC > 10)
{
LOGD("%s: Request delete %p %s after %d ms", logtime(), pendingRequests[i].token, requestToString(pendingRequests[i].request), (unsigned int)(clock()-pendingRequests[i].startTime)/(CLOCKS_PER_SEC/1000));
requestRemoveAt(i);
i--;
} else {
count++;
}
}
}
return count;
}
void requestsLOGD()
{
for(size_t i=0; i<sizeof(pendingRequests)/sizeof(struct RequestInfo) && pendingRequests[i].token!=NULL; i++)
LOGD(" %p %s for %d ms", pendingRequests[i].token, requestToString(pendingRequests[i].request), (unsigned int)(clock()-pendingRequests[i].startTime)/(CLOCKS_PER_SEC/1000));
}
void requestsWaitComplete(char *msg){
if(requestsPending()>0) {
LOGD("%s: Request pending... waiting to complete", logtime());
requestsLOGD();
while(requestsPending()>0) msleep(1);
LOGD("%s: Request completed... continue %s", logtime(), msg!=NULL ? msg : NULL);
}
}
void* pppd_thread(void *param)
{
LOGD("%s: pppd_thread enter", logtime());
requestsWaitComplete("pppd_thread");
pppd_pid = fork();
if(pppd_pid == 0) {
char buff[256];
kill(getppid(), SIGSTOP); //stop stealing my mojo
int act=0;
send_modem("AT+CGACT?");
do {
read_modem(buff, sizeof(buff));
char* actpos=strstr(buff, "+CGACT: 1,");
if(actpos!=NULL) act=atoi(actpos+10);
}while(buff[0]!='0');
if(act!=0) {
kill(getppid(), SIGCONT);
exit(202);
}
sprintf(buff, "AT+CGDCONT=1,\"IP\",\"%s\",,0,0", current_apn);
send_modem(buff);
read_modem(buff, sizeof(buff));
send_modem("ATD*99***1#");
//send_modem("AT+CGDATA=\"PPP\",1");
while(read_modem(buff, sizeof(buff))>0 && buff[0]=='+');
//read_modem(buff, sizeof(buff));
kill(getppid(), SIGCONT);
int atd=atoi(buff);
if(atd!=1 && atd!=3) exit(201);
sleep(1);
close_modem(); //close modem handle before we transform to pppd
int err = execl("/system/bin/pppd", "pppd", "/dev/smd1", "local","nodetach", "defaultroute", "noipdefault", "usepeerdns", "user", current_user, "debug", NULL);
LOGE("%s: PPPD EXEC FAILED (%d)", logtime(),err);
exit(200);
} else {
LOGD("%s: pppd pid is %d", logtime(),pppd_pid);
int status=0;
time_t start = time(NULL);
waitpid(pppd_pid, &status, 0);
pppd_pid=0;
int runTime = time(NULL)-start;
LOGD("%s: PPPD DIED after %d seconds with status %d", logtime(), runTime, status);
if(lastDataError==PDP_FAIL_ERROR_UNSPECIFIED && WIFEXITED(status)){
switch(WEXITSTATUS(status))
{
case 1: lastDataError=PDP_FAIL_INSUFFICIENT_RESOURCES; break;
case 2: lastDataError=PDP_FAIL_SERVICE_OPTION_NOT_SUPPORTED; break;
case 3:
case 4:
lastDataError=PDP_FAIL_PROTOCOL_ERRORS; break;
case 19: lastDataError=PDP_FAIL_USER_AUTHENTICATION; break;
}
}
requestsWaitComplete("pppd_thread");
send_modem("AT+CGACT=0,1");
if(dataConnectionState==DATA_STATE_CONNECTED || dataConnectionState==DATA_STATE_CONNECTION_KILL) {
dataConnectionState=DATA_STATE_DISCONNECTED;
RIL_Data_Call_Response dataCall={ .cid=1, .active=0, .type="IP", .apn=current_apn, .address=current_addr };
s_rilenv->OnUnsolicitedResponse(RIL_UNSOL_DATA_CALL_LIST_CHANGED, &dataCall, sizeof(RIL_Data_Call_Response));
}
}
LOGD("%s: pppd_thread exit", logtime());
return NULL;
}
void* DeactivateData(void* t)
{
dataConnectionState = DATA_STATE_DISCONNECTING;
LOGD("%s: DeactivateData", logtime());
int pid=pppd_pid; //work with pppd_pid copy as thread will set it to 0 after kill
if(pid!=0) {
int status=0;
LOGD(" waiting for pppd to end %d", pid);
kill(pid, SIGTERM);
waitpid(pid, &status, 0);
LOGD("%s: DeactivateData: pppd ended", logtime());
}
//clear dns entries
property_set("net.ppp0.dns1", "");
property_set("net.ppp0.dns2", "");
dataConnectionState = DATA_STATE_DISCONNECTED;
RIL_onRequestComplete((RIL_Token) t, RIL_E_SUCCESS, NULL, 0);
return NULL;
}
void hackDeactivateData(void *data, size_t datalen, RIL_Token t)
{
LOGD("%s: DeactivateData Request", logtime());
char* cid = ((char **)data)[0];
if(atoi(cid)!=1) {
LOGE(" wrong CID %s expected 1", cid);
return;
}
pthread_t tid;
pthread_create(&tid, NULL, DeactivateData, t);
}
int ifc_get_info(const char *name, unsigned *addr, unsigned *mask, unsigned *flags);
int ifc_init(void);
void ifc_close(void);
void* SetupData(void* t)
{
//this should never happen but let's check
if(pppd_pid!=0 ) {
LOGD(" waiting pppd to die");
int status=0;
kill(pppd_pid, SIGTERM);
waitpid(pppd_pid, &status, 0);
}
//reset ppp.dns
property_set("net.ppp0.dns1", "0.0.0.0");
property_set("net.ppp0.dns2", "0.0.0.0");
strcpy(current_addr, "255.255.255.255");
pthread_t thread;
pthread_create(&thread, NULL, pppd_thread, NULL);
//wait for pppd connect
if(ifc_init()) {
LOGE("%s: IFC failed to init", logtime());
sleep(7);
} else {
clock_t start=clock();
//loop till timeout or connected
while(1) {
//check if ppp0 interface is up, if true break loop, else record dnschange value
unsigned addr, mask, flags;
ifc_get_info("ppp0", &addr, &mask, &flags);
if(flags & 1)
{
struct in_addr in_addr = {.s_addr=addr};
strcpy(current_addr, inet_ntoa(in_addr));
LOGD("%s: IP: %s", logtime(),current_addr);
break;
}
//if timeout goto error
if ( (clock()-start)/CLOCKS_PER_SEC > 60 ){
LOGE("%s: ppp0 connect timed out, giving up", logtime());
ifc_close();
goto error;
}
int status, pid=pppd_pid;
if(pid==0 || waitpid(pid, &status, WNOHANG)>0){
LOGE("%s: ppp0 connect timed out, giving up", logtime());
ifc_close();
goto error;
}
msleep(100);
}
}
ifc_close();
//if ip-up exists wait for dns change
char dns1[PROPERTY_VALUE_MAX];
char dns2[PROPERTY_VALUE_MAX];
struct stat sts;
if(stat("/etc/ppp/ip-up", &sts)==0 && (S_ISREG(sts.st_mode) || S_ISLNK(sts.st_mode))) {
clock_t start=clock();
while(1) {
//check if dnschange changed
property_get("net.ppp0.dns1", dns1, "0.0.0.0");
property_get("net.ppp0.dns2", dns2, "0.0.0.0");
if(strcmp(dns1, "0.0.0.0")!=0 && strcmp(dns2, "0.0.0.0")!=0) break;
if((clock()-start)/CLOCKS_PER_SEC > 2) {
LOGE("%s: timeout waiting for dns change", logtime());
break;
}
msleep(100);
}
}
//check ppp.dns values and set defaults if suspect wrong
property_get("net.ppp0.dns1", dns1, "");
if(strlen(dns1)<7 || strcmp(dns1,"0.0.0.0")==0 || strcmp(dns1, "10.11.12.13")==0) {
LOGD("%s: DNS1: %s wrong setting to 8.8.8.8", logtime(),dns1);
property_set("net.ppp0.dns1", "8.8.8.8");
} else {
LOGD("%s: DNS1: %s", logtime(),dns1);
}
property_get("net.ppp0.dns2", dns2, "");
if(strlen(dns2)<7 || strcmp(dns2, "0.0.0.0")==0 || strcmp(dns2, "10.11.12.14")==0) {
LOGD("%s: DNS2: %s wrong setting to 8.8.4.4", logtime(),dns2);
property_set("net.ppp0.dns2", "8.8.4.4");
} else {
LOGD("%s: DNS2: %s", logtime(),dns2);
}
char *response[3] = { "1", "ppp0", current_addr };
dataConnectionState=DATA_STATE_CONNECTED;
RIL_onRequestComplete(t, RIL_E_SUCCESS, response, sizeof(response));
return NULL;
error:
dataConnectionState=DATA_STATE_DISCONNECTED;
RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
return NULL;
}
void hackSetupData(char **data, size_t datalen, RIL_Token t)
{
LOGD("%s: SetupData(%s) Request", logtime(),((const char **)data)[2]);
lastDataError=PDP_FAIL_ERROR_UNSPECIFIED;
if(*data[0]=='0') {
LOGE(" Android want us to connect as CDMA while we are a GSM phone !");
goto error;
}
if(!registrationState) {
LOGE(" network registration state wrong");
lastDataError=PDP_FAIL_REGISTRATION_FAIL;
goto error;
}
if(!gprsRegistrationState) {
LOGE(" gprs registration state wrong");
lastDataError=PDP_FAIL_GPRS_REGISTRATION_FAIL;
goto error;
}
dataConnectionState = DATA_STATE_CONNECTING;
char *apn = ((char **)data)[2];
char *user = ((char **)data)[3];
char *pass = ((char **)data)[4];
if(apn==NULL) apn="";
if(user==NULL || strlen(user)<2) user = "dummy";
if(pass==NULL || strlen(pass)<2) pass = "dummy";
strcpy(current_apn, apn);
strcpy(current_user, user);
//save auth
truncate("/etc/ppp/pap-secrets", 0);
truncate("/etc/ppp/chap-secrets", 0);
char buff[128];
sprintf(buff, "%s * %s\n", user, pass);
int fd;
if((fd=creat("/etc/ppp/pap-secrets", S_IRUSR|S_IWUSR))==-1) {
LOGE("Failed to create /etc/ppp/pap-secrets");
lastDataError=PDP_FAIL_USER_AUTHENTICATION;
goto error;
}
write(fd, buff, strlen(buff));
close(fd);
if((fd=creat("/etc/ppp/chap-secrets", S_IRUSR|S_IWUSR))==-1) {
LOGE("Failed to create /etc/ppp/chap-secrets");
lastDataError=PDP_FAIL_USER_AUTHENTICATION;
goto error;
}
write(fd, buff, strlen(buff));
close(fd);
pthread_t tid;
pthread_create(&tid, NULL, SetupData, t);
return;
error:
dataConnectionState=DATA_STATE_DISCONNECTED;
RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
}
void interceptOnRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen)
{
if(!rmnet_mode) {
struct RequestInfo requestInfo= requestCompleted(t);
if( requestInfo.request==RIL_REQUEST_REGISTRATION_STATE) {
if(responselen>=14*sizeof(char *)) {
char **strings = (char **)response;
int registration = atoi(strings[0]); //1 - Registered, home network; 5 - Registered, roaming
int radio = atoi(strings[3]); //0 == unknown
registrationState=((registration==1 || registration==5) && radio!=0);
LOGD("%s: Registration state %d %d = %d", logtime(), registration, radio, registrationState);
if(!registrationState && pppd_pid!=0 && dataConnectionState==DATA_STATE_CONNECTED){
LOGE("%s: data disconnect due to network registration state", logtime());
lastDataError=PDP_FAIL_REGISTRATION_FAIL;
dataConnectionState=DATA_STATE_CONNECTION_KILL;
kill(pppd_pid, SIGTERM);
}
}
}
if( requestInfo.request==RIL_REQUEST_GPRS_REGISTRATION_STATE) {
if(responselen>=4*sizeof(char *)) {
char **strings = (char **)response;
int registration = atoi(strings[0]); //1 - Registered, home network; 5 - Registered, roaming
int radio = atoi(strings[3]); //0 == unknown; 4 ("unknown") is treated as "out of service" in the Android telephony system
gprsRegistrationState=((registration==1 || registration==5) && (radio!=0 && radio!=4));
LOGD("%s: Registration state %d %d = %d", logtime(), registration, radio, gprsRegistrationState);
if(!gprsRegistrationState && pppd_pid!=0 && dataConnectionState==DATA_STATE_CONNECTED){
LOGE("%s: data disconnect due to gprs registration state", logtime());
lastDataError=PDP_FAIL_GPRS_REGISTRATION_FAIL;
dataConnectionState=DATA_STATE_CONNECTION_KILL;
kill(pppd_pid, SIGTERM);
}
}
}
}
s_rilenv->OnRequestComplete(t, e, response, responselen);
}
void hackDataCallList(char **data, size_t datalen, RIL_Token t)
{
RIL_Data_Call_Response dataCall={ .cid=1, .active=0, .type="IP", .apn=current_apn, .address=current_addr };
LOGD("%s: DataCallList", logtime());
LOGD(" cid=%d, active=%d, type=%s, apn=%s, add=%s", dataCall.cid, dataCall.active, dataCall.type, dataCall.apn, dataCall.address);
s_rilenv->OnRequestComplete(t, RIL_E_SUCCESS, &dataCall, sizeof(RIL_Data_Call_Response));
}
void interceptOnUnsolicitedResponse(int unsolResponse, const void *data, size_t datalen)
{
LOGD("%s: UNSOL %s", logtime(), requestToString(unsolResponse));
s_rilenv->OnUnsolicitedResponse(unsolResponse, data, datalen);
}
void (*htc_onRequest)(int request, void *data, size_t datalen, RIL_Token t);
void onRequest(int request, void *data, size_t datalen, RIL_Token t) {
if(!rmnet_mode) {
switch(request) {
case RIL_REQUEST_SETUP_DATA_CALL:
return hackSetupData(data, datalen, t);
case RIL_REQUEST_DEACTIVATE_DATA_CALL:
return hackDeactivateData(data, datalen, t);
case RIL_REQUEST_DATA_CALL_LIST:
return hackDataCallList(data, datalen, t);
case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE:
s_rilenv->OnRequestComplete(t, RIL_E_SUCCESS,(RIL_LastDataCallActivateFailCause*) &lastDataError, sizeof(RIL_LastDataCallActivateFailCause));
return;
}
requestStarted(t, request);
}
return htc_onRequest(request, data, datalen, t);
}
void writeAdditionalNandInit(){
LOGD("NAND boot, writing additional init commands to /dev/smd0");
send_modem("AT@BRIC=0");
send_modem("AT+CFUN=0");
send_modem("AT+COPS=2");
}
const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc, char **argv)
{
int i;
int ril_argc = 0;
char **ril_argv;
RIL_RadioFunctions *(*htc_RIL_Init)(const struct RIL_Env *env, int argc, char **argv);
RIL_RadioFunctions *s_callbacks;
s_rilenv = env;
LOGD("----------- HTC Ril Wrapper v0.8b5 starting ------------");
// we never free this, but we can't tell if htc ril uses argv after init
ril_argv = (char **)malloc(argc * sizeof(char*));
struct stat sts;
if(stat("/system/ppp", &sts)==0 && (S_ISREG(sts.st_mode) || S_ISLNK(sts.st_mode))) rmnet_mode = 0;
LOGD("rmnet_mode=%d", rmnet_mode);
// Parse command line and prepare ril command line
for(i = 0; i < argc ; i++) {
LOGW("RIL_Init arg[%d]=%s", i, argv[i]);
if(strcmp(argv[i], "rmnet_mode") == 0) continue;
if(strcmp(argv[i], "nand_init") == 0)
nand_init = 1;
else {
ril_argv[ril_argc++] = argv[i];
}
}
if(nand_init) writeAdditionalNandInit();
ril_handler=dlopen("/system/lib/libhtc_ril.so", 0/*Need to RTFM, 0 seems fine*/);
htc_RIL_Init = dlsym(ril_handler, "RIL_Init");
// re-route to our man in the middle functions
htcril_env.OnRequestComplete = interceptOnRequestComplete;
htcril_env.OnUnsolicitedResponse = interceptOnUnsolicitedResponse;
htcril_env.RequestTimedCallback = s_rilenv->RequestTimedCallback;
s_callbacks = htc_RIL_Init(&htcril_env, ril_argc, ril_argv);
htc_onRequest = s_callbacks->onRequest;
s_callbacks->onRequest=onRequest;
return s_callbacks;
}

View File

@@ -18,7 +18,7 @@ ifneq ($(TARGET_SIMULATOR),true)
include $(CLEAR_VARS)
LOCAL_MODULE := lights.htcleo
LOCAL_MODULE := lights.$(TARGET_BOOTLOADER_BOARD_NAME)
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw

View File

@@ -21,7 +21,7 @@ ifneq ($(TARGET_SIMULATOR),true)
# hw/<SENSORS_HARDWARE_MODULE_ID>.<ro.product.board>.so
include $(CLEAR_VARS)
LOCAL_MODULE := sensors.htcleo
LOCAL_MODULE := sensors.$(TARGET_BOOTLOADER_BOARD_NAME)
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw

View File

@@ -32,8 +32,6 @@
<bool name="config_automatic_brightness_available">true</bool>
<bool name="config_animateScreenLights">false</bool>
<!-- disable menu hard key on HD2 in non-pattern lockscreen -->
<bool name="config_disableMenuKeyInLockScreen">true</bool>
@@ -154,6 +152,7 @@
tethering on a new interface called "foo2" add <item>"foo\\d"</item> to the array -->
<string-array translatable="false" name="config_tether_upstream_regexs">
<item>"rmnet\\d"</item>
<item>"ppp\\d"</item>
<item>"eth\\d"</item>
</string-array>
@@ -161,11 +160,7 @@
Wifi interfaces. If the device doesn't want to support tethering over Wifi this
should be empty. An example would be "softap.*" -->
<string-array translatable="false" name="config_tether_wifi_regexs">
<item>"rmnet\\d"</item>
<item>"wl0.1"</item>
</string-array>
<string-array translatable="false" name="config_tether_usb_regexs">
<item>"usb0"</item>
</string-array>
<!-- Vibrator pattern for a very short but reliable vibration for soft keyboard tap -->
@@ -185,5 +180,12 @@
<!-- Enable use of power animations -->
<bool name="config_animateScreenLights">false</bool>
<!-- Enable Tablet tweaks -->
<bool name="cm_default_has_soft_buttons">true</bool>
<bool name="cm_default_show_soft_home">false</bool>
<bool name="cm_default_show_soft_menu">false</bool>
<bool name="cm_default_show_soft_back">false</bool>
<bool name="cm_default_show_soft_search">false</bool>
<bool name="cm_default_show_soft_quick_na">false</bool>
</resources>

View File

@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Whether or not to display the trackball settings -->
<bool name="has_trackball">false</bool>
<bool name="has_dual_notification_led">true</bool>
<bool name="has_camera_button">false</bool>
<bool name="has_rgb_notification_led">false</bool>
<bool name="has_led_flash">true</bool>
<bool name="has_search_button">false</bool>
</resources>

View File

@@ -19,7 +19,7 @@
<!-- Enable the onscreen touch UI for all states of the in-call UI. -->
<bool name="allow_incoming_call_touch_ui">true</bool>
<bool name="allow_in_call_touch_ui">false</bool>
<bool name="allow_in_call_touch_ui">true</bool>
<!-- This is a device with capacitive buttons, so disable the feature
where BACK rejects the current incoming call. (Since it's so

7
postrecoveryboot.sh Normal file
View File

@@ -0,0 +1,7 @@
#!/sbin/sh
sleep 2
if [[ "`grep clk= /proc/cmdline`" == "" ]]; then
sed -i 's/\/boot\t\tmtd/\/boot\t\tyaffs2/g' /etc/recovery.fstab
fi

Binary file not shown.