Skip to content

Try to preserve the app cache on uninstall. #10019

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
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dellis1972
Copy link
Contributor

Context #9259

Due to various reasons adb may not be able to preserve the app cache on uninstall. To work around this we have to use the -k flag to uninstall the app when using the cmd package uninstall call. This will keep the app data and cache on the device.

However this might also fail. So in that case we need to completely uninstall the app and then install it again.

Context #9259

Due to various reasons `adb` may not be able to preserve the app cache
on uninstall. To work around this we have to use the `-k` flag to
uninstall the app when using the `cmd package uninstall` call.
This will keep the app data and cache on the device.

However this might also fail. So in that case we need to completely
uninstall the app and then install it again.
@grendello
Copy link
Contributor

Can we make -k optional (used by default)? Removing the cache is important in performance testing, but
also when one needs to test the application to see how it works from scratch.

@dellis1972
Copy link
Contributor Author

Can we make -k optional (used by default)? Removing the cache is important in performance testing, but also when one needs to test the application to see how it works from scratch.

the -k tries to preserve the cache if it can. If someone uninstalls the app manually on the phone (or emulator) it will delete the cache .

@dellis1972
Copy link
Contributor Author

Can we make -k optional (used by default)? Removing the cache is important in performance testing, but also when one needs to test the application to see how it works from scratch.

note that the very first call to adb uninstall -k <package> has the -k in it.
This only gets used when you are using aab btw. So if the performance tests are using apk this code is completely skipped.

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

I was looking what "fast deployment" does for this in Debug mode, and I can only find the pm command:

Should we only use the pm command here instead of trying two commands? Just to make Debug & Release consistent?

We can also update this target, which is maybe not used:

<Target Name="_Uninstall">
<AndroidAdb
ToolExe="$(AdbToolExe)"
ToolPath="$(AdbToolPath)"
AdbTarget="$(AdbTarget)"
Command="uninstall"
Arguments="$(_AndroidPackage)"
/>
</Target>
<Target Name="Uninstall"
Condition="'$(AndroidApplication)'!='' And $(AndroidApplication)"
DependsOnTargets="$(UninstallDependsOnTargets)">
</Target>

Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
@dellis1972
Copy link
Contributor Author

I was looking what "fast deployment" does for this in Debug mode, and I can only find the pm command:

Should we only use the pm command here instead of trying two commands? Just to make Debug & Release consistent?

We can also update this target, which is maybe not used:

<Target Name="_Uninstall">
<AndroidAdb
ToolExe="$(AdbToolExe)"
ToolPath="$(AdbToolPath)"
AdbTarget="$(AdbTarget)"
Command="uninstall"
Arguments="$(_AndroidPackage)"
/>
</Target>
<Target Name="Uninstall"
Condition="'$(AndroidApplication)'!='' And $(AndroidApplication)"
DependsOnTargets="$(UninstallDependsOnTargets)">
</Target>

So just use the pm and remove the previous call? I'm ok with that, I'll update this PR.

@jonathanpeppers
Copy link
Member

You might review what android-platform-support does in case I missed it, to just check that it always uses pm uninstall.

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.

3 participants