Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Android shutdown (reboot) process     - What is a logical partition management LVM, how to use in Ubuntu (Linux)

- open V switch port mirror in OpenStack neutron (Server)

- The formatted Linux hard drive and mount (Linux)

- RHEL6.5 install the latest version of Vim and increase support for the Python2.7.5 (Linux)

- Linux operating system to solve a serious fault handling (Linux)

- The most simple drive to write and test procedures under linux (Programming)

- Iptables in Ubuntu (Linux)

- JavaScript basic types and type conversion (Programming)

- Linux operating system Study Notes (Linux)

- PHP with FastCGI and mod_php Comments (Server)

- Incremental garbage collection mechanism for Ruby 2.2 (Programming)

- Different versions of MongoDB achieve master-slave replication (Database)

- Linux file system data file deletion problem space is not freed (Database)

- Service manager OpenBSD on rccl (Server)

- UUID in Java (Programming)

- The Hill sorting algorithm (Programming)

- Linux, MySQL root privilege escalation another method (Linux)

- Install the free open source financial software GnuCash 2.6.6 under Ubuntu (Linux)

- Android Send HTTP POST requests (Programming)

- C ++ Supplements - Virtual Function Principle (Programming)

 
         
  Android shutdown (reboot) process
     
  Add Date : 2018-11-21      
         
         
         
  Base On Android 4.2

recovery process and reboot

part 1.
reboot recovery process.
1, RecoverySystem.java in
    private static File RECOVERY_DIR = new File ( "/ cache / recovery");
    private static File COMMAND_FILE = new File (RECOVERY_DIR, "command");
    pm.reboot ( "recovery");
= "PowerManager.java
    public void reboot (String reason) {
        try {
            mService.reboot (false, reason, true);
        } Catch (RemoteException e) {
        }
    }
Examples of mService is PowerManagerService.java
because
public final class PowerManagerService extends IPowerManager.Stub

=> PowerManagerService.java
reboot () {
shutdownOrRebootInternal (false, confirm, reason, wait);
}

 private void shutdownOrRebootInternal (final boolean shutdown, final boolean confirm,
            final String reason, boolean wait) {
 ShutdownThread.reboot (mContext, reason, confirm);
}

=>
ShutdownThread.java

public static void reboot (final Context context, String reason, boolean confirm) {
        mReboot = true;
        mRebootSafeMode = false;
        mRebootReason = reason;
        shutdownInner (context, confirm);
    }

shutdownInner

- "
beginShutdownSequence
Take two wake_lock let the system do not stand, let the screen lit
then
sInstance.start ();. This ShutdwonThread instance start its run method that is invoked

After the run method, turn off the am, radio ...., call
rebootOrShutdown
- "
public static void rebootOrShutdown (boolean reboot, String reason)

- "
PowerManagerService.lowLevelReboot (reason);
And transferred back to the PowerManagerService.

 -> PowerManagerService in
lowLevelReboot ()
SystemProperties.set ( "sys.powerctl", "reboot," + reason); // then pass the reboot into the Kernel

= "
So then, where are we going up?
Reference:
"
KK later Google will shutdown / restart finally transferred to the init process execution. Other Process notification performed by init system property sys.powerctl.
sys.powerctl arranged in init.rc which can refer to
on property: sys.powerctl = *
  powerctl $ {sys.powerctl}
  
Then perform system / core / init / builtins.c # do_powerctl function, call android_reboot restart or shutdown.
Why Factory mode can not adb reboot? Adb reboot under normal circumstances can be restarted, the key is because mediatek / config / {platform} factory_init.rc not defined
on property: sys.powerctl = *
  powerctl $ {sys.powerctl}
  
If you want to add this feature, you can only add two lines in the factory_init.rc
"
Continue with

= "In init.rc and an associated trigger on
396 on property: sys.powerctl = *
397 powerctl $ {sys.powerctl}

= "Calls builtins.c of reference among reboot, recovery
int do_powerctl (int nargs, char ** args)

=>
return android_reboot (cmd, 0, reboot_target);
cmd = ANDROID_RB_RESTART2 // #define ANDROID_RB_RESTART2 0xDEAD0003 in the android_reboot.h
reboot_target = second reference recovery

 = "
/system/core/libcutils/android_reboot.c execution android_reboot ();

case ANDROID_RB_RESTART2:
121 ret = __reboot (LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
122 LINUX_REBOOT_CMD_RESTART2, arg); // arg = recovery

=>
This is defined in the bionic / libc / include / sys / reboot.h in. Description This is a standard system calls
extern int __reboot (int, int, int, void *);

Specifically located bionic / libc / arch-arm / syscalls / __ reboot.S
  1 / * autogenerated by gensyscalls.py * /
  2 #include < asm / unistd.h>
  3 #include < linux / err.h>
  4 #include < machine / asm.h>
  5
  6 ENTRY (__ reboot)
  7 mov ip, r7
  8 ldr r7, = __ NR_reboot
  9 swi # 0
10 mov r7, ip
11 cmn r0, # (MAX_ERRNO + 1)
12 bxls lr
13 neg r0, r0
14 b __set_errno
15 END (__ reboot)

= "Will eventually enter the Kernel
kernel / sys.c
    case LINUX_REBOOT_CMD_RESTART2:
          if (strncpy_from_user (& buffer [0], arg, sizeof (buffer) - 1) < 0) {
              ret = -EFAULT;
              break;
          }
          buffer [sizeof (buffer) - 1] = '\ 0';

          kernel_restart (buffer); // buffer = arg = recovery
          break;

=> Machine_restart ()

=> Arch / arm / kernel / process.c
void machine_restart (char * cmd)
{
    local_irq_disable ();
    smp_send_stop ();

    / * Flush the console to make sure all the relevant messages make it
    * Out to the console drivers * /
    arm_machine_flush_console ();

    arm_pm_restart (reboot_mode, cmd);

    / * Give a grace period for failure to restart of 1s * /
    mdelay (1000); // 1s within the completion no restart reboot failed.

    / * Whoops - the platform was unable to reboot Tell the user * /.!
    printk ( "Reboot failed - System halted \ n");
    local_irq_disable ();
    while (1);
}

= "
void (* arm_pm_restart) (char str, const char * cmd) = arm_machine_restart;
= "
void arm_machine_restart (char mode, const char * cmd)
{
...
aml_write_reg32 (P_AO_RTI_STATUS_REG1, reboot_reason); // This is a flag register
...

arch_reset (mode, cmd); // mode = 'h' cmd = "recovery"
}

Almost, so try it on.

It is necessary to understand this register P_AO_RTI_STATUS_REG1 started the next time, uboot is when reading. This can save some of the state after the shutdown.
     
         
         
         
  More:      
 
- impdp error ORA-31631, ORA-39122 (Database)
- installation of Vim plugin YouCompleteMe under Ubuntu 15.04 (Linux)
- Linux in order to make NMAP hide and seek with the firewall (Linux)
- FastDFS installation and deployment (Server)
- C ++ type conversion and RTTI (Programming)
- Android Touch message passing mechanism analysis (Programming)
- OpenSSL to generate public and private key (Linux)
- Articles do not resolve after opening under Ubuntu WordPress setting a fixed link (Server)
- Ubuntu Eclipse configuration Gtk + 2.0 libraries (Linux)
- Build RPM package uses Docker mirror (Linux)
- map and hash_map STL containers (Programming)
- 64-bit Ubuntu 15.10 How to compile the latest version of the 32 Wine 1.7.53 (Linux)
- OpenDaylight Helium version installed (Linux)
- Improve WordPress performance (Server)
- Linux Open coredump (Linux)
- How VMware extend disk without rebooting the system (Linux)
- Dell R710 server disk recovery database one case (record) (Server)
- Define and modify strings principle in Python (Programming)
- Git uses Details (Linux)
- MongoDB 3.2 Cluster Setup (Database)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.