-
-
Notifications
You must be signed in to change notification settings - Fork 3k
manager: introduce webui package manager api #2928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
this is a squash of: * manager: introduce app package info API for webui-next (KernelSU-Next/KernelSU-Next@58167a4) * manager: sort a-z order for webui-next list packages api (KernelSU-Next/KernelSU-Next@4a9733c) * manager: implement getPackagesIcons and cacheAllPackageIcons api to webui-next (KernelSU-Next/KernelSU-Next@a361fa3) * manager/webui: let getPackagesIcons generate icon and store in cache as well when called (KernelSU-Next/KernelSU-Next@6afa86d) * POC: load icon app via ksu://icon/[packageName] (KernelSU-Next#674) (KernelSU-Next/KernelSU-Next@bc9927b) * manager: refine webui package manager (0400c42) Co-Authored-By: Rifat Azad <[email protected]> Co-Authored-By: Fahrez256Bit <[email protected]> Signed-off-by: KOWX712 <[email protected]>
|
这里同时提供了 ksu://icon/[packageName] 和 getPackagesIcons() 两种获取图标的方式,如果觉得不需要可以移除 getPackagesIcons() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a comprehensive package manager API for the WebUI, enabling web-based modules to query installed applications and retrieve their metadata and icons. The changes include JavaScript interface methods for package listing, detailed package information retrieval, and icon caching mechanisms, along with a custom ksu://icon/[packageName] URL scheme handler.
- Adds JavaScript interface APIs (
listPackages,getPackagesInfo,getPackagesIcons,cacheAllPackageIcons) for package management in WebView - Implements dual icon caching strategies: Base64-encoded strings for JavaScript access and bitmap cache for URL-based access
- Preloads app list at application startup for improved initial response time
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| WebViewInterface.kt | Implements four new JavaScript interface methods for package listing, metadata retrieval, and icon encoding with Base64 caching |
| WebUIActivity.kt | Adds ksu://icon/ URL scheme handler to serve app icons directly via WebView requests and initializes SuperUserViewModel |
| AppIconUtil.java | Provides utility for synchronous icon loading with bitmap caching for the URL handler |
| SuperUserViewModel.kt | Exposes static apps list and getAppIconDrawable() helper for cross-component access |
| KernelSUApplication.kt | Implements ViewModelStoreOwner and preloads app list during application initialization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
manager/app/src/main/java/me/weishu/kernelsu/ui/webui/AppIconUtil.java
Outdated
Show resolved
Hide resolved
manager/app/src/main/java/me/weishu/kernelsu/ui/webui/WebViewInterface.kt
Outdated
Show resolved
Hide resolved
manager/app/src/main/java/me/weishu/kernelsu/ui/webui/WebViewInterface.kt
Outdated
Show resolved
Hide resolved
manager/app/src/main/java/me/weishu/kernelsu/ui/webui/AppIconUtil.java
Outdated
Show resolved
Hide resolved
manager/app/src/main/java/me/weishu/kernelsu/ui/webui/WebViewInterface.kt
Outdated
Show resolved
Hide resolved
manager/app/src/main/java/me/weishu/kernelsu/ui/webui/WebViewInterface.kt
Outdated
Show resolved
Hide resolved
manager/app/src/main/java/me/weishu/kernelsu/ui/webui/WebViewInterface.kt
Outdated
Show resolved
Hide resolved
manager/app/src/main/java/me/weishu/kernelsu/ui/webui/WebViewInterface.kt
Outdated
Show resolved
Hide resolved
manager/app/src/main/java/me/weishu/kernelsu/ui/viewmodel/SuperUserViewModel.kt
Show resolved
Hide resolved
…nterface.kt Co-authored-by: Copilot <[email protected]>
The @RequiresApi(Build.VERSION_CODES.P) annotation is unnecessary here. The PackageInfo.longVersionCode property (line 246) was indeed added in API 28 (P), but this annotation doesn't prevent runtime crashes on older APIs. Consider using a version check or the compat accessor PackageInfoCompat.getLongVersionCode() from AndroidX core library for backward compatibility. Co-authored-by: Copilot <[email protected]>
Memory leak: Bitmaps stored in the cache are never cleared, which can lead to memory exhaustion over time, especially with many applications installed. Consider implementing a size-limited cache (e.g., using LruCache) or clearing the cache when appropriate. Co-Authored-By: Copilot <[email protected]>
…til.java Co-authored-by: Copilot <[email protected]>
The static apps field is accessed from multiple threads without synchronization. The field is written in fetchAppList() (line 173 in the full file) which runs on IO dispatcher, but is read from WebView JavaScript interface methods which run on arbitrary threads. This can lead to race conditions and visibility issues.
…til.java Co-authored-by: Copilot <[email protected]>
|
demo index.html |
|
What about integrating all WebUI X features to KernelSU? |
YuKongA
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm update #2928 --------- Co-authored-by: Copilot <[email protected]>
this is a squash of: * manager: introduce app package info API for webui-next (KernelSU-Next/KernelSU-Next@58167a4) * manager: sort a-z order for webui-next list packages api (KernelSU-Next/KernelSU-Next@4a9733c) * manager: implement getPackagesIcons and cacheAllPackageIcons api to webui-next (KernelSU-Next/KernelSU-Next@a361fa3) * manager/webui: let getPackagesIcons generate icon and store in cache as well when called (KernelSU-Next/KernelSU-Next@6afa86d) * POC: load icon app via ksu://icon/[packageName] (KernelSU-Next#674) (KernelSU-Next/KernelSU-Next@bc9927b) * manager: refine webui package manager (0400c42) Co-Authored-By: Rifat Azad <[email protected]> Co-Authored-By: Fahrez256Bit <[email protected]> Signed-off-by: KOWX712 <[email protected]> --------- Signed-off-by: KOWX712 <[email protected]> Co-authored-by: Rifat Azad <[email protected]> Co-authored-by: Fahrez256Bit <[email protected]> Co-authored-by: Copilot <[email protected]>
npm update tiann#2928 --------- Co-authored-by: Copilot <[email protected]>
- Supported since KernelSU v2.1.2 (tiann/KernelSU#2928)
- Supported since KernelSU v2.1.2 (tiann/KernelSU#2928)
|
@KOWX712 seems not working for me? Icons unavailable. |
- Supported since KernelSU v2.1.2 (tiann/KernelSU#2928)
- sync with tiann/KernelSU#2928 Co-authored-by: Rifat Azad <[email protected]> Co-authored-by: Fahrez256Bit <[email protected]> Signed-off-by: KOWX712 <[email protected]>
- sync with tiann/KernelSU#2928 Co-authored-by: Rifat Azad <[email protected]> Co-authored-by: Fahrez256Bit <[email protected]> Signed-off-by: KOWX712 <[email protected]>
* manager: introduce pm api in webui - sync with tiann/KernelSU#2928 Signed-off-by: KOWX712 <[email protected]> Co-authored-by: Rifat Azad <[email protected]> Co-authored-by: Fahrez256Bit <[email protected]>
ref: tiann/KernelSU#2928 Co-Authored-By: Rifat Azad <[email protected]> Co-Authored-By: Fahrez256Bit <[email protected]> Signed-off-by: KOWX712 <[email protected]>
ref: tiann/KernelSU#2928 Co-Authored-By: Rifat Azad <[email protected]> Co-Authored-By: Fahrez256Bit <[email protected]> Signed-off-by: KOWX712 <[email protected]>
* manager: introduce pm api in webui - sync with tiann/KernelSU#2928 Signed-off-by: KOWX712 <[email protected]> Co-authored-by: Rifat Azad <[email protected]> Co-authored-by: Fahrez256Bit <[email protected]>
ref: tiann/KernelSU#2928 Co-Authored-By: Rifat Azad <[email protected]> Co-Authored-By: Fahrez256Bit <[email protected]> Signed-off-by: KOWX712 <[email protected]>
ref: tiann/KernelSU#2928 Co-Authored-By: Rifat Azad <[email protected]> Co-Authored-By: Fahrez256Bit <[email protected]> Signed-off-by: KOWX712 <[email protected]>
this is a squash of: * manager: introduce app package info API for webui-next (KernelSU-Next/KernelSU-Next@58167a4) * manager: sort a-z order for webui-next list packages api (KernelSU-Next/KernelSU-Next@4a9733c) * manager: implement getPackagesIcons and cacheAllPackageIcons api to webui-next (KernelSU-Next/KernelSU-Next@a361fa3) * manager/webui: let getPackagesIcons generate icon and store in cache as well when called (KernelSU-Next/KernelSU-Next@6afa86d) * POC: load icon app via ksu://icon/[packageName] (KernelSU-Next#674) (KernelSU-Next/KernelSU-Next@bc9927b) * manager: refine webui package manager (KOWX712/KernelSU@0400c42) Co-Authored-By: Rifat Azad <[email protected]> Co-Authored-By: Fahrez256Bit <[email protected]> Co-authored-by: KOWX712 <[email protected]> --------- Co-authored-by: KOWX712 <[email protected]> Co-authored-by: Rifat Azad <[email protected]> Co-authored-by: Fahrez256Bit <[email protected]> Co-authored-by: Copilot <[email protected]> Signed-off-by: u9521 <[email protected]>
npm update tiann#2928 --------- Co-authored-by: Copilot <[email protected]>
this is a squash of: * manager: introduce app package info API for webui-next (KernelSU-Next/KernelSU-Next@58167a4) * manager: sort a-z order for webui-next list packages api (KernelSU-Next/KernelSU-Next@4a9733c) * manager: implement getPackagesIcons and cacheAllPackageIcons api to webui-next (KernelSU-Next/KernelSU-Next@a361fa3) * manager/webui: let getPackagesIcons generate icon and store in cache as well when called (KernelSU-Next/KernelSU-Next@6afa86d) * POC: load icon app via ksu://icon/[packageName] (KernelSU-Next#674) (KernelSU-Next/KernelSU-Next@bc9927b) * manager: refine webui package manager (KOWX712/KernelSU@0400c42) Co-Authored-By: Rifat Azad <[email protected]> Co-Authored-By: Fahrez256Bit <[email protected]> Co-authored-by: KOWX712 <[email protected]> --------- Co-authored-by: KOWX712 <[email protected]> Co-authored-by: Rifat Azad <[email protected]> Co-authored-by: Fahrez256Bit <[email protected]> Co-authored-by: Copilot <[email protected]> Signed-off-by: u9521 <[email protected]>
npm update tiann#2928 --------- Co-authored-by: Copilot <[email protected]>
* manager: introduce pm api in webui - sync with tiann/KernelSU#2928 Signed-off-by: KOWX712 <[email protected]> Co-authored-by: Rifat Azad <[email protected]> Co-authored-by: Fahrez256Bit <[email protected]>


this is a squash of:
manager: introduce app package info API for webui-next (KernelSU-Next/KernelSU-Next@58167a4)
manager: sort a-z order for webui-next list packages api (KernelSU-Next/KernelSU-Next@4a9733c)
manager: implement getPackagesIcons and cacheAllPackageIcons api to webui-next (KernelSU-Next/KernelSU-Next@a361fa3)
manager/webui: let getPackagesIcons generate icon and store in cache as well when called (KernelSU-Next/KernelSU-Next@6afa86d)
POC: load icon app via ksu://icon/[packageName] (KernelSU-Next#674) (KernelSU-Next/KernelSU-Next@bc9927b)
manager: refine webui package manager (KOWX712/KernelSU@0400c42)
Co-Authored-By: Rifat Azad [email protected]
Co-Authored-By: Fahrez256Bit [email protected]
Signed-off-by: KOWX712 [email protected]