Restoring INSTALL_SHORTCUT receiver (Bug. 10343529)

Change-Id: Icd6a97c1d7877241aa9c71bd80dfdbe6e44ca7ee
This commit is contained in:
Winson Chung
2013-09-25 16:29:40 -07:00
parent 10f3e9ff1a
commit 94d6768c65
5 changed files with 45 additions and 34 deletions

View File

@@ -26,13 +26,13 @@
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="system|signature" />
<permission
android:name="com.android.launcher3.permission.INSTALL_SHORTCUT"
android:name="com.android.launcher.permission.INSTALL_SHORTCUT"
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="dangerous"
android:label="@string/permlab_install_shortcut"
android:description="@string/permdesc_install_shortcut" />
<permission
android:name="com.android.launcher3.permission.UNINSTALL_SHORTCUT"
android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="dangerous"
android:label="@string/permlab_uninstall_shortcut"

View File

@@ -37,7 +37,7 @@ import org.json.*;
public class InstallShortcutReceiver extends BroadcastReceiver {
public static final String ACTION_INSTALL_SHORTCUT =
"com.android.launcher3.action.INSTALL_SHORTCUT";
"com.android.launcher.action.INSTALL_SHORTCUT";
public static final String DATA_INTENT_KEY = "intent.data";
public static final String LAUNCH_INTENT_KEY = "intent.launch";

View File

@@ -209,7 +209,8 @@ public class Launcher extends Activity
private static int sScreen = DEFAULT_SCREEN;
// How long to wait before the new-shortcut animation automatically pans the workspace
private static int NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS = 10;
private static int NEW_APPS_PAGE_MOVE_DELAY = 500;
private static int NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS = 5;
private static int NEW_APPS_ANIMATION_DELAY = 500;
private final BroadcastReceiver mCloseSystemDialogsReceiver
@@ -3694,20 +3695,23 @@ public class Launcher extends Activity
// Animate to the correct page
if (newShortcutsScreenId > -1) {
long currentScreenId = mWorkspace.getScreenIdForPageIndex(mWorkspace.getNextPage());
int newScreenIndex = mWorkspace.getPageIndexForScreenId(newShortcutsScreenId);
final int newScreenIndex = mWorkspace.getPageIndexForScreenId(newShortcutsScreenId);
if (newShortcutsScreenId != currentScreenId) {
mWorkspace.snapToPage(newScreenIndex);
// We post the animation slightly delayed to prevent slowdowns
// when we are loading right after we return to launcher.
mWorkspace.postDelayed(new Runnable() {
public void run() {
mWorkspace.snapToPage(newScreenIndex);
mWorkspace.postDelayed(new Runnable() {
public void run() {
anim.playTogether(bounceAnims);
anim.start();
}
}, NEW_APPS_ANIMATION_DELAY);
}
}, NEW_APPS_PAGE_MOVE_DELAY);
}
}
// We post the animation slightly delayed to prevent slowdowns when we are loading
// right after we return to launcher.
mWorkspace.postDelayed(new Runnable() {
public void run() {
anim.playTogether(bounceAnims);
anim.start();
}
}, NEW_APPS_ANIMATION_DELAY);
}
workspace.requestLayout();
}

View File

@@ -281,14 +281,14 @@ public class LauncherModel extends BroadcastReceiver {
return null;
}
public void addAndBindAddedApps(final Context context, final ArrayList<ItemInfo> added,
final ArrayList<AppInfo> addedApps) {
public void addAndBindAddedApps(final Context context, final ArrayList<ItemInfo> workspaceApps,
final ArrayList<AppInfo> allAppsApps) {
Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
addAndBindAddedApps(context, added, cb, addedApps);
addAndBindAddedApps(context, workspaceApps, cb, allAppsApps);
}
public void addAndBindAddedApps(final Context context, final ArrayList<ItemInfo> added,
final Callbacks callbacks, final ArrayList<AppInfo> addedApps) {
if (added.isEmpty()) {
public void addAndBindAddedApps(final Context context, final ArrayList<ItemInfo> workspaceApps,
final Callbacks callbacks, final ArrayList<AppInfo> allAppsApps) {
if (workspaceApps.isEmpty() && allAppsApps.isEmpty()) {
return;
}
// Process the newly added applications and add them to the database first
@@ -308,7 +308,7 @@ public class LauncherModel extends BroadcastReceiver {
}
synchronized(sBgLock) {
Iterator<ItemInfo> iter = added.iterator();
Iterator<ItemInfo> iter = workspaceApps.iterator();
while (iter.hasNext()) {
ItemInfo a = iter.next();
final String name = a.title.toString();
@@ -356,6 +356,7 @@ public class LauncherModel extends BroadcastReceiver {
} else {
throw new RuntimeException("Unexpected info type");
}
// Add the shortcut to the db
addItemToDatabase(context, shortcutInfo,
LauncherSettings.Favorites.CONTAINER_DESKTOP,
@@ -368,24 +369,26 @@ public class LauncherModel extends BroadcastReceiver {
// Update the workspace screens
updateWorkspaceScreenOrder(context, workspaceScreens);
if (!addedShortcutsFinal.isEmpty()) {
if (!addedShortcutsFinal.isEmpty() || !allAppsApps.isEmpty()) {
runOnMainThread(new Runnable() {
public void run() {
Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
if (callbacks == cb && cb != null) {
ItemInfo info = addedShortcutsFinal.get(addedShortcutsFinal.size() - 1);
long lastScreenId = info.screenId;
final ArrayList<ItemInfo> addAnimated = new ArrayList<ItemInfo>();
final ArrayList<ItemInfo> addNotAnimated = new ArrayList<ItemInfo>();
for (ItemInfo i : addedShortcutsFinal) {
if (i.screenId == lastScreenId) {
addAnimated.add(i);
} else {
addNotAnimated.add(i);
if (!addedShortcutsFinal.isEmpty()) {
ItemInfo info = addedShortcutsFinal.get(addedShortcutsFinal.size() - 1);
long lastScreenId = info.screenId;
for (ItemInfo i : addedShortcutsFinal) {
if (i.screenId == lastScreenId) {
addAnimated.add(i);
} else {
addNotAnimated.add(i);
}
}
}
callbacks.bindAppsAdded(addedWorkspaceScreensFinal,
addNotAnimated, addAnimated, addedApps);
addNotAnimated, addAnimated, allAppsApps);
}
}
});
@@ -2514,9 +2517,13 @@ public class LauncherModel extends BroadcastReceiver {
if (added != null) {
// Ensure that we add all the workspace applications to the db
final ArrayList<ItemInfo> addedInfos = new ArrayList<ItemInfo>(added);
Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
addAndBindAddedApps(context, addedInfos, cb, added);
if (!AppsCustomizePagedView.DISABLE_ALL_APPS) {
addAndBindAddedApps(context, new ArrayList<ItemInfo>(), cb, added);
} else {
final ArrayList<ItemInfo> addedInfos = new ArrayList<ItemInfo>(added);
addAndBindAddedApps(context, addedInfos, cb, added);
}
}
if (modified != null) {
final ArrayList<AppInfo> modifiedFinal = modified;

View File

@@ -30,7 +30,7 @@ import java.util.Iterator;
public class UninstallShortcutReceiver extends BroadcastReceiver {
private static final String ACTION_UNINSTALL_SHORTCUT =
"com.android.launcher3.action.UNINSTALL_SHORTCUT";
"com.android.launcher.action.UNINSTALL_SHORTCUT";
// The set of shortcuts that are pending uninstall
private static ArrayList<PendingUninstallShortcutInfo> mUninstallQueue =