- [giveResult] not sending data
param if null
- [Utils] `getApplicationSignature`: returning `SHA-256` signature instead of `SHA` - [Utils] `jsonToBundle`: changed approach
This commit is contained in:
parent
61ca0ffb41
commit
07f81ea602
3 changed files with 45 additions and 32 deletions
|
@ -1,17 +1,26 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Dart SDK">
|
||||
<CLASSES>
|
||||
<root url="file:///home/harsh/flutter/flutter/bin/cache/dart-sdk/lib/async" />
|
||||
<root url="file:///home/harsh/flutter/flutter/bin/cache/dart-sdk/lib/collection" />
|
||||
<root url="file:///home/harsh/flutter/flutter/bin/cache/dart-sdk/lib/convert" />
|
||||
<root url="file:///home/harsh/flutter/flutter/bin/cache/dart-sdk/lib/core" />
|
||||
<root url="file:///home/harsh/flutter/flutter/bin/cache/dart-sdk/lib/developer" />
|
||||
<root url="file:///home/harsh/flutter/flutter/bin/cache/dart-sdk/lib/html" />
|
||||
<root url="file:///home/harsh/flutter/flutter/bin/cache/dart-sdk/lib/io" />
|
||||
<root url="file:///home/harsh/flutter/flutter/bin/cache/dart-sdk/lib/isolate" />
|
||||
<root url="file:///home/harsh/flutter/flutter/bin/cache/dart-sdk/lib/math" />
|
||||
<root url="file:///home/harsh/flutter/flutter/bin/cache/dart-sdk/lib/mirrors" />
|
||||
<root url="file:///home/harsh/flutter/flutter/bin/cache/dart-sdk/lib/typed_data" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/async" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/cli" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/collection" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/convert" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/core" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/developer" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/ffi" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/html" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/indexed_db" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/io" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/isolate" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/js" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/js_util" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/math" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/mirrors" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/svg" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/typed_data" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/web_audio" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/web_gl" />
|
||||
<root url="file://$USER_HOME$/flutter/bin/cache/dart-sdk/lib/web_sql" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
|
|
|
@ -15,24 +15,27 @@ import java.security.MessageDigest
|
|||
|
||||
fun jsonToBundle(json: JSONObject): Bundle {
|
||||
val bundle = Bundle()
|
||||
json.keys().forEach {
|
||||
val k = it
|
||||
val v = json.get(k)
|
||||
when (v) {
|
||||
is Byte -> bundle.putByte(k, v)
|
||||
is ByteArray -> bundle.putByteArray(k, v)
|
||||
is Char -> bundle.putChar(k, v)
|
||||
is CharArray -> bundle.putCharArray(k, v)
|
||||
is CharSequence -> bundle.putCharSequence(k, v)
|
||||
is Float -> bundle.putFloat(k, v)
|
||||
is FloatArray -> bundle.putFloatArray(k, v)
|
||||
is Parcelable -> bundle.putParcelable(k, v)
|
||||
is Short -> bundle.putShort(k, v)
|
||||
is ShortArray -> bundle.putShortArray(k, v)
|
||||
else -> throw IllegalArgumentException("$v is of a type that is not currently supported")
|
||||
try {
|
||||
val iterator: Iterator<String> = json.keys()
|
||||
while (iterator.hasNext()) {
|
||||
val key = iterator.next()
|
||||
val value: Any = json.get(key)
|
||||
when (value.javaClass.getSimpleName()) {
|
||||
"String" -> bundle.putString(key, value as String)
|
||||
"Integer" -> bundle.putInt(key, value as Int)
|
||||
"Long" -> bundle.putLong(key, value as Long)
|
||||
"Boolean" -> bundle.putBoolean(key, value as Boolean)
|
||||
"JSONObject" -> bundle.putBundle(key, jsonToBundle(value as JSONObject))
|
||||
"Float" -> bundle.putFloat(key, value as Float)
|
||||
"Double" -> bundle.putDouble(key, value as Double)
|
||||
else -> bundle.putString(key, value.toString())
|
||||
}
|
||||
}
|
||||
return bundle;
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return bundle
|
||||
|
||||
}
|
||||
|
||||
fun jsonToIntent(json: JSONObject): Intent = Intent().apply {
|
||||
|
@ -125,14 +128,14 @@ fun getApplicationSignature(context: Context, packageName: String): List<String>
|
|||
signatureList = if (sig.hasMultipleSigners()) {
|
||||
// Send all with apkContentsSigners
|
||||
sig.apkContentsSigners.map {
|
||||
val digest = MessageDigest.getInstance("SHA")
|
||||
val digest = MessageDigest.getInstance("SHA-256")
|
||||
digest.update(it.toByteArray())
|
||||
bytesToHex(digest.digest())
|
||||
}
|
||||
} else {
|
||||
// Send one with signingCertificateHistory
|
||||
sig.signingCertificateHistory.map {
|
||||
val digest = MessageDigest.getInstance("SHA")
|
||||
val digest = MessageDigest.getInstance("SHA-256")
|
||||
digest.update(it.toByteArray())
|
||||
bytesToHex(digest.digest())
|
||||
}
|
||||
|
@ -140,7 +143,7 @@ fun getApplicationSignature(context: Context, packageName: String): List<String>
|
|||
} else {
|
||||
val sig = context.packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES).signatures
|
||||
signatureList = sig.map {
|
||||
val digest = MessageDigest.getInstance("SHA")
|
||||
val digest = MessageDigest.getInstance("SHA-256")
|
||||
digest.update(it.toByteArray())
|
||||
bytesToHex(digest.digest())
|
||||
}
|
||||
|
|
|
@ -69,10 +69,11 @@ class ReceiveIntent {
|
|||
.receiveBroadcastStream()
|
||||
.map<ReceivedIntent?>((event) => ReceivedIntent.fromMap(event as Map?));
|
||||
|
||||
static Future<void> giveResult(int resultCode, {Map? data, bool shouldFinish: false}) async {
|
||||
static Future<void> giveResult(int resultCode,
|
||||
{Map<String, dynamic?>? data, bool shouldFinish: false}) async {
|
||||
await _methodChannel.invokeMethod('giveResult', <String, dynamic>{
|
||||
"resultCode": resultCode,
|
||||
"data": json.encode(data),
|
||||
if (data != null) "data": json.encode(data),
|
||||
"shouldFinish": shouldFinish,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue