Commit 6e869802 authored by narinder Rana's avatar narinder Rana
Browse files

Toast message test

parent ebbe52cc
...@@ -19,6 +19,8 @@ package foundation.e.apps.application.model ...@@ -19,6 +19,8 @@ package foundation.e.apps.application.model
import android.content.Context import android.content.Context
import android.os.AsyncTask import android.os.AsyncTask
import android.widget.Toast
import foundation.e.apps.R
import foundation.e.apps.application.model.data.FullData import foundation.e.apps.application.model.data.FullData
import foundation.e.apps.utils.Constants import foundation.e.apps.utils.Constants
import org.bouncycastle.jce.provider.BouncyCastleProvider import org.bouncycastle.jce.provider.BouncyCastleProvider
...@@ -53,6 +55,7 @@ class IntegrityVerificationTask( ...@@ -53,6 +55,7 @@ class IntegrityVerificationTask(
} else { } else {
Security.addProvider(BouncyCastleProvider()) Security.addProvider(BouncyCastleProvider())
verifyAPKSignature( verifyAPKSignature(
context[0],
BufferedInputStream(FileInputStream( BufferedInputStream(FileInputStream(
applicationInfo.getApkFile(context[0], applicationInfo.getApkFile(context[0],
fullData.basicData).absolutePath)), fullData.basicData).absolutePath)),
...@@ -88,6 +91,7 @@ class IntegrityVerificationTask( ...@@ -88,6 +91,7 @@ class IntegrityVerificationTask(
} }
private fun verifyAPKSignature( private fun verifyAPKSignature(
context: Context,
apkInputStream: BufferedInputStream, apkInputStream: BufferedInputStream,
apkSignatureInputStream: InputStream, apkSignatureInputStream: InputStream,
publicKeyInputStream: InputStream): Boolean { publicKeyInputStream: InputStream): Boolean {
...@@ -125,12 +129,12 @@ class IntegrityVerificationTask( ...@@ -125,12 +129,12 @@ class IntegrityVerificationTask(
apkInputStream.close() apkInputStream.close()
apkSignatureInputStream.close() apkSignatureInputStream.close()
publicKeyInputStream.close() publicKeyInputStream.close()
Toast.makeText(context, R.string.Signature_verification_failed, Toast.LENGTH_LONG).show();
return signature.verify() return signature.verify()
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
//Toast message if we want to show message to user //Toast message if we want to show message to user
Toast.makeText(context, R.string.Signature_verification_failed, Toast.LENGTH_LONG).show();
} }
return false; return false;
......
...@@ -184,4 +184,9 @@ ...@@ -184,4 +184,9 @@
<string name="microg_not_installed">Not Installed</string> <string name="microg_not_installed">Not Installed</string>
<string name="microg_installed">Installed</string> <string name="microg_installed">Installed</string>
<string name="Signature_verification_failed">Signature verification failed, aborting install</string>
</resources> </resources>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment