# Android Node Project Log

## 2026-03-11

### Gateway IP Configuration
- **Emulator (laptop)**: 192.168.11.46:18789
- **Real phone**: 192.168.69.1:18789
- These are different because the phone connects via VPN while emulator runs on laptop network

### Client ID Issue
- **ERROR**: Gateway only accepts specific client IDs: "cli" and "test"
- **ERROR**: Tried "android-node", "ios-node", "android", etc. - ALL REJECTED
- **ERROR**: Tried deviceId hash - REJECTED
- **Current solution**: Use "cli" as client ID (only one that works)
- **Note**: This is likely a gateway version issue - official Android/iOS nodes may need different client IDs

### Node ID vs Client ID
- **Node ID**: Should be the device fingerprint/hash (what we call deviceId)
- **Client ID**: Must be a constant string accepted by gateway ("cli", "test")
- The app currently uses deviceId hash in some places and "cli" in others

### Issue: Build failing due to corrupted Android SDK
- The SDK at /opt/android-sdk is corrupted (duplicate platform directories: android-34, android-34-2, android-34-6, etc.)
- Each build attempt creates a new duplicate directory
- **Workaround**: Created clean SDK at /home/nextime/android-sdk
- Updated local.properties to point to new SDK location
- Build now works!

### Code Changes Made
1. **Hardcoded gateway config** (TEMPORARY for testing):
   - File: `NodeService.kt`
   - Added fallback config: IP=192.168.11.46, port=18789, token=<gateway token>
   - **MUST REMOVE** after pairing works

2. **Client ID**: Changed to "cli" (the only working client ID)

### Current Status (2026-03-11 17:15)
- Build: Working ✅
- Install: Working ✅  
- Device Identity: PERSISTENT - uses RSA key pair stored in SharedPreferences ✅
- Device ID: `6a19599727bd964992898ac4251a9e08c52ae4740d2b0c927c11dc5d424a92bf` ✅
- Client ID: "cli" ✅
- Pairing: STILL FAILING - gateway rejects device signature (device not registered) ❌

### Analysis
- Device identity persistence is working correctly (RSA key pair stored in SharedPreferences)
- Gateway requires device registration - no UI to approve nodes
- Cannot register device from here (no gateway API access)
- Current device ID: `6a19599727bd964992898ac4251a9e08c52ae4740d2b0c927c11dc5d424a92bf`
- Token: `415fa3c21b7ef06f22aff571697d88c59c2dc67737681267`

### Next Steps
1. Either register this device manually via gateway UI (not possible from here)
2. Or use a pre-registered device identity from the project
3. Or modify gateway to accept this device signature

### Files Modified
- `app/src/main/java/com/nexlab/openclaw/node/data/remote/NodeClient.kt` - Added device identity persistence
- `app/src/main/java/com/nexlab/openclaw/node/service/NodeService.kt` - Added `nodeClient.setContext(this)`

### Next Steps
1. **BLOCKED**: Rebuild APK with "cli" client ID
2. Test pairing with emulator
3. After pairing works: remove hardcoded config, test on real phone with 192.168.69.1
