@Override
  protected void onDestroy() {
    Xlog.i(TAG, "onDestroy");
    unregisterReceiver(mReceiver);

    sInstance = null;
    super.onDestroy();
  }
 @Override
 protected void onStart() {
   super.onStart();
   Xlog.i(TAG, "onStart");
   OtaPkgManagerActivity.stopSelf();
   mGoToMainEntry = false;
   mNotifyManager.clearNotification(NotifyManager.NOTIFY_NEW_VERSION);
 }
  @Override
  protected void onStop() {
    Xlog.i(TAG, "onStop");
    if (!mGoToMainEntry
        && !mDownloadInfo.getIfNeedRefresh()
        && mDownloadInfo.getActivityID() < 0
        && (MainEntry.getInstance() == null || !MainEntry.getInstance().isStarted())) {
      Xlog.v(TAG, "background, show new version notification");
      mNotifyManager.showNewVersionNotification();
    }

    super.onStop();
  }
 @Override
 protected void onNewIntent(Intent intent) {
   super.onNewIntent(intent);
   Xlog.d(TAG, "onNewIntent " + mPath);
   if (mPath == null || !mPath.equals(intent.getStringExtra(KEY_PATH))) {
     sIsUnzip = false;
     if (mUnzipProgressDialog != null) {
       mUnzipProgressDialog.dismiss();
     }
     if (mCurrentDialog >= 0) {
       this.dismissDialog(mCurrentDialog);
     }
     updateUi(intent);
   }
 }
        @Override
        public void handleMessage(Message msg) {
          Xlog.i(TAG, "handleMessage msg.what = " + msg.what);

          switch (msg.what) {
            case SystemUpdateService.MSG_SDCARDUNKNOWNERROR:
              if (mUnzipProgressDialog != null) {
                sIsUnzip = false;
                mUnzipProgressDialog.dismiss();
              }

              showDialog(DIALOG_NOSDCARD);
              break;
            case SystemUpdateService.MSG_SDCARDINSUFFICENT:
              if (mUnzipProgressDialog != null) {
                sIsUnzip = false;
                mUnzipProgressDialog.dismiss();
              }
              showDialog(DIALOG_NOENOUGHSPACE);
              break;
            case SystemUpdateService.MSG_SDCARDPACKAGEINVALIDATE:
              showDialog(DIALOG_INVALIDATEPACKAGE);
              break;
            case SystemUpdateService.MSG_UNKNOWERROR:
              showDialog(DIALOG_UNKNOWN_ERROR);
              break;
            case SystemUpdateService.MSG_UNZIP_LODING:
              showDialog(DIALOG_UNZIPPING);
              break;
            case SystemUpdateService.MSG_CKSUM_ERROR:
            case SystemUpdateService.MSG_UNZIP_ERROR:
              if (mUnzipProgressDialog != null) {
                sIsUnzip = false;
                mUnzipProgressDialog.dismiss();
              }
              mOTADialogTitleResId = R.string.package_unzip_error;
              mOTADialogMessageResId = R.string.package_error_message_invalid;
              showDialog(DIALOG_OTARESULT);
              break;
            default:
              super.handleMessage(msg);
          }
        }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Xlog.i(TAG, "onCreate");

    sInstance = this;

    setContentView(R.layout.sd_package_ready);
    this.getActionBar().setDisplayHomeAsUpEnabled(true);

    Intent intent = getIntent();
    updateUi(intent);
    mDownloadInfo = DownloadInfo.getInstance(getApplicationContext());
    mNotifyManager = new NotifyManager(this);
    IntentFilter filter = new IntentFilter();
    filter.addAction(Util.Action.ACTION_MEDIA_MOUNT_UPDATEUI);
    filter.addAction(Util.Action.ACTION_MEDIA_UNMOUNT_UPDATEUI);
    registerReceiver(mReceiver, filter);
    mInstallBtn = (Button) this.findViewById(R.id.btn_install);
    mInstallBtn.setOnClickListener(mInstallListener);
  }