Search in sources :

Example 1 with InstallerDelegate

use of org.chromium.chrome.browser.banners.InstallerDelegate in project AndroidChromium by JackyAndroid.

the class WebApkInstaller method installAsyncAndMonitorInstallationFromNative.

/**
     * Installs a WebAPK and monitors the installation process.
     * @param filePath File to install.
     * @param packageName Package name to install WebAPK at.
     * @return True if the install was started. A "true" return value does not guarantee that the
     *         install succeeds.
     */
@CalledByNative
private boolean installAsyncAndMonitorInstallationFromNative(String filePath, String packageName) {
    if (!installingFromUnknownSourcesAllowed()) {
        Log.e(TAG, "WebAPK install failed because installation from unknown sources is disabled.");
        return false;
    }
    mIsInstall = true;
    mWebApkPackageName = packageName;
    // Start monitoring the installation.
    PackageManager packageManager = ContextUtils.getApplicationContext().getPackageManager();
    mInstallTask = new InstallerDelegate(Looper.getMainLooper(), packageManager, createInstallerDelegateObserver(), mWebApkPackageName);
    mInstallTask.start();
    // Start monitoring the application state changes.
    mListener = createApplicationStateListener();
    ApplicationStatus.registerApplicationStateListener(mListener);
    return installDownloadedWebApk(filePath);
}
Also used : PackageManager(android.content.pm.PackageManager) InstallerDelegate(org.chromium.chrome.browser.banners.InstallerDelegate) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 2 with InstallerDelegate

use of org.chromium.chrome.browser.banners.InstallerDelegate in project AndroidChromium by JackyAndroid.

the class AppBannerInfoBarDelegateAndroid method createIntentCallback.

private WindowAndroid.IntentCallback createIntentCallback(final AppData appData) {
    return new WindowAndroid.IntentCallback() {

        @Override
        public void onIntentCompleted(WindowAndroid window, int resultCode, ContentResolver contentResolver, Intent data) {
            boolean isInstalling = resultCode == Activity.RESULT_OK;
            if (isInstalling) {
                // Start monitoring the install.
                PackageManager pm = getPackageManager(ContextUtils.getApplicationContext());
                mInstallTask = new InstallerDelegate(Looper.getMainLooper(), pm, createInstallerDelegateObserver(), appData.packageName());
                mInstallTask.start();
            }
            nativeOnInstallIntentReturned(mNativePointer, isInstalling);
        }
    };
}
Also used : PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent) WindowAndroid(org.chromium.ui.base.WindowAndroid) InstallerDelegate(org.chromium.chrome.browser.banners.InstallerDelegate) ContentResolver(android.content.ContentResolver)

Aggregations

PackageManager (android.content.pm.PackageManager)2 InstallerDelegate (org.chromium.chrome.browser.banners.InstallerDelegate)2 ContentResolver (android.content.ContentResolver)1 Intent (android.content.Intent)1 CalledByNative (org.chromium.base.annotations.CalledByNative)1 WindowAndroid (org.chromium.ui.base.WindowAndroid)1