Skip to content
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
27 changes: 23 additions & 4 deletions Packages/Sequence-Unity/Plugins/Android/AndroidKeyBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,28 @@ private AndroidKeyBridge()

public void init(Context context)
{
if (context == null) {
Log.w("AndroidKeyBridge", "Provided context is null, trying to get UnityPlayer.currentActivity");
try {
context = com.unity3d.player.UnityPlayer.currentActivity;
} catch (Exception e) {
Log.e("AndroidKeyBridge", "Failed to get UnityPlayer.currentActivity", e);
}
}

if (context == null) {
Log.e("AndroidKeyBridge", "Context is still null, cannot initialize AndroidKeyBridge");
return;
}

this.context = context;

if (masterKey == null) {
if (masterKey == null || sharedPreferences == null) {

try {
masterKey = new MasterKey.Builder(context)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build();

sharedPreferences = EncryptedSharedPreferences.create(
context,
"secret_shared_prefs",
Expand All @@ -42,9 +55,9 @@ public void init(Context context)
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
);
} catch (GeneralSecurityException e){
Log.d("Exception", e.getMessage());
Log.d("AndroidKeyBridge", "Encountered error when initializing AndroidKeyBridge: " + e.getMessage());
} catch (IOException e){
Log.d("Exception", e.getMessage());
Log.d("AndroidKeyBridge", "Encountered error when initializing AndroidKeyBridge: " + e.getMessage());
}
}
}
Expand Down Expand Up @@ -74,11 +87,17 @@ public static String GetKeychainValue(String key)

private void RunSaveKeychainValue(String key, String value)
{
if (masterKey == null || sharedPreferences == null) {
init(context);
}
sharedPreferences.edit().putString(key, value).apply();
}

private String RunGetKeychainValue(String key)
{
if (masterKey == null || sharedPreferences == null) {
init(context);
}
return sharedPreferences.getString(key, "");
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Packages/Sequence-Unity/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xyz.0xsequence.waas-unity",
"version": "4.0.4",
"version": "4.0.5",
"displayName": "Sequence Embedded Wallet SDK",
"description": "A Unity SDK for Sequence APIs",
"unity": "2021.3",
Expand Down