private void stopScramblerThread() {
   if (mScramblerThread != null) {
     mScramblerThread.quit();
     mScramblerThread = null;
     mScramblerThreadHandler = null;
   }
 }
  public void dispose() {
    CatLog.d(this, "Disposing CatService object for slot: " + mSlotId);

    // Clean up stk icon if dispose is called
    broadcastCardStateAndIccRefreshResp(CardState.CARDSTATE_ABSENT, null);

    mCmdIf.unSetOnCatSessionEnd(this);
    mCmdIf.unSetOnCatProactiveCmd(this);
    mCmdIf.unSetOnCatEvent(this);
    mCmdIf.unSetOnCatCallSetUp(this);
    mCmdIf.unSetOnCatCcAlphaNotify(this);
    mCmdIf.unSetOnCatSendSmsResult(this);

    mCmdIf.unregisterForIccRefresh(this);
    if (mUiccController != null) {
      mUiccController.unregisterForIccChanged(this);
      mUiccController = null;
    }
    if (mMsgDecoder != null) {
      mMsgDecoder.dispose(mSlotId);
      mMsgDecoder = null;
    }
    mHandlerThread.quit();
    mHandlerThread = null;
    removeCallbacksAndMessages(null);
  }
Ejemplo n.º 3
0
 @Override
 protected void onPause() {
   System.out.println("onPause...........................");
   super.onPause();
   sm.unregisterListener(this);
   mHanderThread.quit();
 }
Ejemplo n.º 4
0
  protected Looper getLooper(int type) {
    if (mHandlerThread != null) {
      mHandlerThread.quit();
      mHandlerThread = null;
    }

    int priority;
    switch (type) {
      case THREAD_TYPE_MAIN_THREAD:
        return Looper.getMainLooper();
      case THREAD_TYPE_HIGH_PRIORITY:
        priority = android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY;
        break;
      case THREAD_TYPE_LOW_PRIORITY:
        priority = android.os.Process.THREAD_PRIORITY_LOWEST;
        break;
      case THREAD_TYPE_NORMAL_PRIORITY:
      default:
        priority = android.os.Process.THREAD_PRIORITY_DEFAULT;
        break;
    }
    String threadName = "DFM Handler Thread #" + priority;
    mHandlerThread = new HandlerThread(threadName, priority);
    mHandlerThread.start();
    return mHandlerThread.getLooper();
  }
Ejemplo n.º 5
0
 @Override
 public void onDestroy() {
   // TODO Auto-generated method stub
   super.onDestroy();
   thread.quit();
   Log.i("info", "Service销毁");
 }
Ejemplo n.º 6
0
        @Override
        public void run() {
          cameraManager.close();

          // cancel background thread
          cameraHandler.removeCallbacksAndMessages(null);
          cameraThread.quit();
        }
Ejemplo n.º 7
0
 @Override
 protected void onDisabled() {
   subtitle = null;
   parserThread.quit();
   parserThread = null;
   parserHelper = null;
   clearTextRenderer();
   source.disable(trackIndex);
 }
Ejemplo n.º 8
0
 @Override
 public void onDestroy() {
   getContentResolver().unregisterContentObserver(mObserver);
   mScanner.shutdown();
   mUpdateThread.quit();
   if (Constants.LOGVV) {
     Log.v(Constants.TAG, "Service onDestroy");
   }
   super.onDestroy();
 }
Ejemplo n.º 9
0
 private void exitThread() {
   synchronized (threadSync) {
     if (handlerThread != null) {
       if (enable_Statistics_LOG) Log.v("UICenter - StatisticsNew", LOG_TAG + "\n=exitThread");
       handlerThread.quit();
       handlerThread = null;
       mHandler = null;
     }
   }
 }
Ejemplo n.º 10
0
 @Override
 protected void onDestroy() {
   if (mWorkerHandler != null) {
     mWorkerHandler.removeMessages(MSG_CHECK_RESULT);
   }
   if (mWorkerThread != null) {
     mWorkerThread.quit();
   }
   super.onDestroy();
 };
Ejemplo n.º 11
0
 public void waitForNotificationOrFail() {
   // Note: The PollingCheck class is taken from the Android CTS (Compatibility Test Suite).
   // It's useful to look at the Android CTS source for ideas on how to test your Android
   // applications.  The reason that PollingCheck works is that, by default, the JUnit
   // testing framework is not running on the main Android application thread.
   new PollingCheck(5000) {
     @Override
     protected boolean check() {
       return mContentChanged;
     }
   }.run();
   mHT.quit();
 }
Ejemplo n.º 12
0
  @Override
  public void onDestroy() {
    super.onDestroy();
    Log.i(TAG, "RadioService onDestroy()");
    thread.quit();
    stopMediaPlayer();
    locationManager.removeUpdates(locationListener);
    unregisterReceiver(batteryListener);
    unregisterReceiver(descentListener);
    nManager.cancel(1);

    RadioStatus.setRunning(false);
  }
Ejemplo n.º 13
0
  @Override
  protected void onDestroy() {
    super.onDestroy();

    mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
    Xlog.d(TAG, "onDestroy set PhoneStateListener.LISTEN_NONE!");

    if (mRestoreDefaultApnThread != null) {
      mRestoreDefaultApnThread.quit();
    }
    if (mRcseExt != null) {
      mRcseExt.removeRcseOnlyApnStateChanged(mListener);
    }
  }
Ejemplo n.º 14
0
  @Override
  public void onDestroy() {
    super.onDestroy();

    sensorHandler.removeCallbacksAndMessages(null);
    mSensorManager.unregisterListener(this, mAccelerometer);
    sensorThread.quit();

    wakeLock.release();

    unregisterReceiver(dataLabeler);

    if (Aware.DEBUG) Log.d(TAG, "Accelerometer service terminated...");
  }
Ejemplo n.º 15
0
  @Override
  protected void onPause() {
    super.onPause();

    if (threadhandler != null) {
      threadhandler.removeCallbacks(load_item);
      threadhandler.removeCallbacks(update_value);
    }
    if (mthread != null) mthread.quit();

    if (location_status == true) {
      locationManager.removeUpdates(this);
      location_status = false;
    }
  }
 private void stopDraw() {
   if (handler != null) {
     handler.quit();
     handler = null;
   }
   if (mDrawThread != null) {
     try {
       mDrawThread.join();
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
     mDrawThread.quit();
     mDrawThread = null;
   }
 }
 public void end() {
   mEndFlag = true;
   synchronized (mDrawingNotify) {
     mDrawingNotify.notifyAll();
   }
   if (mHandler != null) {
     mHandler.pause();
     mHandler = null;
   }
   if (mThread != null) {
     try {
       mThread.join();
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
     mThread.quit();
     mThread = null;
   }
 }
  @Override
  public void onDestroy() {
    if (DEBUG) Log.d(TAG, "onDestroy()");
    mNetworkLocation = null;
    mLocation = null;
    mReportCounts = 0;
    mTrack = 0;
    mPrecise = 0;

    synchronized (mLock) {
      if (mReceiver != null) unregisterReceiver(mReceiver);
      mReceiver = null;
      mHandler = null;
      if (mThread != null) mThread.quit();
      mThread = null;
      if (Utility.hasPermission(Utility.PERMISSION_WAKE_LOCK)) {
        if (mWakelock != null) mWakelock.release();
        mWakelock = null;
      }
    }
  }
 @Override
 public boolean handleMessage(Message msg) {
   if (DEBUG) Log.d(TAG, "Message what: " + msg.what);
   int what = msg.what;
   LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
   switch (what) {
     case MSG_REPORT_COARSE_LOCATION:
       if (mNetworkLocation != null) doReportLocation(mNetworkLocation);
       return true;
     case MSG_REPORT_LOCATION:
       if (DEBUG) Log.d(TAG, "Track left " + mTrack);
       if (mLocation != null) doReportLocation(mLocation);
       if (--mTrack <= 0) {
         locationManager.removeUpdates(this);
         // Let AsyncTask finish
         mHandler.removeMessages(MSG_STOP_SELF);
         mHandler.sendEmptyMessageDelayed(MSG_STOP_SELF, 5000);
       }
       return true;
     case MSG_GET_LOCATION:
       if (Utility.hasPermission(Utility.PERMISSION_FINE_LOCATION))
         locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1, 4, this);
       if (Utility.hasPermission(Utility.PERMISSION_COARSE_LOCATION))
         locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1, 4, this);
       mHandler.sendEmptyMessageDelayed(MSG_STOP_SELF, STOP_SELF_DELAY);
       return true;
     case MSG_STOP_SELF:
       locationManager.removeUpdates(this);
       synchronized (mLock) {
         mHandler = null;
         if (mThread != null) mThread.quit();
         mThread = null;
       }
       doReportFinish();
       return true;
   }
   return false;
 }
Ejemplo n.º 20
0
 // Called by native code to quit the camera thread. This needs to be done manually, otherwise the
 // thread and handler will not be garbage collected.
 private void release() {
   Logging.d(TAG, "release");
   if (isReleased()) {
     throw new IllegalStateException("Already released");
   }
   ThreadUtils.invokeUninterruptibly(
       cameraThreadHandler,
       new Runnable() {
         @Override
         public void run() {
           if (camera != null) {
             throw new IllegalStateException("Release called while camera is running");
           }
           if (cameraStatistics.pendingFramesCount() != 0) {
             throw new IllegalStateException("Release called with pending frames left");
           }
         }
       });
   surfaceHelper.disconnect();
   cameraThread.quit();
   ThreadUtils.joinUninterruptibly(cameraThread);
   cameraThread = null;
 }
Ejemplo n.º 21
0
  public void clear() {
    if (handlerThread != null) {
      handlerThread.quit();
    }
    if (imageCache != null) {

      Iterator<Entry<String, SoftReference<Bitmap>>> iterator = imageCache.entrySet().iterator();
      while (iterator.hasNext()) {
        Entry<String, SoftReference<Bitmap>> entry = iterator.next();

        SoftReference<Bitmap> bitmapcache_ = entry.getValue();
        if (bitmapcache_ != null) {
          Bitmap bitmap_ = bitmapcache_.get();

          if (bitmap_ != null) {
            bitmap_.recycle();
          }
        }
      }
      imageCache.clear();
    }
    FileUtil.deleteDirectiory(getFolderNmae());
    mGPUImageCache = null;
  }
  protected Looper getLooper(int type) {
    if (mDrawThread != null) {
      mDrawThread.quit();
      mDrawThread = null;
    }
    int priority = Thread.NORM_PRIORITY;
    String threadName = "DFM Drawing thread";
    switch (type) {
      case THREAD_TYPE_MAIN_THREAD:
        {
          return Looper.getMainLooper();
        }
      case THREAD_TYPE_HIGH_PRIORITY:
        {
          priority = Thread.MAX_PRIORITY;
          threadName += Thread.MAX_PRIORITY;
        }
        break;
      case THREAD_TYPE_NORMAL_PRIORITY:
        {
          priority = Thread.NORM_PRIORITY;
          threadName += Thread.NORM_PRIORITY;
        }
        break;
      case THREAD_TYPE_LOW_PRIORITY:
        {
          priority = Thread.MIN_PRIORITY;
          threadName += Thread.MIN_PRIORITY;
        }
        break;
    }

    mDrawThread = new HandlerThread(threadName, priority);
    mDrawThread.start();
    return mDrawThread.getLooper();
  }
Ejemplo n.º 23
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   tabQueueHandler = null;
   handlerThread.quit();
 }
Ejemplo n.º 24
0
 void shutdown() {
   statsThread.quit();
 }
 @Override
 public void run() {
   mHandlerThread.quit();
 }
Ejemplo n.º 26
0
 public void recycleWorkerHandler() {
   if (null != mHandlerThread && null != mWorkerHandler) {
     mHandlerThread.quit();
     mWorkerHandler.removeCallbacksAndMessages(null);
   }
 }
Ejemplo n.º 27
0
 @Override
 public void onDestroy() {
   mHandlerThread.quit();
   super.onDestroy();
 }
Ejemplo n.º 28
0
        @Override
        public boolean handleMessage(Message msg) {
          Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);

          final int startId = msg.arg1;
          if (DEBUG_LIFECYCLE) Log.v(TAG, "Updating for startId " + startId);

          // Since database is current source of truth, our "active" status
          // depends on database state. We always get one final update pass
          // once the real actions have finished and persisted their state.

          // TODO: switch to asking real tasks to derive active state
          // TODO: handle media scanner timeouts

          final boolean isActive;
          synchronized (mDownloads) {
            isActive = updateLocked();
          }

          if (msg.what == MSG_FINAL_UPDATE) {
            // Dump thread stacks belonging to pool
            for (Map.Entry<Thread, StackTraceElement[]> entry :
                Thread.getAllStackTraces().entrySet()) {
              if (entry.getKey().getName().startsWith("pool")) {
                Log.d(TAG, entry.getKey() + ": " + Arrays.toString(entry.getValue()));
              }
            }

            // Dump speed and update details
            mNotifier.dumpSpeeds();

            Log.wtf(
                TAG,
                "Final update pass triggered, isActive="
                    + isActive
                    + "; someone didn't update correctly.");
          }

          if (isActive) {
            // Still doing useful work, keep service alive. These active
            // tasks will trigger another update pass when they're finished.

            // Enqueue delayed update pass to catch finished operations that
            // didn't trigger an update pass; these are bugs.
            enqueueFinalUpdate();

          } else {
            // No active tasks, and any pending update messages can be
            // ignored, since any updates important enough to initiate tasks
            // will always be delivered with a new startId.

            if (stopSelfResult(startId)) {
              if (DEBUG_LIFECYCLE) Log.v(TAG, "Nothing left; stopped");
              getContentResolver().unregisterContentObserver(mObserver);
              mScanner.shutdown();
              mUpdateThread.quit();
            }
          }

          return true;
        }
Ejemplo n.º 29
0
 @TargetApi(5)
 public void stop() {
   router.unregisterConnHandler(sessionId);
   myThread.quit();
 }