Program: 79815
Project: 79815
Buggy source:
public NotificationPeek(NotificationHub notificationHub,Context context){
  mNotificationHub=notificationHub;
  mContext=context;
  mNotificationHelper=new NotificationHelper(context,this);
  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_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,getClass().getSimpleName() + "String_Node_Str");
  sPeekView=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);
    }
  }
;
  sPeekView.setOnTouchListener(UnlockGesture.createTouchListener(mContext,new UnlockGesture.UnlockGestureCallback(){
    @Override public void onUnlocked(){
      dismissNotification();
    }
  }
));
  NotificationLayout rootView=new NotificationLayout(context);
  rootView.setOrientation(LinearLayout.VERTICAL);
  rootView.setNotificationPeek(NotificationPeek.this);
  rootView.setId(NOTIFICATION_LAYOUT_ID);
  sPeekView.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);
  mNotificationView.setId(NOTIFICATION_VIEW_ID);
  rootView.addView(mNotificationView);
  mNotificationIcon=new ImageView(context);
  mNotificationIcon.setId(NOTIFICATION_ICON_ID);
  mNotificationIcon.setScaleType(ImageView.ScaleType.CENTER_CROP);
  mNotificationIcon.setOnTouchListener(NotificationHelper.getHighlightTouchListener(Color.DKGRAY));
  mNotificationText=new TextView(context);
  mNotificationText.setId(NOTIFICATION_TEXT_ID);
  Typeface typeface=Typeface.create("String_Node_Str",Typeface.NORMAL);
  mNotificationText.setTypeface(typeface);
  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);
  rootView.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.setId(NOTIFICATION_CONTAINER_ID);
  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);
  sPeekView.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);
  updateBackgroundImageView();
}

Fixed version (ground truth):
public NotificationPeek(NotificationHub notificationHub,Context context){
  mNotificationHub=notificationHub;
  mContext=context;
  mNotificationHelper=new NotificationHelper(context,this);
  mWallpaperFactory=new WallpaperFactory(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_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,getClass().getSimpleName() + "String_Node_Str");
  sPeekView=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);
    }
  }
;
  sPeekView.setOnTouchListener(UnlockGesture.createTouchListener(mContext,new UnlockGesture.UnlockGestureCallback(){
    @Override public void onUnlocked(){
      dismissNotification();
    }
  }
));
  NotificationLayout rootView=new NotificationLayout(context);
  rootView.setOrientation(LinearLayout.VERTICAL);
  rootView.setNotificationPeek(NotificationPeek.this);
  rootView.setId(NOTIFICATION_LAYOUT_ID);
  sPeekView.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);
  mNotificationView.setId(NOTIFICATION_VIEW_ID);
  rootView.addView(mNotificationView);
  mNotificationIcon=new ImageView(context);
  mNotificationIcon.setId(NOTIFICATION_ICON_ID);
  mNotificationIcon.setScaleType(ImageView.ScaleType.CENTER_CROP);
  mNotificationIcon.setOnTouchListener(NotificationHelper.getHighlightTouchListener(Color.DKGRAY));
  mNotificationText=new TextView(context);
  mNotificationText.setId(NOTIFICATION_TEXT_ID);
  Typeface typeface=Typeface.create("String_Node_Str",Typeface.NORMAL);
  mNotificationText.setTypeface(typeface);
  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);
  rootView.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.setId(NOTIFICATION_CONTAINER_ID);
  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);
  sPeekView.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);
  updateBackgroundImageView();
}