# Seed demo contacts + SMS for Messaging UI preview (emulator-5556) # Usage: powershell -ExecutionPolicy Bypass -File tools/seed_demo_data.ps1 $ErrorActionPreference = "Continue" $sdk = "$env:LOCALAPPDATA\Android\Sdk" $adb = Join-Path $sdk "platform-tools\adb.exe" $serial = "emulator-5556" function Invoke-Adb { param([Parameter(ValueFromRemainingArguments = $true)][string[]]$CmdArgs) & $adb -s $serial @CmdArgs } Write-Host "== Default SMS + permissions ==" Invoke-Adb shell cmd role add-role-holder android.app.role.SMS com.bnkode.notie | Out-Null Invoke-Adb shell settings put secure sms_default_application com.bnkode.notie | Out-Null foreach ($p in @( "READ_SMS","RECEIVE_SMS","SEND_SMS","RECEIVE_MMS", "READ_CONTACTS","WRITE_CONTACTS","READ_PHONE_STATE", "READ_PHONE_NUMBERS","POST_NOTIFICATIONS" )) { Invoke-Adb shell pm grant com.bnkode.notie "android.permission.$p" 2>$null | Out-Null } $demo = @( @{ Name = "Sarah Jenkins"; Phone = "+15551230001"; Msgs = @("Can you review the Looply mock before standup?","Also dropped the Figma link.","Morning! Coffee run in 10?") } @{ Name = "Product Design"; Phone = "+15551230002"; Msgs = @("Team sync moved to 3pm.","New icon set is ready for QA.") } @{ Name = "David Chen"; Phone = "+15551230003"; Msgs = @("On my way - traffic near Market St.","Got the package. Thanks!") } @{ Name = "Marcus Knight"; Phone = "+15551230004"; Msgs = @("Ship checklist looks good. Ship it.","Need one more screenshot.") } @{ Name = "Priya Patel"; Phone = "+15551230005"; Msgs = @("Unread reminder: invoice 4821 waiting.","Ping me when you are free.") } @{ Name = "Alex Rivera"; Phone = "+15551230006"; Msgs = @("Weekend hike still on?","Bring extra water.") } @{ Name = "Jordan Lee"; Phone = "+15551230007"; Msgs = @("Draft PR for home chips is up.","Can you take a look before EOD?") } @{ Name = "Mom"; Phone = "+15551230008"; Msgs = @("Call me when you land.","Love you!") } @{ Name = "Cafe Nova"; Phone = "+15551230009"; Msgs = @("Your order is ready for pickup.","Table for 2 confirmed at 7:30.") } @{ Name = "Bank Alerts"; Phone = "+15551230010"; Msgs = @("Purchase of 42.18 at LOOPLY MARKET.","Your statement is available.") } @{ Name = "Nina Okonkwo"; Phone = "+15551230011"; Msgs = @("Shared the brand tokens doc.","Purple 5A31F4 is locked.") } @{ Name = "Chris Park"; Phone = "+15551230012"; Msgs = @("Gym at 6?","Bring the resistance bands.") } @{ Name = "Emily Watson"; Phone = "+15551230013"; Msgs = @("Flight delayed 40 min.","See you at baggage claim.") } @{ Name = "Support Desk"; Phone = "+15551230014"; Msgs = @("Ticket 9021 resolved. Reply STOP to opt out.","We received your request.") } @{ Name = "Leo Martinez"; Phone = "+15551230015"; Msgs = @("Game night Friday?","I will bring snacks.") } @{ Name = "Hannah Kim"; Phone = "+15551230016"; Msgs = @("Updated the contacts card layout.","Looks much closer to Message Q.") } @{ Name = "Delivery"; Phone = "+15551230017"; Msgs = @("Driver is 3 stops away.","Pin: leave at door.") } @{ Name = "Sam Torres"; Phone = "+15551230018"; Msgs = @("Lunch tomorrow?","That new ramen place.") } @{ Name = "Auto Bot"; Phone = "+15551230019"; Msgs = @("Automation rule ran successfully.","3 messages routed to Archives.") } @{ Name = "Riley Quinn"; Phone = "+15551230020"; Msgs = @("Photo from the rooftop attached concept.","Cant wait for launch week!") } @{ Name = "Dr Patel"; Phone = "+15551230021"; Msgs = @("Appointment confirmed for Tue 10:30am.","Reply C to confirm.") } @{ Name = "Gym Club"; Phone = "+15551230022"; Msgs = @("Class starts in 20 minutes.","Membership renews next month.") } @{ Name = "Mia Chen"; Phone = "+15551230023"; Msgs = @("Sent the locale strings.","KO EN both look good.") } @{ Name = "Owen Brooks"; Phone = "+15551230024"; Msgs = @("Parking is full - use lot B.","See you inside.") } ) Write-Host "== Contacts ($($demo.Count)) ==" foreach ($c in $demo) { Invoke-Adb shell "content insert --uri content://com.android.contacts/raw_contacts --bind account_type:s:com.android.local --bind account_name:s:Phone" | Out-Null $row = (Invoke-Adb shell "content query --uri content://com.android.contacts/raw_contacts --projection _id --sort '_id DESC'") | Select-Object -First 1 if ($row -match "_id=(\d+)") { $id = $Matches[1] Invoke-Adb shell "content insert --uri content://com.android.contacts/data --bind raw_contact_id:i:$id --bind mimetype:s:vnd.android.cursor.item/name --bind data1:s:'$($c.Name)'" | Out-Null Invoke-Adb shell "content insert --uri content://com.android.contacts/data --bind raw_contact_id:i:$id --bind mimetype:s:vnd.android.cursor.item/phone_v2 --bind data1:s:$($c.Phone) --bind data2:i:2" | Out-Null Write-Host " + $($c.Name)" } } Write-Host "== SMS threads ==" $sends = 0 foreach ($c in $demo) { for ($i = $c.Msgs.Count - 1; $i -ge 0; $i--) { Invoke-Adb emu sms send $c.Phone $c.Msgs[$i] | Out-Null $sends++ Start-Sleep -Milliseconds 120 } Write-Host " thread $($c.Name)" } Write-Host " sends=$sends" Write-Host "== Mark half read ==" for ($i = 0; $i -lt $demo.Count; $i += 2) { $phone = $demo[$i].Phone Invoke-Adb shell "content update --uri content://sms --bind read:i:1 --bind seen:i:1 --where `"address='$phone'`"" | Out-Null } Write-Host "== Relaunch ==" Invoke-Adb shell am force-stop com.bnkode.notie | Out-Null Start-Sleep -Seconds 1 Invoke-Adb shell am start -n com.bnkode.notie/com.android.messaging.ui.conversationlist.ConversationListActivity | Out-Null Write-Host "Done."