IDEA:
- 只有跑特定一隻客製的APP
- 避免其他APP執行(除了白名單的APP)
General requirements for such applications
- 只允許單一APP執行
- 只能聯絡白名單的聯絡人(透過電話或SMS)。Only whitelisted contacts are allowed to be contacted (via Phone or SMS)
- 只有白名單APP可以被使用
- 追蹤APP安裝及反安裝
- Disable status bar.
Approaches for developing Kiosk Mode applications
Following are the two approaches that you can take depending on your expertise and skill.
兩種方式可以達到Kiosk Mode:
- Developing as a Launcher application
- Building a custom ROM
Developing as a Launcher application
總是只有你的APP被執行 (Only your app is allowed to run always)
安裝你的Launcher後。你可以用使用指令pm disable <PACKAGE_OR_COMPONENT>
關閉舊的Launcher APP。
此時,開機後你的Launcher APP會自動被開啟。(沒有什麼花招 XD)
檢查有沒有應用程式被打開 (Detect when new applications are opened)
你可能需要知道被執行的APP是不是被允許使用的,以下提供兩種方法:
使用repeated alarm
heavy on resources and drains battery very quickly
例如每五秒,從目前執行中的APP取得最上面的Activity(topmost activity) -> 檢查他的Package是否允許被執行 ->如果是不允許
-> 回到首頁,並使用ActivityManager.killBackgroundProcess()
砍了這隻APP(無法作用在system apps)- 使用 AccessibilityService
it lets you know when a new application window is opened and then you can check which application is currently running and act accordingly. This is on demand and is not heavy on resources. The caveat is that you have to manually enable the service from Settings –> Accessibility. Assuming physical control over the devices, so this should not be an issue, but it’s manual and that’s the downside.
偵測APP被安裝及反安裝 (Detect if new applications are installed or uninstalled)
關閉狀態欄 (Disable status bar)
you’ll need android.permission.SYSTEM_ALERT_WINDOW permission to put your view on top of all other windows.
Also you can make your Launcher app fullscreen as well.
讓你的APP成為裝置管理者 (Make your app a Device Administrator)
提供較高的存取權限來執行管理任務(provide some elevated access rights to perform administrative tasks)
如:remotely lock screen, wipe out the data
自動更新 (Automatic Update)
如果你想要自動更新的支援,卻又不想要發佈在Play Store,然後你需要去root你的裝置
and run a separate app which will update your app when there is a new version.
This requires you to build a backend as well. I wrote a blog post on this topic some time ago, Android Auto-updating Homescreen Application
Source: