Program: 79830
Project: 79830
Buggy source:
public NotificationPeek(NotificationHub notificationHub,Context context){
  mNotificationHub=notificationHub;
  mContext=context;
  mSensorHandler=new SensorActivityHandler(context,this);
  mHandler=new Handler(Looper.getMainLooper());
  mWakeLockHandler=new Handler();
  mSensorHandler.registerScreenReceiver();
  mPartialWakeLockRunnable=new Runnable(){
    @Override public void run(){
      if (mPartialWakeLock.isHeld()) {
        if (mEventsRegistered) {
          if (DEBUG) {
            Log.d(TAG,"String_Node_Str");
          }
          tryUnregisterEventListeners();
          mEventsRegistered=false;
        }
        mPartialWakeLock.release();
      }
    }
  }
;
  mLockScreenRunnable=new Runnable(){
    @Override public void run(){
      if (mShowing) {
        if (DEBUG) {
          Log.d(TAG,"String_Node_Str");
        }
        mDevicePolicyManager.lockNow();
        if (mScreenWakeLock.isHeld()) {
          mScreenWakeLock.release();
        }
      }
    }
  }
;
  mDevicePolicyManager=(DevicePolicyManager)context.getSystemService(Context.DEVICE_POLICY_SERVICE);
  mKeyguardManager=(KeyguardManager)context.getSystemService(Context.KEYGUARD_SERVICE);
  mPowerManager=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  mPartialWakeLock=mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,getClass().getSimpleName() + "String_Node_Str");
  mScreenWakeLock=mPowerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,getClass().getSimpleName() + "String_Node_Str");
  TelephonyManager telephonyManager=(TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE);
  telephonyManager.listen(new CallStateListener(),PhoneStateListener.LISTEN_CALL_STATE);
  mPeekView=new RelativeLayout(context){
    @Override public boolean onInterceptTouchEvent(    MotionEvent event){
      int action=event.getAction();
      if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE) {
        if (action == MotionEvent.ACTION_DOWN) {
          mHandler.removeCallbacksAndMessages(null);
        }
      }
      if (action == MotionEvent.ACTION_UP) {
        scheduleTasks();
      }
      return super.onInterceptTouchEvent(event);
    }
  }
;
  mPeekView.setOnTouchListener(new View.OnTouchListener(){
    @Override public boolean onTouch(    View v,    MotionEvent event){
      if (event.getAction() == MotionEvent.ACTION_UP) {
        dismissNotification();
      }
      return true;
    }
  }
);
  NotificationLayout rootView=new NotificationLayout(context);
  rootView.setOrientation(LinearLayout.VERTICAL);
  rootView.setNotificationPeek(NotificationPeek.this);
  mPeekView.addView(rootView);
  RelativeLayout.LayoutParams rootLayoutParams=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
  rootLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT,RelativeLayout.TRUE);
  rootView.setLayoutParams(rootLayoutParams);
  mNotificationView=new LinearLayout(context);
  mNotificationView.setOrientation(LinearLayout.VERTICAL);
  rootView.addView(mNotificationView);
  mNotificationIcon=new ImageView(context);
  mNotificationIcon.setScaleType(ImageView.ScaleType.CENTER_CROP);
  mNotificationIcon.setOnTouchListener(PanelHelper.getHighlightTouchListener(Color.DKGRAY));
  mNotificationText=new TextView(context);
  Typeface textTypeface=Typeface.create("String_Node_Str",Typeface.NORMAL);
  mNotificationText.setTypeface(textTypeface);
  mNotificationText.setGravity(Gravity.CENTER);
  mNotificationText.setEllipsize(TextUtils.TruncateAt.END);
  mNotificationText.setSingleLine(true);
  mNotificationText.setPadding(0,mContext.getResources().getDimensionPixelSize(R.dimen.item_padding),0,0);
  mNotificationView.addView(mNotificationIcon);
  mNotificationView.addView(mNotificationText);
  int iconSize=mContext.getResources().getDimensionPixelSize(R.dimen.notification_icon_size);
  LinearLayout.LayoutParams linearLayoutParams=new LinearLayout.LayoutParams(iconSize,iconSize);
  linearLayoutParams.gravity=Gravity.CENTER_HORIZONTAL;
  mNotificationIcon.setLayoutParams(linearLayoutParams);
  linearLayoutParams=new LinearLayout.LayoutParams(mContext.getResources().getDimensionPixelSize(R.dimen.notification_text_width),LinearLayout.LayoutParams.WRAP_CONTENT);
  linearLayoutParams.gravity=Gravity.CENTER_HORIZONTAL;
  mNotificationText.setLayoutParams(linearLayoutParams);
  mNotificationsContainer=new GridLayout(context){
    @Override public boolean onTouchEvent(    MotionEvent ev){
      int action=ev.getAction();
      if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE) {
        StatusBarNotification n=getNotificationFromEvent(ev);
        if (n != null) {
          updateSelection(n);
        }
      }
      return true;
    }
  }
;
  mNotificationsContainer.setColumnCount(COL_NUM);
  mNotificationsContainer.setOrientation(LinearLayout.HORIZONTAL);
  mNotificationsContainer.setPadding(0,mContext.getResources().getDimensionPixelSize(R.dimen.item_padding) * 2,0,0);
  LayoutTransition transitioner=new LayoutTransition();
  transitioner.enableTransitionType(LayoutTransition.CHANGING);
  transitioner.disableTransitionType(LayoutTransition.DISAPPEARING);
  transitioner.disableTransitionType(LayoutTransition.APPEARING);
  transitioner.disableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
  transitioner.disableTransitionType(LayoutTransition.CHANGE_APPEARING);
  mNotificationsContainer.setLayoutTransition(transitioner);
  mPeekView.addView(mNotificationsContainer);
  RelativeLayout.LayoutParams notificationsLayoutParams=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
  notificationsLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
  notificationsLayoutParams.addRule(RelativeLayout.BELOW,rootView.getId());
  mNotificationsContainer.setLayoutParams(notificationsLayoutParams);
}

Fixed version (ground truth):
public NotificationPeek(NotificationHub notificationHub,Context context){
  mNotificationHub=notificationHub;
  mContext=context;
  mSensorHandler=new SensorActivityHandler(context,this);
  mHandler=new Handler(Looper.getMainLooper());
  mWakeLockHandler=new Handler();
  mSensorHandler.registerScreenReceiver();
  mPartialWakeLockRunnable=new Runnable(){
    @Override public void run(){
      if (mPartialWakeLock.isHeld()) {
        if (mEventsRegistered) {
          if (DEBUG) {
            Log.d(TAG,"String_Node_Str");
          }
          tryUnregisterEventListeners();
          mEventsRegistered=false;
        }
        mPartialWakeLock.release();
      }
    }
  }
;
  mLockScreenRunnable=new Runnable(){
    @Override public void run(){
      if (mShowing) {
        if (DEBUG) {
          Log.d(TAG,"String_Node_Str");
        }
        mDevicePolicyManager.lockNow();
        if (mScreenWakeLock.isHeld()) {
          mScreenWakeLock.release();
        }
      }
    }
  }
;
  mDevicePolicyManager=(DevicePolicyManager)context.getSystemService(Context.DEVICE_POLICY_SERVICE);
  mKeyguardManager=(KeyguardManager)context.getSystemService(Context.KEYGUARD_SERVICE);
  mPowerManager=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
  mPartialWakeLock=mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,getClass().getSimpleName() + "String_Node_Str");
  mScreenWakeLock=mPowerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,getClass().getSimpleName() + "String_Node_Str");
  TelephonyManager telephonyManager=(TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE);
  telephonyManager.listen(new CallStateListener(),PhoneStateListener.LISTEN_CALL_STATE);
  mPeekView=new RelativeLayout(context){
    @Override public boolean onInterceptTouchEvent(    MotionEvent event){
      int action=event.getAction();
      if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE) {
        if (action == MotionEvent.ACTION_DOWN) {
          mHandler.removeCallbacksAndMessages(null);
        }
      }
      if (action == MotionEvent.ACTION_UP) {
        scheduleTasks();
      }
      return super.onInterceptTouchEvent(event);
    }
  }
;
  mPeekView.setOnTouchListener(new View.OnTouchListener(){
    @Override public boolean onTouch(    View v,    MotionEvent event){
      if (event.getAction() == MotionEvent.ACTION_UP) {
        dismissNotification();
      }
      return true;
    }
  }
);
  NotificationLayout rootView=new NotificationLayout(context);
  rootView.setOrientation(LinearLayout.VERTICAL);
  rootView.setNotificationPeek(NotificationPeek.this);
  rootView.setId(1);
  mPeekView.addView(rootView);
  RelativeLayout.LayoutParams rootLayoutParams=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
  rootLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT,RelativeLayout.TRUE);
  rootView.setLayoutParams(rootLayoutParams);
  mNotificationView=new LinearLayout(context);
  mNotificationView.setOrientation(LinearLayout.VERTICAL);
  rootView.addView(mNotificationView);
  mNotificationIcon=new ImageView(context);
  mNotificationIcon.setScaleType(ImageView.ScaleType.CENTER_CROP);
  mNotificationIcon.setOnTouchListener(PanelHelper.getHighlightTouchListener(Color.DKGRAY));
  mNotificationText=new TextView(context);
  Typeface textTypeface=Typeface.create("String_Node_Str",Typeface.NORMAL);
  mNotificationText.setTypeface(textTypeface);
  mNotificationText.setGravity(Gravity.CENTER);
  mNotificationText.setEllipsize(TextUtils.TruncateAt.END);
  mNotificationText.setSingleLine(true);
  mNotificationText.setPadding(0,mContext.getResources().getDimensionPixelSize(R.dimen.item_padding),0,0);
  mNotificationView.addView(mNotificationIcon);
  mNotificationView.addView(mNotificationText);
  int iconSize=mContext.getResources().getDimensionPixelSize(R.dimen.notification_icon_size);
  LinearLayout.LayoutParams linearLayoutParams=new LinearLayout.LayoutParams(iconSize,iconSize);
  linearLayoutParams.gravity=Gravity.CENTER_HORIZONTAL;
  mNotificationIcon.setLayoutParams(linearLayoutParams);
  linearLayoutParams=new LinearLayout.LayoutParams(mContext.getResources().getDimensionPixelSize(R.dimen.notification_text_width),LinearLayout.LayoutParams.WRAP_CONTENT);
  linearLayoutParams.gravity=Gravity.CENTER_HORIZONTAL;
  mNotificationText.setLayoutParams(linearLayoutParams);
  mNotificationsContainer=new GridLayout(context){
    @Override public boolean onTouchEvent(    MotionEvent ev){
      int action=ev.getAction();
      if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE) {
        StatusBarNotification n=getNotificationFromEvent(ev);
        if (n != null) {
          updateSelection(n);
        }
      }
      return true;
    }
  }
;
  mNotificationsContainer.setColumnCount(COL_NUM);
  mNotificationsContainer.setOrientation(LinearLayout.HORIZONTAL);
  mNotificationsContainer.setPadding(0,mContext.getResources().getDimensionPixelSize(R.dimen.item_padding) * 2,0,0);
  LayoutTransition transitioner=new LayoutTransition();
  transitioner.enableTransitionType(LayoutTransition.CHANGING);
  transitioner.disableTransitionType(LayoutTransition.DISAPPEARING);
  transitioner.disableTransitionType(LayoutTransition.APPEARING);
  transitioner.disableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
  transitioner.disableTransitionType(LayoutTransition.CHANGE_APPEARING);
  mNotificationsContainer.setLayoutTransition(transitioner);
  mPeekView.addView(mNotificationsContainer);
  RelativeLayout.LayoutParams notificationsLayoutParams=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
  notificationsLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
  notificationsLayoutParams.addRule(RelativeLayout.BELOW,rootView.getId());
  mNotificationsContainer.setLayoutParams(notificationsLayoutParams);
}