20

Background

It might be useful for apps to allow to ask the user to answer why it was decided to uninstall them.

The problem

It seems that the Dolphin web browser app (and "everything me launcher") somehow managed to bypass it, and now it shows a webpage (on the default web browser) each time the app is being uninstalled.

This happens even if I uninstall using ADB.

As a user, I really hate it, but it's still interesting since as far as I know, apps can't get intents for the uninstallation of themselves.

Question

How could it be? How did they manage to overcome this?

Is this a hack?

android developer
  • 114,585
  • 152
  • 739
  • 1,270
  • Does dolphin uses device admin? – Pankaj Kumar Aug 26 '13 at 08:58
  • @PankajKumar no. it didn't show any special dialog. it also doesn't seem to have a permission to check running apps, and even though it has a permission to read from logs, it wouldn't work since i've tested it on a 4.1.2 device... – android developer Aug 26 '13 at 09:00
  • That might be the less known solution I think. Actually the same App prevents user to clear app data and shows own screen, when I was working on an application I looked for that solution and Found that. So I think solution must exists (Without any hack)... – Pankaj Kumar Aug 26 '13 at 09:06
  • @PankajKumar are you sure? they seem to have a special clearing actions in the manage-application app, which prevents me from testing it . i didn't even know it's possible to customize it . wonder how it's done too. – android developer Aug 26 '13 at 09:25
  • Yes I am sure for the "clear app data" option. – Pankaj Kumar Aug 26 '13 at 09:28
  • @PankajKumar how did you clear the app's data ? using adb ? i can't clear it using the normal way. it shows its own customized screen, even on older devices. – android developer Aug 26 '13 at 10:36
  • In customised screen you can see they gave some buttons, you can keep same as. Now you can clear prefs by clear method, for db you can write a method to delete all entries... in same way. By the way I just deleted all the files which was in application storage in my application.. – Pankaj Kumar Aug 26 '13 at 10:40
  • @PankajKumar so you used their screen. i thought you meant that their uninstallation link appears when you clear the data. in short - you see what i see, meaning their screen for cleaning stuff. – android developer Aug 26 '13 at 10:43
  • Actually I am talking about the feature which I used as same as dolphin that is "clear data". But I didn't have any idea about how they listen app uninstall. – Pankaj Kumar Aug 26 '13 at 10:48
  • Anything u found? How on earth they are listening and hitting URL? ADB i see 10-20 12:37:01.137: D/AndroidRuntime(4028): Calling main entry com.android.commands.am.Am 10-20 12:37:01.137: D/dalvikvm(4028): Note: class Landroid/app/ActivityManagerNative; has 163 unimplemented (abstract) methods 10-20 12:37:01.147: I/ActivityManager(527): START u0 {act=android.intent.action.VIEW dat=http://survey.dolphin.com/int/uninstall?id=014f4d198 – NitZRobotKoder Oct 20 '13 at 08:26
  • 1
    @NitZRobotKoder no i haven't found anything. still, it's interesting to know how they did it. – android developer Oct 20 '13 at 09:56
  • @NitZRobotKoder i think you've put the wrong link... – android developer Oct 20 '13 at 10:26
  • @android developer i have started a separate version of mine lets moniter here. http://stackoverflow.com/questions/19475765/androidlisten-to-own-application-uninstall-event – NitZRobotKoder Oct 20 '13 at 14:08
  • @NitZRobotKoder why did you do it? – android developer Oct 20 '13 at 15:18
  • @android developer just to more audience alert on this.Later we can mark as duplicate. – NitZRobotKoder Oct 20 '13 at 15:25
  • @NitZRobotKoder ok. please let me know if you find anything. – android developer Oct 21 '13 at 06:41
  • In the google play console there are plenty of graphs to show uninstalled by device, country, version etc.. maybe they are showing that data? – reidisaki Feb 10 '14 at 23:06
  • @reidisaki what are you talking about? – android developer Feb 10 '14 at 23:29
  • I guess they made something on a NDK layer. I think (not sure) there are some possibilities to overcome any SDK feature (especially if device is rooted). Like it could be some kind of a service used to track this. – Stan May 05 '15 at 13:30
  • @androiddeveloper did you find anything on this topic ? please help here http://stackoverflow.com/questions/31192938/how-to-get-uninstall-event-of-own-application thanks in advance :) – N Sharma Jul 02 '15 at 19:22

3 Answers3

1

Maybe the app has a background service which checks the foreground app when it's own onDestroy() callback is fired, and if the foreground app is the uninstalling activity of android Package installer, it launch a new intent for the webpage?

Louis CAD
  • 10,965
  • 2
  • 39
  • 58
  • 1
    Could be, and maybe the service's process is different than the one of the app. – android developer May 05 '15 at 12:40
  • You can have any kind of service in your app but even if it runs in a separate process it would be uninstalled with app together. Service is not an app you could install/uninstall separately. I guess ATM app is being uninstalled any its services would be killed right away. So it won't work this way. – Stan May 05 '15 at 13:41
  • I think services and other app process are properly killed with callbacks and a deadline, so, if the app was writing in shared storage (SD card, flash media memory...), files don't get corrupted. – Louis CAD May 05 '15 at 13:50
  • Maybe. Someone also said that maybe they use NDK to overcome this. – android developer May 05 '15 at 14:23
0

My guess is that they're using ACTION_PACKAGE_REMOVED. http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REMOVED Either that, or Robin Hood and Frei Tuck method, where each one listens to broadcasts events from the other.
Just a guess, but will look into it.
This might be an option: How can an app detect that it's going to be uninstalled?

Community
  • 1
  • 1
Filipe YaBa Polido
  • 1,656
  • 1
  • 17
  • 39
  • 1
    no, this intent cannot be received by the app that get uninstalled. even the documentation say so: "The package that is being installed does not receive this Intent." – android developer Feb 15 '14 at 14:07
  • After posting, I've came across a site that says this doesn't work on 4.4 However, having 2 programs is still plausible?! I've done this before, program X looks for Y, and Y looks for X, if any of them stops, the other starts it again. – Filipe YaBa Polido Feb 15 '14 at 15:03
  • an app cannot (and should not) force the user to install another app. it can get the event of uninstallation of another app, but that's not the question i've asked here. can you please show me the website you are talking about? – android developer Feb 15 '14 at 15:51
  • Hmm... contradicting information on various websites, let me do some tests on Eclipse, I'll post the results then. – Filipe YaBa Polido Feb 15 '14 at 16:31
  • i've already tried this intent, if that's what you are asking about - the documentation is correct : it won't be sent to the app that is being uninstalled... – android developer Feb 15 '14 at 16:42
  • Well... I'm giving up on this, even Dolphin in uninstalled without any warning or new activity (using CM10 ROM). – Filipe YaBa Polido Feb 15 '14 at 17:33
  • so it occurs even there? perhaps they found a weak spot that they abuse it. maybe it's totally different from what we think of. i was thinking maybe they use BackupAgent, so that when it tries to backup, they will check if the app is being uninstalled, but i didn't succeed checking out this theory. – android developer Feb 15 '14 at 17:51
  • I was trying to reproduce the original to understand what was going on, but can't. It uninstalls normally. – Filipe YaBa Polido Feb 15 '14 at 18:04
  • I don't understand. are you saying that on CM it doesn't open a website after uninstallation? – android developer Feb 15 '14 at 18:57
  • Yes, it just uninstalls without alerts or something. I'm using this one: https://play.google.com/store/apps/details?id=mobi.mgeek.TunnyBrowser Must try on a stock rom to see. – Filipe YaBa Polido Feb 15 '14 at 19:05
  • i've tried again and it does open a website. maybe you forgot to open the app before uninstalling it? please try to install, then run it, and only after that, uninstall it. – android developer Feb 15 '14 at 22:04
  • No, only thing different, besides CM rom it's that I have Link2SD installed and it links automatically all the apps. I'll try again in another phone. – Filipe YaBa Polido Feb 15 '14 at 22:21
  • what does Link2SD have to do with that? it just moves apps to the sd card, no? – android developer Feb 15 '14 at 22:24
0

Please try to get the top activity in the task via ActivityManager, and check if it is the uninstall activity.

Core code:

ComponentName topActivity = mActivityManager.getRunningTasks(1).get(0).topActivity;
String packageName = topActivity.getPackageName();
String className = topActivity.getClassName();
Log.v(TAG, "packageName" + packageName);
Log.v(TAG, "className" + className);

if ("com.android.packageinstaller".equals(packageName)
    && "com.android.packageinstaller.UninstallerActivity".equals(className)) {
//Do anything you want here
}
vaibhav
  • 634
  • 1
  • 4
  • 23
  • I don't think this is how they did it because it was triggered even by uninstalling using root. I wonder though how come I don't see this behavior now on Android 5.1 . Could it be that they've stopped with this behavior? – android developer May 22 '15 at 10:12