Skip to content

Commit

Permalink
Merge pull request #66 from payatu/banditamit
Browse files Browse the repository at this point in the history
new Vulnerability Added-Receiver
  • Loading branch information
banditAmit authored Jul 19, 2024
2 parents 4860b56 + 242d08f commit 780bdf7
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 4 deletions.
68 changes: 64 additions & 4 deletions app/src/main/java/com/BugBazaar/ui/addresses/Address.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,56 @@
package com.BugBazaar.ui.addresses;

import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.database.sqlite.SQLiteDatabase;
import android.database.Cursor;
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.BugBazaar.R;
import com.BugBazaar.ui.BaseActivity;
import com.BugBazaar.ui.SessionManager;
import com.BugBazaar.ui.Signin;

import java.util.List;

public class Address extends BaseActivity {
private SessionManager sessionManager;
private EditText editTextNewAddrNickName;
private EditText editTextNewAddress;
private EditText searchBoxEditText;
private Button btnSaveAddress;
private Button btnSearchAddress;
private LinearLayout addressListLayout;
private SQLiteDatabase database;
private AddressDatabaseHelper dbHelper; // Declare dbHelper here
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_address);
addressListLayout = findViewById(R.id.addressListLayout);

///





///


//Toolbar title set
TextView toolbarTitle = findViewById(R.id.toolbarTitle);
Expand Down Expand Up @@ -68,9 +100,10 @@ public void onClick(View v) {
} else {
addressListLayout.removeAllViews();
// Insert data into the SQLite database
dbHelper.insertAddress(nickname, address);

sendacrosscomponents(nickname,address);
List<AddressItem> addresses = dbHelper.getAllAddresses();
Toast.makeText(getApplicationContext(), "Address has been saved Successfully", Toast.LENGTH_SHORT).show();


for (AddressItem item : addresses) {
View customAddressView = inflater.inflate(R.layout.item_address, null);
Expand Down Expand Up @@ -131,9 +164,36 @@ public void onClick(View v) {
}
});
}
//Code to handle backbutton

private void sendacrosscomponents(String nickname, String address) {
Intent intent = new Intent("bugbazaar.address_update");
intent.putExtra("nickname",nickname);
intent.putExtra("address",address);
sendImplicitBroadcast(this,intent);
}

private static void sendImplicitBroadcast(Context ctxt, Intent i) {
PackageManager pm=ctxt.getPackageManager();
List<ResolveInfo> matches=pm.queryBroadcastReceivers(i, 0);

for (ResolveInfo resolveInfo : matches) {
Intent explicit=new Intent(i);
ComponentName cn=
new ComponentName(resolveInfo.activityInfo.applicationInfo.packageName,
resolveInfo.activityInfo.name);

explicit.setComponent(cn);
Log.d("test", String.valueOf(cn));
ctxt.sendBroadcast(explicit);
}
}


//Code to handle backbutton
public void onBackButtonClick(View view) {
onBackPressed(); // Navigate back to the previous activity
}



}
15 changes: 15 additions & 0 deletions app/src/main/java/com/BugBazaar/ui/addresses/AddressReceiver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.BugBazaar.ui.addresses;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

public class AddressReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {

Toast.makeText(context.getApplicationContext(), "address hacker changes", Toast.LENGTH_SHORT).show();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ protected void onCreate(Bundle savedInstanceState) {
txtFinalCostOS = findViewById(R.id.txtFinalCostOS);
btnProceedPaymentOS = findViewById(R.id.btnProceedPaymentOS);


// Retrieve all addresses from the AddressDB database
addressDBHelper = new AddressDatabaseHelper(this);
addressList = addressDBHelper.getAllAddresses();
Expand Down

0 comments on commit 780bdf7

Please sign in to comment.