Program: 180918
Project: 180918
Buggy source:
@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  mHandler=new Handler(getMainLooper());
  mDPM=(DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
  ComponentName cn=(ComponentName)getIntent().getParcelableExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN);
  if (cn == null) {
    Log.w(TAG,"String_Node_Str" + getIntent().getAction());
    finish();
    return;
  }
  if (DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN.equals(getIntent().getAction())) {
    if (mDPM.isAdminActive(cn)) {
      setResult(Activity.RESULT_OK);
      finish();
      return;
    }
  }
  ActivityInfo ai;
  try {
    ai=getPackageManager().getReceiverInfo(cn,PackageManager.GET_META_DATA);
  }
 catch (  PackageManager.NameNotFoundException e) {
    Log.w(TAG,"String_Node_Str" + cn,e);
    finish();
    return;
  }
  ResolveInfo ri=new ResolveInfo();
  ri.activityInfo=ai;
  try {
    mDeviceAdmin=new DeviceAdminInfo(this,ri);
  }
 catch (  XmlPullParserException e) {
    Log.w(TAG,"String_Node_Str" + cn,e);
    finish();
    return;
  }
catch (  IOException e) {
    Log.w(TAG,"String_Node_Str" + cn,e);
    finish();
    return;
  }
  mAddMsgText=getIntent().getCharSequenceExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION);
  setContentView(R.layout.device_admin_add);
  mTitle=(TextView)findViewById(R.id.title);
  mAdminIcon=(ImageView)findViewById(R.id.admin_icon);
  mAdminName=(TextView)findViewById(R.id.admin_name);
  mAdminDescription=(TextView)findViewById(R.id.admin_description);
  mAddMsg=(TextView)findViewById(R.id.add_msg);
  mAdminWarning=(TextView)findViewById(R.id.admin_warning);
  mAdminPolicies=(ViewGroup)findViewById(R.id.admin_policies);
  mActionButton=(Button)findViewById(R.id.action_button);
  mActionButton.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      if (mAdding) {
        mDPM.setActiveAdmin(mDeviceAdmin.getComponent());
        setResult(Activity.RESULT_OK);
        finish();
      }
 else {
        mDPM.getRemoveWarning(mDeviceAdmin.getComponent(),new RemoteCallback(mHandler){
          @Override protected void onResult(          Bundle bundle){
            CharSequence msg=bundle != null ? bundle.getCharSequence(DeviceAdminReceiver.EXTRA_DISABLE_WARNING) : null;
            if (msg == null) {
              mDPM.removeActiveAdmin(mDeviceAdmin.getComponent());
              finish();
            }
 else {
              Bundle args=new Bundle();
              args.putCharSequence(DeviceAdminReceiver.EXTRA_DISABLE_WARNING,msg);
              showDialog(DIALOG_WARNING,args);
            }
          }
        }
);
      }
    }
  }
);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  mHandler=new Handler(getMainLooper());
  mDPM=(DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
  ComponentName cn=(ComponentName)getIntent().getParcelableExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN);
  if (cn == null) {
    Log.w(TAG,"String_Node_Str" + getIntent().getAction());
    finish();
    return;
  }
  if (DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN.equals(getIntent().getAction())) {
    if (mDPM.isAdminActive(cn)) {
      setResult(Activity.RESULT_OK);
      finish();
      return;
    }
  }
  ActivityInfo ai;
  try {
    ai=getPackageManager().getReceiverInfo(cn,PackageManager.GET_META_DATA);
  }
 catch (  PackageManager.NameNotFoundException e) {
    Log.w(TAG,"String_Node_Str" + cn,e);
    finish();
    return;
  }
  ResolveInfo ri=new ResolveInfo();
  ri.activityInfo=ai;
  try {
    mDeviceAdmin=new DeviceAdminInfo(this,ri);
  }
 catch (  XmlPullParserException e) {
    Log.w(TAG,"String_Node_Str" + cn,e);
    finish();
    return;
  }
catch (  IOException e) {
    Log.w(TAG,"String_Node_Str" + cn,e);
    finish();
    return;
  }
  mAddMsgText=getIntent().getCharSequenceExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION);
  setContentView(R.layout.device_admin_add);
  mTitle=(TextView)findViewById(R.id.title);
  mAdminIcon=(ImageView)findViewById(R.id.admin_icon);
  mAdminName=(TextView)findViewById(R.id.admin_name);
  mAdminDescription=(TextView)findViewById(R.id.admin_description);
  mAddMsg=(TextView)findViewById(R.id.add_msg);
  mAdminWarning=(TextView)findViewById(R.id.admin_warning);
  mAdminPolicies=(ViewGroup)findViewById(R.id.admin_policies);
  mActionButton=(Button)findViewById(R.id.action_button);
  mActionButton.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      if (mAdding) {
        try {
          mDPM.setActiveAdmin(mDeviceAdmin.getComponent());
          setResult(Activity.RESULT_OK);
        }
 catch (        RuntimeException e) {
          Log.w(TAG,"String_Node_Str" + mDeviceAdmin.getComponent(),e);
          if (mDPM.isAdminActive(mDeviceAdmin.getComponent())) {
            setResult(Activity.RESULT_OK);
          }
        }
        finish();
      }
 else {
        mDPM.getRemoveWarning(mDeviceAdmin.getComponent(),new RemoteCallback(mHandler){
          @Override protected void onResult(          Bundle bundle){
            CharSequence msg=bundle != null ? bundle.getCharSequence(DeviceAdminReceiver.EXTRA_DISABLE_WARNING) : null;
            if (msg == null) {
              mDPM.removeActiveAdmin(mDeviceAdmin.getComponent());
              finish();
            }
 else {
              Bundle args=new Bundle();
              args.putCharSequence(DeviceAdminReceiver.EXTRA_DISABLE_WARNING,msg);
              showDialog(DIALOG_WARNING,args);
            }
          }
        }
);
      }
    }
  }
);
}