Loading play-services-core/src/main/kotlin/org/microg/gms/ui/SafetyNetRecentAttestationPreferencesFragment.kt +12 −18 Original line number Diff line number Diff line Loading @@ -49,9 +49,10 @@ class SafetyNetRecentAttestationPreferencesFragment : PreferenceFragmentCompat() } } if(snetSummary.responseStatus==null){ status.summary = "Not completed yet" }else if(snetSummary.responseStatus!!.isSuccess) { val snetResponseStatus = snetSummary.responseStatus if (snetResponseStatus == null) { status.summary = getString(R.string.pref_safetynet_test_not_completed) } else if (snetResponseStatus.isSuccess) { try { val json = JSONObject(snetSummary.responseData!!) evalType.summary = json.getString("evaluationType") Loading @@ -61,23 +62,16 @@ class SafetyNetRecentAttestationPreferencesFragment : PreferenceFragmentCompat() val ctsProfileMatch = json.getBoolean("ctsProfileMatch") status.summary = when { basicIntegrity && ctsProfileMatch -> { "Integrity and CTS passed" basicIntegrity && ctsProfileMatch -> getString(R.string.pref_safetynet_test_integrity_cts_passed) basicIntegrity -> getString(R.string.pref_safetynet_test_cts_failed) else -> getString(R.string.pref_safetynet_test_integrity_failed) } basicIntegrity -> { "CTS failed" } else -> { "Integrity failed" } } } catch (e: JSONException) { e.printStackTrace() status.summary = "Invalid JSON" status.summary = getString(R.string.pref_safetynet_test_invalid_json) } } else { status.summary = snetSummary.responseStatus!!.statusMessage status.summary = snetResponseStatus.statusMessage } copyResult.setOnPreferenceClickListener { Loading @@ -85,7 +79,7 @@ class SafetyNetRecentAttestationPreferencesFragment : PreferenceFragmentCompat() val clip = ClipData.newPlainText("JSON JWS data", snetSummary.responseData) clipboard.setPrimaryClip(clip) Toast.makeText(context, "Copied to clipboard !", Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.pref_safetynet_recent_copied, Toast.LENGTH_SHORT).show() true } Loading play-services-core/src/main/kotlin/org/microg/gms/ui/SafetyNetRecentRecaptchaPreferencesFragment.kt +5 −5 Original line number Diff line number Diff line Loading @@ -30,13 +30,13 @@ class SafetyNetRecentRecaptchaPreferencesFragment : PreferenceFragmentCompat() { time.summary = DateUtils.getRelativeDateTimeString(context, snetSummary.timestamp, DateUtils.MINUTE_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, DateUtils.FORMAT_SHOW_TIME) if(snetSummary.responseStatus==null){ status.summary = "Not completed yet" val snetResponseStatus = snetSummary.responseStatus if (snetResponseStatus == null) { status.summary = getString(R.string.pref_safetynet_test_not_completed) } else { status.summary = snetSummary.responseStatus!!.statusMessage status.summary = snetResponseStatus.statusMessage token.summary = snetSummary.responseData } } } No newline at end of file play-services-core/src/main/kotlin/org/microg/gms/ui/SafetyNetUtils.kt +9 −3 Original line number Diff line number Diff line Loading @@ -18,8 +18,14 @@ import org.microg.gms.safetynet.SafetyNetRequestType fun formatSummaryForSafetyNetResult(context: Context, result: String?, status: Status?, type: SafetyNetRequestType): Pair<String, Drawable?> { when (type) { SafetyNetRequestType.ATTESTATION -> { if (status?.isSuccess != true) return context.getString(R.string.pref_test_summary_failed, status?.statusMessage) to ContextCompat.getDrawable(context, R.drawable.ic_circle_error) if (result == null) return context.getString(R.string.pref_test_summary_failed, "No result") to ContextCompat.getDrawable(context, R.drawable.ic_circle_warn) if (status?.isSuccess != true) { return context.getString(R.string.pref_test_summary_failed, status?.statusMessage) to ContextCompat.getDrawable(context, R.drawable.ic_circle_error) } if (result == null) { return context.getString(R.string.pref_test_summary_failed, context.getString(R.string.pref_safetynet_test_no_result)) to ContextCompat.getDrawable(context, R.drawable.ic_circle_warn) } val (basicIntegrity, ctsProfileMatch, advice) = try { JSONObject(result).let { Triple( Loading @@ -32,7 +38,7 @@ fun formatSummaryForSafetyNetResult(context: Context, result: String?, status: S Log.w(TAG, e) return context.getString( R.string.pref_test_summary_failed, "Invalid JSON" context.getString(R.string.pref_safetynet_test_invalid_json) ) to ContextCompat.getDrawable(context, R.drawable.ic_circle_error) } val adviceText = if (advice == "") "" else "\n" + advice.split(",").map { Loading play-services-core/src/main/res/values/strings.xml +9 −0 Original line number Diff line number Diff line Loading @@ -195,6 +195,8 @@ This can take a couple of minutes."</string> <string name="pref_device_registration_import_custom_profile_summary">Import device profile from file</string> <string name="pref_device_registration_select_profile_title">Select profile</string> <string name="pref_device_registration_device_profile_category">Device profile</string> <string name="pref_safetynet_recent_uses">Recent uses</string> <string name="pref_safetynet_recent_copy_json">Copy JSON JWS data</string> <string name="pref_safetynet_recent_advice">Advice</string> <string name="pref_safetynet_recent_eval_type">Evaluation type</string> Loading @@ -206,5 +208,12 @@ This can take a couple of minutes."</string> <string name="pref_safetynet_recent_request_type">Request type</string> <string name="pref_safetynet_recent_cat_basic">Basic data</string> <string name="pref_safetynet_recent_token">Token</string> <string name="pref_safetynet_recent_copied">Copied to clipboard!</string> <string name="pref_safetynet_test_integrity_cts_passed">Integrity and CTS passed</string> <string name="pref_safetynet_test_cts_failed">CTS failed</string> <string name="pref_safetynet_test_integrity_failed">Integrity failed</string> <string name="pref_safetynet_test_not_completed">Not completed yet</string> <string name="pref_safetynet_test_no_result">No result</string> <string name="pref_safetynet_test_invalid_json">Invalid JSON</string> </resources> play-services-core/src/main/res/xml/preferences_safetynet_app.xml +1 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ xmlns:tools="http://schemas.android.com/tools"> <PreferenceCategory android:key="prefcat_safetynet_recent_list" android:title="Recent uses"> android:title="@string/pref_safetynet_recent_uses"> <Preference android:enabled="false" android:key="pref_safetynet_recent_none" Loading Loading
play-services-core/src/main/kotlin/org/microg/gms/ui/SafetyNetRecentAttestationPreferencesFragment.kt +12 −18 Original line number Diff line number Diff line Loading @@ -49,9 +49,10 @@ class SafetyNetRecentAttestationPreferencesFragment : PreferenceFragmentCompat() } } if(snetSummary.responseStatus==null){ status.summary = "Not completed yet" }else if(snetSummary.responseStatus!!.isSuccess) { val snetResponseStatus = snetSummary.responseStatus if (snetResponseStatus == null) { status.summary = getString(R.string.pref_safetynet_test_not_completed) } else if (snetResponseStatus.isSuccess) { try { val json = JSONObject(snetSummary.responseData!!) evalType.summary = json.getString("evaluationType") Loading @@ -61,23 +62,16 @@ class SafetyNetRecentAttestationPreferencesFragment : PreferenceFragmentCompat() val ctsProfileMatch = json.getBoolean("ctsProfileMatch") status.summary = when { basicIntegrity && ctsProfileMatch -> { "Integrity and CTS passed" basicIntegrity && ctsProfileMatch -> getString(R.string.pref_safetynet_test_integrity_cts_passed) basicIntegrity -> getString(R.string.pref_safetynet_test_cts_failed) else -> getString(R.string.pref_safetynet_test_integrity_failed) } basicIntegrity -> { "CTS failed" } else -> { "Integrity failed" } } } catch (e: JSONException) { e.printStackTrace() status.summary = "Invalid JSON" status.summary = getString(R.string.pref_safetynet_test_invalid_json) } } else { status.summary = snetSummary.responseStatus!!.statusMessage status.summary = snetResponseStatus.statusMessage } copyResult.setOnPreferenceClickListener { Loading @@ -85,7 +79,7 @@ class SafetyNetRecentAttestationPreferencesFragment : PreferenceFragmentCompat() val clip = ClipData.newPlainText("JSON JWS data", snetSummary.responseData) clipboard.setPrimaryClip(clip) Toast.makeText(context, "Copied to clipboard !", Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.pref_safetynet_recent_copied, Toast.LENGTH_SHORT).show() true } Loading
play-services-core/src/main/kotlin/org/microg/gms/ui/SafetyNetRecentRecaptchaPreferencesFragment.kt +5 −5 Original line number Diff line number Diff line Loading @@ -30,13 +30,13 @@ class SafetyNetRecentRecaptchaPreferencesFragment : PreferenceFragmentCompat() { time.summary = DateUtils.getRelativeDateTimeString(context, snetSummary.timestamp, DateUtils.MINUTE_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, DateUtils.FORMAT_SHOW_TIME) if(snetSummary.responseStatus==null){ status.summary = "Not completed yet" val snetResponseStatus = snetSummary.responseStatus if (snetResponseStatus == null) { status.summary = getString(R.string.pref_safetynet_test_not_completed) } else { status.summary = snetSummary.responseStatus!!.statusMessage status.summary = snetResponseStatus.statusMessage token.summary = snetSummary.responseData } } } No newline at end of file
play-services-core/src/main/kotlin/org/microg/gms/ui/SafetyNetUtils.kt +9 −3 Original line number Diff line number Diff line Loading @@ -18,8 +18,14 @@ import org.microg.gms.safetynet.SafetyNetRequestType fun formatSummaryForSafetyNetResult(context: Context, result: String?, status: Status?, type: SafetyNetRequestType): Pair<String, Drawable?> { when (type) { SafetyNetRequestType.ATTESTATION -> { if (status?.isSuccess != true) return context.getString(R.string.pref_test_summary_failed, status?.statusMessage) to ContextCompat.getDrawable(context, R.drawable.ic_circle_error) if (result == null) return context.getString(R.string.pref_test_summary_failed, "No result") to ContextCompat.getDrawable(context, R.drawable.ic_circle_warn) if (status?.isSuccess != true) { return context.getString(R.string.pref_test_summary_failed, status?.statusMessage) to ContextCompat.getDrawable(context, R.drawable.ic_circle_error) } if (result == null) { return context.getString(R.string.pref_test_summary_failed, context.getString(R.string.pref_safetynet_test_no_result)) to ContextCompat.getDrawable(context, R.drawable.ic_circle_warn) } val (basicIntegrity, ctsProfileMatch, advice) = try { JSONObject(result).let { Triple( Loading @@ -32,7 +38,7 @@ fun formatSummaryForSafetyNetResult(context: Context, result: String?, status: S Log.w(TAG, e) return context.getString( R.string.pref_test_summary_failed, "Invalid JSON" context.getString(R.string.pref_safetynet_test_invalid_json) ) to ContextCompat.getDrawable(context, R.drawable.ic_circle_error) } val adviceText = if (advice == "") "" else "\n" + advice.split(",").map { Loading
play-services-core/src/main/res/values/strings.xml +9 −0 Original line number Diff line number Diff line Loading @@ -195,6 +195,8 @@ This can take a couple of minutes."</string> <string name="pref_device_registration_import_custom_profile_summary">Import device profile from file</string> <string name="pref_device_registration_select_profile_title">Select profile</string> <string name="pref_device_registration_device_profile_category">Device profile</string> <string name="pref_safetynet_recent_uses">Recent uses</string> <string name="pref_safetynet_recent_copy_json">Copy JSON JWS data</string> <string name="pref_safetynet_recent_advice">Advice</string> <string name="pref_safetynet_recent_eval_type">Evaluation type</string> Loading @@ -206,5 +208,12 @@ This can take a couple of minutes."</string> <string name="pref_safetynet_recent_request_type">Request type</string> <string name="pref_safetynet_recent_cat_basic">Basic data</string> <string name="pref_safetynet_recent_token">Token</string> <string name="pref_safetynet_recent_copied">Copied to clipboard!</string> <string name="pref_safetynet_test_integrity_cts_passed">Integrity and CTS passed</string> <string name="pref_safetynet_test_cts_failed">CTS failed</string> <string name="pref_safetynet_test_integrity_failed">Integrity failed</string> <string name="pref_safetynet_test_not_completed">Not completed yet</string> <string name="pref_safetynet_test_no_result">No result</string> <string name="pref_safetynet_test_invalid_json">Invalid JSON</string> </resources>
play-services-core/src/main/res/xml/preferences_safetynet_app.xml +1 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ xmlns:tools="http://schemas.android.com/tools"> <PreferenceCategory android:key="prefcat_safetynet_recent_list" android:title="Recent uses"> android:title="@string/pref_safetynet_recent_uses"> <Preference android:enabled="false" android:key="pref_safetynet_recent_none" Loading