Skip to content

Commit fd897b2

Browse files
Changed the installed function. Updated the java path after successful installation
1 parent 4703a13 commit fd897b2

1 file changed

Lines changed: 44 additions & 29 deletions

File tree

  • Framework/install_handler/android

Framework/install_handler/android/java.py

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -432,34 +432,49 @@ async def _verify_java_installation(jdk_home):
432432
return False
433433

434434

435-
async def install():
436-
"""Install Java by calling JDK installation function"""
435+
async def install() -> bool:
436+
"""Main function to setup JDK 21 LTS"""
437437
print("[installer][android-java] Installing...")
438-
439-
# Call JDK installation function
440-
success = await install_jdk()
441-
442-
if success:
443-
print("[installer][android-java] Java installation successful")
444-
await send_response({
445-
"action": "status",
446-
"data": {
447-
"category": "Android",
448-
"name": "Java",
449-
"status": "installed",
450-
"comment": "Java is installed",
451-
}
452-
})
438+
439+
# Check if JDK 21 is already installed
440+
if await check_status():
441+
print("[installer][android-java] JDK 21 is already installed")
453442
return True
454-
else:
455-
print("[installer][android-java] Java installation failed")
456-
await send_response({
457-
"action": "status",
458-
"data": {
459-
"category": "Android",
460-
"name": "Java",
461-
"status": "not installed",
462-
"comment": "Failed to install Java",
463-
}
464-
})
465-
return False
443+
444+
jdk_home = None
445+
446+
# If JDK is not installed, download and install it
447+
if not jdk_home:
448+
# Download and extract JDK
449+
jdk_archive = await _download_jdk()
450+
if not jdk_archive:
451+
return False
452+
453+
jdk_home = await _extract_jdk(jdk_archive)
454+
if not jdk_home:
455+
return False
456+
457+
# Clean up archive
458+
try:
459+
jdk_archive.unlink()
460+
except:
461+
pass
462+
463+
# Verify installation
464+
if not await _verify_java_installation(jdk_home):
465+
print("[installer][android-jdk] Java installation verification failed")
466+
return False
467+
468+
print("[installer][android-jdk] JDK 21 LTS setup complete")
469+
await send_response({
470+
"action": "status",
471+
"data": {
472+
"category": "Android",
473+
"name": "Java",
474+
"status": "installed",
475+
"comment": f"Java is installed at {jdk_home}",
476+
}
477+
})
478+
479+
update_java_path()
480+
return True

0 commit comments

Comments
 (0)