Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 一些应用程序如何跟踪自己在android上的卸载_Java_Android_Java Native Interface_Uninstallation - Fatal编程技术网

Java 一些应用程序如何跟踪自己在android上的卸载

Java 一些应用程序如何跟踪自己在android上的卸载,java,android,java-native-interface,uninstallation,Java,Android,Java Native Interface,Uninstallation,我发现卸载后在浏览器中打开他们的页面 他们可以在所有android版本(4、5和6.*)上实现这一点,但我不知道如何实现 也许有人有什么想法?我知道同样的问题和其他问题,但他们仍然没有答案 “这不是inotify的bug,因为它只在

我发现卸载后在浏览器中打开他们的页面

他们可以在所有android版本(4、5和6.*)上实现这一点,但我不知道如何实现

也许有人有什么想法?我知道同样的问题和其他问题,但他们仍然没有答案

“这不是inotify的bug,因为它只在<4.4.2 android上工作,没有其他进程以新的方式监听相同的bug,”我检查道


他们的lib
永恒中有一些魔力。因此

应用程序可以通过操作指定一个
广播接收器

"android.intent.action.PACKAGE_REMOVED" 
每次删除包时都会调用它,即使它是应用程序自己的包。然后,在
接收器中
,应用程序可以检查到底是哪个软件包被移除,并做出相应的反应


请注意,不同版本的系统可能会对此进行不同的处理,在应用程序进程关闭之前,为
接收器提供不同的时间量。因此,执行的操作应该快速且针对外部目标,例如发送
操作视图
意图,其中包含您提到的网页url:-)

让我试着澄清一下

在Android 4.4之前,我们可以使用
inotify
,它提供了一种监控文件系统事件的机制,我们创建了一个守护进程来监控我们在应用程序目录中创建的文件是否被删除或我们的主应用程序目录是否被删除,这应该在用户卸载应用程序时发生,JNI代码将如下所示:

// initializes a new inotify instance and returns a file descriptor
fd = inotify_init();
// watch directory delete/create events 
inotify_add_watch(fd, DIRECTORY, IN_DELETE | IN_CREATE);
__android_log_print(ANDROID_LOG_INFO, "TAG", "Watching [%s]", DIRECTORY);
// TODO: implement checkIfDeleted
if(checkIfDeleted()) {
    // execute intent to open url
    system("/system/bin/am start --user 0 -a android.intent.action.VIEW -d https://www...");
这不再有效,因为卸载还会杀死组进程,并附加当前源代码中的相关代码

看看git

我需要更多的时间在无根设备上进行调查,360security使用特定的体系结构(也称为ABI)打包应用程序,并且可能按照API来减少APK大小,不幸的是,apkmirror(.com)只有ARM可供下载,我更喜欢阅读x86,可能在不久的将来编辑此答案

到目前为止,本机代码似乎正在创建文件并使用锁来检测卸载后进程何时死机,然后使用JNI接口调用回调

为了简化,它似乎将自身锁定,然后加入同步模块
notify_和_waitfor

您可以看到Android 5.0的本机代码示例

NativeHelper源代码(反编译):

所有带有关键字
native
的方法都在
externate
二进制文件中实现

package com.qihoo.eternity;

import com.qihoo.eternity.b;

public class NativeHelper {
    static {
        try {
            System.loadLibrary((String)"eternity");
        }
        catch (Exception exception) {}
    }

    public native void look(String var1, String var2, String var3, String var4, String var5);

    public void onU() {
        b.a().g();
    }

    public native void pass(String var1, String var2);

    public void peerDead() {
        b.a().f();
    }

    public native void watch(String var1, String var2, String var3, String var4);

    public native void watch2(String var1, String var2, String var3, String var4, String var5);
}
NativeHelper的应用程序引用:

com/qihoo/eternity/b.java:203:
    new NativeHelper().look(b.this.h.getPackageName(), b.b((b)b.this).f, string2, b.b(b.this.i), string3);
com/qihoo/eternity/b.java:224:
    new NativeHelper().watch(new File(file, "a1").getAbsolutePath(), new File(file, "a2").getAbsolutePath(), new File(file, "a3").getAbsolutePath(), new File(file, "a4").getAbsolutePath());
com/qihoo/eternity/b.java:264:
    new NativeHelper().watch(new File(file, "a2").getAbsolutePath(), new File(file, "a1").getAbsolutePath(), new File(file, "a4").getAbsolutePath(), new File(file, "a3").getAbsolutePath());
com/qihoo/eternity/b.java:518:
    new NativeHelper().pass(this.a, this.b);
com/qihoo/eternity/b.java:563:
    new NativeHelper().watch2(new File(file, "b1").getAbsolutePath(), new File(file, "b2").getAbsolutePath(), new File(file, "b3").getAbsolutePath(), new File(file, "b4").getAbsolutePath(), b.this.h.getDir("lib", 0).getAbsolutePath());
com/qihoo/eternity/b.java:588:
    new NativeHelper().watch2(new File(file, "b2").getAbsolutePath(), new File(file, "b1").getAbsolutePath(), new File(file, "b4").getAbsolutePath(), new File(file, "b3").getAbsolutePath(), b.this.h.getDir("lib", 0).getAbsolutePath());

一种解决方案是在JNI文件夹中包含共享对象
eventure.so
,并实现
NativeHelper.onU
method:)

@AdamArold,但链接的问题没有回答这个问题。公认的答案只是说“不,在同一个应用程序中不可能”,但没有解释为什么有些应用程序可以做到这一点。想想看,你有一个服务器,可以监听来自你安装的持续通信。经过一定时间后,如果没有看到响应,您应该能够将安装标记为无效。不过,这无助于在卸载时打开浏览器,但有助于跟踪活动状态users@cricket_007是的,您可以使用推送通知来跟踪它,例如像appsflyer跟踪系统那样。但你是怎么说打开浏览器对你没有帮助的uninstall@AlexanderPereverzev你找到解决办法了吗?没有!这不是事实,你的应用程序没有收到这个意图)看,嗯,我很确定我用这个方法做过一次。。。让我检查一下你是对的,它似乎不起作用。因此,他们必须使用一些黑客手段,比如卸载时调用的未记录回调,或者侦听主应用卸载的另一个应用。。。如果我有什么建议的话-打开他们的.apk并检查代码。即使它是模糊的,您也应该能够看到字符串常量,这可以让您了解它们是如何实现此行为的:-)我很感激其他人能够理解这一点,因为这是我以前尝试过的,只是发现它不起作用。这可以广播给其他应用程序接收,但不能卸载应用程序。@Kelevandos有其他应用程序可以实现这一点。请尝试找出黑客。感谢进一步调查此问题。只是一个想法,我们可以跟踪卸载屏幕的打开吗?我们可以钩住一切,系统调用和应用程序代码,但是,为了什么?当你问它是如何完成的,有一个守护进程没有被卸载流杀死,因为它没有连接到应用程序进程,或者它正在创建一些死锁,似乎它们使用
NativeHelper
和使用
new NativeHelper().watch()
new NativeHelper()为不同的abi编写了不同的代码.watch2
我们可以跟踪ARM的自卸载吗?另外,
新文件(文件,“a2”)
的值应该是多少?它应该是我们的应用程序私有目录中的某个内容吗?此外,此方法是否会消耗电池?1)仅在卸载时调用
onU()。2) 是的,它在应用程序的目录中创建文件,并使用锁和分叉进程,这样其中一个进程就不会被杀死,因为它不在同一个组中(通过在设备外壳中运行
ps
可以看到,例如查看组列
ua_51
)。3) 哪种方法?两个进程同时监视另一个进程的锁,其中一个进程可以立即听到另一个进程挂起的声音,因为它们是阻塞方法,没有功耗效率问题,而不是
usleep