blob: cd06414d3f7b172f27306807daa305e50bd0c191 [file] [log] [blame]
Sunny Goyalfa401a12015-04-10 13:45:42 -07001package com.android.launcher3;
2
Winson Chung1054d4e2018-03-05 19:39:21 +00003import static android.appwidget.AppWidgetManager.INVALID_APPWIDGET_ID;
4import static android.appwidget.AppWidgetProviderInfo.WIDGET_FEATURE_RECONFIGURABLE;
Samuel Fufacc1e1072019-09-06 16:19:11 -07005
Tony Wickham62dbe982021-05-12 16:19:58 -07006import static com.android.launcher3.Launcher.REQUEST_RECONFIGURE_APPWIDGET;
Winson Chung1054d4e2018-03-05 19:39:21 +00007import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
Samuel Fufa5cf3e862020-02-03 20:22:54 -08008import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.DISMISS_PREDICTION;
Winson Chung1054d4e2018-03-05 19:39:21 +00009import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.RECONFIGURE;
10import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.UNINSTALL;
thiruramff484512020-05-11 11:19:58 -070011import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ITEM_DROPPED_ON_DONT_SUGGEST;
12import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ITEM_DROPPED_ON_UNINSTALL;
13import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ITEM_UNINSTALL_CANCELLED;
14import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ITEM_UNINSTALL_COMPLETED;
Sunny Goyale396abf2020-04-06 15:11:17 -070015import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_SYSTEM_MASK;
16import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_SYSTEM_NO;
Sunny Goyal076839c2017-10-30 13:52:20 -070017
Winson Chung1054d4e2018-03-05 19:39:21 +000018import android.appwidget.AppWidgetHostView;
Winson Chung1054d4e2018-03-05 19:39:21 +000019import android.appwidget.AppWidgetProviderInfo;
Sunny Goyalfa401a12015-04-10 13:45:42 -070020import android.content.ComponentName;
21import android.content.Context;
Sunny Goyald5bd67d2016-03-11 01:10:19 -080022import android.content.Intent;
Sunny Goyal8e0e1d72016-10-10 10:41:41 -070023import android.content.pm.ApplicationInfo;
Sunny Goyal3e9be432017-01-05 15:22:41 -080024import android.content.pm.LauncherActivityInfo;
Sunny Goyale7b00122019-10-02 16:13:34 -070025import android.content.pm.LauncherApps;
Sunny Goyalf2db2532017-03-01 17:27:16 -080026import android.content.pm.PackageManager;
Sunny Goyald5bd67d2016-03-11 01:10:19 -080027import android.net.Uri;
Sunny Goyalfa401a12015-04-10 13:45:42 -070028import android.os.Bundle;
Sunny Goyal7c74e4a2016-12-15 15:53:17 -080029import android.os.UserHandle;
Sunny Goyalfa401a12015-04-10 13:45:42 -070030import android.os.UserManager;
Sunny Goyal0236d0b2017-10-24 14:54:30 -070031import android.util.ArrayMap;
Sunny Goyalfa401a12015-04-10 13:45:42 -070032import android.util.AttributeSet;
Jon Mirandac56e3ff2017-08-23 12:13:24 -070033import android.util.Log;
Sunny Goyal3dce5f32017-10-05 11:40:05 -070034import android.view.View;
Sunny Goyald5bd67d2016-03-11 01:10:19 -080035import android.widget.Toast;
Sunny Goyalaa8ef112015-06-12 20:04:41 -070036
Samuel Fufa5cf3e862020-02-03 20:22:54 -080037import com.android.launcher3.config.FeatureFlags;
Sunny Goyal3dce5f32017-10-05 11:40:05 -070038import com.android.launcher3.dragndrop.DragOptions;
Samuel Fufacc1e1072019-09-06 16:19:11 -070039import com.android.launcher3.logging.FileLog;
Sunny Goyal384b5782021-02-09 22:50:02 -080040import com.android.launcher3.logging.InstanceId;
41import com.android.launcher3.logging.InstanceIdSequence;
thiruramff484512020-05-11 11:19:58 -070042import com.android.launcher3.logging.StatsLogManager;
Sunny Goyal852537f2020-07-15 17:02:16 -070043import com.android.launcher3.logging.StatsLogManager.StatsLogger;
Sunny Goyale396abf2020-04-06 15:11:17 -070044import com.android.launcher3.model.data.ItemInfo;
45import com.android.launcher3.model.data.ItemInfoWithIcon;
46import com.android.launcher3.model.data.LauncherAppWidgetInfo;
Sunny Goyale7b00122019-10-02 16:13:34 -070047import com.android.launcher3.util.PackageManagerHelper;
Yogisha Dixit4ff5ee32021-05-04 14:58:34 +010048import com.android.launcher3.util.PendingRequestArgs;
Yogisha Dixit741fae92021-02-22 14:03:44 +000049import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
Sunny Goyalfa401a12015-04-10 13:45:42 -070050
Jon Mirandac56e3ff2017-08-23 12:13:24 -070051import java.net.URISyntaxException;
52
Winson Chung1054d4e2018-03-05 19:39:21 +000053/**
54 * Drop target which provides a secondary option for an item.
55 * For app targets: shows as uninstall
56 * For configurable widgets: shows as setup
Samuel Fufa5cf3e862020-02-03 20:22:54 -080057 * For predicted app icons: don't suggest app
Winson Chung1054d4e2018-03-05 19:39:21 +000058 */
59public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmListener {
Sunny Goyalfa401a12015-04-10 13:45:42 -070060
Winson Chung1054d4e2018-03-05 19:39:21 +000061 private static final String TAG = "SecondaryDropTarget";
Sunny Goyal0236d0b2017-10-24 14:54:30 -070062
63 private static final long CACHE_EXPIRE_TIMEOUT = 5000;
64 private final ArrayMap<UserHandle, Boolean> mUninstallDisabledCache = new ArrayMap<>(1);
thiruramff484512020-05-11 11:19:58 -070065 private final StatsLogManager mStatsLogManager;
Sunny Goyal0236d0b2017-10-24 14:54:30 -070066 private final Alarm mCacheExpireAlarm;
vadimt3d64ffd2020-02-27 11:28:47 -080067 private boolean mHadPendingAlarm;
Jon Mirandac56e3ff2017-08-23 12:13:24 -070068
Mehdi Alizadeh8517b692018-04-23 15:55:26 -070069 protected int mCurrentAccessibilityAction = -1;
Winson Chung1054d4e2018-03-05 19:39:21 +000070 public SecondaryDropTarget(Context context, AttributeSet attrs) {
Sunny Goyalfa401a12015-04-10 13:45:42 -070071 this(context, attrs, 0);
72 }
73
Winson Chung1054d4e2018-03-05 19:39:21 +000074 public SecondaryDropTarget(Context context, AttributeSet attrs, int defStyle) {
Sunny Goyalfa401a12015-04-10 13:45:42 -070075 super(context, attrs, defStyle);
Sunny Goyal0236d0b2017-10-24 14:54:30 -070076 mCacheExpireAlarm = new Alarm();
thiruramff484512020-05-11 11:19:58 -070077 mStatsLogManager = StatsLogManager.newInstance(context);
Sunny Goyalfa401a12015-04-10 13:45:42 -070078 }
79
80 @Override
vadimt3d64ffd2020-02-27 11:28:47 -080081 protected void onAttachedToWindow() {
82 super.onAttachedToWindow();
83 if (mHadPendingAlarm) {
84 mCacheExpireAlarm.setAlarm(CACHE_EXPIRE_TIMEOUT);
vadimt908e9bb2020-02-28 18:02:30 -080085 mCacheExpireAlarm.setOnAlarmListener(this);
vadimt3d64ffd2020-02-27 11:28:47 -080086 mHadPendingAlarm = false;
87 }
88 }
89
90 @Override
91 protected void onDetachedFromWindow() {
92 super.onDetachedFromWindow();
93 if (mCacheExpireAlarm.alarmPending()) {
94 mCacheExpireAlarm.cancelAlarm();
vadimt908e9bb2020-02-28 18:02:30 -080095 mCacheExpireAlarm.setOnAlarmListener(null);
vadimt3d64ffd2020-02-27 11:28:47 -080096 mHadPendingAlarm = true;
97 }
98 }
99
100 @Override
Sunny Goyalfa401a12015-04-10 13:45:42 -0700101 protected void onFinishInflate() {
102 super.onFinishInflate();
Winson Chung1054d4e2018-03-05 19:39:21 +0000103 setupUi(UNINSTALL);
Sunny Goyalda1dfa32017-04-26 22:34:49 -0700104 }
105
Mehdi Alizadeh8517b692018-04-23 15:55:26 -0700106 protected void setupUi(int action) {
Winson Chung1054d4e2018-03-05 19:39:21 +0000107 if (action == mCurrentAccessibilityAction) {
108 return;
109 }
110 mCurrentAccessibilityAction = action;
111
112 if (action == UNINSTALL) {
Yogisha Dixita3a6f512021-04-28 13:45:37 +0100113 setDrawable(R.drawable.ic_uninstall_no_shadow);
Winson Chung1054d4e2018-03-05 19:39:21 +0000114 updateText(R.string.uninstall_drop_target_label);
Samuel Fufa5cf3e862020-02-03 20:22:54 -0800115 } else if (action == DISMISS_PREDICTION) {
Yogisha Dixita3a6f512021-04-28 13:45:37 +0100116 setDrawable(R.drawable.ic_block_no_shadow);
Samuel Fufa5cf3e862020-02-03 20:22:54 -0800117 updateText(R.string.dismiss_prediction_label);
118 } else if (action == RECONFIGURE) {
Yogisha Dixita3a6f512021-04-28 13:45:37 +0100119 setDrawable(R.drawable.ic_setting);
Winson Chung1054d4e2018-03-05 19:39:21 +0000120 updateText(R.string.gadget_setup_text);
121 }
Sunny Goyalfa401a12015-04-10 13:45:42 -0700122 }
123
124 @Override
Sunny Goyal0236d0b2017-10-24 14:54:30 -0700125 public void onAlarm(Alarm alarm) {
126 mUninstallDisabledCache.clear();
Sunny Goyal1a70cef2015-04-22 11:29:51 -0700127 }
128
Sunny Goyal0236d0b2017-10-24 14:54:30 -0700129 @Override
130 public int getAccessibilityAction() {
Winson Chung1054d4e2018-03-05 19:39:21 +0000131 return mCurrentAccessibilityAction;
132 }
133
134 @Override
Sunny Goyal0236d0b2017-10-24 14:54:30 -0700135 protected boolean supportsDrop(ItemInfo info) {
Winson Chung1054d4e2018-03-05 19:39:21 +0000136 return supportsAccessibilityDrop(info, getViewUnderDrag(info));
137 }
138
139 @Override
140 public boolean supportsAccessibilityDrop(ItemInfo info, View view) {
141 if (view instanceof AppWidgetHostView) {
142 if (getReconfigurableWidgetId(view) != INVALID_APPWIDGET_ID) {
143 setupUi(RECONFIGURE);
144 return true;
145 }
146 return false;
Samuel Fufa5cf3e862020-02-03 20:22:54 -0800147 } else if (FeatureFlags.ENABLE_PREDICTION_DISMISS.get() && info.isPredictedItem()) {
148 setupUi(DISMISS_PREDICTION);
149 return true;
Winson Chung1054d4e2018-03-05 19:39:21 +0000150 }
151
152 setupUi(UNINSTALL);
Sunny Goyal0236d0b2017-10-24 14:54:30 -0700153 Boolean uninstallDisabled = mUninstallDisabledCache.get(info.user);
154 if (uninstallDisabled == null) {
155 UserManager userManager =
156 (UserManager) getContext().getSystemService(Context.USER_SERVICE);
157 Bundle restrictions = userManager.getUserRestrictions(info.user);
158 uninstallDisabled = restrictions.getBoolean(UserManager.DISALLOW_APPS_CONTROL, false)
Sunny Goyal6b0aa872017-09-29 07:54:37 -0700159 || restrictions.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS, false);
Sunny Goyal0236d0b2017-10-24 14:54:30 -0700160 mUninstallDisabledCache.put(info.user, uninstallDisabled);
Sunny Goyal6b0aa872017-09-29 07:54:37 -0700161 }
Sunny Goyal0236d0b2017-10-24 14:54:30 -0700162 // Cancel any pending alarm and set cache expiry after some time
163 mCacheExpireAlarm.setAlarm(CACHE_EXPIRE_TIMEOUT);
vadimt908e9bb2020-02-28 18:02:30 -0800164 mCacheExpireAlarm.setOnAlarmListener(this);
Sunny Goyal0236d0b2017-10-24 14:54:30 -0700165 if (uninstallDisabled) {
Sunny Goyala52ecb02016-12-16 15:04:51 -0800166 return false;
Sunny Goyalfa401a12015-04-10 13:45:42 -0700167 }
168
Sunny Goyal076839c2017-10-30 13:52:20 -0700169 if (info instanceof ItemInfoWithIcon) {
170 ItemInfoWithIcon iconInfo = (ItemInfoWithIcon) info;
171 if ((iconInfo.runtimeStatusFlags & FLAG_SYSTEM_MASK) != 0) {
172 return (iconInfo.runtimeStatusFlags & FLAG_SYSTEM_NO) != 0;
Sunny Goyal6b0aa872017-09-29 07:54:37 -0700173 }
174 }
Sunny Goyal0236d0b2017-10-24 14:54:30 -0700175 return getUninstallTarget(info) != null;
Sunny Goyalfa401a12015-04-10 13:45:42 -0700176 }
177
178 /**
Sunny Goyal8e0e1d72016-10-10 10:41:41 -0700179 * @return the component name that should be uninstalled or null.
Sunny Goyalfa401a12015-04-10 13:45:42 -0700180 */
Sunny Goyal0236d0b2017-10-24 14:54:30 -0700181 private ComponentName getUninstallTarget(ItemInfo item) {
Sunny Goyal8e0e1d72016-10-10 10:41:41 -0700182 Intent intent = null;
Sunny Goyal7c74e4a2016-12-15 15:53:17 -0800183 UserHandle user = null;
Sunny Goyal1fe0c2c2017-08-15 12:54:42 -0700184 if (item != null &&
Sunny Goyalc5939392018-12-07 11:43:47 -0800185 item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
Sunny Goyal1fe0c2c2017-08-15 12:54:42 -0700186 intent = item.getIntent();
187 user = item.user;
Sunny Goyal8e0e1d72016-10-10 10:41:41 -0700188 }
189 if (intent != null) {
Sunny Goyale7b00122019-10-02 16:13:34 -0700190 LauncherActivityInfo info = mLauncher.getSystemService(LauncherApps.class)
Sunny Goyal8e0e1d72016-10-10 10:41:41 -0700191 .resolveActivity(intent, user);
192 if (info != null
193 && (info.getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
194 return info.getComponentName();
Sunny Goyalfa401a12015-04-10 13:45:42 -0700195 }
196 }
197 return null;
198 }
199
200 @Override
Sunny Goyal3dce5f32017-10-05 11:40:05 -0700201 public void onDrop(DragObject d, DragOptions options) {
202 // Defer onComplete
Sunny Goyal1797af42017-10-06 13:29:57 -0700203 d.dragSource = new DeferredOnComplete(d.dragSource, getContext());
Sunny Goyal852537f2020-07-15 17:02:16 -0700204
Sunny Goyal3dce5f32017-10-05 11:40:05 -0700205 super.onDrop(d, options);
Sunny Goyal384b5782021-02-09 22:50:02 -0800206 doLog(d.logInstanceId, d.originalDragInfo);
207 }
208
209 private void doLog(InstanceId logInstanceId, ItemInfo itemInfo) {
210 StatsLogger logger = mStatsLogManager.logger().withInstanceId(logInstanceId);
211 if (itemInfo != null) {
212 logger.withItemInfo(itemInfo);
Sunny Goyal852537f2020-07-15 17:02:16 -0700213 }
thiruramff484512020-05-11 11:19:58 -0700214 if (mCurrentAccessibilityAction == UNINSTALL) {
Sunny Goyal852537f2020-07-15 17:02:16 -0700215 logger.log(LAUNCHER_ITEM_DROPPED_ON_UNINSTALL);
thiruramff484512020-05-11 11:19:58 -0700216 } else if (mCurrentAccessibilityAction == DISMISS_PREDICTION) {
Sunny Goyal852537f2020-07-15 17:02:16 -0700217 logger.log(LAUNCHER_ITEM_DROPPED_ON_DONT_SUGGEST);
thiruramff484512020-05-11 11:19:58 -0700218 }
Sunny Goyalfa401a12015-04-10 13:45:42 -0700219 }
220
221 @Override
Sunny Goyal0f76b562016-12-13 19:37:10 -0800222 public void completeDrop(final DragObject d) {
Winson Chung1054d4e2018-03-05 19:39:21 +0000223 ComponentName target = performDropAction(getViewUnderDrag(d.dragInfo), d.dragInfo);
Sunny Goyal3dce5f32017-10-05 11:40:05 -0700224 if (d.dragSource instanceof DeferredOnComplete) {
225 DeferredOnComplete deferred = (DeferredOnComplete) d.dragSource;
226 if (target != null) {
227 deferred.mPackageName = target.getPackageName();
Sunny Goyalb65d7662021-03-07 15:09:11 -0800228 mLauncher.addOnResumeCallback(deferred::onLauncherResume);
Sunny Goyal3dce5f32017-10-05 11:40:05 -0700229 } else {
230 deferred.sendFailure();
231 }
232 }
Tony Wickham734dfbe2015-09-16 16:22:36 -0700233 }
234
Winson Chung1054d4e2018-03-05 19:39:21 +0000235 private View getViewUnderDrag(ItemInfo info) {
236 if (info instanceof LauncherAppWidgetInfo && info.container == CONTAINER_DESKTOP &&
237 mLauncher.getWorkspace().getDragInfo() != null) {
238 return mLauncher.getWorkspace().getDragInfo().cell;
239 }
240 return null;
241 }
242
243 /**
244 * Verifies that the view is an reconfigurable widget and returns the corresponding widget Id,
245 * otherwise return {@code INVALID_APPWIDGET_ID}
246 */
247 private int getReconfigurableWidgetId(View view) {
248 if (!(view instanceof AppWidgetHostView)) {
249 return INVALID_APPWIDGET_ID;
250 }
251 AppWidgetHostView hostView = (AppWidgetHostView) view;
252 AppWidgetProviderInfo widgetInfo = hostView.getAppWidgetInfo();
253 if (widgetInfo == null || widgetInfo.configure == null) {
254 return INVALID_APPWIDGET_ID;
255 }
256 if ( (LauncherAppWidgetProviderInfo.fromProviderInfo(getContext(), widgetInfo)
257 .getWidgetFeatures() & WIDGET_FEATURE_RECONFIGURABLE) == 0) {
258 return INVALID_APPWIDGET_ID;
259 }
260 return hostView.getAppWidgetId();
261 }
262
Sunny Goyal3dce5f32017-10-05 11:40:05 -0700263 /**
264 * Performs the drop action and returns the target component for the dragObject or null if
265 * the action was not performed.
266 */
Winson Chung1054d4e2018-03-05 19:39:21 +0000267 protected ComponentName performDropAction(View view, ItemInfo info) {
268 if (mCurrentAccessibilityAction == RECONFIGURE) {
269 int widgetId = getReconfigurableWidgetId(view);
270 if (widgetId != INVALID_APPWIDGET_ID) {
Yogisha Dixit4ff5ee32021-05-04 14:58:34 +0100271 mLauncher.setWaitingForResult(
272 PendingRequestArgs.forWidgetInfo(widgetId, null, info));
Tony Wickham62dbe982021-05-12 16:19:58 -0700273 mLauncher.getAppWidgetHost().startConfigActivity(mLauncher, widgetId,
274 REQUEST_RECONFIGURE_APPWIDGET);
Winson Chung1054d4e2018-03-05 19:39:21 +0000275 }
276 return null;
277 }
Samuel Fufa5cf3e862020-02-03 20:22:54 -0800278 if (mCurrentAccessibilityAction == DISMISS_PREDICTION) {
Sunny Goyal852537f2020-07-15 17:02:16 -0700279 // We sent the log event, nothing else left to do
Samuel Fufa5cf3e862020-02-03 20:22:54 -0800280 return null;
281 }
Winson Chung1054d4e2018-03-05 19:39:21 +0000282 // else: mCurrentAccessibilityAction == UNINSTALL
283
Sunny Goyal0236d0b2017-10-24 14:54:30 -0700284 ComponentName cn = getUninstallTarget(info);
Sunny Goyal8e0e1d72016-10-10 10:41:41 -0700285 if (cn == null) {
Sunny Goyald5bd67d2016-03-11 01:10:19 -0800286 // System applications cannot be installed. For now, show a toast explaining that.
287 // We may give them the option of disabling apps this way.
Sunny Goyal0236d0b2017-10-24 14:54:30 -0700288 Toast.makeText(mLauncher, R.string.uninstall_system_app_text, Toast.LENGTH_SHORT).show();
Sunny Goyal3dce5f32017-10-05 11:40:05 -0700289 return null;
290 }
291 try {
Sunny Goyal0236d0b2017-10-24 14:54:30 -0700292 Intent i = Intent.parseUri(mLauncher.getString(R.string.delete_package_intent), 0)
Sunny Goyal3dce5f32017-10-05 11:40:05 -0700293 .setData(Uri.fromParts("package", cn.getPackageName(), cn.getClassName()))
294 .putExtra(Intent.EXTRA_USER, info.user);
Sunny Goyal0236d0b2017-10-24 14:54:30 -0700295 mLauncher.startActivity(i);
Samuel Fufacc1e1072019-09-06 16:19:11 -0700296 FileLog.d(TAG, "start uninstall activity " + cn.getPackageName());
Sunny Goyal3dce5f32017-10-05 11:40:05 -0700297 return cn;
298 } catch (URISyntaxException e) {
299 Log.e(TAG, "Failed to parse intent to start uninstall activity for item=" + info);
300 return null;
301 }
302 }
303
Sunny Goyal0236d0b2017-10-24 14:54:30 -0700304 @Override
305 public void onAccessibilityDrop(View view, ItemInfo item) {
Sunny Goyal384b5782021-02-09 22:50:02 -0800306 doLog(new InstanceIdSequence().newInstanceId(), item);
Winson Chung1054d4e2018-03-05 19:39:21 +0000307 performDropAction(view, item);
Sunny Goyal3dce5f32017-10-05 11:40:05 -0700308 }
309
310 /**
311 * A wrapper around {@link DragSource} which delays the {@link #onDropCompleted} action until
312 * {@link #onLauncherResume}
313 */
Sunny Goyalb65d7662021-03-07 15:09:11 -0800314 private class DeferredOnComplete implements DragSource {
Sunny Goyal3dce5f32017-10-05 11:40:05 -0700315
316 private final DragSource mOriginal;
317 private final Context mContext;
318
319 private String mPackageName;
320 private DragObject mDragObject;
321
322 public DeferredOnComplete(DragSource original, Context context) {
323 mOriginal = original;
324 mContext = context;
325 }
326
327 @Override
Sunny Goyal1797af42017-10-06 13:29:57 -0700328 public void onDropCompleted(View target, DragObject d,
Sunny Goyal3dce5f32017-10-05 11:40:05 -0700329 boolean success) {
330 mDragObject = d;
331 }
332
Sunny Goyal3dce5f32017-10-05 11:40:05 -0700333 public void onLauncherResume() {
334 // We use MATCH_UNINSTALLED_PACKAGES as the app can be on SD card as well.
Sunny Goyale7b00122019-10-02 16:13:34 -0700335 if (new PackageManagerHelper(mContext).getApplicationInfo(mPackageName,
336 mDragObject.dragInfo.user, PackageManager.MATCH_UNINSTALLED_PACKAGES) == null) {
Sunny Goyal3dce5f32017-10-05 11:40:05 -0700337 mDragObject.dragSource = mOriginal;
Winson Chung1054d4e2018-03-05 19:39:21 +0000338 mOriginal.onDropCompleted(SecondaryDropTarget.this, mDragObject, true);
thiruramc6a38ba2020-06-16 18:58:13 -0700339 mStatsLogManager.logger().withInstanceId(mDragObject.logInstanceId)
340 .log(LAUNCHER_ITEM_UNINSTALL_COMPLETED);
Sunny Goyal3dce5f32017-10-05 11:40:05 -0700341 } else {
342 sendFailure();
thiruramc6a38ba2020-06-16 18:58:13 -0700343 mStatsLogManager.logger().withInstanceId(mDragObject.logInstanceId)
344 .log(LAUNCHER_ITEM_UNINSTALL_CANCELLED);
Jon Mirandac56e3ff2017-08-23 12:13:24 -0700345 }
Sunny Goyalfa401a12015-04-10 13:45:42 -0700346 }
Sunny Goyal3dce5f32017-10-05 11:40:05 -0700347
348 public void sendFailure() {
349 mDragObject.dragSource = mOriginal;
350 mDragObject.cancelled = true;
Winson Chung1054d4e2018-03-05 19:39:21 +0000351 mOriginal.onDropCompleted(SecondaryDropTarget.this, mDragObject, false);
Sunny Goyald5bd67d2016-03-11 01:10:19 -0800352 }
Sunny Goyalfa401a12015-04-10 13:45:42 -0700353 }
354}