原文出自:http://blog.csdn.net/wdaming1986/article/details/11988531

最近看恢复出厂的一个问题,以前也查过这方面的流程,所以这里整理一些AP+framework层的流程;

在setting-->备份与重置--->恢复出厂设置--->重置手机--->清除全部内容--->手机关机--->开机--->进行恢复出厂的操作--->开机流程;

Step 1:前面找settings中的布局我就省略了,这部分相对简单一些,直接到清除全部内容这个按钮的操作,

对应的java类是setting中的MasterClearConfirm.java这个类,

[java] view plaincopyprint?
  1. private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {
  2. public void onClick(View v) {
  3. if (Utils.isMonkeyRunning()) {
  4. return;
  5. }
  6. if (mEraseSdCard) {
  7. Intent intent = new Intent(ExternalStorageFormatter.FORMAT_AND_FACTORY_RESET);
  8. intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME);
  9. getActivity().startService(intent);
  10. } else {
  11. getActivity().sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));
  12. // Intent handling is asynchronous -- assume it will happen soon.
  13. }
  14. }
  15. };
private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {public void onClick(View v) {if (Utils.isMonkeyRunning()) {return;}if (mEraseSdCard) {Intent intent = new Intent(ExternalStorageFormatter.FORMAT_AND_FACTORY_RESET);intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME);getActivity().startService(intent);} else {getActivity().sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));// Intent handling is asynchronous -- assume it will happen soon.}}};

通过上述的代码,可以看出,实际上点击清除全部内容的时候,如果前面勾选上格式哈SD卡,就会执行mEraseSdCard为true里面的逻辑,如果没有勾选,就执行mEraseSdCard=false的逻辑,其实就是发送一个广播,

[java] view plaincopyprint?
  1. <span style="font-size: 14px;">“android.intent.action.MASTER_CLEAR”</span>
<span style="font-size:14px;">“android.intent.action.MASTER_CLEAR”</span>

Step 2:这个广播接受的地方,参见AndroidManifest.xml中的代码,如下:

[html] view plaincopyprint?
  1. <receiver android:name="com.android.server.MasterClearReceiver"
  2. android:permission="android.permission.MASTER_CLEAR"
  3. android:priority="100" >
  4. <intent-filter>
  5. <!-- For Checkin, Settings, etc.: action=MASTER_CLEAR -->
  6. <action android:name="android.intent.action.MASTER_CLEAR" />
  7. <!-- MCS always uses REMOTE_INTENT: category=MASTER_CLEAR -->
  8. <action android:name="com.google.android.c2dm.intent.RECEIVE" />
  9. <category android:name="android.intent.category.MASTER_CLEAR" />
  10. </intent-filter>
  11. </receiver>
<receiver android:name="com.android.server.MasterClearReceiver"android:permission="android.permission.MASTER_CLEAR"android:priority="100" ><intent-filter><!-- For Checkin, Settings, etc.: action=MASTER_CLEAR --><action android:name="android.intent.action.MASTER_CLEAR" /><!-- MCS always uses REMOTE_INTENT: category=MASTER_CLEAR --><action android:name="com.google.android.c2dm.intent.RECEIVE" /><category android:name="android.intent.category.MASTER_CLEAR" /></intent-filter></receiver>

找这个MasterClearReceiver.java这个receiver,下面来看看这个onReceiver()里面做了什么操作:

[java] view plaincopyprint?
  1. public void onReceive(final Context context, final Intent intent) {
  2. if (intent.getAction().equals(Intent.ACTION_REMOTE_INTENT)) {
  3. if (!"google.com".equals(intent.getStringExtra("from"))) {
  4. Slog.w(TAG, "Ignoring master clear request -- not from trusted server.");
  5. return;
  6. }
  7. }
  8. Slog.w(TAG, "!!! FACTORY RESET !!!");
  9. // The reboot call is blocking, so we need to do it on another thread.
  10. Thread thr = new Thread("Reboot") {
  11. @Override
  12. public void run() {
  13. try {
  14. RecoverySystem.rebootWipeUserData(context);
  15. Log.wtf(TAG, "Still running after master clear?!");
  16. } catch (IOException e) {
  17. Slog.e(TAG, "Can't perform master clear/factory reset", e);
  18. }
  19. }
  20. };
  21. thr.start();
  22. }
public void onReceive(final Context context, final Intent intent) {if (intent.getAction().equals(Intent.ACTION_REMOTE_INTENT)) {if (!"google.com".equals(intent.getStringExtra("from"))) {Slog.w(TAG, "Ignoring master clear request -- not from trusted server.");return;}}Slog.w(TAG, "!!! FACTORY RESET !!!");// The reboot call is blocking, so we need to do it on another thread.Thread thr = new Thread("Reboot") {@Overridepublic void run() {try {RecoverySystem.rebootWipeUserData(context);Log.wtf(TAG, "Still running after master clear?!");} catch (IOException e) {Slog.e(TAG, "Can't perform master clear/factory reset", e);}}};thr.start();}

这个里面主要的操作是:RecoverySystem.rebootWipeUserData(context);准备做重启的动作,告诉手机要清除userData的数据;

Step 3:接着来看看RecoverySystem.rebootWipeUserData()这个方法做了哪些操作:

[java] view plaincopyprint?
  1. public static void rebootWipeUserData(Context context) throws IOException {
  2. final ConditionVariable condition = new ConditionVariable();
  3. Intent intent = new Intent("android.intent.action.MASTER_CLEAR_NOTIFICATION");
  4. context.sendOrderedBroadcastAsUser(intent, UserHandle.OWNER,
  5. android.Manifest.permission.MASTER_CLEAR,
  6. new BroadcastReceiver() {
  7. @Override
  8. public void onReceive(Context context, Intent intent) {
  9. condition.open();
  10. }
  11. }, null, 0, null, null);
  12. // Block until the ordered broadcast has completed.
  13. condition.block();
  14. bootCommand(context, "--wipe_data\n--locale=" + Locale.getDefault().toString());
  15. }
public static void rebootWipeUserData(Context context) throws IOException {final ConditionVariable condition = new ConditionVariable();Intent intent = new Intent("android.intent.action.MASTER_CLEAR_NOTIFICATION");context.sendOrderedBroadcastAsUser(intent, UserHandle.OWNER,android.Manifest.permission.MASTER_CLEAR,new BroadcastReceiver() {@Overridepublic void onReceive(Context context, Intent intent) {condition.open();}}, null, 0, null, null);// Block until the ordered broadcast has completed.condition.block();bootCommand(context, "--wipe_data\n--locale=" + Locale.getDefault().toString());}

这个里面的广播可以先忽略不计,重点来看看bootCommand()这个方法,注意这个参数“--wipe_data\n--locale=”

[java] view plaincopyprint?
  1. private static void bootCommand(Context context, String arg) throws IOException {
  2. RECOVERY_DIR.mkdirs();  // In case we need it
  3. COMMAND_FILE.delete();  // In case it's not writable
  4. LOG_FILE.delete();
  5. FileWriter command = new FileWriter(COMMAND_FILE);
  6. try {
  7. command.write(arg);
  8. command.write("\n");
  9. } finally {
  10. command.close();
  11. }
  12. // Having written the command file, go ahead and reboot
  13. PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
  14. pm.reboot("recovery");
  15. throw new IOException("Reboot failed (no permissions?)");
  16. }
private static void bootCommand(Context context, String arg) throws IOException {RECOVERY_DIR.mkdirs();  // In case we need itCOMMAND_FILE.delete();  // In case it's not writableLOG_FILE.delete();FileWriter command = new FileWriter(COMMAND_FILE);try {command.write(arg);command.write("\n");} finally {command.close();}// Having written the command file, go ahead and rebootPowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);pm.reboot("recovery");throw new IOException("Reboot failed (no permissions?)");}

这个方法的操作大致是“写节点/cache/recovery/command”,把传递过来的字符串写进去;然后调用PowerManager进行重启操作,reboot();

Step 4:接着我们来看看PowerManager的reboot方法做了哪些操作:

[java] view plaincopyprint?
  1. public void reboot(String reason) {
  2. try {
  3. mService.reboot(false, reason, true);
  4. } catch (RemoteException e) {
  5. }
  6. }
  public void reboot(String reason) {try {mService.reboot(false, reason, true);} catch (RemoteException e) {}}

这个调用到了PowerManagerService.java这个类的reboot方法中了:

[java] view plaincopyprint?
  1. @Override // Binder call
  2. public void reboot(boolean confirm, String reason, boolean wait) {
  3. mContext.enforceCallingOrSelfPermission(android.Manifest.permission.REBOOT, null);
  4. final long ident = Binder.clearCallingIdentity();
  5. try {
  6. shutdownOrRebootInternal(false, confirm, reason, wait);
  7. } finally {
  8. Binder.restoreCallingIdentity(ident);
  9. }
  10. }
@Override // Binder callpublic void reboot(boolean confirm, String reason, boolean wait) {mContext.enforceCallingOrSelfPermission(android.Manifest.permission.REBOOT, null);final long ident = Binder.clearCallingIdentity();try {shutdownOrRebootInternal(false, confirm, reason, wait);} finally {Binder.restoreCallingIdentity(ident);}}

重点来看看shutdownOrRebootInternal()这个方法,

[java] view plaincopyprint?
  1. private void shutdownOrRebootInternal(final boolean shutdown, final boolean confirm,
  2. final String reason, boolean wait) {
  3. if (mHandler == null || !mSystemReady) {
  4. throw new IllegalStateException("Too early to call shutdown() or reboot()");
  5. }
  6. Runnable runnable = new Runnable() {
  7. @Override
  8. public void run() {
  9. synchronized (this) {
  10. if (shutdown) {
  11. ShutdownThread.shutdown(mContext, confirm);
  12. } else {
  13. ShutdownThread.reboot(mContext, reason, confirm);
  14. }
  15. }
  16. }
  17. };
  18. // ShutdownThread must run on a looper capable of displaying the UI.
  19. Message msg = Message.obtain(mHandler, runnable);
  20. msg.setAsynchronous(true);
  21. mHandler.sendMessage(msg);
  22. // PowerManager.reboot() is documented not to return so just wait for the inevitable.
  23. if (wait) {
  24. synchronized (runnable) {
  25. while (true) {
  26. try {
  27. runnable.wait();
  28. } catch (InterruptedException e) {
  29. }
  30. }
  31. }
  32. }
  33. }
private void shutdownOrRebootInternal(final boolean shutdown, final boolean confirm,final String reason, boolean wait) {if (mHandler == null || !mSystemReady) {throw new IllegalStateException("Too early to call shutdown() or reboot()");}Runnable runnable = new Runnable() {@Overridepublic void run() {synchronized (this) {if (shutdown) {ShutdownThread.shutdown(mContext, confirm);} else {ShutdownThread.reboot(mContext, reason, confirm);}}}};// ShutdownThread must run on a looper capable of displaying the UI.Message msg = Message.obtain(mHandler, runnable);msg.setAsynchronous(true);mHandler.sendMessage(msg);// PowerManager.reboot() is documented not to return so just wait for the inevitable.if (wait) {synchronized (runnable) {while (true) {try {runnable.wait();} catch (InterruptedException e) {}}}}}

由于传递过来的shutdown为false,所以执行ShutdownThread.reboot(mContext, reason, confirm);reason:recevory

下面调用到ShutdownThread

   Step 5:这个追踪ShutdownThread.reboot()这个方法,这就有点像破案电影,一点一点查找罪犯的难点;

来窥视一下这个类:

[java] view plaincopyprint?
  1. public static void reboot(final Context context, String reason, boolean confirm) {
  2. mReboot = true;
  3. mRebootSafeMode = false;
  4. mRebootReason = reason;
  5. Log.d(TAG, "reboot");
  6. shutdownInner(context, confirm);
  7. }
 public static void reboot(final Context context, String reason, boolean confirm) {mReboot = true;mRebootSafeMode = false;mRebootReason = reason;Log.d(TAG, "reboot");shutdownInner(context, confirm);}

这个里面做的操作就是给这个变量mRebootReason复制“recevory”,重点调用shutdownInner()这个方法;

[java] view plaincopyprint?
  1. <span style="font-size: 14px;">static void shutdownInner(final Context context, boolean confirm) {
  2. // ensure that only one thread is trying to power down.
  3. // any additional calls are just returned
  4. synchronized (sIsStartedGuard) {
  5. if (sIsStarted) {
  6. Log.d(TAG, "Request to shutdown already running, returning.");
  7. return;
  8. }
  9. }
  10. Log.d(TAG, "Notifying thread to start radio shutdown");
  11. bConfirmForAnimation = confirm;
  12. final int longPressBehavior = context.getResources().getInteger(
  13. com.android.internal.R.integer.config_longPressOnPowerBehavior);
  14. final int resourceId = mRebootSafeMode
  15. ? com.android.internal.R.string.reboot_safemode_confirm
  16. : (longPressBehavior == 2
  17. ? com.android.internal.R.string.shutdown_confirm_question
  18. : com.android.internal.R.string.shutdown_confirm);
  19. Log.d(TAG, "Notifying thread to start shutdown longPressBehavior=" + longPressBehavior);
  20. if (confirm) {
  21. final CloseDialogReceiver closer = new CloseDialogReceiver(context);
  22. if (sConfirmDialog != null) {
  23. sConfirmDialog.dismiss();
  24. }
  25. if (sConfirmDialog == null) {
  26. Log.d(TAG, "PowerOff dialog doesn't exist. Create it first");
  27. sConfirmDialog = new AlertDialog.Builder(context)
  28. .setTitle(mRebootSafeMode
  29. ? com.android.internal.R.string.reboot_safemode_title
  30. : com.android.internal.R.string.power_off)
  31. .setMessage(resourceId)
  32. .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() {
  33. public void onClick(DialogInterface dialog, int which) {
  34. beginShutdownSequence(context);
  35. if (sConfirmDialog != null) {
  36. sConfirmDialog = null;
  37. }
  38. }
  39. })
  40. .setNegativeButton(com.android.internal.R.string.no, new DialogInterface.OnClickListener() {
  41. public void onClick(DialogInterface dialog, int which) {
  42. synchronized (sIsStartedGuard) {
  43. sIsStarted = false;
  44. }
  45. if (sConfirmDialog != null) {
  46. sConfirmDialog = null;
  47. }
  48. }
  49. })
  50. .create();
  51. sConfirmDialog.setCancelable(false);//blocking back key
  52. sConfirmDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
  53. /*if (!context.getResources().getBoolean(
  54. com.android.internal.R.bool.config_sf_slowBlur)) {
  55. sConfirmDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
  56. }*/
  57. /* To fix video+UI+blur flick issue */
  58. sConfirmDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
  59. }
  60. closer.dialog = sConfirmDialog;
  61. sConfirmDialog.setOnDismissListener(closer);
  62. if (!sConfirmDialog.isShowing()) {
  63. sConfirmDialog.show();
  64. }
  65. } else {
  66. beginShutdownSequence(context);
  67. }
  68. }</span>
<span style="font-size:14px;">static void shutdownInner(final Context context, boolean confirm) {// ensure that only one thread is trying to power down.// any additional calls are just returnedsynchronized (sIsStartedGuard) {if (sIsStarted) {Log.d(TAG, "Request to shutdown already running, returning.");return;}}Log.d(TAG, "Notifying thread to start radio shutdown");bConfirmForAnimation = confirm;final int longPressBehavior = context.getResources().getInteger(com.android.internal.R.integer.config_longPressOnPowerBehavior);final int resourceId = mRebootSafeMode? com.android.internal.R.string.reboot_safemode_confirm: (longPressBehavior == 2? com.android.internal.R.string.shutdown_confirm_question: com.android.internal.R.string.shutdown_confirm);Log.d(TAG, "Notifying thread to start shutdown longPressBehavior=" + longPressBehavior);if (confirm) {final CloseDialogReceiver closer = new CloseDialogReceiver(context);if (sConfirmDialog != null) {sConfirmDialog.dismiss();}if (sConfirmDialog == null) {Log.d(TAG, "PowerOff dialog doesn't exist. Create it first");sConfirmDialog = new AlertDialog.Builder(context).setTitle(mRebootSafeMode? com.android.internal.R.string.reboot_safemode_title: com.android.internal.R.string.power_off).setMessage(resourceId).setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialog, int which) {beginShutdownSequence(context);if (sConfirmDialog != null) {sConfirmDialog = null;}}}).setNegativeButton(com.android.internal.R.string.no, new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialog, int which) {synchronized (sIsStartedGuard) {sIsStarted = false;}if (sConfirmDialog != null) {sConfirmDialog = null;}}}).create();sConfirmDialog.setCancelable(false);//blocking back keysConfirmDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);/*if (!context.getResources().getBoolean(com.android.internal.R.bool.config_sf_slowBlur)) {sConfirmDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);}*//* To fix video+UI+blur flick issue */sConfirmDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);}closer.dialog = sConfirmDialog;sConfirmDialog.setOnDismissListener(closer);if (!sConfirmDialog.isShowing()) {sConfirmDialog.show();}} else {beginShutdownSequence(context);}}</span>

看beginShutdownSequence()这个方法吧,重点调用到这个方法里面去了,来瞅瞅这个方法:

[java] view plaincopyprint?
  1. <span style="font-size: 14px;">private static void beginShutdownSequence(Context context) {
  2. synchronized (sIsStartedGuard) {
  3. if (sIsStarted) {
  4. Log.e(TAG, "ShutdownThread is already running, returning.");
  5. return;
  6. }
  7. sIsStarted = true;
  8. }
  9. // start the thread that initiates shutdown
  10. sInstance.mContext = context;
  11. sInstance.mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
  12. sInstance.mHandler = new Handler() {
  13. };
  14. bPlayaudio = true;
  15. if (!bConfirmForAnimation) {
  16. if (!sInstance.mPowerManager.isScreenOn()) {
  17. bPlayaudio = false;
  18. }
  19. }
  20. // throw up an indeterminate system dialog to indicate radio is
  21. // shutting down.
  22. beginAnimationTime = 0;
  23. boolean mShutOffAnimation = false;
  24. try {
  25. if (mIBootAnim == null) {
  26. mIBootAnim = MediatekClassFactory.createInstance(IBootAnimExt.class);
  27. }
  28. } catch (Exception e) {
  29. e.printStackTrace();
  30. }
  31. int screenTurnOffTime = mIBootAnim.getScreenTurnOffTime();
  32. mShutOffAnimation = mIBootAnim.isCustBootAnim();
  33. Log.e(TAG, "mIBootAnim get screenTurnOffTime : " + screenTurnOffTime);
  34. String cust = SystemProperties.get("ro.operator.optr");
  35. if (cust != null) {
  36. if (cust.equals("CUST")) {
  37. mShutOffAnimation = true;
  38. }
  39. }
  40. synchronized (mEnableAnimatingSync) {
  41. if(!mEnableAnimating) {
  42. //                sInstance.mPowerManager.setBacklightBrightness(PowerManager.BRIGHTNESS_DIM);
  43. } else {
  44. if (mShutOffAnimation) {
  45. Log.e(TAG, "mIBootAnim.isCustBootAnim() is true");
  46. bootanimCust();
  47. } else {
  48. pd = new ProgressDialog(context);
  49. pd.setTitle(context.getText(com.android.internal.R.string.power_off));
  50. pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));
  51. pd.setIndeterminate(true);
  52. pd.setCancelable(false);
  53. pd.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
  54. /* To fix video+UI+blur flick issue */
  55. pd.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
  56. pd.show();
  57. }
  58. sInstance.mHandler.postDelayed(mDelayDim, screenTurnOffTime );
  59. }
  60. }
  61. // make sure we never fall asleep again
  62. sInstance.mCpuWakeLock = null;
  63. try {
  64. sInstance.mCpuWakeLock = sInstance.mPowerManager.newWakeLock(
  65. 。。。 。。。
  66. }</span>
<span style="font-size:14px;">private static void beginShutdownSequence(Context context) {synchronized (sIsStartedGuard) {if (sIsStarted) {Log.e(TAG, "ShutdownThread is already running, returning.");       return;}sIsStarted = true;}// start the thread that initiates shutdownsInstance.mContext = context;sInstance.mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE);sInstance.mHandler = new Handler() {};    bPlayaudio = true;if (!bConfirmForAnimation) {if (!sInstance.mPowerManager.isScreenOn()) {bPlayaudio = false;}}// throw up an indeterminate system dialog to indicate radio is// shutting down.beginAnimationTime = 0;boolean mShutOffAnimation = false;try {if (mIBootAnim == null) {mIBootAnim = MediatekClassFactory.createInstance(IBootAnimExt.class);}} catch (Exception e) {e.printStackTrace();}int screenTurnOffTime = mIBootAnim.getScreenTurnOffTime();mShutOffAnimation = mIBootAnim.isCustBootAnim();Log.e(TAG, "mIBootAnim get screenTurnOffTime : " + screenTurnOffTime);String cust = SystemProperties.get("ro.operator.optr");if (cust != null) {if (cust.equals("CUST")) {mShutOffAnimation = true;}}synchronized (mEnableAnimatingSync) {if(!mEnableAnimating) {
//                sInstance.mPowerManager.setBacklightBrightness(PowerManager.BRIGHTNESS_DIM);} else {if (mShutOffAnimation) {Log.e(TAG, "mIBootAnim.isCustBootAnim() is true");bootanimCust();} else {pd = new ProgressDialog(context);pd.setTitle(context.getText(com.android.internal.R.string.power_off));pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));pd.setIndeterminate(true);pd.setCancelable(false);pd.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);/* To fix video+UI+blur flick issue */pd.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);pd.show();}sInstance.mHandler.postDelayed(mDelayDim, screenTurnOffTime ); }}// make sure we never fall asleep againsInstance.mCpuWakeLock = null;try {sInstance.mCpuWakeLock = sInstance.mPowerManager.newWakeLock(。。。 。。。
}</span>

这段代码有句话会影响关机动画播放不完

“sInstance.mHandler.postDelayed(mDelayDim, screenTurnOffTime ); ”

解决办法

(1)“可以把这个screenTurnOffTime时间乘以2,这个时间看log是5000毫秒,就是5秒,乘以2就是10秒,大概就能播放完全关机动画了。”

(2)把这句话注释掉,但是有可能会引起问题,导致恢复出厂设置的时候没有进行恢复出厂的操作。目前正在追踪此问题;

这段代码中还有影响关机动画是否走客制化的关机动画,如果ro.operator.optr这个属性配置的是CUST,则会走客制化的关机动画,否则走系统默认的关机动画;

[java] view plaincopyprint?
  1. String cust = SystemProperties.get("ro.operator.optr");
  2. if (cust != null) {
  3. if (cust.equals("CUST")) {
  4. mShutOffAnimation = true;
  5. }
  6. }
String cust = SystemProperties.get("ro.operator.optr");if (cust != null) {if (cust.equals("CUST")) {mShutOffAnimation = true;}}

然后重点看 sInstance.start();这个方法,就走到了run()方法里满了;

    Step 6: 来看看ShutDownThread.java这个类的run()方法;

[java] view plaincopyprint?
  1. <span style="font-size: 14px;">public void run() {
  2. checkShutdownFlow();
  3. while (mShutdownFlow == IPO_SHUTDOWN_FLOW) {
  4. stMgr.saveStates(mContext);
  5. stMgr.enterShutdown(mContext);
  6. running();
  7. }
  8. if (mShutdownFlow != IPO_SHUTDOWN_FLOW) {
  9. stMgr.enterShutdown(mContext);
  10. running();
  11. }
  12. }</span>
<span style="font-size:14px;">public void run() {checkShutdownFlow();while (mShutdownFlow == IPO_SHUTDOWN_FLOW) {stMgr.saveStates(mContext);stMgr.enterShutdown(mContext);running();} if (mShutdownFlow != IPO_SHUTDOWN_FLOW) {stMgr.enterShutdown(mContext);running();}}</span>

重点看running()这个方法:

下面这个方法比较长,来分析一下:

[java] view plaincopyprint?
  1. <span style="font-size: 14px;">public void running() {
  2. if(sPreShutdownApi != null){
  3. try {
  4. sPreShutdownApi.onPowerOff();
  5. } catch (RemoteException e) {
  6. Log.e(TAG, "onPowerOff exception" + e.getMessage());
  7. }
  8. }else{
  9. Log.w(TAG, "sPreShutdownApi is null");
  10. }
  11. command = SystemProperties.get("sys.ipo.pwrdncap");
  12. BroadcastReceiver br = new BroadcastReceiver() {
  13. @Override public void onReceive(Context context, Intent intent) {
  14. // We don't allow apps to cancel this, so ignore the result.
  15. actionDone();
  16. }
  17. };
  18. /*
  19. * Write a system property in case the system_server reboots before we
  20. * get to the actual hardware restart. If that happens, we'll retry at
  21. * the beginning of the SystemServer startup.
  22. */
  23. {
  24. String reason = (mReboot ? "1" : "0") + (mRebootReason != null ? mRebootReason : "");
  25. SystemProperties.set(SHUTDOWN_ACTION_PROPERTY, reason);
  26. }
  27. /*
  28. * If we are rebooting into safe mode, write a system property
  29. * indicating so.
  30. */
  31. if (mRebootSafeMode) {
  32. SystemProperties.set(REBOOT_SAFEMODE_PROPERTY, "1");
  33. }
  34. Log.i(TAG, "Sending shutdown broadcast...");
  35. // First send the high-level shut down broadcast.
  36. mActionDone = false;
  37. /// M: 2012-05-20 ALPS00286063 @{
  38. mContext.sendBroadcast(new Intent("android.intent.action.ACTION_PRE_SHUTDOWN"));
  39. /// @} 2012-05-20
  40. mContext.sendOrderedBroadcastAsUser((new Intent()).setAction(Intent.ACTION_SHUTDOWN).putExtra("_mode", mShutdownFlow),
  41. UserHandle.ALL, null, br, mHandler, 0, null, null);
  42. final long endTime = SystemClock.elapsedRealtime() + MAX_BROADCAST_TIME;
  43. synchronized (mActionDoneSync) {
  44. while (!mActionDone) {
  45. long delay = endTime - SystemClock.elapsedRealtime();
  46. if (delay <= 0) {
  47. Log.w(TAG, "Shutdown broadcast ACTION_SHUTDOWN timed out");
  48. if (mShutdownFlow == IPO_SHUTDOWN_FLOW) {
  49. Log.d(TAG, "change shutdown flow from ipo to normal: ACTION_SHUTDOWN timeout");
  50. mShutdownFlow = NORMAL_SHUTDOWN_FLOW;
  51. }
  52. break;
  53. }
  54. try {
  55. mActionDoneSync.wait(delay);
  56. } catch (InterruptedException e) {
  57. }
  58. }
  59. }
  60. // Also send ACTION_SHUTDOWN_IPO in IPO shut down flow
  61. if (mShutdownFlow == IPO_SHUTDOWN_FLOW) {
  62. mActionDone = false;
  63. mContext.sendOrderedBroadcast(new Intent("android.intent.action.ACTION_SHUTDOWN_IPO"), null,
  64. br, mHandler, 0, null, null);
  65. final long endTimeIPO = SystemClock.elapsedRealtime() + MAX_BROADCAST_TIME;
  66. synchronized (mActionDoneSync) {
  67. while (!mActionDone) {
  68. long delay = endTimeIPO - SystemClock.elapsedRealtime();
  69. if (delay <= 0) {
  70. Log.w(TAG, "Shutdown broadcast ACTION_SHUTDOWN_IPO timed out");
  71. if (mShutdownFlow == IPO_SHUTDOWN_FLOW) {
  72. Log.d(TAG, "change shutdown flow from ipo to normal: ACTION_SHUTDOWN_IPO timeout");
  73. mShutdownFlow = NORMAL_SHUTDOWN_FLOW;
  74. }
  75. break;
  76. }
  77. try {
  78. mActionDoneSync.wait(delay);
  79. } catch (InterruptedException e) {
  80. }
  81. }
  82. }
  83. }
  84. if (mShutdownFlow != IPO_SHUTDOWN_FLOW) {
  85. // power off auto test, don't modify
  86. Log.i(TAG, "Shutting down activity manager...");
  87. final IActivityManager am =
  88. ActivityManagerNative.asInterface(ServiceManager.checkService("activity"));
  89. if (am != null) {
  90. try {
  91. am.shutdown(MAX_BROADCAST_TIME);
  92. } catch (RemoteException e) {
  93. }
  94. }
  95. }
  96. // power off auto test, don't modify
  97. // Shutdown radios.
  98. Log.i(TAG, "Shutting down radios...");
  99. shutdownRadios(MAX_RADIO_WAIT_TIME);
  100. // power off auto test, don't modify
  101. Log.i(TAG, "Shutting down MountService...");
  102. if ( (mShutdownFlow == IPO_SHUTDOWN_FLOW) && (command.equals("1")||command.equals("3")) ) {
  103. Log.i(TAG, "bypass MountService!");
  104. } else {
  105. // Shutdown MountService to ensure media is in a safe state
  106. IMountShutdownObserver observer = new IMountShutdownObserver.Stub() {
  107. public void onShutDownComplete(int statusCode) throws RemoteException {
  108. Log.w(TAG, "Result code " + statusCode + " from MountService.shutdown");
  109. if (statusCode < 0) {
  110. mShutdownFlow = NORMAL_SHUTDOWN_FLOW;
  111. }
  112. actionDone();
  113. }
  114. };
  115. // Set initial variables and time out time.
  116. mActionDone = false;
  117. final long endShutTime = SystemClock.elapsedRealtime() + MAX_SHUTDOWN_WAIT_TIME;
  118. synchronized (mActionDoneSync) {
  119. try {
  120. final IMountService mount = IMountService.Stub.asInterface(
  121. ServiceManager.checkService("mount"));
  122. if (mount != null) {
  123. mount.shutdown(observer);
  124. } else {
  125. Log.w(TAG, "MountService unavailable for shutdown");
  126. }
  127. } catch (Exception e) {
  128. Log.e(TAG, "Exception during MountService shutdown", e);
  129. }
  130. while (!mActionDone) {
  131. long delay = endShutTime - SystemClock.elapsedRealtime();
  132. if (delay <= 0) {
  133. Log.w(TAG, "Shutdown wait timed out");
  134. if (mShutdownFlow == IPO_SHUTDOWN_FLOW) {
  135. Log.d(TAG, "change shutdown flow from ipo to normal: MountService");
  136. mShutdownFlow = NORMAL_SHUTDOWN_FLOW;
  137. }
  138. break;
  139. }
  140. try {
  141. mActionDoneSync.wait(delay);
  142. } catch (InterruptedException e) {
  143. }
  144. }
  145. }
  146. }
  147. // power off auto test, don't modify
  148. //mountSerivce ���
  149. Log.i(TAG, "MountService shut done...");
  150. // [MTK] fix shutdown animation timing issue
  151. //==================================================================
  152. try {
  153. SystemProperties.set("service.shutanim.running","1");
  154. Log.i(TAG, "set service.shutanim.running to 1");
  155. } catch (Exception ex) {
  156. Log.e(TAG, "Failed to set 'service.shutanim.running' = 1).");
  157. }
  158. //==================================================================
  159. if (mShutdownFlow == IPO_SHUTDOWN_FLOW) {
  160. if (SHUTDOWN_VIBRATE_MS > 0) {
  161. // vibrate before shutting down
  162. Vibrator vibrator = new SystemVibrator();
  163. try {
  164. vibrator.vibrate(SHUTDOWN_VIBRATE_MS);
  165. } catch (Exception e) {
  166. // Failure to vibrate shouldn't interrupt shutdown.  Just log it.
  167. Log.w(TAG, "Failed to vibrate during shutdown.", e);
  168. }
  169. // vibrator is asynchronous so we need to wait to avoid shutting down too soon.
  170. try {
  171. Thread.sleep(SHUTDOWN_VIBRATE_MS);
  172. } catch (InterruptedException unused) {
  173. }
  174. }
  175. // Shutdown power
  176. // power off auto test, don't modify
  177. Log.i(TAG, "Performing ipo low-level shutdown...");
  178. delayForPlayAnimation();
  179. if (sInstance.mScreenWakeLock != null && sInstance.mScreenWakeLock.isHeld()) {
  180. sInstance.mScreenWakeLock.release();
  181. sInstance.mScreenWakeLock = null;
  182. }
  183. sInstance.mHandler.removeCallbacks(mDelayDim);
  184. stMgr.shutdown(mContext);
  185. stMgr.finishShutdown(mContext);
  186. //To void previous UI flick caused by shutdown animation stopping before BKL turning off
  187. if (pd != null) {
  188. pd.dismiss();
  189. pd = null;
  190. } else if (beginAnimationTime > 0) {
  191. try {
  192. SystemProperties.set("service.bootanim.exit","1");
  193. Log.i(TAG, "set 'service.bootanim.exit' = 1).");
  194. } catch (Exception ex) {
  195. Log.e(TAG, "Failed to set 'service.bootanim.exit' = 1).");
  196. }
  197. //SystemProperties.set("ctl.stop","bootanim");
  198. }
  199. synchronized (sIsStartedGuard) {
  200. sIsStarted = false;
  201. }
  202. sInstance.mPowerManager.setBacklightBrightnessOff(false);
  203. sInstance.mCpuWakeLock.acquire(2000);
  204. synchronized (mShutdownThreadSync) {
  205. try {
  206. mShutdownThreadSync.wait();
  207. } catch (InterruptedException e) {
  208. }
  209. }
  210. } else {
  211. rebootOrShutdown(mReboot, mRebootReason);
  212. }
  213. }</span>
 <span style="font-size:14px;">public void running() {if(sPreShutdownApi != null){try {sPreShutdownApi.onPowerOff();} catch (RemoteException e) {Log.e(TAG, "onPowerOff exception" + e.getMessage());}}else{Log.w(TAG, "sPreShutdownApi is null");}command = SystemProperties.get("sys.ipo.pwrdncap");BroadcastReceiver br = new BroadcastReceiver() {@Override public void onReceive(Context context, Intent intent) {// We don't allow apps to cancel this, so ignore the result.actionDone();}};/** Write a system property in case the system_server reboots before we* get to the actual hardware restart. If that happens, we'll retry at* the beginning of the SystemServer startup.*/{String reason = (mReboot ? "1" : "0") + (mRebootReason != null ? mRebootReason : "");SystemProperties.set(SHUTDOWN_ACTION_PROPERTY, reason);}/** If we are rebooting into safe mode, write a system property* indicating so.*/if (mRebootSafeMode) {SystemProperties.set(REBOOT_SAFEMODE_PROPERTY, "1");}Log.i(TAG, "Sending shutdown broadcast...");// First send the high-level shut down broadcast.mActionDone = false;/// M: 2012-05-20 ALPS00286063 @{mContext.sendBroadcast(new Intent("android.intent.action.ACTION_PRE_SHUTDOWN"));/// @} 2012-05-20mContext.sendOrderedBroadcastAsUser((new Intent()).setAction(Intent.ACTION_SHUTDOWN).putExtra("_mode", mShutdownFlow),UserHandle.ALL, null, br, mHandler, 0, null, null);final long endTime = SystemClock.elapsedRealtime() + MAX_BROADCAST_TIME;synchronized (mActionDoneSync) {while (!mActionDone) {long delay = endTime - SystemClock.elapsedRealtime();if (delay <= 0) {Log.w(TAG, "Shutdown broadcast ACTION_SHUTDOWN timed out");if (mShutdownFlow == IPO_SHUTDOWN_FLOW) {Log.d(TAG, "change shutdown flow from ipo to normal: ACTION_SHUTDOWN timeout");mShutdownFlow = NORMAL_SHUTDOWN_FLOW;}break;}try {mActionDoneSync.wait(delay);} catch (InterruptedException e) {}}}// Also send ACTION_SHUTDOWN_IPO in IPO shut down flowif (mShutdownFlow == IPO_SHUTDOWN_FLOW) {mActionDone = false;mContext.sendOrderedBroadcast(new Intent("android.intent.action.ACTION_SHUTDOWN_IPO"), null,br, mHandler, 0, null, null);final long endTimeIPO = SystemClock.elapsedRealtime() + MAX_BROADCAST_TIME;synchronized (mActionDoneSync) {while (!mActionDone) {long delay = endTimeIPO - SystemClock.elapsedRealtime();if (delay <= 0) {Log.w(TAG, "Shutdown broadcast ACTION_SHUTDOWN_IPO timed out");if (mShutdownFlow == IPO_SHUTDOWN_FLOW) {Log.d(TAG, "change shutdown flow from ipo to normal: ACTION_SHUTDOWN_IPO timeout");mShutdownFlow = NORMAL_SHUTDOWN_FLOW;}break;}try {mActionDoneSync.wait(delay);} catch (InterruptedException e) {}}}}if (mShutdownFlow != IPO_SHUTDOWN_FLOW) {// power off auto test, don't modifyLog.i(TAG, "Shutting down activity manager...");final IActivityManager am =ActivityManagerNative.asInterface(ServiceManager.checkService("activity"));if (am != null) {try {am.shutdown(MAX_BROADCAST_TIME);} catch (RemoteException e) {}}}// power off auto test, don't modify// Shutdown radios.Log.i(TAG, "Shutting down radios...");shutdownRadios(MAX_RADIO_WAIT_TIME);// power off auto test, don't modifyLog.i(TAG, "Shutting down MountService...");if ( (mShutdownFlow == IPO_SHUTDOWN_FLOW) && (command.equals("1")||command.equals("3")) ) {Log.i(TAG, "bypass MountService!");} else {// Shutdown MountService to ensure media is in a safe stateIMountShutdownObserver observer = new IMountShutdownObserver.Stub() {public void onShutDownComplete(int statusCode) throws RemoteException {Log.w(TAG, "Result code " + statusCode + " from MountService.shutdown");if (statusCode < 0) {mShutdownFlow = NORMAL_SHUTDOWN_FLOW; }actionDone();}};// Set initial variables and time out time.mActionDone = false;final long endShutTime = SystemClock.elapsedRealtime() + MAX_SHUTDOWN_WAIT_TIME;synchronized (mActionDoneSync) {try {final IMountService mount = IMountService.Stub.asInterface(ServiceManager.checkService("mount"));if (mount != null) {mount.shutdown(observer);} else {Log.w(TAG, "MountService unavailable for shutdown");}} catch (Exception e) {Log.e(TAG, "Exception during MountService shutdown", e);}while (!mActionDone) {long delay = endShutTime - SystemClock.elapsedRealtime();if (delay <= 0) {Log.w(TAG, "Shutdown wait timed out");if (mShutdownFlow == IPO_SHUTDOWN_FLOW) {Log.d(TAG, "change shutdown flow from ipo to normal: MountService");mShutdownFlow = NORMAL_SHUTDOWN_FLOW;}break;}try {mActionDoneSync.wait(delay);} catch (InterruptedException e) {}}}}// power off auto test, don't modify//mountSerivce ���Log.i(TAG, "MountService shut done...");// [MTK] fix shutdown animation timing issue//==================================================================try {SystemProperties.set("service.shutanim.running","1");Log.i(TAG, "set service.shutanim.running to 1");} catch (Exception ex) {Log.e(TAG, "Failed to set 'service.shutanim.running' = 1).");}//==================================================================if (mShutdownFlow == IPO_SHUTDOWN_FLOW) {if (SHUTDOWN_VIBRATE_MS > 0) {// vibrate before shutting downVibrator vibrator = new SystemVibrator();try {vibrator.vibrate(SHUTDOWN_VIBRATE_MS);} catch (Exception e) {// Failure to vibrate shouldn't interrupt shutdown.  Just log it.Log.w(TAG, "Failed to vibrate during shutdown.", e);}// vibrator is asynchronous so we need to wait to avoid shutting down too soon.try {Thread.sleep(SHUTDOWN_VIBRATE_MS);} catch (InterruptedException unused) {}}// Shutdown power// power off auto test, don't modifyLog.i(TAG, "Performing ipo low-level shutdown...");delayForPlayAnimation();if (sInstance.mScreenWakeLock != null && sInstance.mScreenWakeLock.isHeld()) {sInstance.mScreenWakeLock.release();sInstance.mScreenWakeLock = null;}sInstance.mHandler.removeCallbacks(mDelayDim); stMgr.shutdown(mContext);stMgr.finishShutdown(mContext);//To void previous UI flick caused by shutdown animation stopping before BKL turning off         if (pd != null) {pd.dismiss();pd = null;} else if (beginAnimationTime > 0) {try {SystemProperties.set("service.bootanim.exit","1");Log.i(TAG, "set 'service.bootanim.exit' = 1).");} catch (Exception ex) {Log.e(TAG, "Failed to set 'service.bootanim.exit' = 1).");}  //SystemProperties.set("ctl.stop","bootanim");}synchronized (sIsStartedGuard) {sIsStarted = false;}sInstance.mPowerManager.setBacklightBrightnessOff(false); sInstance.mCpuWakeLock.acquire(2000); synchronized (mShutdownThreadSync) {try {mShutdownThreadSync.wait();} catch (InterruptedException e) {}}} else {rebootOrShutdown(mReboot, mRebootReason);}}</span>

这个方法做了一些列的操作,会关闭一些操作,如:

  1. shutdownRadios(MAX_RADIO_WAIT_TIME);
  2. mount.shutdown(observer);
  3. stMgr.shutdown(mContext);

重点看  rebootOrShutdown(mReboot, mRebootReason);这个方法;准备重启的方法;

Step 7:来看看rebootOrShutdown()这个方法:

[java] view plaincopyprint?
  1. <span style="font-size: 14px;">public static void rebootOrShutdown(boolean reboot, String reason) {
  2. if (reboot) {
  3. Log.i(TAG, "Rebooting, reason: " + reason);
  4. if ( (reason != null) && reason.equals("recovery") ) {
  5. delayForPlayAnimation();
  6. }
  7. try {
  8. PowerManagerService.lowLevelReboot(reason);
  9. } catch (Exception e) {
  10. Log.e(TAG, "Reboot failed, will attempt shutdown instead", e);
  11. }
  12. } else if (SHUTDOWN_VIBRATE_MS > 0) {
  13. // vibrate before shutting down
  14. Vibrator vibrator = new SystemVibrator();
  15. try {
  16. vibrator.vibrate(SHUTDOWN_VIBRATE_MS);
  17. } catch (Exception e) {
  18. // Failure to vibrate shouldn't interrupt shutdown.  Just log it.
  19. Log.w(TAG, "Failed to vibrate during shutdown.", e);
  20. }
  21. // vibrator is asynchronous so we need to wait to avoid shutting down too soon.
  22. try {
  23. Thread.sleep(SHUTDOWN_VIBRATE_MS);
  24. } catch (InterruptedException unused) {
  25. }
  26. }
  27. delayForPlayAnimation();
  28. // Shutdown power
  29. // power off auto test, don't modify
  30. Log.i(TAG, "Performing low-level shutdown...");
  31. //PowerManagerService.lowLevelShutdown();
  32. //add your func: HDMI off
  33. //add for MFR
  34. try {
  35. if (ImHDMI == null)
  36. ImHDMI=MediatekClassFactory.createInstance(IHDMINative.class);
  37. } catch (Exception e) {
  38. e.printStackTrace();
  39. }
  40. ImHDMI.hdmiPowerEnable(false);
  41. try {
  42. if (mTvOut == null)
  43. mTvOut =MediatekClassFactory.createInstance(ITVOUTNative.class);
  44. } catch (Exception e) {
  45. e.printStackTrace();
  46. }
  47. mTvOut.tvoutPowerEnable(false);
  48. //add your func: HDMI off
  49. //unmout data/cache partitions while performing shutdown
  50. SystemProperties.set("ctl.start", "shutdown");
  51. /* sleep for a long time, prevent start another service */
  52. try {
  53. Thread.currentThread().sleep(Integer.MAX_VALUE);
  54. } catch ( Exception e) {
  55. Log.e(TAG, "Shutdown rebootOrShutdown Thread.currentThread().sleep exception!");
  56. }
  57. }</span>
<span style="font-size:14px;">public static void rebootOrShutdown(boolean reboot, String reason) {if (reboot) {Log.i(TAG, "Rebooting, reason: " + reason);if ( (reason != null) && reason.equals("recovery") ) {delayForPlayAnimation();}try {PowerManagerService.lowLevelReboot(reason);} catch (Exception e) {Log.e(TAG, "Reboot failed, will attempt shutdown instead", e);}} else if (SHUTDOWN_VIBRATE_MS > 0) {// vibrate before shutting downVibrator vibrator = new SystemVibrator();try {vibrator.vibrate(SHUTDOWN_VIBRATE_MS);} catch (Exception e) {// Failure to vibrate shouldn't interrupt shutdown.  Just log it.Log.w(TAG, "Failed to vibrate during shutdown.", e);}// vibrator is asynchronous so we need to wait to avoid shutting down too soon.try {Thread.sleep(SHUTDOWN_VIBRATE_MS);} catch (InterruptedException unused) {}}delayForPlayAnimation();// Shutdown power// power off auto test, don't modifyLog.i(TAG, "Performing low-level shutdown...");//PowerManagerService.lowLevelShutdown();//add your func: HDMI off//add for MFRtry {if (ImHDMI == null)ImHDMI=MediatekClassFactory.createInstance(IHDMINative.class);} catch (Exception e) {e.printStackTrace();            }ImHDMI.hdmiPowerEnable(false);try {if (mTvOut == null)mTvOut =MediatekClassFactory.createInstance(ITVOUTNative.class);} catch (Exception e) {e.printStackTrace();           }mTvOut.tvoutPowerEnable(false);//add your func: HDMI off//unmout data/cache partitions while performing shutdownSystemProperties.set("ctl.start", "shutdown");/* sleep for a long time, prevent start another service */try {Thread.currentThread().sleep(Integer.MAX_VALUE);} catch ( Exception e) {Log.e(TAG, "Shutdown rebootOrShutdown Thread.currentThread().sleep exception!");  }}</span>

关机震动也在这个方法里面;这个方法重点看PowerManagerService.lowLevelReboot(reason);

Log.i(TAG, "Rebooting, reason: " + reason);这句log也很重要,可以有助于我们分析代码;

Step 8:下面来看看PowerManagerServices.java这个类的lowLevelReboot()这个方法:

[java] view plaincopyprint?
  1. <span style="font-size: 18px;">public static void lowLevelReboot(String reason) throws IOException {
  2. nativeReboot(reason);
  3. }</span>
<span style="font-size:18px;">public static void lowLevelReboot(String reason) throws IOException {nativeReboot(reason);}</span>

这个方法调用到了native里面,后面的操作我就不分析了。。。

大致流程是:

关机,然后开机,底层判断节点后进入恢复出厂模式,recevory.img释放完全后,进入开机的流程。。。

以后有进展再补充这部分的流程,整个过程大致就是这个样子了,里面的细节有好多没有分析,大家可以自行研究。。。,抛砖引玉的目的达到了。

android恢复出厂设置流程分析相关推荐

  1. android 恢复出厂设置流程分析,基于Android系统快速恢复出厂设置方法实现.doc

    基于Android系统快速恢复出厂设置方法实现 基于Android系统快速恢复出厂设置方法实现 摘 要:针对使用Android系统的智能电视进行恢复出厂设置时重置速度慢的情况进行了研究和分析,从其重置 ...

  2. Android恢复出厂设置流程分析【Android源码解析十】

    最近看恢复出厂的一个问题,以前也查过这方面的流程,所以这里整理一些AP+framework层的流程: 在setting-->备份与重置--->恢复出厂设置--->重置手机---> ...

  3. Android6.0 Reset恢复出厂设置流程分析

    点击Settings应用中的恢复出厂设置按钮后流程分析: 先使用grep命令搜索"恢复出厂设置"字符串,找到相应的布局文件: packages/apps/Settings/res/ ...

  4. android 恢复出厂设置 界面,android恢复出厂设置流程概括

    恢复出厂设置流程概括 ============================================= 恢复出厂设置流程概括: 一. 设置模块中进行恢复出厂设置操作,系统一共做了两件事: 1 ...

  5. android 恢复出厂设置 代码,android恢复出厂设置以及系统升级流程

    http://www.bangchui.org/simple/?t5938.html ============================================= 恢复出厂设置流程概括: ...

  6. Android 恢复出厂设置(recovery)

    Android 恢复出厂设置基本流程 (1)遥控器/按键板后门键触发,或者应用里面从系统设置里面恢复出厂选项也可触发: // 后面以系统设置的应用触发为例 (2)选择恢复出厂设置之后,就会发送广播&q ...

  7. android 恢复出厂设置 时间,Android 恢复出厂设置后,时间不能恢复替:2013年1月1日...

    Android 恢复出厂设置后,时间不能恢复为:2013年1月1日 前言         欢迎大家我分享和推荐好用的代码段~~声明         欢迎转载,但请保留文章原始出处: CSDN:http ...

  8. Android 恢复出厂设置(系统时间不修改)

    Android恢复出厂设置时,只会将/data和/cache分区进行清除,时间和其他分区不会清除, 时间由rtc硬件模块来进行维护的,时间更新后会将时间信息写入此硬件模块,在系统启动时,RTC硬件驱动 ...

  9. Android恢复出厂设置代码流程分析

    工作中排查到了恢复出厂设置的bug, 有一些细节是需要注意的,于是把这块的代码流程看一下: 代码基于:Android9.0 应用层: 就发送MASTER_CLEAR的广播, 这里没有带参数的 priv ...

最新文章

  1. 重磅直播|基于激光雷达的感知、定位导航应用
  2. ORB-SLAM(1) --- 让程序飞起来
  3. cmake (4)引用子目录的库
  4. 全球农企对话国际农民丰收节贸易会·万祥军:拜耳谋定领先
  5. c语言变凉存储性,C语言数据的表示和存储(IEEE 754标准)
  6. 服务器端利器--双缓冲队列
  7. 关系数据模型和关系数据库系统
  8. STM32移植LWIP
  9. 『001』如何在自己的网页里引入一个聊天机器人(。・∀・)ノ
  10. Eclipse中启动tomcat: java.lang.OutOfMemoryError: PermGen space的解决方法
  11. 用python偷懒Arcgis(地类编码转地类名称)
  12. python 广义线性模型_scikit-learn 1.1 广义线性模型(Generalized Linear Models)
  13. word文档如何画线条流程图_如何在WORD中画流程图
  14. docker生态-mysql客户端phpAdmin
  15. maven读取不到包,项目名爆红
  16. 收集的一些学习ios的好网站
  17. 不用远程软件,校园网电脑之间如何远程连接
  18. 怎么查看php-fpm的错误日志,php fpm如何开启错误日志
  19. 压测⼯具本地快速安装Jmeter5.x以及基础功能组件介绍线程组和Sampler
  20. itextpdf简单使用 制作豆瓣日志pdf

热门文章

  1. 我的不靠谱择业[饮水思源feeling]
  2. 杂谈:饮水思源与Java仍在但Sun已死
  3. 04笔记 离散数学——关系——基于离散数学(第3版)_章炯民,陶增乐
  4. python量化交易:Joinquant_量化交易基础【三】:python基本语法与变量
  5. %20ld c语言,C语言第二次实验报告 - osc_ldea7g3t的个人空间 - OSCHINA - 中文开源技术交流社区...
  6. 超松弛迭代法求解二维电磁场有限差分方程(附Matlab代码)
  7. 遇到的MAVEN各种问题以及解决方案
  8. 前端--实体,meta,语义化标签1
  9. 如何判断合法的立即数
  10. 腾讯被爆内测配送机器人,与阿里顺丰直面物流竞争!