Skip to content

firebaseをパッケージから削除した,その他バグ回収 - #4

Merged
hihumikan merged 3 commits into
mainfrom
features/firebaseandneterrbug
Mar 1, 2026
Merged

firebaseをパッケージから削除した,その他バグ回収#4
hihumikan merged 3 commits into
mainfrom
features/firebaseandneterrbug

Conversation

@hihumikan

@hihumikan hihumikan commented Mar 1, 2026

Copy link
Copy Markdown
Member

背景

  • Firebase を現在使っていない構成にもかかわらず com.google.gms.google-services プラグインが有効になっており、google-services.json 不足で Debug ビルドが失敗していた。
  • センシング開始時に空の fileName が渡される経路があり、File name cannot be empty でアプリがクラッシュしていた。
  • Negativeモデルを送信する などの短時間計測で、計測自体は終わっていても停止完了の通知が UI まで返らず、「計測中」のまま終了しないことがあった。
  • WebView でサブリソース読込エラーまで画面全体のエラーとして扱っていたため、ERR_CLEARTEXT_NOT_PERMITTED 発生時にページ全体が見えなくなるケースがあった。

実施内容

  • app/build.gradle.kts から未使用の com.google.gms.google-services プラグインを削除し、google-services.json なしでも Debug ビルドできるようにした。
  • SensingUsecase で空の fileName をそのまま流さず、空の場合は日時付きのデフォルト名に補完するようにした。
  • SettingViewModel / SensingWorker からのセンシング開始時に、用途が分かるファイル名を渡すように変更した。
  • SensingRepositorysamplingFrequency バリデーションを見直し、実装で利用している -1.0 を有効値として扱うようにした。
  • SensingRepository の停止処理を見直し、各センサー停止後に確実に onStopped を返すように変更した。
  • SensingUsecase 側の不要なクリーンアップ呼び出しを外し、停止完了前に後続処理が切れる状態を解消した。
  • WebViewComponent では main frame の読込失敗のみを画面エラー扱いとし、サブリソース失敗でページ全体を閉じないようにした。

Summary by CodeRabbit

リリースノート

  • バグ修正

    • WebViewコンポーネントのエラー処理を改善し、メインフレームのエラーのみを適切に処理するようにしました。
  • その他

    • 内部の非同期処理フレームワークを最適化し、より効率的な処理フローに変更しました。

@coderabbitai

coderabbitai Bot commented Mar 1, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@hihumikan has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 19 minutes and 36 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 091249c and 67617f1.

📒 Files selected for processing (3)
  • app/src/main/java/net/kajilab/elpissender/presenter/ui/view/setting/SettingViewModel.kt
  • app/src/main/java/net/kajilab/elpissender/repository/SensingRepository.kt
  • app/src/main/java/net/kajilab/elpissender/usecase/SensingUsecase.kt

Walkthrough

IDE設定の追加・更新、GradleからGoogle Servicesプラグイン削除、WebViewのエラー処理をメインフレームのみに制限、センシング関連でfileName正規化とRxJava除去(blocking呼び出しへ移行)を行う変更。

Changes

Cohort / File(s) Summary
IDEプロジェクト設定
.idea/deploymentTargetSelector.xml, .idea/material_theme_project_new.xml
.idea/deploymentTargetSelector.xmlのタイムスタンプ/SelectionState更新と、Material Theme構成ファイルを新規追加。
Gradleビルド設定
app/build.gradle.kts
アプリ側ビルドスクリプトから com.google.gms.google-services プラグインを削除。
WebViewコンポーネント
app/src/main/java/net/kajilab/elpissender/presenter/ui/view/components/WebViewComponent.kt
onReceivedErrorでサブフレームのエラーを無視するために「メインフレームのみ」ガードを追加。
ViewModel / Worker 呼び出し
app/src/main/java/net/kajilab/elpissender/presenter/ui/view/setting/SettingViewModel.kt, app/src/main/java/net/kajilab/elpissender/service/SensingWorker.kt
timerStart 呼び出しの fileName 引数を空文字から具体的な識別子(例: debug_10sec, ${sampleType}_room_$roomId, manual_sensing, worker_sensing)へ変更。
センシング リポジトリ / ユースケース
app/src/main/java/net/kajilab/elpissender/repository/SensingRepository.kt, app/src/main/java/net/kajilab/elpissender/usecase/SensingUsecase.kt
RxJava(CompositeDisposable、Single、Schedulers)依存を除去し、sensor.stop() 呼び出しを blockingGet 相当の同期呼び出しに置換。onCleared() と compositeDisposable を削除。usecase 側で fileName を正規化する resolveFileName を追加。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant UI as UI / ViewModel
  participant Usecase as SensingUsecase
  participant Repo as SensingRepository
  participant Sensor as Sensor (各センサー)
  UI->>Usecase: start(fileName)
  Usecase->>Repo: sensorStart(resolvedFileName, params)
  Repo->>Sensor: start(params)
  Sensor-->>Repo: started (path)
  Repo-->>Usecase: started (paths)
  Usecase-->>UI: onStarted(paths)

  rect rgba(100,150,255,0.5)
  UI->>Usecase: stop()
  Usecase->>Repo: sensorStop()
  Repo->>Sensor: stop() (blocking)
  Sensor-->>Repo: stopped or error
  Repo-->>Usecase: listOf(paths or nulls)
  Usecase-->>UI: onStopped(list)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 夜明けの草むらで私は囁く
古い非同期は風に消え
名前は明るく、流れは静かに
小さなファイルたちが歌い出す
センシングの朝、跳ねる一歩 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR titleはFirebaseの削除と複数のバグ修正という実際の変更内容を反映しており、主な変更を適切に要約している。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch features/firebaseandneterrbug

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hihumikan hihumikan changed the title WIP on main firebaseをパッケージから削除した,その他バグ回収 Mar 1, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
.idea/deploymentTargetSelector.xml (1)

1-21: IDE設定ファイルはバージョン管理から除外を検討してください。

.idea/deploymentTargetSelector.xml はIDEが自動生成するマシン固有の設定ファイルです。以下の理由から .gitignore に追加することを推奨します:

  1. タイムスタンプやデバイス選択状態は開発者ごとに異なり、不要なマージコンフリクトの原因になります
  2. Line 10にデバイスシリアル番号(serial=48221FDJH0021D)が含まれており、公開リポジトリでは避けるべき情報です
📝 .gitignoreへの追加案
+.idea/deploymentTargetSelector.xml
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.idea/deploymentTargetSelector.xml around lines 1 - 21, The committed
IDE-generated deploymentTargetSelector XML contains a machine-specific device
serial (the DeviceId element with identifier="serial=48221FDJH0021D") and should
not be versioned; update the repository ignore rules to exclude IDE-generated
deployment target files, stop tracking this file (remove it from the index and
commit the removal), and purge the exposed serial from repository history using
a history-rewrite tool (e.g., git filter-repo or BFG) so the DeviceId identifier
value is removed; after rewriting history, force-push and inform collaborators
to rebase/clone to avoid reintroducing the SelectionState runConfigName="app"
entry.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/src/main/java/net/kajilab/elpissender/repository/SensingRepository.kt`:
- Around line 49-59: 現在の sensors.map ブロックは sensor.stop().blockingGet() を Main
スレッドで呼んでおり ANR を誘発するため、blockingGet を使わないように修正してください: sensor.stop() をメインでブロックせずに
I/O スレッドで実行する(たとえば Rx の場合は sensor.stop().subscribeOn(Schedulers.io())
を使って非同期に集約するか、コルーチン化して suspend 関数に変換して await する)ように変更し、SensingUsecase.stop() を
suspend にして SettingViewModel.stopSensing() 側は viewModelScope.launch
内で呼ぶようにしてください(該当シンボル: sensor.stop().blockingGet(), sensors.map, files,
onStopped(files), SensingUsecase.stop(), SettingViewModel.stopSensing(),
viewModelScope.launch)。

In `@app/src/main/java/net/kajilab/elpissender/usecase/SensingUsecase.kt`:
- Around line 182-185: resolveFileName currently only trims and checks blank but
lets dangerous strings like "/" or ".." through; update resolveFileName to
sanitize the input by removing or replacing path separators and traversal
sequences (e.g., "/", "\", "..") and any characters outside a safe whitelist
(letters, digits, dot, underscore, dash), strip leading dots, collapse repeated
dots, then fallback to "sensing_${DateUtils.getNowDate()}" if the sanitized
result is empty; ensure you update the function resolveFileName to perform these
checks and sanitization before returning the filename.

---

Nitpick comments:
In @.idea/deploymentTargetSelector.xml:
- Around line 1-21: The committed IDE-generated deploymentTargetSelector XML
contains a machine-specific device serial (the DeviceId element with
identifier="serial=48221FDJH0021D") and should not be versioned; update the
repository ignore rules to exclude IDE-generated deployment target files, stop
tracking this file (remove it from the index and commit the removal), and purge
the exposed serial from repository history using a history-rewrite tool (e.g.,
git filter-repo or BFG) so the DeviceId identifier value is removed; after
rewriting history, force-push and inform collaborators to rebase/clone to avoid
reintroducing the SelectionState runConfigName="app" entry.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7d6cb0 and cce867d.

📒 Files selected for processing (8)
  • .idea/deploymentTargetSelector.xml
  • .idea/material_theme_project_new.xml
  • app/build.gradle.kts
  • app/src/main/java/net/kajilab/elpissender/presenter/ui/view/components/WebViewComponent.kt
  • app/src/main/java/net/kajilab/elpissender/presenter/ui/view/setting/SettingViewModel.kt
  • app/src/main/java/net/kajilab/elpissender/repository/SensingRepository.kt
  • app/src/main/java/net/kajilab/elpissender/service/SensingWorker.kt
  • app/src/main/java/net/kajilab/elpissender/usecase/SensingUsecase.kt
💤 Files with no reviewable changes (1)
  • app/build.gradle.kts

Comment on lines +182 to +185
private fun resolveFileName(fileName: String): String {
val normalized = fileName.trim()
return normalized.ifBlank { "sensing_${DateUtils.getNowDate()}" }
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

ファイル名正規化が不十分で、危険文字列を通してしまいます。

Line 182-185 は空文字対策のみで、/.. などを含む入力を通します。sampleType 由来の値が来る経路もあるため、ファイル操作先の逸脱や失敗リスクがあります。

🔧 修正案(危険文字の除去を追加)
 private fun resolveFileName(fileName: String): String {
-    val normalized = fileName.trim()
-    return normalized.ifBlank { "sensing_${DateUtils.getNowDate()}" }
+    val normalized = fileName.trim().ifBlank { "sensing_${DateUtils.getNowDate()}" }
+    return normalized
+        .replace(Regex("""[\\/:*?"<>|]"""), "_")
+        .replace("..", "_")
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private fun resolveFileName(fileName: String): String {
val normalized = fileName.trim()
return normalized.ifBlank { "sensing_${DateUtils.getNowDate()}" }
}
private fun resolveFileName(fileName: String): String {
val normalized = fileName.trim().ifBlank { "sensing_${DateUtils.getNowDate()}" }
return normalized
.replace(Regex("""[\\/:*?"<>|]"""), "_")
.replace("..", "_")
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/java/net/kajilab/elpissender/usecase/SensingUsecase.kt` around
lines 182 - 185, resolveFileName currently only trims and checks blank but lets
dangerous strings like "/" or ".." through; update resolveFileName to sanitize
the input by removing or replacing path separators and traversal sequences
(e.g., "/", "\", "..") and any characters outside a safe whitelist (letters,
digits, dot, underscore, dash), strip leading dots, collapse repeated dots, then
fallback to "sensing_${DateUtils.getNowDate()}" if the sanitized result is
empty; ensure you update the function resolveFileName to perform these checks
and sanitization before returning the filename.

@hihumikan
hihumikan merged commit 37ee816 into main Mar 1, 2026
2 checks passed
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