public RingerSwitchObserver(Context context) {

    mContext = context;

    ThemeUtils.registerThemeChangeReceiver(
        context,
        new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
            mUiContext = null;
          }
        });

    mHandler = new Handler();
    mVolumeChangeUiRunnable =
        new Runnable() {
          @Override
          public void run() {
            getVolumePanel()
                .postVolumeChanged(
                    AudioManager.STREAM_RING,
                    AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_VIBRATE);
          }
        };

    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "RingerSwitchObserver");
    mWakeLock.setReferenceCounted(false);

    startObserving(RINGER_SWITCH_UEVENT_MATCH);

    init(); // set initial status
  }
  private final synchronized VolumePanel getVolumePanel() {
    if (mUiContext == null || mVolumePanel == null) {
      if (mUiContext == null) {
        mUiContext = ThemeUtils.createUiContext(mContext);
      }
      final Context context = mUiContext != null ? mUiContext : mContext;
      mVolumePanel = new VolumePanel(mContext, (AudioService) mAudioService);
    }

    return mVolumePanel;
  }