Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new Vulnerability Added-Receiver #66

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading