X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fandroid%2Fappmgr%2Fsrc%2Forg%2Fanbox%2Fappmgr%2FPackageEventReceiver.java;fp=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fandroid%2Fappmgr%2Fsrc%2Forg%2Fanbox%2Fappmgr%2FPackageEventReceiver.java;h=1f299ba160ff5e268e415c1819729d00ba3077d4;hb=e26c1ec581be598521517829adba8c8dd23a768f;hp=0000000000000000000000000000000000000000;hpb=6699c1aea74eeb0eb400e6299079f0c7576f716f;p=iec.git diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/PackageEventReceiver.java b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/PackageEventReceiver.java new file mode 100644 index 0000000..1f299ba --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/PackageEventReceiver.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +package org.anbox.appmgr; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.util.Log; + +public class PackageEventReceiver extends BroadcastReceiver { + private static final String TAG = "AnboxAppMgr"; + + private PlatformService mPlatformService; + + private String getPackageName(Intent intent) { + Uri uri = intent.getData(); + String package_name = (uri != null ? uri.getSchemeSpecificPart() : null); + return package_name; + } + + @Override + public void onReceive(Context context, Intent intent) { + if (mPlatformService == null) + mPlatformService = new PlatformService(context); + + if (intent.getAction() == Intent.ACTION_PACKAGE_ADDED || + intent.getAction() == Intent.ACTION_PACKAGE_CHANGED) { + // Send updated list of applications to the host so that it + // can update the list of applications available for the user. + mPlatformService.sendApplicationListUpdate(); + } else if (intent.getAction() == Intent.ACTION_PACKAGE_REMOVED) { + // Only send notification when package got removed and not replaced + if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { + mPlatformService.notifyPackageRemoved(getPackageName(intent)); + } + } + } +}