Skip to content

Commit

Permalink
Merge pull request #55 from frogobox/develop/piracy-checker
Browse files Browse the repository at this point in the history
DEVELOP :: Piracy checker original
  • Loading branch information
amirisback authored Jun 21, 2023
2 parents 265c9bb + 671aba9 commit e5e247a
Show file tree
Hide file tree
Showing 62 changed files with 5,128 additions and 48 deletions.
22 changes: 7 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,7 @@ fun Context.hasWriteExtStoragePermission(): Boolean {

```

### Added Function

<details>
<summary>Click for detail !!!</summary>
## Added Function

## FrogoLog

Expand Down Expand Up @@ -560,7 +557,7 @@ FLog.d(this@MainActivity)
- Full documentation
- Custom Layout Notification

### Screenshoot Sample
### Screen shot Sample

<table>
<tr>
Expand Down Expand Up @@ -750,16 +747,11 @@ FrogoNotification.Inject(this) // Intialize for Context

### For Documentation

- Method with
description [Click Here](https://github.com/amirisback/frogo-notification/blob/master/frogonotification/src/main/java/com/frogobox/frogonotification/IFrogoNotification.kt)
- Simple
Notification [Click Here](https://github.com/amirisback/frogo-notification/blob/master/app/src/main/java/com/frogobox/notification/simple/MainActivity.kt)
- With Action
Replay [Click Here](https://github.com/amirisback/frogo-notification/blob/master/app/src/main/java/com/frogobox/notification/custom/NotificationService.kt)
- With Inbox Style (
Stack) [Click Here](https://github.com/amirisback/frogo-notification/blob/master/app/src/main/java/com/frogobox/notification/stack/StackNotifActivity.kt)

</details>
- Method with description [Click Here](https://github.com/amirisback/frogo-notification/blob/master/frogonotification/src/main/java/com/frogobox/frogonotification/IFrogoNotification.kt)
- Simple Notification [Click Here](https://github.com/amirisback/frogo-notification/blob/master/app/src/main/java/com/frogobox/notification/simple/MainActivity.kt)
- With Action Replay [Click Here](https://github.com/amirisback/frogo-notification/blob/master/app/src/main/java/com/frogobox/notification/custom/NotificationService.kt)
- With Inbox Style (Stack) [Click Here](https://github.com/amirisback/frogo-notification/blob/master/app/src/main/java/com/frogobox/notification/stack/StackNotifActivity.kt)
- Piracy Checker [Click Here](https://github.com/javiersantos/PiracyChecker)

## Colaborator

Expand Down
26 changes: 24 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand All @@ -16,36 +16,57 @@
android:supportsRtl="true"
android:theme="@style/ThemeSdk"
tools:targetApi="tiramisu">

<activity
android:name=".viewpager.VPagerActivity"
android:exported="false" />

<activity
android:name=".news.NewsDetailActivity"
android:exported="false" />

<activity
android:name=".news.NewsActivity"
android:exported="false" />

<activity
android:name=".main.MainJavaActivity"
android:exported="false" />

<activity
android:name=".log.LogActivity"
android:exported="false" />

<activity
android:name=".notification.simple.ManualActivity"
android:exported="false" />

<activity
android:name=".notification.stack.StackNotifActivity"
android:exported="false" />

<activity
android:name=".notification.custom.ReplyActivity"
android:exported="false" />

<activity
android:name=".notification.custom.CustomNotifActivity"
android:exported="false" />

<activity
android:name=".notification.simple.MainNotifActivity"
android:exported="false" />

<activity
android:name=".piracy.KotlinActivity"
android:exported="false"
android:theme="@style/AppTheme.NoActionBar"/>

<activity
android:name=".piracy.PiracyMainActivity"
android:exported="false"
android:theme="@style/AppTheme.NoActionBar"/>

<activity
android:name=".main.MainActivity"
android:exported="true"
Expand All @@ -67,6 +88,7 @@
<service
android:name=".notification.custom.NotificationService"
android:exported="false" />

</application>

</manifest>
23 changes: 18 additions & 5 deletions app/src/main/java/com/frogobox/appsdk/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import com.frogobox.appsdk.databinding.ActivityMainBinding
import com.frogobox.appsdk.log.LogActivity
import com.frogobox.appsdk.news.NewsActivity
import com.frogobox.appsdk.notification.simple.MainNotifActivity
import com.frogobox.appsdk.piracy.KotlinActivity
import com.frogobox.appsdk.piracy.PiracyMainActivity
import com.frogobox.appsdk.viewpager.VPagerActivity
import com.frogobox.sdk.ext.preference
import com.frogobox.sdk.ext.showLogD
import com.frogobox.sdk.ext.startActivityExt
import com.frogobox.sdk.ui.FrogoAboutUsActivity
Expand Down Expand Up @@ -56,21 +57,33 @@ class MainActivity : CoreMainActivity<ActivityMainBinding>() {
}

btnWebviewFrogobox.setOnClickListener {
FrogoWebViewActivity.startActivityExt(this@MainActivity,
FrogoWebViewActivity.startActivityExt(
this@MainActivity,
"https://frogobox.github.io",
"Frogobox")
"Frogobox"
)
}

btnWebviewAmirisback.setOnClickListener {
FrogoWebViewActivity.startActivityExt(this@MainActivity,
FrogoWebViewActivity.startActivityExt(
this@MainActivity,
"https://amirisback.github.io",
"Faisal Amir")
"Faisal Amir"
)
}

btnAboutUs.setOnClickListener {
startActivityExt<FrogoAboutUsActivity>()
}

btnPiracyKotlin.setOnClickListener {
startActivityExt<KotlinActivity>()
}

btnPiracyMain.setOnClickListener {
startActivityExt<PiracyMainActivity>()
}

}
}

Expand Down
148 changes: 148 additions & 0 deletions app/src/main/java/com/frogobox/appsdk/piracy/KotlinActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package com.frogobox.appsdk.piracy

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AlertDialog
import com.frogobox.appsdk.R
import com.frogobox.appsdk.core.BaseActivity
import com.frogobox.appsdk.databinding.ActivityPiracyBinding
import com.frogobox.sdkutil.piracychecker.allow
import com.frogobox.sdkutil.piracychecker.callback
import com.frogobox.sdkutil.piracychecker.doNotAllow
import com.frogobox.sdkutil.piracychecker.enums.Display
import com.frogobox.sdkutil.piracychecker.enums.InstallerID
import com.frogobox.sdkutil.piracychecker.onError
import com.frogobox.sdkutil.piracychecker.piracyChecker
import com.frogobox.sdkutil.piracychecker.utils.apkSignatures

class KotlinActivity : BaseActivity<ActivityPiracyBinding>() {

private var piracyCheckerDisplay = Display.DIALOG

override fun setupViewBinding(): ActivityPiracyBinding {
return ActivityPiracyBinding.inflate(layoutInflater)
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setSupportActionBar(binding.toolbar)
setupUI()
}

private fun setupUI() {
binding.apply {

// Show APK signature
apkSignatures.forEach { Log.e("Signature", it) }

layoutContentMain.apply {

radioDisplay.setOnCheckedChangeListener { _, i ->
when (i) {
R.id.radio_dialog -> piracyCheckerDisplay = Display.DIALOG
R.id.radio_activity -> piracyCheckerDisplay = Display.ACTIVITY
}
}

cvReadSignature.setOnClickListener { readSignature() }
cvVerifySignature.setOnClickListener { verifySignature() }
cvVerifyInstallerId.setOnClickListener { verifyInstallerId() }
cvVerifyUnauthorizedApps.setOnClickListener { verifyUnauthorizedApps() }
cvVerifyStores.setOnClickListener { verifyStores() }
cvVerifyDebug.setOnClickListener { verifyDebug() }
cvVerifyEmulator.setOnClickListener { verifyEmulator() }
}

fabToGithub.setOnClickListener {
toGithub()
}
}
}

private fun toGithub() {
startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse("https://github.com/frogobox/frogo-sdk")
)
)
}

private fun verifySignature() {
piracyChecker {
display(piracyCheckerDisplay)
enableSigningCertificates("478yYkKAQF+KST8y4ATKvHkYibo=") // Wrong signature
//enableSigningCertificates("VHZs2aiTBiap/F+AYhYeppy0aF0=") // Right signature
}.start()
}

private fun readSignature() {
val dialogMessage = StringBuilder()
apkSignatures.forEach {
Log.e("Signature", it)
dialogMessage.append("* ").append(it).append("\n")
}
AlertDialog.Builder(this)
.setTitle("APK")
.setMessage(dialogMessage.toString())
.show()
}

private fun verifyInstallerId() {
piracyChecker {
display(piracyCheckerDisplay)
enableInstallerId(InstallerID.GOOGLE_PLAY)
}.start()
}

private fun verifyUnauthorizedApps() {
piracyChecker {
display(piracyCheckerDisplay)
enableUnauthorizedAppsCheck()
//blockIfUnauthorizedAppUninstalled("license_checker", "block")
}.start()
}

private fun verifyStores() {
piracyChecker {
display(piracyCheckerDisplay)
enableStoresCheck()
}.start()
}

private fun verifyDebug() {
piracyChecker {
display(piracyCheckerDisplay)
enableDebugCheck()
callback {
allow {
// Do something when the user is allowed to use the app
}
doNotAllow { piracyCheckerError, pirateApp ->
// You can either do something specific when the user is not allowed to use the app
// Or manage the error, using the 'error' parameter, yourself (Check errors at {@link PiracyCheckerError}).

// Additionally, if you enabled the check of pirate apps and/or third-party stores, the 'app' param
// is the app that has been detected on device. App can be null, and when null, it means no pirate app or store was found,
// or you disabled the check for those apps.
// This allows you to let users know the possible reasons why license is been invalid.
}
onError { error ->
// This method is not required to be implemented/overriden but...
// You can either do something specific when an error occurs while checking the license,
// Or manage the error, using the 'error' parameter, yourself (Check errors at {@link PiracyCheckerError}).
}
}
}.start()
}

private fun verifyEmulator() {
piracyChecker {
display(piracyCheckerDisplay)
enableEmulatorCheck(false)
}.start()
}

}
Loading

0 comments on commit e5e247a

Please sign in to comment.