Skip to content

支持将 WiTV 设为启动桌面 - #9

Merged
yunnysunny merged 2 commits into
mainfrom
feature/use-as-launcher
Oct 5, 2026
Merged

yunnysunny merged 2 commits into
mainfrom
feature/use-as-launcher

Conversation

@yunnysunny

@yunnysunny yunnysunny commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

改动概要

  • 新增 作为桌面启动 开关(设置 → 播放选项),默认关闭。它控制一个 HOME 类型的 activity-alias:开关不打开时,系统完全不会把 WiTV 当作桌面。
  • 普通应用无法用代码把自己设为默认桌面。打开开关后会跳转到系统的「默认桌面」设置页;盒子上没有这个页面时,会临时启用另一个 HOME 组件,让系统丢弃已保存的默认桌面,重新弹出选择框。
  • 返回键弹窗新增 切换应用,列出其他桌面和全部可启动的应用,并提供「更改默认桌面…」入口。WiTV 成为桌面后,用户就从这里打开其他应用。
  • PlayerActivity 改为 singleTask,新实例创建时会关掉旧实例。作为桌面被拉起时,它可能和从启动器打开的那个实例分属两个任务;不做处理的话,两个播放器会同时拉流。
  • WiTV 是默认桌面时,休息一下 改为把任务退到后台,而不是 finish()。否则系统会立刻把桌面重新拉起来。
  • 启动流程:先等网络就绪,再在后台线程预热 MediaCodecList,然后才起播。测试盒子开机时 mediacodec 会崩溃,约 30 秒不可用。这期间 ExoPlayer 的播放线程卡在解码器查询上,15 秒的换源超时一到就判为「所有播放源均不可用」。预热之后,换源计时从能解码时才开始。
  • 切换面板会排除开机向导和 FallbackHome,它们是优先级不为默认值的 HOME 组件。
  • 使用手册新增「作为桌面启动」一节,配真机截图。

测试

  • ./gradlew testDebugUnitTest(LauncherHelperTest:排除自身、按包名去重、按名称排序、过滤非桌面的 HOME 组件)
  • ./gradlew assembleDebug
  • 开关关闭时按 Home,直接回到原桌面,不弹选择框(p230,Android 7.1)
  • 打开开关 → 系统「默认应用」页 → 主屏幕应用 → 选 WiTV;按 Home 回到同一个实例(只有一个任务、一个播放器)
  • 重启后进入 WiTV。udpxy 和组播直收各测一次:mediacodec 恢复期间显示「正在等待系统解码服务…」,之后第一次尝试约 3 秒起播
  • 返回键 → 切换应用,能打开其他桌面和应用;按 Home 回到 WiTV
  • 「更改默认桌面…」能切回原来的桌面
  • WiTV 是默认桌面时关闭开关,按 Home 回到原来的桌面

已知行为

  • WiTV 是默认桌面、后台没有其他任务时,点 休息一下 没有可见效果。

🤖 Generated with Claude Code

yunnysunny and others added 2 commits October 4, 2026 21:13
Add an opt-in "作为桌面启动" toggle under 播放选项. It flips a disabled-by-default
HOME activity-alias, so the system never sees WiTV as a launcher unless the
user asks for it. Apps can't make themselves the default home, so enabling it
opens the system home settings, or on boxes without that page briefly enables
a second HOME alias to make the system drop the saved default and re-ask.

The exit dialog gets a "切换应用" button listing other launchers and every
launchable app, plus a "更改默认桌面…" entry — the only way out to other apps
once WiTV is home. PlayerActivity becomes singleTask so Home returns to the
running instance, and "休息一下" moves the task back instead of finishing when
WiTV is the default home (finishing would just get it relaunched).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Testing on a p230 (Android 7.1) turned up four problems:

- Pressing Home with WiTV as default launcher started a second
  PlayerActivity in the home stack while the original task kept running,
  so two players pulled the stream at once. A new instance now finishes
  the old one, and the old one no longer clears the PlayerManager the new
  one registered.
- On boot the box's mediacodec service crashes (SIGILL) and is gone for
  ~30 s. ExoPlayer's playback thread blocked on the codec query while the
  data kept arriving, and the 15 s source timeout then gave up with "all
  sources failed". Warm up MediaCodecList on a background thread before
  playing, with a hint if it takes a while, so the source timer only starts
  once decoding is possible. Also wait for network before the first load.
- The app switcher listed com.android.provision as a launcher. Only list
  HOME activities with the default priority, which drops setup wizards and
  FallbackHome.
- The system home settings page was opened inside WiTV's task; open it in
  its own task.

Docs: add the launcher section with real-device screenshots to the user
guide and refresh the exit dialog and playback settings screenshots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yunnysunny yunnysunny changed the title Let WiTV be installed as the home launcher 支持将 WiTV 设为启动桌面 Oct 5, 2026
@yunnysunny
yunnysunny merged commit 743a646 into main Oct 5, 2026
1 check passed
@yunnysunny
yunnysunny deleted the feature/use-as-launcher branch October 5, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant