From 913778d62879929670eb99c9d850c1b0e0c23233 Mon Sep 17 00:00:00 2001 From: BanditAmit Date: Fri, 19 Jul 2024 14:42:18 +0530 Subject: [PATCH] new Vulnerability Added-Receiver --- .../com/BugBazaar/ui/addresses/Address.java | 47 +++++++++++++++++-- .../ui/addresses/AddressReceiver.java | 15 ++++++ .../BugBazaar/ui/payment/OrderSummary.java | 1 + 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/com/BugBazaar/ui/addresses/AddressReceiver.java diff --git a/app/src/main/java/com/BugBazaar/ui/addresses/Address.java b/app/src/main/java/com/BugBazaar/ui/addresses/Address.java index 42b659d..597afd8 100644 --- a/app/src/main/java/com/BugBazaar/ui/addresses/Address.java +++ b/app/src/main/java/com/BugBazaar/ui/addresses/Address.java @@ -1,5 +1,9 @@ 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; @@ -39,6 +43,15 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_address); addressListLayout = findViewById(R.id.addressListLayout); + /// + + + + + + /// + + //Toolbar title set TextView toolbarTitle = findViewById(R.id.toolbarTitle); toolbarTitle.setText("Addresses"); @@ -87,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 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); @@ -150,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 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 } + + } diff --git a/app/src/main/java/com/BugBazaar/ui/addresses/AddressReceiver.java b/app/src/main/java/com/BugBazaar/ui/addresses/AddressReceiver.java new file mode 100644 index 0000000..5dd9819 --- /dev/null +++ b/app/src/main/java/com/BugBazaar/ui/addresses/AddressReceiver.java @@ -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(); + } +} diff --git a/app/src/main/java/com/BugBazaar/ui/payment/OrderSummary.java b/app/src/main/java/com/BugBazaar/ui/payment/OrderSummary.java index b7c7f8d..b211d0e 100644 --- a/app/src/main/java/com/BugBazaar/ui/payment/OrderSummary.java +++ b/app/src/main/java/com/BugBazaar/ui/payment/OrderSummary.java @@ -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();