Removing support for adding legacy shortcuts.

All existing legacy shortcuts will be migrated one-time to deep shortcuts
This shortcuts are pinned under the Launcher package, with custom badging

Bug: 275875209
Test: Updated unit tests
Flag: N/A
Change-Id: I7da001f724776ad8d6c807517b7e4e259de626c2
This commit is contained in:
Sunny Goyal
2023-03-29 16:52:27 -07:00
parent f6bf07a5fe
commit 84b48d8deb
19 changed files with 375 additions and 334 deletions
@@ -24,8 +24,10 @@ import android.content.Intent;
import android.content.pm.LauncherApps;
import android.content.pm.LauncherApps.PinItemRequest;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import android.os.Build;
import android.os.Parcelable;
import android.os.SystemClock;
import androidx.annotation.Nullable;
@@ -63,17 +65,10 @@ public class PinRequestHelper {
}
} else {
// Block the worker thread until the accept() is called.
MODEL_EXECUTOR.execute(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(acceptDelay);
} catch (InterruptedException e) {
// Ignore
}
if (request.isValid()) {
request.accept();
}
MODEL_EXECUTOR.execute(() -> {
SystemClock.sleep(acceptDelay);
if (request.isValid()) {
request.accept();
}
});
}
@@ -95,4 +90,13 @@ public class PinRequestHelper {
Parcelable extra = intent.getParcelableExtra(LauncherApps.EXTRA_PIN_ITEM_REQUEST);
return extra instanceof PinItemRequest ? (PinItemRequest) extra : null;
}
/**
* Returns a PinItemRequest corresponding to the provided ShortcutInfo
*/
public static PinItemRequest createRequestForShortcut(Context context, ShortcutInfo info) {
return context.getSystemService(LauncherApps.class)
.getPinItemRequest(context.getSystemService(ShortcutManager.class)
.createShortcutResultIntent(info));
}
}