Repository navigation
ADFA-6510: Instant Wipe (self-destruct; circular-sweep wipes the workspace, neutralizes to the disguise) #2137
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
Open
davidschachterADFA
wants to merge
55
commits into
feature/ADFA-40-instant-hide
Choose a base branch
from
feature/ADFA-6510-instant-wipe
base: feature/ADFA-40-instant-hide
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,373
−82
Open
Changes from all commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
c441594
ADFA-40: add :security module with Instant Hide gesture detectors
davidschachterADFA c788145
ADFA-40: add Instant Hide preference flag and Security settings toggle
davidschachterADFA 8ce92df
ADFA-40: add the Code Breaker cryptogram disguise, aliases, and redirect
davidschachterADFA af31299
ADFA-40: spotless reformat EdgeToEdgeIDEActivity.kt (no functional ch…
davidschachterADFA 275aeb3
ADFA-40: wire the Instant Hide triggers into the IDE
davidschachterADFA 5af8d85
ADFA-40: move Instant Hide strings to :resources; add module docs
davidschachterADFA bef5d7d
ADFA-40: trigger face-down hide on orientation alone
davidschachterADFA 3f798c6
ADFA-40: fix README face-down description (orientation only)
davidschachterADFA 5131c64
ADFA-40: close the deep-link concealment bypass
davidschachterADFA 922c17d
ADFA-40: apply FLAG_SECURE immediately when Instant Hide is toggled
davidschachterADFA cecc3f2
ADFA-6510: Instant Wipe PR1 -- WipeManager engine + secure shredder +…
davidschachterADFA 59331d7
ADFA-6510: Instant Wipe PR2 -- CircleGestureDetector + geometry tests
davidschachterADFA 00ece25
ADFA-6510: Instant Wipe PR3 (1/2) -- arm toggle + destructive confirm…
davidschachterADFA 5bca548
ADFA-6510: Instant Wipe PR3 (2/2) -- safe gesture practice overlay
davidschachterADFA f95fb0b
ADFA-6510: Instant Wipe PR4 (1/2) -- wipe orchestration (inert; no tr…
davidschachterADFA ad4699c
ADFA-6510: Instant Wipe PR4 (2/2) -- wire the circle gesture on all s…
davidschachterADFA e2ee8c6
ADFA-6510: mount SecurityController on the terminal (hide + FLAG_SECU…
davidschachterADFA 7030f04
ADFA-6510: Instant Wipe PR5 -- tamper tripwire + neutralization-on-la…
davidschachterADFA fd7ff41
ADFA-6510: tamper neutralizes instead of re-wiping
davidschachterADFA 5f54f03
ADFA-6510: close the splash-screen concealment leak on the stealth la…
davidschachterADFA 4801fd0
ADFA-6510: add an Instant Hide gesture rehearsal (parity with Instant…
davidschachterADFA b02dd6b
ADFA-6510: address self-review findings (F01-F05)
davidschachterADFA f94c610
ADFA-6510: address self-review nits (F06-F09)
davidschachterADFA d87b55a
Merge branch 'stage' into feature/ADFA-40-instant-hide
davidschachterADFA c53d755
Merge origin/feature/ADFA-40-instant-hide into feature/ADFA-6510-inst…
davidschachterADFA af5918b
ADFA-6510: wipe-aware launcher-alias reconcile (folds in ADFA-6507)
davidschachterADFA a7b0847
ADFA-6510: pin the ADFA-6507 alias ordering + reconcile with unit tests
davidschachterADFA 774498c
ADFA-6510: address PR #2137 review (F01 exit guard, F02 marker ordering)
davidschachterADFA abfb237
Merge branch 'stage' into feature/ADFA-40-instant-hide
davidschachterADFA 88d1a7d
Merge branch 'feature/ADFA-40-instant-hide' into feature/ADFA-6510-in…
davidschachterADFA 6452f50
Merge branch 'stage' into feature/ADFA-40-instant-hide
davidschachterADFA 0da3e75
Merge branch 'feature/ADFA-40-instant-hide' into feature/ADFA-6510-in…
davidschachterADFA 7db4744
Merge branch 'stage' into feature/ADFA-40-instant-hide
davidschachterADFA 6b127c0
Merge branch 'feature/ADFA-40-instant-hide' into feature/ADFA-6510-in…
davidschachterADFA 624b5e7
Merge branch 'stage' into feature/ADFA-40-instant-hide
davidschachterADFA e157811
style: spotless reformat CrashHandlerActivity, no functional change
davidschachterADFA 7883d86
ADFA-40: keep the launcher component name so pinned icons survive
davidschachterADFA f724770
ADFA-40: show the stealth icon on the disguise's Recents card
davidschachterADFA 7fc6218
ADFA-40: mount Instant Hide on every activity
davidschachterADFA 18006bb
Merge remote-tracking branch 'origin/feature/ADFA-40-instant-hide' in…
davidschachterADFA a75e2e0
Merge branch 'feature/ADFA-40-instant-hide' into feature/ADFA-6510-in…
davidschachterADFA 87dfd8f
ADFA-6510: keep a wiped install the disguise on every entry point
davidschachterADFA 732c2fc
ADFA-6510: wipe the relocated build output and Quick Build's scratch
davidschachterADFA ba954e5
ADFA-6510: never follow a symbolic link out of a wipe target
davidschachterADFA c09d360
ADFA-40: hide once per screen-off broadcast
davidschachterADFA ee9591d
Merge remote-tracking branch 'origin/feature/ADFA-40-instant-hide' in…
davidschachterADFA 3e5d00a
ADFA-40: keep the disguise up after a hide; restart the idle minute o…
davidschachterADFA e6b0a8f
Merge feature/ADFA-40-instant-hide into feature/ADFA-6510-instant-wipe
davidschachterADFA cad0788
ADFA-6510: start the wipe's disguise and the stealth splash's through…
davidschachterADFA b0ce82a
ADFA-6510: log wipe target paths in a dry run only
davidschachterADFA 439c54f
ADFA-40: document that the app's own name still shows while hidden
davidschachterADFA bed36d6
Merge feature/ADFA-40-instant-hide into feature/ADFA-6510-instant-wipe
davidschachterADFA 5099486
ADFA-6510: repair a launcher left with no icon or with both icons
davidschachterADFA bf132b0
ADFA-6510: stop other apps from starting StealthSplashActivity
davidschachterADFA b6946a0
Merge feature/ADFA-40-instant-hide into feature/ADFA-6510-instant-wipe
davidschachterADFA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
app/src/main/java/com/itsaky/androidide/activities/StealthSplashActivity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * This file is part of AndroidIDE. | ||
| * | ||
| * AndroidIDE is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * AndroidIDE is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.itsaky.androidide.activities | ||
|
|
||
| import android.app.Activity | ||
| import android.os.Bundle | ||
| import com.itsaky.androidide.security.InstantHide | ||
|
|
||
| /** | ||
| * Launcher entry for the stealth "Code Breaker" activity-aliases (ADFA-40 / ADFA-6510). | ||
| * | ||
| * Separate from [LauncherActivity] purely so its splash theme can avoid the real Code On The Go | ||
| * branding: the OS paints the system starting window from the launched activity's theme before any | ||
| * app code runs, so routing the stealth aliases through [LauncherActivity] (whose `AppTheme.Splash` | ||
| * shows the IDE logo) flashed that logo for ~200ms before the disguise appeared. A stealth alias is | ||
| * only ever enabled while the disguise is engaged, so tapping it must show only the game -- this | ||
| * forwards straight to the cryptogram, never the IDE, reusing a running one so the puzzle survives. | ||
| */ | ||
| class StealthSplashActivity : Activity() { | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| // The lifecycle callback has already shown the disguise if the app is hidden or neutralized. | ||
| if (!isFinishing) InstantHide.showDisguise(this, InstantHide.disguiseIntent(this)) | ||
| } | ||
| } |
168 changes: 168 additions & 0 deletions
168
app/src/main/java/com/itsaky/androidide/app/AppWipeService.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| /* | ||
| * This file is part of AndroidIDE. | ||
| * | ||
| * AndroidIDE is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * AndroidIDE is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.itsaky.androidide.app | ||
|
|
||
| import android.app.Activity | ||
| import android.content.Context | ||
| import android.content.Intent | ||
| import android.util.Log | ||
| import android.widget.Toast | ||
| import androidx.annotation.VisibleForTesting | ||
| import com.itsaky.androidide.BuildConfig | ||
| import com.itsaky.androidide.lookup.Lookup | ||
| import com.itsaky.androidide.preferences.internal.GeneralPreferences | ||
| import com.itsaky.androidide.preferences.internal.SecurityPreferences | ||
| import com.itsaky.androidide.projects.IProjectManager | ||
| import com.itsaky.androidide.projects.builder.BuildService | ||
| import com.itsaky.androidide.quickbuild.EnvironmentQuickBuildPaths | ||
| import com.itsaky.androidide.roomData.recentproject.RecentProjectRoomDatabase | ||
| import com.itsaky.androidide.security.InstantHide | ||
| import com.itsaky.androidide.security.LauncherAliasManager | ||
| import com.itsaky.androidide.security.NeutralizationMarker | ||
| import com.itsaky.androidide.security.SecurityOverride | ||
| import com.itsaky.androidide.security.WipeManager | ||
| import com.itsaky.androidide.security.WipePlan | ||
| import com.itsaky.androidide.security.WipeService | ||
| import com.itsaky.androidide.security.WipeTeardown | ||
| import com.itsaky.androidide.services.builder.BuildOutputLocation | ||
| import com.itsaky.androidide.utils.Environment | ||
| import com.termux.app.TermuxService | ||
| import com.termux.shared.termux.TermuxConstants | ||
| import kotlinx.coroutines.Dispatchers | ||
| import kotlinx.coroutines.MainScope | ||
| import kotlinx.coroutines.launch | ||
| import kotlinx.coroutines.withContext | ||
| import java.io.File | ||
| import java.util.concurrent.atomic.AtomicBoolean | ||
|
|
||
| /** | ||
| * The `:app` implementation of [WipeService] (ADFA-6510). It resolves the real on-device paths, tears | ||
| * down the IDE's runtime holds, presents the disguise, and runs [WipeManager] on the app-scoped | ||
| * coroutine with [Dispatchers.IO] (which outlives the activity it finishes). Honours the | ||
| * `/sdcard/Download/CodeOnTheGo.nowipe` dry-run override (debug-only dev/QA scaffold; remove before GA). | ||
| */ | ||
| class AppWipeService( | ||
| private val app: Context, | ||
| ) : WipeService { | ||
| // Guards against a second circle (on the just-shown disguise) starting a concurrent wipe before the | ||
| // first finishes blanking the prefs. Never reset: a wipe is terminal (a fresh process re-creates it). | ||
| private val wipeStarted = AtomicBoolean(false) | ||
|
|
||
| override fun trigger(activity: Activity) { | ||
| // The /sdcard/Download/CodeOnTheGo.nowipe override is honoured only in debug builds, so a | ||
| // dropped file can never silently no-op a real wipe in a release build (F02). | ||
| val dryRun = BuildConfig.DEBUG && SecurityOverride.isWipeDryRun() | ||
| if (!wipeStarted.compareAndSet(false, true)) return | ||
|
|
||
| // Present the disguise immediately (reuse Instant Hide's presentation): the Code Breaker game | ||
| // covers the screen while the destroy pass runs behind it. Shown in dry-run too, so the whole | ||
| // flow is exercised; the exit gesture restores it since dry-run writes no marker. | ||
| SecurityPreferences.isHiddenStateActive = true | ||
| runCatching { LauncherAliasManager.setStealthMode(activity, true) } | ||
| // As a hide does: floating windows and notifications outlive the activity and would show the IDE | ||
| // over the disguise until the teardown below reaches them. | ||
| InstantHide.hideOutsideActivities(app) | ||
| InstantHide.showDisguise(activity, InstantHide.newDisguiseIntent(activity)) | ||
|
|
||
| // File IO + build cancel: off the main thread, on the app scope so it survives the finished activity. | ||
| (app as IDEApplication).coroutineScope.launch(Dispatchers.IO) { | ||
| runCatching { Environment.init(app) } | ||
| val result = WipeManager.wipe(buildPlan(), teardown(dryRun), dryRun) { line -> Log.w(TAG, line) } | ||
| if (dryRun) { | ||
| // Advisory in dry-run only (QA). A real wipe shows nothing user-visible: a toast would | ||
| // pop over the disguise and announce the wipe to anyone watching the seized device (F01). | ||
| withContext(Dispatchers.Main) { | ||
| Toast | ||
| .makeText( | ||
| app, | ||
| "Instant Wipe dry run: ${result.enumeratedTargets.size} target(s), nothing deleted", | ||
| Toast.LENGTH_LONG, | ||
| ).show() | ||
| } | ||
| } else { | ||
| Log.w(TAG, "Instant Wipe complete") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| internal fun buildPlan(): WipePlan { | ||
| val db = app.getDatabasePath(RECENTS_DB) | ||
| val dbFiles = listOf(db, File(db.path + "-wal"), File(db.path + "-shm")) | ||
| return WipePlan( | ||
| // The user's source plus the small Recents DB files (sensitive metadata: project | ||
| // names/paths). The DB is closed first in a real wipe (see teardown), so shredding its files | ||
| // carries no open-fd hazard. Cache dirs inside each project are fast-deleted (skipDirs) so | ||
| // the shred stays fast on a multi-GB workspace. | ||
| secureTargets = listOfNotNull(Environment.PROJECTS_DIR) + dbFiles, | ||
| secureTargetSkipDirs = setOf("build", ".gradle", ".cg"), | ||
| // Bulk regenerable caches. Build output lives outside the projects since ADFA-4930, and | ||
| // Quick Build's scratch beside it; both hold the compiled app, and the build output's folder | ||
| // names carry the project names. | ||
| fastDeleteTargets = | ||
| listOfNotNull(Environment.ANDROIDIDE_HOME, Environment.GRADLE_USER_HOME) + | ||
| File(app.noBackupFilesDir, BuildOutputLocation.DIR_NAME) + | ||
| EnvironmentQuickBuildPaths(app).projectScratchRoot, | ||
| markerFiles = listOf(NeutralizationMarker.pipFile(app), NeutralizationMarker.pip2File(app)), | ||
| ) | ||
| } | ||
|
|
||
| private fun teardown(dryRun: Boolean): WipeTeardown = | ||
| object : WipeTeardown { | ||
| override fun stopEverything() { | ||
| // Cancel any in-progress Gradle build (async; fire-and-forget). Null when not running. | ||
| runCatching { | ||
| val build = Lookup.getDefault().lookup(BuildService.KEY_BUILD_SERVICE) | ||
| if (build != null && build.isBuildInProgress) build.cancelCurrentBuild() | ||
| } | ||
| // Stop the Termux session (delivered via startService; the service stops itself). | ||
| runCatching { | ||
| app.startService( | ||
| Intent(app, TermuxService::class.java).apply { | ||
| action = TermuxConstants.TERMUX_APP.TERMUX_SERVICE.ACTION_STOP_SERVICE | ||
| }, | ||
| ) | ||
| } | ||
| // Release the open project's in-memory state (does not touch files). | ||
| runCatching { IProjectManager.getInstance().destroy() } | ||
| // Close the Recents Room DB before its files are shredded, so no connection holds or | ||
| // rewrites them. Real wipe only: afterwards the app is neutralized and the IDE -- the | ||
| // DB's only user -- never runs again, so the now-closed cached instance is never touched. | ||
| // Skipped in dry-run, which must not mutate state (and where the app keeps running). | ||
| if (!dryRun) { | ||
| runCatching { | ||
| val db = RecentProjectRoomDatabase.getDatabase(app, MainScope()) | ||
| if (db.isOpen) db.close() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override fun resetBookkeeping() { | ||
| runCatching { GeneralPreferences.lastOpenedProject = GeneralPreferences.NO_OPENED_PROJECT } | ||
| } | ||
|
|
||
| override fun clearPreferences() { | ||
| SecurityPreferences.clearAll() | ||
| } | ||
| } | ||
|
|
||
| companion object { | ||
| private const val TAG = "AppWipeService" | ||
| private const val RECENTS_DB = "RecentProject_database" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.