Merge "Revert "Add UI updates for incremental app installs.""
This commit is contained in:
committed by
Android (Google) Code Review
commit
cdfed2320a
+1
-1
@@ -67,7 +67,7 @@ public class PackageInstallStateChangedTaskTest {
|
||||
for (ItemInfo info : mModelHelper.getBgDataModel().itemsIdMap) {
|
||||
if (info instanceof WorkspaceItemInfo) {
|
||||
assertEquals(updates.contains(info.id) ? progress: 0,
|
||||
((WorkspaceItemInfo) info).getProgressLevel());
|
||||
((WorkspaceItemInfo) info).getInstallProgress());
|
||||
} else {
|
||||
assertEquals(updates.contains(info.id) ? progress: -1,
|
||||
((LauncherAppWidgetInfo) info).installProgress);
|
||||
|
||||
@@ -50,7 +50,6 @@ import android.view.View;
|
||||
import android.view.ViewDebug;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
import com.android.launcher3.Launcher.OnResumeCallback;
|
||||
@@ -72,6 +71,7 @@ import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||
import com.android.launcher3.model.data.PackageItemInfo;
|
||||
import com.android.launcher3.model.data.PromiseAppInfo;
|
||||
import com.android.launcher3.model.data.RemoteActionItemInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.util.SafeCloseable;
|
||||
@@ -287,7 +287,10 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
public void applyFromWorkspaceItem(WorkspaceItemInfo info, boolean promiseStateChanged) {
|
||||
applyIconAndLabel(info);
|
||||
setTag(info);
|
||||
applyLoadingState(promiseStateChanged);
|
||||
if (promiseStateChanged || (info.hasPromiseIconUi())) {
|
||||
applyPromiseState(promiseStateChanged);
|
||||
}
|
||||
|
||||
applyDotState(info, false /* animate */);
|
||||
}
|
||||
|
||||
@@ -300,8 +303,9 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
// Verify high res immediately
|
||||
verifyHighRes();
|
||||
|
||||
if ((info.runtimeStatusFlags & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) {
|
||||
applyProgressLevel(info.getProgressLevel());
|
||||
if (info instanceof PromiseAppInfo) {
|
||||
PromiseAppInfo promiseAppInfo = (PromiseAppInfo) info;
|
||||
applyProgressLevel(promiseAppInfo.level);
|
||||
}
|
||||
applyDotState(info, false /* animate */);
|
||||
}
|
||||
@@ -331,10 +335,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
mDotParams.color = IconPalette.getMutedColor(info.bitmap.color, 0.54f);
|
||||
|
||||
setIcon(iconDrawable);
|
||||
applyLabel(info);
|
||||
}
|
||||
|
||||
private void applyLabel(ItemInfoWithIcon info) {
|
||||
setText(info.title);
|
||||
if (info.contentDescription != null) {
|
||||
setContentDescription(info.isDisabled()
|
||||
@@ -595,35 +595,21 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
mLongPressHelper.cancelLongPress();
|
||||
}
|
||||
|
||||
/** Applies the loading progress value to the progress bar.
|
||||
*
|
||||
* If this app is installing, the progress bar will be updated with the installation progress.
|
||||
* If this app is installed and downloading incrementally, the progress bar will be updated
|
||||
* with the total download progress.
|
||||
*/
|
||||
public void applyLoadingState(boolean promiseStateChanged) {
|
||||
public void applyPromiseState(boolean promiseStateChanged) {
|
||||
if (getTag() instanceof WorkspaceItemInfo) {
|
||||
WorkspaceItemInfo info = (WorkspaceItemInfo) getTag();
|
||||
int progressLevel = info.getProgressLevel();
|
||||
if ((info.runtimeStatusFlags & ItemInfoWithIcon.FLAG_INCREMENTAL_DOWNLOAD_ACTIVE)
|
||||
!= 0) {
|
||||
updateProgressBarUi(progressLevel, progressLevel == 100);
|
||||
} else if (info.hasPromiseIconUi() || (info.runtimeStatusFlags
|
||||
& ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
|
||||
updateProgressBarUi(progressLevel, promiseStateChanged);
|
||||
final boolean isPromise = info.hasPromiseIconUi();
|
||||
final int progressLevel = isPromise ?
|
||||
((info.hasStatusFlag(WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE) ?
|
||||
info.getInstallProgress() : 0)) : 100;
|
||||
|
||||
PreloadIconDrawable preloadDrawable = applyProgressLevel(progressLevel);
|
||||
if (preloadDrawable != null && promiseStateChanged) {
|
||||
preloadDrawable.maybePerformFinishedAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateProgressBarUi(int progressLevel, boolean maybePerformFinishedAnimation) {
|
||||
PreloadIconDrawable preloadDrawable = applyProgressLevel(progressLevel);
|
||||
if (preloadDrawable != null && maybePerformFinishedAnimation) {
|
||||
preloadDrawable.maybePerformFinishedAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
/** Applies the given progress level to the this icon's progress bar. */
|
||||
@Nullable
|
||||
public PreloadIconDrawable applyProgressLevel(int progressLevel) {
|
||||
if (getTag() instanceof ItemInfoWithIcon) {
|
||||
ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
|
||||
@@ -643,11 +629,9 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
if (mIcon instanceof PreloadIconDrawable) {
|
||||
preloadDrawable = (PreloadIconDrawable) mIcon;
|
||||
preloadDrawable.setLevel(progressLevel);
|
||||
preloadDrawable.setIsDisabled(!info.isAppStartable());
|
||||
} else {
|
||||
preloadDrawable = newPendingIcon(getContext(), info);
|
||||
preloadDrawable.setLevel(progressLevel);
|
||||
preloadDrawable.setIsDisabled(!info.isAppStartable());
|
||||
setIcon(preloadDrawable);
|
||||
}
|
||||
return preloadDrawable;
|
||||
|
||||
@@ -137,6 +137,7 @@ import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.FolderInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.model.data.PromiseAppInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.notification.NotificationListener;
|
||||
import com.android.launcher3.pm.PinRequestHelper;
|
||||
@@ -2515,8 +2516,8 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindIncrementalDownloadProgressUpdated(AppInfo app) {
|
||||
mAppsView.getAppsStore().updateProgressBar(app);
|
||||
public void bindPromiseAppProgressUpdated(PromiseAppInfo app) {
|
||||
mAppsView.getAppsStore().updatePromiseAppProgress(app);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -48,7 +48,6 @@ import com.android.launcher3.model.LoaderResults;
|
||||
import com.android.launcher3.model.LoaderTask;
|
||||
import com.android.launcher3.model.ModelDelegate;
|
||||
import com.android.launcher3.model.ModelWriter;
|
||||
import com.android.launcher3.model.PackageIncrementalDownloadUpdatedTask;
|
||||
import com.android.launcher3.model.PackageInstallStateChangedTask;
|
||||
import com.android.launcher3.model.PackageUpdatedTask;
|
||||
import com.android.launcher3.model.ShortcutsChangedTask;
|
||||
@@ -196,15 +195,6 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
|
||||
PackageUpdatedTask.OP_UNSUSPEND, user, packageNames));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackageLoadingProgressChanged(
|
||||
String packageName, UserHandle user, float progress) {
|
||||
if (Utilities.ATLEAST_S) {
|
||||
enqueueModelUpdateTask(new PackageIncrementalDownloadUpdatedTask(
|
||||
packageName, user, progress));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShortcutsChanged(String packageName, List<ShortcutInfo> shortcuts,
|
||||
UserHandle user) {
|
||||
|
||||
@@ -107,13 +107,12 @@ public final class Utilities {
|
||||
public static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||
public static final Person[] EMPTY_PERSON_ARRAY = new Person[0];
|
||||
|
||||
public static final boolean ATLEAST_P = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P;
|
||||
public static final boolean ATLEAST_R = BuildCompat.isAtLeastR();
|
||||
|
||||
public static final boolean ATLEAST_Q = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
|
||||
|
||||
public static final boolean ATLEAST_R = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R;
|
||||
|
||||
public static final boolean ATLEAST_S = BuildCompat.isAtLeastS();
|
||||
public static final boolean ATLEAST_P =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.P;
|
||||
|
||||
/**
|
||||
* Set on a motion event dispatched from the nav bar. See {@link MotionEvent#setEdgeFlags(int)}.
|
||||
|
||||
@@ -3154,7 +3154,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
ItemOperator op = (info, v) -> {
|
||||
if (info instanceof WorkspaceItemInfo && v instanceof BubbleTextView
|
||||
&& updates.contains(info)) {
|
||||
((BubbleTextView) v).applyLoadingState(false /* promiseStateChanged */);
|
||||
((BubbleTextView) v).applyPromiseState(false /* promiseStateChanged */);
|
||||
} else if (v instanceof PendingAppWidgetHostView
|
||||
&& info instanceof LauncherAppWidgetInfo
|
||||
&& updates.contains(info)) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.view.ViewGroup;
|
||||
import com.android.launcher3.BubbleTextView;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.PromiseAppInfo;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.PackageUserKey;
|
||||
|
||||
@@ -144,17 +145,10 @@ public class AllAppsStore {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the AppInfo's associated icon's progress bar.
|
||||
*
|
||||
* If this app is installed and supports incremental downloads, the progress bar will be updated
|
||||
* the app's total download progress. Otherwise, the progress bar will be updated to the app's
|
||||
* installation progress.
|
||||
*/
|
||||
public void updateProgressBar(AppInfo app) {
|
||||
public void updatePromiseAppProgress(PromiseAppInfo app) {
|
||||
updateAllIcons((child) -> {
|
||||
if (child.getTag() == app) {
|
||||
child.applyProgressLevel(app.getProgressLevel());
|
||||
child.applyProgressLevel(app.level);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.graphics.PreloadIconDrawable;
|
||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
|
||||
@@ -395,10 +394,9 @@ public class PreviewItemManager {
|
||||
}
|
||||
|
||||
private void setDrawable(PreviewItemDrawingParams p, WorkspaceItemInfo item) {
|
||||
if (item.hasPromiseIconUi() || (item.runtimeStatusFlags
|
||||
& ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) {
|
||||
if (item.hasPromiseIconUi()) {
|
||||
PreloadIconDrawable drawable = newPendingIcon(mContext, item);
|
||||
drawable.setLevel(item.getProgressLevel());
|
||||
drawable.setLevel(item.getInstallProgress());
|
||||
p.drawable = drawable;
|
||||
} else {
|
||||
p.drawable = newIcon(mContext, item);
|
||||
|
||||
@@ -117,8 +117,6 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
|
||||
mIndicatorColor = IconPalette.getPreloadProgressColor(context, mIconColor);
|
||||
|
||||
setInternalProgress(0);
|
||||
|
||||
setIsDisabled(!info.isAppStartable());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -268,12 +266,14 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
|
||||
mIconScale = SMALL_SCALE;
|
||||
mScaledTrackPath.reset();
|
||||
mTrackAlpha = MAX_PAINT_ALPHA;
|
||||
setIsDisabled(true);
|
||||
}
|
||||
|
||||
if (progress < 1 && progress > 0) {
|
||||
mPathMeasure.getSegment(0, progress * mTrackLength, mScaledProgressPath, true);
|
||||
mIconScale = SMALL_SCALE;
|
||||
mTrackAlpha = MAX_PAINT_ALPHA;
|
||||
setIsDisabled(true);
|
||||
} else if (progress >= 1) {
|
||||
setIsDisabled(mItem.isDisabled());
|
||||
mScaledTrackPath.set(mScaledProgressPath);
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.pm.InstallSessionHelper;
|
||||
import com.android.launcher3.pm.PackageInstallInfo;
|
||||
import com.android.launcher3.util.GridOccupancy;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
@@ -133,9 +132,7 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
workspaceInfo.setProgressLevel(
|
||||
(int) (sessionInfo.getProgress() * 100),
|
||||
PackageInstallInfo.STATUS_INSTALLING);
|
||||
workspaceInfo.setInstallProgress((int) sessionInfo.getProgress());
|
||||
}
|
||||
|
||||
if (hasActivity) {
|
||||
|
||||
@@ -21,11 +21,11 @@ import static com.android.launcher3.model.data.AppInfo.EMPTY_ARRAY;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.LauncherActivityInfo;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.os.LocaleList;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.android.launcher3.compat.AlphabeticIndexCompat;
|
||||
import com.android.launcher3.icons.IconCache;
|
||||
import com.android.launcher3.model.BgDataModel.Callbacks;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.PromiseAppInfo;
|
||||
import com.android.launcher3.pm.PackageInstallInfo;
|
||||
import com.android.launcher3.util.FlagOp;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
@@ -149,7 +150,7 @@ public class AllAppsList {
|
||||
.getApplicationInfo(installInfo.packageName, installInfo.user, 0);
|
||||
// only if not yet installed
|
||||
if (applicationInfo == null) {
|
||||
AppInfo info = new AppInfo(installInfo);
|
||||
PromiseAppInfo info = new PromiseAppInfo(installInfo);
|
||||
mIconCache.getTitleAndIcon(info, info.usingLowResIcon());
|
||||
info.sectionName = mIndex.computeSectionName(info.title);
|
||||
|
||||
@@ -158,26 +159,24 @@ public class AllAppsList {
|
||||
}
|
||||
}
|
||||
|
||||
/** Updates the given PackageInstallInfo's associated AppInfo's installation info. */
|
||||
public List<AppInfo> updatePromiseInstallInfo(PackageInstallInfo installInfo) {
|
||||
List<AppInfo> updatedAppInfos = new ArrayList<>();
|
||||
UserHandle user = installInfo.user;
|
||||
for (int i = data.size() - 1; i >= 0; i--) {
|
||||
public PromiseAppInfo updatePromiseInstallInfo(PackageInstallInfo installInfo) {
|
||||
UserHandle user = Process.myUserHandle();
|
||||
for (int i=0; i < data.size(); i++) {
|
||||
final AppInfo appInfo = data.get(i);
|
||||
final ComponentName tgtComp = appInfo.getTargetComponent();
|
||||
if (tgtComp != null && tgtComp.getPackageName().equals(installInfo.packageName)
|
||||
&& appInfo.user.equals(user)) {
|
||||
if (installInfo.state == PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING
|
||||
|| installInfo.state == PackageInstallInfo.STATUS_INSTALLING) {
|
||||
appInfo.setProgressLevel(installInfo);
|
||||
|
||||
updatedAppInfos.add(appInfo);
|
||||
&& appInfo.user.equals(user)
|
||||
&& appInfo instanceof PromiseAppInfo) {
|
||||
final PromiseAppInfo promiseAppInfo = (PromiseAppInfo) appInfo;
|
||||
if (installInfo.state == PackageInstallInfo.STATUS_INSTALLING) {
|
||||
promiseAppInfo.level = installInfo.progress;
|
||||
return promiseAppInfo;
|
||||
} else if (installInfo.state == PackageInstallInfo.STATUS_FAILED) {
|
||||
removeApp(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return updatedAppInfos;
|
||||
return null;
|
||||
}
|
||||
|
||||
private void removeApp(int index) {
|
||||
@@ -269,14 +268,8 @@ public class AllAppsList {
|
||||
if (applicationInfo == null) {
|
||||
add(new AppInfo(context, info, user), info);
|
||||
} else {
|
||||
Intent launchIntent = AppInfo.makeLaunchIntent(info);
|
||||
|
||||
mIconCache.getTitleAndIcon(applicationInfo, info, true /* useLowResIcon */);
|
||||
applicationInfo.sectionName = mIndex.computeSectionName(applicationInfo.title);
|
||||
applicationInfo.setProgressLevel(
|
||||
PackageManagerHelper.getLoadingProgress(info),
|
||||
PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING);
|
||||
applicationInfo.intent = launchIntent;
|
||||
|
||||
mDataChanged = true;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.FolderInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.model.data.PromiseAppInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.pm.UserCache;
|
||||
import com.android.launcher3.shortcuts.ShortcutKey;
|
||||
@@ -458,11 +459,7 @@ public class BgDataModel {
|
||||
void preAddApps();
|
||||
void bindAppsAdded(IntArray newScreens,
|
||||
ArrayList<ItemInfo> addNotAnimated, ArrayList<ItemInfo> addAnimated);
|
||||
|
||||
/**
|
||||
* Binds updated incremental download progress
|
||||
*/
|
||||
void bindIncrementalDownloadProgressUpdated(AppInfo app);
|
||||
void bindPromiseAppProgressUpdated(PromiseAppInfo app);
|
||||
void bindWorkspaceItemsChanged(List<WorkspaceItemInfo> updated);
|
||||
void bindWidgetsRestored(ArrayList<LauncherAppWidgetInfo> widgets);
|
||||
void bindRestoreItemsChange(HashSet<ItemInfo> updates);
|
||||
|
||||
@@ -35,13 +35,11 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.LongSparseArray;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.LauncherSettings.Favorites;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.Workspace;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
@@ -94,9 +92,6 @@ public class LoaderCursor extends CursorWrapper {
|
||||
private final int restoredIndex;
|
||||
private final int intentIndex;
|
||||
|
||||
@Nullable
|
||||
private LauncherActivityInfo mActivityInfo;
|
||||
|
||||
// Properties loaded per iteration
|
||||
public long serialNumber;
|
||||
public UserHandle user;
|
||||
@@ -137,8 +132,6 @@ public class LoaderCursor extends CursorWrapper {
|
||||
public boolean moveToNext() {
|
||||
boolean result = super.moveToNext();
|
||||
if (result) {
|
||||
mActivityInfo = null;
|
||||
|
||||
// Load common properties.
|
||||
itemType = getInt(itemTypeIndex);
|
||||
container = getInt(containerIndex);
|
||||
@@ -252,10 +245,6 @@ public class LoaderCursor extends CursorWrapper {
|
||||
return info;
|
||||
}
|
||||
|
||||
public LauncherActivityInfo getLauncherActivityInfo() {
|
||||
return mActivityInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an WorkspaceItemInfo object for a shortcut that is an application.
|
||||
*/
|
||||
@@ -275,25 +264,25 @@ public class LoaderCursor extends CursorWrapper {
|
||||
Intent newIntent = new Intent(Intent.ACTION_MAIN, null);
|
||||
newIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
newIntent.setComponent(componentName);
|
||||
mActivityInfo = mContext.getSystemService(LauncherApps.class)
|
||||
LauncherActivityInfo lai = mContext.getSystemService(LauncherApps.class)
|
||||
.resolveActivity(newIntent, user);
|
||||
if ((mActivityInfo == null) && !allowMissingTarget) {
|
||||
if ((lai == null) && !allowMissingTarget) {
|
||||
Log.d(TAG, "Missing activity found in getShortcutInfo: " + componentName);
|
||||
return null;
|
||||
}
|
||||
|
||||
final WorkspaceItemInfo info = new WorkspaceItemInfo();
|
||||
info.itemType = Favorites.ITEM_TYPE_APPLICATION;
|
||||
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
|
||||
info.user = user;
|
||||
info.intent = newIntent;
|
||||
|
||||
mIconCache.getTitleAndIcon(info, mActivityInfo, useLowResIcon);
|
||||
mIconCache.getTitleAndIcon(info, lai, useLowResIcon);
|
||||
if (mIconCache.isDefaultIcon(info.bitmap, user)) {
|
||||
loadIcon(info);
|
||||
}
|
||||
|
||||
if (mActivityInfo != null) {
|
||||
AppInfo.updateRuntimeFlagsForActivityTarget(info, mActivityInfo);
|
||||
if (lai != null) {
|
||||
AppInfo.updateRuntimeFlagsForActivityTarget(info, lai);
|
||||
}
|
||||
|
||||
// from the db
|
||||
|
||||
@@ -69,7 +69,6 @@ import com.android.launcher3.logging.FileLog;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.FolderInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.model.data.PackageItemInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
@@ -592,24 +591,11 @@ public class LoaderTask implements Runnable {
|
||||
if (c.restoreFlag != 0 && !TextUtils.isEmpty(targetPkg)) {
|
||||
tempPackageKey.update(targetPkg, c.user);
|
||||
SessionInfo si = installingPkgs.get(tempPackageKey);
|
||||
LauncherActivityInfo activityInfo =
|
||||
c.getLauncherActivityInfo();
|
||||
if (si == null) {
|
||||
info.runtimeStatusFlags &=
|
||||
~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE;
|
||||
} else if (activityInfo == null) {
|
||||
int installProgress = (int) (si.getProgress() * 100);
|
||||
|
||||
info.setProgressLevel(
|
||||
installProgress,
|
||||
PackageInstallInfo.STATUS_INSTALLING);
|
||||
} else {
|
||||
info.setProgressLevel(
|
||||
PackageManagerHelper
|
||||
.getLoadingProgress(activityInfo),
|
||||
PackageInstallInfo
|
||||
.STATUS_INSTALLED_DOWNLOADING);
|
||||
}
|
||||
if (si == null) {
|
||||
info.status &= ~WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE;
|
||||
} else {
|
||||
info.setInstallProgress((int) (si.getProgress() * 100));
|
||||
}
|
||||
}
|
||||
|
||||
c.checkAndAddItem(info, mBgDataModel);
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.launcher3.model;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.pm.PackageInstallInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Handles updates due to incremental download progress updates.
|
||||
*/
|
||||
public class PackageIncrementalDownloadUpdatedTask extends BaseModelUpdateTask {
|
||||
|
||||
private final UserHandle mUser;
|
||||
private final int mProgress;
|
||||
private final String mPackageName;
|
||||
|
||||
public PackageIncrementalDownloadUpdatedTask(
|
||||
String packageName, UserHandle user, float progress) {
|
||||
mUser = user;
|
||||
mProgress = 1 - progress > 0.001 ? (int) (100 * progress) : 100;
|
||||
mPackageName = packageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList appsList) {
|
||||
PackageInstallInfo downloadInfo = new PackageInstallInfo(
|
||||
mPackageName,
|
||||
PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING,
|
||||
mProgress,
|
||||
mUser);
|
||||
|
||||
synchronized (appsList) {
|
||||
List<AppInfo> updatedAppInfos = appsList.updatePromiseInstallInfo(downloadInfo);
|
||||
if (!updatedAppInfos.isEmpty()) {
|
||||
for (AppInfo appInfo : updatedAppInfos) {
|
||||
appInfo.runtimeStatusFlags &= ~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE;
|
||||
scheduleCallbackTask(
|
||||
c -> c.bindIncrementalDownloadProgressUpdated(appInfo));
|
||||
}
|
||||
}
|
||||
bindApplicationsIfNeeded();
|
||||
}
|
||||
|
||||
final ArrayList<WorkspaceItemInfo> updatedWorkspaceItems = new ArrayList<>();
|
||||
synchronized (dataModel) {
|
||||
dataModel.forAllWorkspaceItemInfos(mUser, si -> {
|
||||
ComponentName cn = si.getTargetComponent();
|
||||
if ((cn != null) && cn.getPackageName().equals(mPackageName)) {
|
||||
si.runtimeStatusFlags &= ~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE;
|
||||
si.setProgressLevel(downloadInfo);
|
||||
updatedWorkspaceItems.add(si);
|
||||
}
|
||||
});
|
||||
}
|
||||
bindUpdatedWorkspaceItems(updatedWorkspaceItems);
|
||||
}
|
||||
}
|
||||
@@ -20,15 +20,14 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.model.data.PromiseAppInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.pm.PackageInstallInfo;
|
||||
import com.android.launcher3.util.InstantAppResolver;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Handles changes due to a sessions updates for a currently installing app.
|
||||
@@ -60,11 +59,9 @@ public class PackageInstallStateChangedTask extends BaseModelUpdateTask {
|
||||
}
|
||||
|
||||
synchronized (apps) {
|
||||
List<AppInfo> updatedAppInfos = apps.updatePromiseInstallInfo(mInstallInfo);
|
||||
if (!updatedAppInfos.isEmpty()) {
|
||||
for (AppInfo appInfo : updatedAppInfos) {
|
||||
scheduleCallbackTask(c -> c.bindIncrementalDownloadProgressUpdated(appInfo));
|
||||
}
|
||||
PromiseAppInfo updated = apps.updatePromiseInstallInfo(mInstallInfo);
|
||||
if (updated != null) {
|
||||
scheduleCallbackTask(c -> c.bindPromiseAppProgressUpdated(updated));
|
||||
}
|
||||
bindApplicationsIfNeeded();
|
||||
}
|
||||
@@ -74,13 +71,11 @@ public class PackageInstallStateChangedTask extends BaseModelUpdateTask {
|
||||
dataModel.forAllWorkspaceItemInfos(mInstallInfo.user, si -> {
|
||||
ComponentName cn = si.getTargetComponent();
|
||||
if (si.hasPromiseIconUi() && (cn != null)
|
||||
&& cn.getPackageName().equals(mInstallInfo.packageName)) {
|
||||
int installProgress = mInstallInfo.progress;
|
||||
|
||||
si.setProgressLevel(installProgress, PackageInstallInfo.STATUS_INSTALLING);
|
||||
&& mInstallInfo.packageName.equals(cn.getPackageName())) {
|
||||
si.setInstallProgress(mInstallInfo.progress);
|
||||
if (mInstallInfo.state == PackageInstallInfo.STATUS_FAILED) {
|
||||
// Mark this info as broken.
|
||||
si.runtimeStatusFlags &= ~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE;
|
||||
si.status &= ~WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE;
|
||||
}
|
||||
updates.add(si);
|
||||
}
|
||||
|
||||
@@ -28,13 +28,10 @@ import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.pm.PackageInstallInfo;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
|
||||
@@ -107,37 +104,13 @@ public class AppInfo extends ItemInfoWithIcon {
|
||||
this.intent = intent;
|
||||
}
|
||||
|
||||
public AppInfo(@NonNull PackageInstallInfo installInfo) {
|
||||
componentName = installInfo.componentName;
|
||||
intent = new Intent(Intent.ACTION_MAIN)
|
||||
.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
.setComponent(componentName)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
|
||||
user = installInfo.user;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String dumpProperties() {
|
||||
return super.dumpProperties() + " componentName=" + componentName;
|
||||
}
|
||||
|
||||
public WorkspaceItemInfo makeWorkspaceItem() {
|
||||
WorkspaceItemInfo workspaceItemInfo = new WorkspaceItemInfo(this);
|
||||
|
||||
if ((runtimeStatusFlags & FLAG_INSTALL_SESSION_ACTIVE) != 0) {
|
||||
// We need to update the component name when the apk is installed
|
||||
workspaceItemInfo.status |= WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON;
|
||||
// Since the user is manually placing it on homescreen, it should not be auto-removed
|
||||
// later
|
||||
workspaceItemInfo.status |= WorkspaceItemInfo.FLAG_RESTORE_STARTED;
|
||||
workspaceItemInfo.status |= FLAG_INSTALL_SESSION_ACTIVE;
|
||||
}
|
||||
if ((runtimeStatusFlags & FLAG_INCREMENTAL_DOWNLOAD_ACTIVE) != 0) {
|
||||
workspaceItemInfo.runtimeStatusFlags |= FLAG_INCREMENTAL_DOWNLOAD_ACTIVE;
|
||||
}
|
||||
|
||||
return workspaceItemInfo;
|
||||
return new WorkspaceItemInfo(this);
|
||||
}
|
||||
|
||||
public ComponentKey toComponentKey() {
|
||||
@@ -156,12 +129,6 @@ public class AppInfo extends ItemInfoWithIcon {
|
||||
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ComponentName getTargetComponent() {
|
||||
return componentName;
|
||||
}
|
||||
|
||||
public static void updateRuntimeFlagsForActivityTarget(
|
||||
ItemInfoWithIcon info, LauncherActivityInfo lai) {
|
||||
ApplicationInfo appInfo = lai.getApplicationInfo();
|
||||
@@ -176,11 +143,6 @@ public class AppInfo extends ItemInfoWithIcon {
|
||||
// The icon for a non-primary user is badged, hence it's not exactly an adaptive icon.
|
||||
info.runtimeStatusFlags |= FLAG_ADAPTIVE_ICON;
|
||||
}
|
||||
|
||||
// Sets the progress level, installation and incremental download flags.
|
||||
info.setProgressLevel(
|
||||
PackageManagerHelper.getLoadingProgress(lai),
|
||||
PackageInstallInfo.STATUS_INSTALLED);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,15 +16,7 @@
|
||||
|
||||
package com.android.launcher3.model.data;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.icons.BitmapInfo;
|
||||
import com.android.launcher3.pm.PackageInstallInfo;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
|
||||
/**
|
||||
* Represents an ItemInfo which also holds an icon.
|
||||
@@ -95,35 +87,12 @@ public abstract class ItemInfoWithIcon extends ItemInfo {
|
||||
*/
|
||||
public static final int FLAG_ICON_BADGED = 1 << 9;
|
||||
|
||||
/**
|
||||
* The icon is being installed. If {@link WorkspaceItemInfo#FLAG_RESTORED_ICON} or
|
||||
* {@link WorkspaceItemInfo#FLAG_AUTOINSTALL_ICON} is set, then the icon is either being
|
||||
* installed or is in a broken state.
|
||||
*/
|
||||
public static final int FLAG_INSTALL_SESSION_ACTIVE = 1 << 10;
|
||||
|
||||
/**
|
||||
* This icon is still being downloaded.
|
||||
*/
|
||||
public static final int FLAG_INCREMENTAL_DOWNLOAD_ACTIVE = 1 << 11;
|
||||
|
||||
public static final int FLAG_SHOW_DOWNLOAD_PROGRESS_MASK = FLAG_INSTALL_SESSION_ACTIVE
|
||||
| FLAG_INCREMENTAL_DOWNLOAD_ACTIVE;
|
||||
|
||||
/**
|
||||
* Status associated with the system state of the underlying item. This is calculated every
|
||||
* time a new info is created and not persisted on the disk.
|
||||
*/
|
||||
public int runtimeStatusFlags = 0;
|
||||
|
||||
/**
|
||||
* The download progress of the package that this shortcut represents. For legacy apps, this
|
||||
* will always be the installation progress. For apps that support incremental downloads, this
|
||||
* will only match be the installation progress until the app is installed, then this will the
|
||||
* total download progress.
|
||||
*/
|
||||
private int mProgressLevel = 100;
|
||||
|
||||
protected ItemInfoWithIcon() { }
|
||||
|
||||
protected ItemInfoWithIcon(ItemInfoWithIcon info) {
|
||||
@@ -144,72 +113,6 @@ public abstract class ItemInfoWithIcon extends ItemInfo {
|
||||
return bitmap.isLowRes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the app this shortcut represents is able to be started. For legacy apps,
|
||||
* this returns whether it is fully installed. For apps that support incremental downloads,
|
||||
* this returns whether the app is either fully downloaded or has installed and is downloading
|
||||
* incrementally.
|
||||
*/
|
||||
public boolean isAppStartable() {
|
||||
return ((runtimeStatusFlags & FLAG_INSTALL_SESSION_ACTIVE) == 0)
|
||||
&& (((runtimeStatusFlags & FLAG_INCREMENTAL_DOWNLOAD_ACTIVE) != 0)
|
||||
|| mProgressLevel == 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the download progress for the app this shortcut represents. If this app is not yet
|
||||
* installed or does not support incremental downloads, this will return the installation
|
||||
* progress.
|
||||
*/
|
||||
public int getProgressLevel() {
|
||||
if ((runtimeStatusFlags & FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) {
|
||||
return mProgressLevel;
|
||||
}
|
||||
return 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the download progress for the app this shortcut represents. If this app is not yet
|
||||
* installed or does not support incremental downloads, this will set
|
||||
* {@code FLAG_INSTALL_SESSION_ACTIVE}. If this app is downloading incrementally, this will
|
||||
* set {@code FLAG_INCREMENTAL_DOWNLOAD_ACTIVE}. Otherwise, this will remove both flags.
|
||||
*/
|
||||
public void setProgressLevel(PackageInstallInfo installInfo) {
|
||||
setProgressLevel(installInfo.progress, installInfo.state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the download progress for the app this shortcut represents.
|
||||
*/
|
||||
public void setProgressLevel(int progress, int status) {
|
||||
if (status == PackageInstallInfo.STATUS_INSTALLING) {
|
||||
mProgressLevel = progress;
|
||||
runtimeStatusFlags = progress < 100
|
||||
? runtimeStatusFlags | FLAG_INSTALL_SESSION_ACTIVE
|
||||
: runtimeStatusFlags & ~FLAG_INSTALL_SESSION_ACTIVE;
|
||||
} else if (status == PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING) {
|
||||
mProgressLevel = progress;
|
||||
runtimeStatusFlags = runtimeStatusFlags & ~FLAG_INSTALL_SESSION_ACTIVE;
|
||||
runtimeStatusFlags = progress < 100
|
||||
? runtimeStatusFlags | FLAG_INCREMENTAL_DOWNLOAD_ACTIVE
|
||||
: runtimeStatusFlags & ~FLAG_INCREMENTAL_DOWNLOAD_ACTIVE;
|
||||
} else {
|
||||
mProgressLevel = status == PackageInstallInfo.STATUS_INSTALLED ? 100 : 0;
|
||||
runtimeStatusFlags = runtimeStatusFlags & ~FLAG_INSTALL_SESSION_ACTIVE;
|
||||
runtimeStatusFlags = runtimeStatusFlags & ~FLAG_INCREMENTAL_DOWNLOAD_ACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
/** Creates an intent to that launches the app store at this app's page. */
|
||||
@Nullable
|
||||
public Intent getMarketIntent(Context context) {
|
||||
ComponentName componentName = getTargetComponent();
|
||||
|
||||
return componentName != null
|
||||
? new PackageManagerHelper(context).getMarketIntent(componentName.getPackageName())
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a copy of this
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.launcher3.model.data;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.launcher3.pm.PackageInstallInfo;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
|
||||
public class PromiseAppInfo extends AppInfo {
|
||||
|
||||
public int level = 0;
|
||||
|
||||
public PromiseAppInfo(@NonNull PackageInstallInfo installInfo) {
|
||||
componentName = installInfo.componentName;
|
||||
intent = new Intent(Intent.ACTION_MAIN)
|
||||
.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
.setComponent(componentName)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkspaceItemInfo makeWorkspaceItem() {
|
||||
WorkspaceItemInfo shortcut = new WorkspaceItemInfo(this);
|
||||
shortcut.setInstallProgress(level);
|
||||
// We need to update the component name when the apk is installed
|
||||
shortcut.status |= WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON;
|
||||
// Since the user is manually placing it on homescreen, it should not be auto-removed later
|
||||
shortcut.status |= WorkspaceItemInfo.FLAG_RESTORE_STARTED;
|
||||
return shortcut;
|
||||
}
|
||||
|
||||
public Intent getMarketIntent(Context context) {
|
||||
return new PackageManagerHelper(context).getMarketIntent(componentName.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -57,15 +57,21 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon {
|
||||
*/
|
||||
public static final int FLAG_AUTOINSTALL_ICON = 1 << 1;
|
||||
|
||||
/**
|
||||
* The icon is being installed. If {@link #FLAG_RESTORED_ICON} or {@link #FLAG_AUTOINSTALL_ICON}
|
||||
* is set, then the icon is either being installed or is in a broken state.
|
||||
*/
|
||||
public static final int FLAG_INSTALL_SESSION_ACTIVE = 1 << 2;
|
||||
|
||||
/**
|
||||
* Indicates that the widget restore has started.
|
||||
*/
|
||||
public static final int FLAG_RESTORE_STARTED = 1 << 2;
|
||||
public static final int FLAG_RESTORE_STARTED = 1 << 3;
|
||||
|
||||
/**
|
||||
* Web UI supported.
|
||||
*/
|
||||
public static final int FLAG_SUPPORTS_WEB_UI = 1 << 3;
|
||||
public static final int FLAG_SUPPORTS_WEB_UI = 1 << 4;
|
||||
|
||||
/**
|
||||
* The intent used to start the application.
|
||||
@@ -92,6 +98,11 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon {
|
||||
*/
|
||||
@NonNull private String[] personKeys = Utilities.EMPTY_STRING_ARRAY;
|
||||
|
||||
/**
|
||||
* The installation progress [0-100] of the package that this shortcut represents.
|
||||
*/
|
||||
private int mInstallProgress;
|
||||
|
||||
|
||||
public WorkspaceItemInfo() {
|
||||
itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
|
||||
@@ -103,6 +114,7 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon {
|
||||
intent = new Intent(info.intent);
|
||||
iconResource = info.iconResource;
|
||||
status = info.status;
|
||||
mInstallProgress = info.mInstallProgress;
|
||||
personKeys = info.personKeys.clone();
|
||||
}
|
||||
|
||||
@@ -156,6 +168,15 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon {
|
||||
return isPromise() && !hasStatusFlag(FLAG_SUPPORTS_WEB_UI);
|
||||
}
|
||||
|
||||
public int getInstallProgress() {
|
||||
return mInstallProgress;
|
||||
}
|
||||
|
||||
public void setInstallProgress(int progress) {
|
||||
mInstallProgress = progress;
|
||||
status |= FLAG_INSTALL_SESSION_ACTIVE;
|
||||
}
|
||||
|
||||
public void updateFromDeepShortcutInfo(ShortcutInfo shortcutInfo, Context context) {
|
||||
// {@link ShortcutInfo#getActivity} can change during an update. Recreate the intent
|
||||
intent = ShortcutKey.makeIntent(shortcutInfo);
|
||||
|
||||
@@ -25,8 +25,7 @@ public final class PackageInstallInfo {
|
||||
|
||||
public static final int STATUS_INSTALLED = 0;
|
||||
public static final int STATUS_INSTALLING = 1;
|
||||
public static final int STATUS_INSTALLED_DOWNLOADING = 2;
|
||||
public static final int STATUS_FAILED = 3;
|
||||
public static final int STATUS_FAILED = 2;
|
||||
|
||||
public final ComponentName componentName;
|
||||
public final String packageName;
|
||||
@@ -57,4 +56,5 @@ public final class PackageInstallInfo {
|
||||
public static PackageInstallInfo fromState(int state, String packageName, UserHandle user) {
|
||||
return new PackageInstallInfo(packageName, state, 0 /* progress */, user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ import com.android.launcher3.allapps.AllAppsContainerView;
|
||||
import com.android.launcher3.model.BgDataModel;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.model.data.PromiseAppInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.popup.PopupContainerWithArrow;
|
||||
import com.android.launcher3.popup.PopupDataProvider;
|
||||
@@ -215,8 +215,8 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity
|
||||
ArrayList<ItemInfo> addAnimated) { }
|
||||
|
||||
@Override
|
||||
public void bindIncrementalDownloadProgressUpdated(AppInfo app) {
|
||||
mAppsView.getAppsStore().updateProgressBar(app);
|
||||
public void bindPromiseAppProgressUpdated(PromiseAppInfo app) {
|
||||
mAppsView.getAppsStore().updatePromiseAppProgress(app);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -315,11 +315,9 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity
|
||||
if (tag instanceof ItemInfo) {
|
||||
ItemInfo item = (ItemInfo) tag;
|
||||
Intent intent;
|
||||
if (item instanceof ItemInfoWithIcon
|
||||
&& (((ItemInfoWithIcon) item).runtimeStatusFlags
|
||||
& ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
|
||||
ItemInfoWithIcon appInfo = (ItemInfoWithIcon) item;
|
||||
intent = appInfo.getMarketIntent(this);
|
||||
if (item instanceof PromiseAppInfo) {
|
||||
PromiseAppInfo promiseAppInfo = (PromiseAppInfo) item;
|
||||
intent = promiseAppInfo.getMarketIntent(this);
|
||||
} else {
|
||||
intent = item.getIntent();
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.FolderInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.model.data.PromiseAppInfo;
|
||||
import com.android.launcher3.model.data.RemoteActionItemInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.pm.InstallSessionHelper;
|
||||
@@ -231,12 +231,8 @@ public class ItemClickHandler {
|
||||
? shortcut.getIntent().getComponent().getPackageName()
|
||||
: shortcut.getIntent().getPackage();
|
||||
if (!TextUtils.isEmpty(packageName)) {
|
||||
onClickPendingAppItem(
|
||||
v,
|
||||
launcher,
|
||||
packageName,
|
||||
(shortcut.runtimeStatusFlags
|
||||
& ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0);
|
||||
onClickPendingAppItem(v, launcher, packageName,
|
||||
shortcut.hasStatusFlag(WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -270,12 +266,9 @@ public class ItemClickHandler {
|
||||
TestLogging.recordEvent(
|
||||
TestProtocol.SEQUENCE_MAIN, "start: startAppShortcutOrInfoActivity");
|
||||
Intent intent;
|
||||
if (item instanceof ItemInfoWithIcon
|
||||
&& (((ItemInfoWithIcon) item).runtimeStatusFlags
|
||||
& ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
|
||||
ItemInfoWithIcon appInfo = (ItemInfoWithIcon) item;
|
||||
intent = new PackageManagerHelper(launcher)
|
||||
.getMarketIntent(appInfo.getTargetComponent().getPackageName());
|
||||
if (item instanceof PromiseAppInfo) {
|
||||
PromiseAppInfo promiseAppInfo = (PromiseAppInfo) item;
|
||||
intent = promiseAppInfo.getMarketIntent(launcher);
|
||||
} else {
|
||||
intent = item.getIntent();
|
||||
}
|
||||
|
||||
@@ -45,11 +45,10 @@ import android.widget.Toast;
|
||||
|
||||
import com.android.launcher3.PendingAddItemInfo;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.model.data.PromiseAppInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
@@ -201,12 +200,9 @@ public class PackageManagerHelper {
|
||||
* Starts the details activity for {@code info}
|
||||
*/
|
||||
public void startDetailsActivityForInfo(ItemInfo info, Rect sourceBounds, Bundle opts) {
|
||||
if (info instanceof ItemInfoWithIcon
|
||||
&& (((ItemInfoWithIcon) info).runtimeStatusFlags
|
||||
& ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
|
||||
ItemInfoWithIcon appInfo = (ItemInfoWithIcon) info;
|
||||
mContext.startActivity(new PackageManagerHelper(mContext)
|
||||
.getMarketIntent(appInfo.getTargetComponent().getPackageName()));
|
||||
if (info instanceof PromiseAppInfo) {
|
||||
PromiseAppInfo promiseAppInfo = (PromiseAppInfo) info;
|
||||
mContext.startActivity(promiseAppInfo.getMarketIntent(mContext));
|
||||
return;
|
||||
}
|
||||
ComponentName componentName = null;
|
||||
@@ -323,12 +319,4 @@ public class PackageManagerHelper {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Returns the incremental download progress for the given shortcut's app. */
|
||||
public static int getLoadingProgress(LauncherActivityInfo info) {
|
||||
if (Utilities.ATLEAST_S) {
|
||||
return (int) (100 * info.getLoadingProgress());
|
||||
}
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user