Merge pull request #2008 from rhari991/remove-uninstalled-apps-automatically

Remove api apps when they are uninstalled
This commit is contained in:
Dominik Schürmann 2017-01-24 11:40:25 +01:00 committed by GitHub
commit 4bdccd329c
2 changed files with 31 additions and 0 deletions

View file

@ -110,6 +110,13 @@
<action android:name="org.torproject.android.intent.action.STATUS"/>
</intent-filter>
</receiver>
<!-- broadcast receiver for listening to package uninstalls -->
<receiver android:name=".remote.PackageUninstallReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
<data android:scheme="package"/>
</intent-filter>
</receiver>
<!-- singleTop for NFC dispatch, see SecurityTokenOperationActivity -->
<activity
android:name=".ui.MainActivity"

View file

@ -0,0 +1,24 @@
package org.sufficientlysecure.keychain.remote;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import org.sufficientlysecure.keychain.provider.KeychainContract;
public class PackageUninstallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_PACKAGE_FULLY_REMOVED.equals(intent.getAction())) {
Uri uri = intent.getData();
if (uri == null) {
return;
}
String packageName = uri.getEncodedSchemeSpecificPart();
Uri appUri = KeychainContract.ApiApps.buildByPackageNameUri(packageName);
context.getContentResolver().delete(appUri, null, null);
}
}
}