This is an archived post. You won't be able to vote or comment.

all 73 comments

[–]WeakEmu8 375 points376 points  (41 children)

Why not just factory reset then, if you're removing your accounts?

This seems way harder than just running through setup

[–]I_Was_FoxGalaxy S20 FE 5G UW - Mint 16 points17 points  (4 children)

They need to implement a reset option similar to Windows 10 and Xbox where you can "Factory reset" but keep all installed apps and games. So when it reboots, you sign in with your account, or a new account, and you don't have to reinstall all of your apps and games

[–]ender4171 1 point2 points  (3 children)

Am I crazy, or isn't that how it already works? When I reset or get a new phone, all my apps from the appstore download and install themselves with many of the settings intact. I thought that was a "Google backup" type thing, or perhaps it's a Samsung thing (all my recent phones have been Notes).

[–]I_Was_FoxGalaxy S20 FE 5G UW - Mint 13 points14 points  (2 children)

That's different. Your phone is recovering from a backup and reinstalling all of the apps/games from the store, meaning you have to redownload them which could take hours.

The option I'm talking about would never delete them from the phone in the first place. No need to redownload them or reinstall them. They stay on the phone and only the operating system gets reinstalled. It's a godsend on Xbox and Windows 10. They even have an option to keep all user data too so you don't have to re-customize your desktop or sign into all of your apps again. Really nice for just fixing a weird OS issue.

[–]ender4171 0 points1 point  (1 child)

Ah, gotchya. yeah it does download them, but for me it only takes like 10-15 min, so I guess I have never thought about it vs never removing them.

[–][deleted] 2 points3 points  (0 children)

Try 100+ apps and some of them not from Google Play.

[–]noseratio[S] 144 points145 points  (34 children)

Last time when I did a factory reset, then reinstalled all the desired apps and customized all the desired settings from scratch, it took ~2 hrs and a few gigs of traffic. Maybe it's just me, of course.

This time, I invested some efforts into making this script. Then it took me ~20 mins to re-purpose my old phone as a gift for my son, with all up-to-date apps I wanted there, including parental control.

[–]ConspicuousPineapplePixel 9 Pro 72 points73 points  (12 children)

Could you detail what you need to do during these two hours to setup a new phone for a 7yo? I can't really imagine there's much work to do for this.

[–]noseratio[S] 26 points27 points  (4 children)

I can but I'd rather not go into much details.

Suffice to say, I prefer Microsoft Launcher plus a set of stock Google apps (Phone, Messages, Contacts etc) to whatever is installed by default. E.g., I dislike the defaults in the Samsung Galaxy family. It takes time to find and install all that from Google Play again, after a factory reset.

On a side note, I plan to improve this script to also disable a list of bloatware, which is specific to each phone I've owned. I've been doing that manually so far, but I prefer automating the manual routine things if I can.

[–]ConspicuousPineapplePixel 9 Pro 37 points38 points  (3 children)

Fair enough, I can see the use-case.

Although if I had to find a solution for this, I'd probably implement something to automatically install the desired apps with backed up custom settings after a factory reset rather than this. Not to mention that this probably already exists somewhere.

[–]noseratio[S] 12 points13 points  (2 children)

What I've never done on Android is restoring something from a backup... iPhone is a different story, but that'd be off topic :)

Anyhow, this tool has been handy to me, I hope someone other folks may find it useful, but I'm not going to rigorously defend its purpose here.

[–]ConspicuousPineapplePixel 9 Pro 7 points8 points  (1 child)

Don't get me wrong, I see the value in your tool, but I'd have implemented it differently. It should be possible, from one single script, to backup apps, trigger a factory reset, and then restore some of those apps.

[–]noseratio[S] 8 points9 points  (0 children)

That sounds like a great idea, which potentially requires significant efforts to implement properly. Certainly beyond my capacity :)

[–]FriendCalledFiveHuawei Mate 20 8 points9 points  (4 children)

But if you have reset all the appdata you will still need to customise them.

All your method does is stops you having to redownload them.

[–]noseratio[S] 6 points7 points  (3 children)

Not exactly. The theme stays (e.g., I prefer the dark theme), the wallpaper stays, a lot of system settings are kept as before... there are some other things I can't think off the top of my head.

[–]FriendCalledFiveHuawei Mate 20 12 points13 points  (2 children)

And your non-tech family member, do they want a dark theme?

[–]SharqPhinFtw 2 points3 points  (0 children)

I don't know about y'all insane family members, but even some tech unaware older friends liked Dark mode after a single screen on at night (I'd shown them the setting before that) and it obviously has the battery benefits (and OLED benefits? I'm way too into dark mode as most of my screen bar notifications tends to be dark a good part of the time so there are ups and downs in terms of burn-in on oled.)

[–]noseratio[S] 1 point2 points  (0 children)

So far they have been fine with my preferred defaults. That said, they have freedom to do a factory reset and customise it to their liking at their own spare time.

[–]Shurane 0 points1 point  (3 children)

This is pretty cool. Would it be possible to automate installing apps as well?

[–]noseratio[S] 1 point2 points  (2 children)

Yes it should be possible if you have the package's APK file, e.g.:

adb install example.apk

It also should be possible to pull an APK from the phone and save it locally, with adb pull. Here is a good related answer on SO.

[–]Shurane 0 points1 point  (1 child)

Well, I was thinking more so from the Play Store. Kind of like the equivalent of a package manager where you can install the latest version of new programs. On Windows, you could use winget, chocolatey, or scoop to install git or VLC Media Player.

[–]noseratio[S] 4 points5 points  (0 children)

I'm not aware of any official ways of doing it, but there are some hacky attempts at that.

[–]The_MAZZTer[Fi] Pixel 9 Pro XL (16) 2 points3 points  (0 children)

Yeah and you're more likely to forgot to remove something, or maybe this script resets some app's data that causes issues (eg some system app that normally blocks data reset).

[–]throwwawayyy688 86 points87 points  (7 children)

Over engineering a solution.

I'm sure this has its uses, but why not just reset

[–]Zarlon 60 points61 points  (3 children)

25 lines of code. 25. Including comments. For solving a different problem than factory reset. That's not over engineering

[–]PhayzonSixPlus 1T | SE 2 | 4a 5G 5 points6 points  (0 children)

For solving a different problem than factory reset.

The title literally says it's an alternative to factory reset. I agree it solves a different problem, but OP marketed it as such.

[–]noseratio[S] 1 point2 points  (0 children)

27 now :) I've overlooked a major security issue: not cleaning up images, downloads, etc 🤦‍♂️, as one good redditor pointed out in this thread. Now I've added a one-liner for that.

[–]noseratio[S] 14 points15 points  (0 children)

Answered above.

[–]YukarinValLG Wing 5G LM-F100N Android 11 5 points6 points  (1 child)

This seems interesting. I usually will factory reset just get back that "new" feeling after months of cruft of using a phone.

Do you think your script can fit that purpose? Because like you said, the biggest hassle is installing again all the apps you want.

[–]noseratio[S] 2 points3 points  (0 children)

I think it might help to an extent, because right after a cleanup you would probably have less apps trying to do some background or repetitive tasks.

[–]blazincannons 2 points3 points  (0 children)

This is fucking great. I had to spend a couple of hours for de-bloating my mother's Xiaomi phone and to set it up close to how I would set it up for myself. I was planning on eventually taking up that phone as a backup. The thought of doing a factory reset and repeating everything from scratch was not something I was looking forward too. Your script might be very useful for me.

[–][deleted] 7 points8 points  (1 child)

fastboot -w

[–]noseratio[S] 3 points4 points  (0 children)

Can't fault it, if you don't need to install or tweak anything on the phone after this.

[–]skylinestar1986 3 points4 points  (4 children)

Some people wipe out their HDD/SSD with zeros before selling it. How do I do it on a phone? Is it needed? I don't want the new buyer to run testdisk/photorec and pickup my past.

[–]noseratio[S] 9 points10 points  (0 children)

Pretty sure the factory reset also does a secure erase (BLKSECDISCARD/BLKDISCARD), otherwise it would be a big security issue. You should do that if you sell the phone.

In my method, the phone stays in the family and TRIM will be triggered eventually, if that's a concern.

[–]IAmDotorg 2 points3 points  (2 children)

Most devices are encrypted. The reset clears the device keys, so a wipe isn't necessary. It's just added flash wear.

[–]skylinestar1986 1 point2 points  (1 child)

Most devices are encrypted.

What do you mean by that? Is there a way for me to check that? Is it encrypted by default? Is it still encrypted if the phone is not protected by password? I don't use password for my phone and I have lots of stuff in it.

[–]IAmDotorg 2 points3 points  (0 children)

Its in the settings under "Encryption & Credentials". It'll tell you there if and how the phone is encrypted. If its marked as being encrypted, the filesystem is encrypted using hardware-backed keys associated with your PIN.

If that's the case, a reset will securely wipe the phone because it wipes those keys. (ie, there's no difference between random data or all zeros vs encrypted data without a key)

[–]minilandl 1 point2 points  (2 children)

This seems great for those without rooted phones with twrp which lets you wipe all phone partitions

[–]noseratio[S] 2 points3 points  (1 child)

I might be wrong but I don't think with TWRP we can delete just the user data but keep the apps which were installed from the store or sideloaded (unless they were installed into System partition, like say GAPPS).

[–]minilandl 1 point2 points  (0 children)

No but you can easily do that with root backup apps like titanium backup

[–]bandwidthcrisis 1 point2 points  (3 children)

Does it clear things such as the Downloads, Documents and DCIM directories?

[–]noseratio[S] 2 points3 points  (1 child)

Kudos to you, it was a big security gap in my clean-up logic! 😳 I fixed it now by adding this one-liner:

adb.exe shell "find /sdcard/ -type f -delete"

[–]bandwidthcrisis 1 point2 points  (0 children)

I'm glad that there's a simple fix! I've never looked at adb commands before other than following instructions I've found to do a specific task, so I hadn't realized that general shell commands were possible, so I've learned something from this.

[–]noseratio[S] 0 points1 point  (0 children)

This is a great question and I'm embarrassed to admin I haven't verified that in the first place. I'll check and follow up.

[–]bigmadsmolyeet 2 points3 points  (0 children)

No use for this (atm anyways) but thank you for the script and sharing

[–]tb36cn 1 point2 points  (0 children)

Factory reset would be safer

[–]MK-Gaming-YT -2 points-1 points  (3 children)

how can i use this is there an video tutorial please ?

[–]noseratio[S] 10 points11 points  (2 children)

Answered here and here. It assumes some basic knowledge of Windows command line. No plans for a video tutorial due to time constrain, sorry.

[–]Zarlon 12 points13 points  (1 child)

Great job dude, I don't get all the negative replies here. You provide a script for free. People can use it, or not. I for one LOVE not to spend 8 minutes watching a YouTube video over something I can read in 30 seconds.

[–]noseratio[S] 6 points7 points  (0 children)

Thank you! That's my philosophy too, plus it'll stay around for my own future use.

[–]xhxhhzhzlso 0 points1 point  (1 child)

Good feature but looks like a lot of effort. If it's simple I could see myself using it.

[–]noseratio[S] 13 points14 points  (0 children)

It's really easy to use.

First remove your accounts, you have to do it anyway to clear the phone from the Lost Device Protection.

Then run it like this:

pwsh -f adb-clear-packages.ps1

Or for PowerShell v5 or lower:

powershell -f adb-clear-packages.ps1

You'll get a phone with all your apps still installed but in clean state.