Skip to content

Commit

Permalink
Add reboot hook for bootmenu.
Browse files Browse the repository at this point in the history
Use it to force a SIM PIN request after reboot.
Update stable recovery to do that as well.
  • Loading branch information
maniac103 authored and Gerrit Code Review committed Jan 25, 2013
1 parent 4b99497 commit 84c2acb
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions BoardConfigCommon.mk
Expand Up @@ -96,6 +96,7 @@ BOARD_USES_BOOTMENU := true
BOARD_WITH_CPCAP := true
BOARD_MMC_DEVICE := /dev/block/mmcblk1
BOARD_BOOTMODE_CONFIG_FILE := /cache/recovery/bootmode.conf
BOARD_BOOTMENU_REBOOT_HOOK := ../../../device/motorola/jordan-common/reboot_hook.c

# Recovery
TARGET_RECOVERY_PIXEL_FORMAT := "BGRA_8888"
Expand Down
Binary file modified bootmenu/recovery/sbin/recovery
Binary file not shown.
8 changes: 7 additions & 1 deletion bootmenu/script/pre_bootmenu.sh
Expand Up @@ -60,12 +60,18 @@ chmod 4755 /sbin/adbd.root
rm -f /default.prop
cp -f $BM_ROOTDIR/config/default.prop /default.prop

## mount cache
## mount cache & data
mkdir -p /cache
mkdir -p /data

# stock mount, with fsck
if [ -x /system/bin/mount_ext3.sh ]; then
/system/bin/mount_ext3.sh cache /cache
/system/bin/mount_ext3.sh data /data
fi

if [ ! -d /data/data ]; then
mount -t $FS_DATA -o noatime,nodiratime,errors=continue $PART_DATA /data
fi

# mount cache for boot mode and recovery logs
Expand Down
3 changes: 3 additions & 0 deletions bootmenu/script/reboot_command.sh
Expand Up @@ -31,4 +31,7 @@ if [ -z "$R" ]; then
rm -f $BM_CONFIG
fi

# force SIM PIN check after reboot
echo lock > /data/simpin

sync
2 changes: 2 additions & 0 deletions profiles/2nd-init/init.mapphone_umts.rc
Expand Up @@ -153,6 +153,8 @@ on property:sys.chargeonly.mode=0
on property:sys.chargeonly.mode=1
start console
write /data/simpin lock
chmod 0660 /data/simpin
chown system system /data/simpin
exec /system/bin/charge_only_mode
exec /system/bin/stop zygote

Expand Down
44 changes: 44 additions & 0 deletions reboot_hook.c
@@ -0,0 +1,44 @@
/*
* 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.
*/

#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <private/android_filesystem_config.h>

void board_reboot_hook(const char *reason, int *need_clear_reason)
{
int fd;

if (reason != NULL && strncmp(reason, "bppanic", 7) == 0) {
*need_clear_reason = 1;
return;
}

/* force SIM PIN check after reboot */
fd = open("/data/simpin", O_WRONLY | O_CREAT, 0660);
if (fd >= 0) {
int ret;
do {
ret = write(fd, "lock", 4);
} while (ret < 0 && errno == EINTR);
fchown(fd, -1, AID_SYSTEM);
fchmod(fd, 0660);
close(fd);
}
}

0 comments on commit 84c2acb

Please sign in to comment.