Skip to content

Commit

Permalink
new Vulnerability Added-Receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
banditAmit committed Jul 19, 2024
1 parent fb0da32 commit 913778d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
47 changes: 44 additions & 3 deletions app/src/main/java/com/BugBazaar/ui/addresses/Address.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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<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 @@ -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<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 913778d

Please sign in to comment.