From 2b7e8fb79c3a8dcd1ba42b87df9efcdfed7382f3 Mon Sep 17 00:00:00 2001 From: wkouki Date: Tue, 16 Apr 2024 15:59:08 +0900 Subject: [PATCH] - Change to show exception correctly when logging errors in several cases --- .../niap/permissions/BasePermissionTester.java | 2 +- .../niap/permissions/InstallPermissionTester.java | 2 +- .../niap/permissions/SignaturePermissionTester.java | 9 ++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/niap-cc/Permissions/Tester/app/src/main/java/com/android/certifications/niap/permissions/BasePermissionTester.java b/niap-cc/Permissions/Tester/app/src/main/java/com/android/certifications/niap/permissions/BasePermissionTester.java index c07d0de..26553b6 100644 --- a/niap-cc/Permissions/Tester/app/src/main/java/com/android/certifications/niap/permissions/BasePermissionTester.java +++ b/niap-cc/Permissions/Tester/app/src/main/java/com/android/certifications/niap/permissions/BasePermissionTester.java @@ -290,7 +290,7 @@ public boolean runPermissionTest(String permission, PermissionTest test, } catch (UnexpectedPermissionTestFailureException e) { testPassed = false; - mLogger.logInfo(permission + "/"+ e.getMessage()); + mLogger.logInfo(permission + "/"+ e.getMessage(),e); } catch (Throwable t) { // Any other Throwable indicates the test did not fail due to a SecurityException; // treat the API as successful if the caller specified exceptions are allowed. diff --git a/niap-cc/Permissions/Tester/app/src/main/java/com/android/certifications/niap/permissions/InstallPermissionTester.java b/niap-cc/Permissions/Tester/app/src/main/java/com/android/certifications/niap/permissions/InstallPermissionTester.java index 5368926..c10d3ba 100644 --- a/niap-cc/Permissions/Tester/app/src/main/java/com/android/certifications/niap/permissions/InstallPermissionTester.java +++ b/niap-cc/Permissions/Tester/app/src/main/java/com/android/certifications/niap/permissions/InstallPermissionTester.java @@ -1190,7 +1190,7 @@ public void onServiceConnected(ComponentName name, IBinder binder) { } catch (RemoteException e) { binderSuccess.set(false); //e.printStackTrace(); - mLogger.logError(name+" failure."+e.getMessage()); + mLogger.logError(name+" failure."+e.getMessage(),e); } lock.notify(); } diff --git a/niap-cc/Permissions/Tester/app/src/main/java/com/android/certifications/niap/permissions/SignaturePermissionTester.java b/niap-cc/Permissions/Tester/app/src/main/java/com/android/certifications/niap/permissions/SignaturePermissionTester.java index e98f760..db92bd5 100644 --- a/niap-cc/Permissions/Tester/app/src/main/java/com/android/certifications/niap/permissions/SignaturePermissionTester.java +++ b/niap-cc/Permissions/Tester/app/src/main/java/com/android/certifications/niap/permissions/SignaturePermissionTester.java @@ -5492,7 +5492,7 @@ public void onServiceConnected(ComponentName name, IBinder binder) { } catch (RemoteException e) { binderSuccess.set(false); //e.printStackTrace(); - mLogger.logError(name+" failure."+e.getMessage()); + mLogger.logError(name+" failure."+e.getMessage(),e); } lock.notify(); } @@ -5785,7 +5785,7 @@ public boolean runPermissionTest(String permission, PermissionTest test) { // should have been thrown so the result of the test should be the opposite of // whether the permission was granted. mLogger.logDebug( - "Caught a SecurityException for permission " + permission + ": ", e); + "Caught a SecurityException for permission " + permission, e); if (e.getCause() != null) { mLogger.logDebug("Cause of SecurityException: ", e.getCause()); } @@ -5793,9 +5793,8 @@ public boolean runPermissionTest(String permission, PermissionTest test) { } catch (BypassTestException bte) { mLogger.logTestSkipped(permission, permissionGranted, bte.getMessage()); } catch (UnexpectedPermissionTestFailureException e) { - //mLogger.logTestSkipped(permission, permissionGranted, bte.getMessage()) mLogger.logDebug( - "Caught a UnexpectedPermissionTestFailureException for permission " + permission + ": ", e); + "Caught a UnexpectedPermissionTestFailureException for permission " + permission , e); testPassed = getAndLogTestStatus(permission, permissionGranted, false);; } catch (Throwable t) { // Some of the signature / privileged tests can fail for other reasons (primarily @@ -5803,7 +5802,7 @@ public boolean runPermissionTest(String permission, PermissionTest test) { // APIs guarded by signature permissions), but if they make it past the // SecurityException then the API should be considered successfully invoked. if (Constants.DEBUG) { - mLogger.logDebug("Caught a Throwable for permission " + permission + ": ", t); + mLogger.logDebug("Caught a Throwable for permission " + permission , t); } testPassed = getAndLogTestStatus(permission, permissionGranted, true); }