-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ee281b
commit a498b17
Showing
34 changed files
with
1,705 additions
and
1,561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
protect/src/main/java/com/webileapps/safeguard/AppActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.webileapps.safeguard; | ||
|
||
import android.content.Context; | ||
import android.os.Bundle; | ||
import android.view.MotionEvent; | ||
import android.view.WindowManager; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import android.widget.Toast; | ||
|
||
public class AppActivity extends AppCompatActivity { | ||
private static Context context; | ||
|
||
public static Context getContext() { | ||
return context; | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
// Tapjacking Prevention | ||
getWindow().setFlags( | ||
WindowManager.LayoutParams.FLAG_SECURE, | ||
WindowManager.LayoutParams.FLAG_SECURE | ||
); | ||
context = this; | ||
} | ||
|
||
@Override | ||
public boolean dispatchTouchEvent(MotionEvent event) { | ||
if ((event.getFlags() & MotionEvent.FLAG_WINDOW_IS_OBSCURED) != 0) { | ||
// Alert user and block the touch event | ||
Toast.makeText(this, getString(R.string.tap_jacking_alert), Toast.LENGTH_SHORT).show(); | ||
return false; // Block event processing | ||
} | ||
return super.dispatchTouchEvent(event); // Allow normal event processing | ||
} | ||
} |
36 changes: 0 additions & 36 deletions
36
protect/src/main/java/com/webileapps/safeguard/AppActivity.kt
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
protect/src/main/java/com/webileapps/safeguard/AppLifecycleObserver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.webileapps.safeguard; | ||
|
||
import android.content.Context; | ||
import android.content.pm.PackageInfo; | ||
import android.content.pm.PackageManager; | ||
import android.util.Log; | ||
import androidx.lifecycle.DefaultLifecycleObserver; | ||
import androidx.lifecycle.LifecycleOwner; | ||
import androidx.annotation.NonNull; | ||
|
||
public class AppLifecycleObserver implements DefaultLifecycleObserver { | ||
private final Context context; | ||
private SecurityChecker securityChecker; | ||
|
||
public AppLifecycleObserver(Context context) { | ||
this.context = context; | ||
} | ||
|
||
@Override | ||
public void onStart(@NonNull LifecycleOwner owner) { | ||
Log.e("APP>>>", "App is in Foreground"); | ||
// Perform security checks in sequence | ||
performSecurityChecks(); | ||
} | ||
|
||
private void performSecurityChecks() { | ||
securityChecker = SecurityConfigManager.getSecurityChecker(); | ||
securityChecker.runSecurityChecks(); | ||
} | ||
|
||
@Override | ||
public void onStop(@NonNull LifecycleOwner owner) { | ||
Log.e("APP>>>", "App is in Background"); | ||
if (securityChecker != null) { | ||
securityChecker.cleanup(); | ||
} | ||
} | ||
|
||
private void detectOverlayApps(Context context) { | ||
PackageManager pm = context.getPackageManager(); | ||
for (PackageInfo packageInfo : pm.getInstalledPackages(PackageManager.GET_PERMISSIONS)) { | ||
String[] requestedPermissions = packageInfo.requestedPermissions; | ||
if (requestedPermissions != null) { | ||
for (String permission : requestedPermissions) { | ||
if ("android.permission.SYSTEM_ALERT_WINDOW".equals(permission)) { | ||
// Log or handle apps with SYSTEM_ALERT_WINDOW permission | ||
Log.d("OverlayDetection", "App using SYSTEM_ALERT_WINDOW: " + packageInfo.packageName); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
47 changes: 0 additions & 47 deletions
47
protect/src/main/java/com/webileapps/safeguard/AppLifecycleObserver.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.