Event System
Event Types Overview
Section titled “Event Types Overview”The Byteria SDK provides comprehensive event coverage across all security and operational domains:
Initialization Events:
INIT_COMPLETE: SDK initialization successfulINIT_FAILED: SDK initialization failedFIRST_INIT: First-time initializationINVALID_APP_KEY: Invalid application key provided
Security Events:
THREAT_DETECTED: Security threat identifiedSECURE_DEVICE: Device verified as secureINVALID_DATE_OR_TIME: Device date/time is invalidSCAN_SUCCESS: Security scan completedSCAN_RESPONSE: Scan results availableSCAN_FAILED: Security scan failedRISK_FACTOR_DETECTED: A risk factor was detected during a scan
Network Events:
NETWORK_INIT: Network initializationNETWORK_MTLS: mTLS connection establishedJWT_AUTH_SUCCESS: JWT authentication successfulNETWORK_ERROR: Network connectivity errorAUTH_FAILED: Authentication failedREQUEST_FAILED: API request failed
Storage Events:
KEYSTORE_SUCCESS: Keystore operation successfulKEYSTORE_FAILED: Keystore operation failedKEY_EXCHANGE_SUCCESS: Key exchange completedKEYS_FOUND_STORAGE: Existing keys foundKEYS_CREATED_NEW: New keys created
Callback Events:
CALLBACK_SUCCESS: Callback operation successfulCALLBACK_FAILED: Callback operation failed
Callback Result Handling
Section titled “Callback Result Handling”Complete Event Processing:
public class ComprehensiveEventHandler implements AlphynSecurityListener {
@Override public void onSuccess(AlphynCallbackResult result) { logEvent("SUCCESS", result);
// Route to specific handlers based on operation type switch (result.getOperationType()) { case INITIALIZATION: handleInitializationSuccess(result); break; case SECURITY_SCAN: handleSecuritySuccess(result); break; case SCAN_RESPONSE: handleScanResponse(result); break; case NETWORK: // Network events are informational - no action required Log.d("ByteriaNetwork", result.getOriginalEventType() + ": " + result.getMessage()); break; case STORAGE: // Storage events are informational - no action required Log.d("ByteriaStorage", result.getOriginalEventType() + ": " + result.getMessage()); break; case CALLBACK: handleCallbackSuccess(result); break; } }
@Override public void onFailure(AlphynCallbackResult result) { logEvent("FAILURE", result);
// Handle failures with appropriate recovery strategies switch (result.getOperationType()) { case INITIALIZATION: handleInitializationFailure(result); break; case NETWORK: // Network failures are handled automatically by SDK with retry logic Log.w("ByteriaNetwork", "Network issue (SDK handling): " + result.getMessage()); break; case STORAGE: // Storage failures are handled automatically by SDK with fallback mechanisms Log.w("ByteriaStorage", "Storage issue (SDK handling): " + result.getMessage()); break; default: handleGenericFailure(result); break; } }
@Override public void onThreatDetected(AlphynCallbackResult result) { logEvent("THREAT", result);
// Immediate threat response ThreatResponse response = evaluateThreat(result); executeThreatResponse(response); }
private void logEvent(String category, AlphynCallbackResult result) { Log.i("ByteriaEvents", String.format("[%s] %s: %s (%s)", category, result.getOperationType(), result.getOriginalEventType(), result.getMessage())); }}Event Lifecycle
Section titled “Event Lifecycle”Event Flow Management:
public class EventLifecycleManager { private final Map<AlphynEventType, Long> eventTimestamps = new HashMap<>(); private final List<EventListener> listeners = new ArrayList<>();
public void trackEvent(AlphynCallbackResult result) { AlphynEventType eventType = result.getOriginalEventType(); long timestamp = System.currentTimeMillis();
// Record event timing eventTimestamps.put(eventType, timestamp);
// Analyze event patterns analyzeEventPattern(eventType, timestamp);
// Notify listeners notifyEventListeners(result); }
private void analyzeEventPattern(AlphynEventType eventType, long timestamp) { // Implement event pattern analysis Long lastEvent = eventTimestamps.get(eventType); if (lastEvent != null) { long interval = timestamp - lastEvent; Log.d("EventAnalysis", String.format("Event %s interval: %dms", eventType, interval)); } }
public interface EventListener { void onEventProcessed(AlphynCallbackResult result); }}