diff options
Diffstat (limited to 'src/com/android/launcher3/compat/PackageInstallerCompat.java')
-rw-r--r-- | src/com/android/launcher3/compat/PackageInstallerCompat.java | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/com/android/launcher3/compat/PackageInstallerCompat.java b/src/com/android/launcher3/compat/PackageInstallerCompat.java index c7fe0cec8..112cca540 100644 --- a/src/com/android/launcher3/compat/PackageInstallerCompat.java +++ b/src/com/android/launcher3/compat/PackageInstallerCompat.java @@ -16,9 +16,13 @@ package com.android.launcher3.compat; +import android.content.ComponentName; import android.content.Context; +import android.content.pm.PackageInstaller; +import android.support.annotation.NonNull; import java.util.HashMap; +import java.util.List; public abstract class PackageInstallerCompat { @@ -46,19 +50,34 @@ public abstract class PackageInstallerCompat { public abstract void onStop(); public static final class PackageInstallInfo { + public final ComponentName componentName; public final String packageName; + public final int state; + public final int progress; - public int state; - public int progress; - - public PackageInstallInfo(String packageName) { - this.packageName = packageName; + private PackageInstallInfo(@NonNull PackageInstaller.SessionInfo info) { + this.state = STATUS_INSTALLING; + this.packageName = info.getAppPackageName(); + this.componentName = new ComponentName(packageName, ""); + this.progress = (int) (info.getProgress() * 100f); } public PackageInstallInfo(String packageName, int state, int progress) { - this.packageName = packageName; this.state = state; + this.packageName = packageName; + this.componentName = new ComponentName(packageName, ""); this.progress = progress; } + + public static PackageInstallInfo fromInstallingState(PackageInstaller.SessionInfo info) { + return new PackageInstallInfo(info); + } + + public static PackageInstallInfo fromState(int state, String packageName) { + return new PackageInstallInfo(packageName, state, 0 /* progress */); + } + } + + public abstract List<PackageInstaller.SessionInfo> getAllVerifiedSessions(); } |