Exemplo n.º 1
0
 @Override
 public void onPause() {
   super.onPause();
   BigLog.i(tag, Logging.getCurrentMethodName(), logHighlight);
   buttonProcessor.onStopClicked();
   android.os.Process.killProcess(android.os.Process.myPid());
 }
    public void uncaughtException(Thread t, Throwable e) {
      try {
        // Don't re-enter -- avoid infinite loops if crash-reporting crashes.
        if (mCrashing) return;
        mCrashing = true;

        // Try to end profiling. If a profiler is running at this point, and we kill the
        // process (below), the in-memory buffer will be lost. So try to stop, which will
        // flush the buffer. (This makes method trace profiling useful to debug crashes.)
        if (ActivityThread.currentActivityThread() != null) {
          ActivityThread.currentActivityThread().stopProfiling();
        }

        // Bring up crash dialog, wait for it to be dismissed
        ActivityManagerNative.getDefault()
            .handleApplicationCrash(mApplicationObject, new ApplicationErrorReport.CrashInfo(e));
      } catch (Throwable t2) {
        try {
          Clog_e(TAG, "Error reporting crash", t2);
        } catch (Throwable t3) {
          // Even Clog_e() fails!  Oh well.
        }
      } finally {
        // Try everything to make sure this process goes away.
        Process.killProcess(Process.myPid());
        System.exit(10);
      }
    }
Exemplo n.º 3
0
 public ThemeInfo getCurrentThemeInfo() {
   ContentResolver contentResolver = getContext().getContentResolver();
   if (mCurrentThemeInfo == null) {
     String where = ThemeColumns.IS_APPLY + "=" + 1;
     Cursor cursor = contentResolver.query(ThemeColumns.CONTENT_URI, null, where, null, null);
     if (cursor != null) {
       if (cursor.moveToFirst()) {
         mCurrentThemeInfo = ThemeInfo.CreateFromDB(cursor);
       }
       cursor.close();
     }
     if (mCurrentThemeInfo == null) {
       HomeUtils.markThemeAsApply(
           getContext(), HomeDataBaseHelper.getInstance(getContext()).getDefaultThemeID());
       cursor = contentResolver.query(ThemeColumns.CONTENT_URI, null, where, null, null);
       if (cursor != null) {
         if (cursor.moveToFirst()) {
           mCurrentThemeInfo = ThemeInfo.CreateFromDB(cursor);
         }
         cursor.close();
       }
     }
     if (mCurrentThemeInfo == null) {
       // 数据库错误,删除数据库
       HomeUtils.deleteFile(getContext().getDatabasePath(ProviderUtils.DATABASE_NAME).getParent());
       Process.killProcess(Process.myPid());
     }
   }
   mCurrentThemeInfo.initFromXML(getContext());
   return mCurrentThemeInfo;
 }
Exemplo n.º 4
0
  @Override
  public void onDestroy() {
    super.onDestroy();

    Log.i(TAG, "Stopping service");

    stopForeground(true);

    if (acceptor != null) {
      try {
        acceptor.close();
      } catch (IOException e) {
        // We don't care
      }
    }

    try {
      executor.shutdownNow();
      executor.awaitTermination(10, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
      // Too bad
    } finally {
      started = false;

      // Unfortunately, we have no way to clean up some Binder-based callbacks
      // (namely IRotationWatcher) on lower API levels without killing the process,
      // which will allow DeathRecipient to handle it on their side.
      Process.killProcess(Process.myPid());
    }
  }
Exemplo n.º 5
0
 @Override
 protected void onPostExecute(Boolean result) {
   String path =
       mContext.getString(R.string.theme)
           + "/"
           + theme
           + "/"
           + mContext.getString(R.string.wallpaper)
           + "/"
           + mContext.getString(R.string.wallpaper)
           + ".jpg";
   Bitmap bitmap = null;
   try {
     bitmap = BitmapFactory.decodeStream(mContext.getAssets().open(path));
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   Drawable d = new BitmapDrawable(bitmap);
   setKeyguardBg(d);
   Intent intent = new Intent(ThemeEffectPreview.this, Launcher.class);
   startActivity(intent);
   finish();
   android.os.Process.killProcess(android.os.Process.myPid());
 }
  @Override
  public void uncaughtException(Thread thread, Throwable exception) {
    final StringWriter stackTrace = new StringWriter();
    exception.printStackTrace(new PrintWriter(stackTrace));
    System.err.println(stackTrace);

    // 发送错误到FixBooksDirectoryActivity;开启一个activity用于处理和显示页面
    Intent intent =
        new Intent(
            FBReaderIntents.Action.CRASH,
            new Uri.Builder().scheme(exception.getClass().getSimpleName()).build());

    intent.setPackage(FBReaderIntents.DEFAULT_PACKAGE);
    try {
      myContext.startActivity(intent);
    } catch (ActivityNotFoundException e) {
      // 如果进不去,则跳转到手动提交bug页面
      intent = new Intent(myContext, BugReportActivity.class);
      intent.putExtra(BugReportActivity.STACKTRACE, stackTrace.toString());
      myContext.startActivity(intent);
    }

    if (myContext instanceof Activity) {
      ((Activity) myContext).finish();
    }

    Process.killProcess(Process.myPid());
    System.exit(10);
  }
Exemplo n.º 7
0
  @Override
  public void uncaughtException(Thread thread, Throwable ex) {
    try {
      final Writer result = new StringWriter();
      final PrintWriter printWriter = new PrintWriter(result);
      ex.printStackTrace(printWriter);
      String errorReport =
          String.format(
              "[%s]\nAndroidVersion=%s\nIMEI=%s\nID=%s\n%s",
              new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()),
              VERSION.RELEASE,
              getIMEI(),
              Preference.getUsername(mAppContext),
              result.toString());

      Log.e(LOGTAG, errorReport);

      File logFile = new File(mAppContext.getFilesDir(), LOG_FILE);
      FileWriter fw = new FileWriter(logFile, true);

      fw.write(errorReport);

      fw.flush();
      fw.close();

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      android.os.Process.killProcess(android.os.Process.myPid());
    }
  }
Exemplo n.º 8
0
  @Override
  public void uncaughtException(Thread arg0, Throwable arg1) {
    // 把错误的堆栈信息 获取出来
    String errorInfo = getErrorInfo(arg1);
    String uuidKey = UUID.nameUUIDFromBytes(errorInfo.getBytes()).toString();

    String existsException = Utils.getSharedPreferences("uncaughtException").getString(uuidKey, "");
    if (!existsException.equals("")) {
      // -- this uncaughtException has got
      Debug.Log("Exception has got yet: " + errorInfo);
      Debug.Log("kill self() ");
      android.os.Process.killProcess(android.os.Process.myPid());
      return;
    }

    Editor editor = Utils.getSharedPreferences("uncaughtException").edit();
    editor.putString(uuidKey, "Mark");
    editor.commit();

    String content = DeviceInfo.getInfo(context).toString();
    String msg = content + "\nStack:\n" + errorInfo;

    Debug.Log("uncaughtException: " + msg);

    errorContent = msg;

    //        sendExceptionMsg();
  }
Exemplo n.º 9
0
  /** 当UncaughtException发生时会转入该函数来处理 */
  @Override
  public void uncaughtException(Thread thread, Throwable throwable) {
    //        if (!handleException(throwable) && mLocalExceptionHandler != null) {
    //            //如果用户没有处理则让系统默认的异常处理器来处理
    //            mLocalExceptionHandler.uncaughtException(thread, throwable);
    //        } else {
    //            try {
    //                Thread.sleep(1000);
    //            } catch (InterruptedException e) {
    //                Log.e(TAG, "error : ", e);
    //            }
    //            //退出程序
    //            android.os.Process.killProcess(android.os.Process.myPid());
    //            System.exit(1);
    //
    //        }

    handleException(throwable);

    if (mLocalExceptionHandler != null) {
      // 如果用户没有处理则让系统默认的异常处理器来处理
      mLocalExceptionHandler.uncaughtException(thread, throwable);
    } else {
      try {
        Thread.sleep(2000);
      } catch (InterruptedException e) {
        Log.e(TAG, "error : ", e);
      }
      // 退出程序
      android.os.Process.killProcess(android.os.Process.myPid());
      System.exit(1);
    }
  }
Exemplo n.º 10
0
  private void InstallFile(File f) {
    mProgress.dismiss();
    if (f.length() < fileLength) {
      return;
    }
    try {
      String command = "chmod " + 777 + " " + f.getPath();
      Runtime runtime = Runtime.getRuntime();
      runtime.exec(command);
    } catch (IOException e) {
      e.printStackTrace();
    }
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(android.content.Intent.ACTION_VIEW);

    intent.setDataAndType(Uri.fromFile(f), "application/vnd.android.package-archive");
    myActivity.startActivity(intent);

    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    //
    // 部分机型,安装过程中,要先退出自身进程,才能安装成功。
    //		BaseHelper.exitProcessSilently(myActivity);

    // 防止下载后安装,但用户单击取消情况下的问题
    //        application.destroy();
    //        myActivity.finish();
    android.os.Process.killProcess(android.os.Process.myPid());
  }
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i("ServiceStartArguments", "Starting #" + startId + ": " + intent.getExtras());
    Message msg = mServiceHandler.obtainMessage();
    msg.arg1 = startId;
    msg.arg2 = flags;
    msg.obj = intent.getExtras();
    mServiceHandler.sendMessage(msg);
    Log.i("ServiceStartArguments", "Sending: " + msg);

    // For the start fail button, we will simulate the process dying
    // for some reason in onStartCommand().
    if (intent.getBooleanExtra("fail", false)) {
      // Don't do this if we are in a retry... the system will
      // eventually give up if we keep crashing.
      if ((flags & START_FLAG_RETRY) == 0) {
        // Since the process hasn't finished handling the command,
        // it will be restarted with the command again, regardless of
        // whether we return START_REDELIVER_INTENT.
        Process.killProcess(Process.myPid());
      }
    }

    // Normally we would consistently return one kind of result...
    // however, here we will select between these two, so you can see
    // how they impact the behavior.  Try killing the process while it
    // is in the middle of executing the different commands.
    return intent.getBooleanExtra("redeliver", false) ? START_REDELIVER_INTENT : START_NOT_STICKY;
  }
Exemplo n.º 12
0
 public AwSettings(Context context) {
   mContext = context;
   mBlockNetworkLoads =
       mContext.checkPermission(
               android.Manifest.permission.INTERNET, Process.myPid(), Process.myUid())
           != PackageManager.PERMISSION_GRANTED;
 }
Exemplo n.º 13
0
 private void refreshExit(String result) {
   EMChatManager.getInstance().logout();
   ShareSDK.stopSDK(this);
   Intent intent = new Intent(this, IfanService.class);
   stopService(intent);
   android.os.Process.killProcess(android.os.Process.myPid());
 }
Exemplo n.º 14
0
 public static synchronized void destory() {
   decreaseUserCount();
   if (sUserCount <= 0 && sSelf != null) {
     sSelf.clearUp();
     sSelf = null;
     sIsPrepare = false;
     sUserCount = 0;
     if (sThemeAppinBilling != null) {
       sThemeAppinBilling.destory();
       sThemeAppinBilling = null;
     }
     // 销毁HttpAdapter
     SimpleHttpAdapter.destory();
     // 销毁HttpTool
     GoStoreHttpTool.destory();
     // 释放ImageManager里面的资源
     ImageManager.destory();
     // 销毁线程池
     ThreadPoolManager.destory();
     // 销毁缓存管理器
     CacheManager.destory();
     GoStoreCacheManager.destory();
     // 退出商店督促gc回收
     System.gc();
     // 把进程杀掉
     android.os.Process.killProcess(android.os.Process.myPid());
   }
 }
Exemplo n.º 15
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   //		BeeFrameworkApp.getInstance().showBug(this);
   // TODO Auto-generated method stub
   if (keyCode == KeyEvent.KEYCODE_BACK) {
     if (isExit == false) {
       isExit = true;
       ToastView toast = new ToastView(getApplicationContext(), "再按一次退出程序");
       toast.setGravity(Gravity.CENTER, 0, 0);
       toast.show();
       Handler mHandler =
           new Handler() {
             @Override
             public void handleMessage(Message msg) {
               super.handleMessage(msg);
               isExit = false;
             }
           };
       mHandler.sendEmptyMessageDelayed(0, 3000);
       return true;
     } else {
       android.os.Process.killProcess(android.os.Process.myPid());
       return false;
     }
   }
   return true;
 }
Exemplo n.º 16
0
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   // exit program when key back is entered
   if (keyCode == KeyEvent.KEYCODE_BACK) {
     android.os.Process.killProcess(android.os.Process.myPid());
   }
   return super.onKeyDown(keyCode, event);
 }
Exemplo n.º 17
0
  public static void log(XHook hook, int priority, String msg) {
    // Check if logging enabled
    int uid = Process.myUid();
    if (!mLogDetermined && uid > 0) {
      mLogDetermined = true;
      try {
        if (uid == Process.SYSTEM_UID)
          mLog = PrivacyService.getSettingBool(0, PrivacyManager.cSettingLog, false);
        else mLog = PrivacyManager.getSettingBool(0, PrivacyManager.cSettingLog, false, true);
      } catch (Throwable ignored) {
        mLog = false;
      }
    }

    // Log if enabled
    if (priority != Log.DEBUG && (priority == Log.INFO ? mLog : true))
      if (hook == null) Log.println(priority, "XPrivacy", msg);
      else
        Log.println(priority, String.format("XPrivacy/%s", hook.getClass().getSimpleName()), msg);

    // Report to service
    if (Process.myUid() > 0 && priority == Log.ERROR)
      if (Process.myUid() == Process.SYSTEM_UID) PrivacyService.reportErrorInternal(msg);
      else
        try {
          IPrivacyService client = PrivacyService.getClient();
          if (client != null) client.reportError(msg);
        } catch (RemoteException ignored) {
        }
  }
 public boolean resume() {
   int i = Process.getThreadPriority(Process.myTid());
   Process.setThreadPriority(Process.THREAD_PRIORITY_URGENT_AUDIO);
   if (audioResume(ctx)) paused = false;
   Process.setThreadPriority(i);
   return paused == false;
 }
 @Override
 public void onStop() {
   super.onStop();
   /** 프로세스 완전 종료 방법 */
   finish();
   android.os.Process.killProcess(android.os.Process.myPid());
 }
Exemplo n.º 20
0
  public void jumpToFragment(int index) {

    FragmentManager fragmentManager = this.getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    if (index == 0) {
      FragmentMain fragmentMain = new FragmentMain();
      fragmentTransaction.replace(R.id.fragmentContainer, fragmentMain);
    } else if (index == 1) {
      FragmentOne fragmentOne = new FragmentOne();
      fragmentTransaction.replace(R.id.fragmentContainer, fragmentOne);
    } else if (index == 2) {
      FragmentTwo fragmentTwo = new FragmentTwo();
      fragmentTransaction.replace(R.id.fragmentContainer, fragmentTwo);
    } else if (index == 3) {
      FragmentThree fragmentThree = new FragmentThree();
      fragmentTransaction.replace(R.id.fragmentContainer, fragmentThree);
    } else if (index == 4) {
      FragmentFour fragmentFour = new FragmentFour();
      fragmentTransaction.replace(R.id.fragmentContainer, fragmentFour);
    } else if (index == 5) {
      FragmentAbout fragmentAbout = new FragmentAbout();
      fragmentTransaction.replace(R.id.fragmentContainer, fragmentAbout);
    } else if (index == 6) {
      android.os.Process.killProcess(android.os.Process.myPid()); // 获取PID
      System.exit(0);
    }
    fragmentTransaction.commit();
  }
 @Override
 public void onReceive(Context context, Intent intent) {
   String action = intent.getAction();
   if (action.equals(ACTION_LOCALE_CHANGED)) {
     android.os.Process.killProcess(android.os.Process.myPid());
     System.exit(10);
   }
 }
Exemplo n.º 22
0
 protected void onPause() {
   super.onPause();
   if (CNetTVChannelView.isApplicationBroughtToBackground(this.getApplicationContext())
       && !CNetTvConfig.g_UserId.equals("")) {
     // Log.i("debug", "pause5");
     android.os.Process.killProcess(android.os.Process.myPid());
   }
 }
Exemplo n.º 23
0
 public boolean ccKeyDown(int keyCode, KeyEvent event) {
   int pid = android.os.Process.myPid();
   android.os.Process.killProcess(pid);
   Runtime r = Runtime.getRuntime();
   r.gc();
   System.gc();
   return true;
 }
Exemplo n.º 24
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   mConfiguration.unregisterObserver(mObserver);
   // mManager.setOnCancelListener(null);
   android.os.Process.killProcess(android.os.Process.myPid());
   System.exit(1);
 }
Exemplo n.º 25
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   app.getMultitalkNetworkManager().destroy();
   if (logCheckTimer != null) {
     logCheckTimer.cancel();
   }
   Process.killProcess(Process.myPid());
 }
Exemplo n.º 26
0
  private void quitNow() {
    // stop background service
    MaintainUserStatusService.unschedule(MainActivity.this);

    // quit
    finish();
    android.os.Process.killProcess(android.os.Process.myPid());
    System.exit(0);
  }
Exemplo n.º 27
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    try {
      int nPid = android.os.Process.myPid();
      android.os.Process.killProcess(nPid);
    } catch (Exception e) {

    }
  }
Exemplo n.º 28
0
 /** 退出应用程序 */
 public void AppExit(Context context) {
   try {
     finishAllActivity();
     // 杀死该应用进程
     android.os.Process.killProcess(android.os.Process.myPid());
     System.exit(0);
   } catch (Exception e) {
   }
 }
Exemplo n.º 29
0
 @Override
 protected void onNewIntent(Intent intent) {
   if (intent.getBooleanExtra("logout", false)) {
     // logout
     app.getMultitalkNetworkManager().destroy();
     finish();
     Process.killProcess(Process.myPid());
   }
 }
Exemplo n.º 30
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   // 关闭广告
   AppConnect.getInstance(this).close();
   // System.exit(0);
   // 或者下面这种方式
   android.os.Process.killProcess(android.os.Process.myPid());
 }