Merge \"Stop adding FLAG_ACTIVITY_RESET_TASK_IF_NEEDED when...\" into nyc-mr1-dev

am: ceadb1a86a

Change-Id: If26f5a2e8f2a0533b145025734e5819e72a48b28
This commit is contained in:
Makoto Onuki
2016-07-20 00:24:42 +00:00
committed by android-build-merger
7 changed files with 72 additions and 12 deletions

View File

@@ -10066,6 +10066,7 @@ package android.content.pm {
method public android.os.PersistableBundle getExtras();
method public java.lang.String getId();
method public android.content.Intent getIntent();
method public android.content.Intent getIntents();
method public long getLastChangedTimestamp();
method public java.lang.CharSequence getLongLabel();
method public java.lang.String getPackage();
@@ -10092,6 +10093,7 @@ package android.content.pm {
method public android.content.pm.ShortcutInfo.Builder setExtras(android.os.PersistableBundle);
method public android.content.pm.ShortcutInfo.Builder setIcon(android.graphics.drawable.Icon);
method public android.content.pm.ShortcutInfo.Builder setIntent(android.content.Intent);
method public android.content.pm.ShortcutInfo.Builder setIntents(android.content.Intent[]);
method public android.content.pm.ShortcutInfo.Builder setLongLabel(java.lang.CharSequence);
method public android.content.pm.ShortcutInfo.Builder setRank(int);
method public android.content.pm.ShortcutInfo.Builder setShortLabel(java.lang.CharSequence);
@@ -10108,6 +10110,7 @@ package android.content.pm {
method public java.util.List<android.content.pm.ShortcutInfo> getManifestShortcuts();
method public int getMaxShortcutCountPerActivity();
method public java.util.List<android.content.pm.ShortcutInfo> getPinnedShortcuts();
method public boolean isRateLimitingActive();
method public void removeAllDynamicShortcuts();
method public void removeDynamicShortcuts(java.util.List<java.lang.String>);
method public void reportShortcutUsed(java.lang.String);

View File

@@ -10491,6 +10491,7 @@ package android.content.pm {
method public android.os.PersistableBundle getExtras();
method public java.lang.String getId();
method public android.content.Intent getIntent();
method public android.content.Intent getIntents();
method public long getLastChangedTimestamp();
method public java.lang.CharSequence getLongLabel();
method public java.lang.String getPackage();
@@ -10517,6 +10518,7 @@ package android.content.pm {
method public android.content.pm.ShortcutInfo.Builder setExtras(android.os.PersistableBundle);
method public android.content.pm.ShortcutInfo.Builder setIcon(android.graphics.drawable.Icon);
method public android.content.pm.ShortcutInfo.Builder setIntent(android.content.Intent);
method public android.content.pm.ShortcutInfo.Builder setIntents(android.content.Intent[]);
method public android.content.pm.ShortcutInfo.Builder setLongLabel(java.lang.CharSequence);
method public android.content.pm.ShortcutInfo.Builder setRank(int);
method public android.content.pm.ShortcutInfo.Builder setShortLabel(java.lang.CharSequence);
@@ -10533,6 +10535,7 @@ package android.content.pm {
method public java.util.List<android.content.pm.ShortcutInfo> getManifestShortcuts();
method public int getMaxShortcutCountPerActivity();
method public java.util.List<android.content.pm.ShortcutInfo> getPinnedShortcuts();
method public boolean isRateLimitingActive();
method public void removeAllDynamicShortcuts();
method public void removeDynamicShortcuts(java.util.List<java.lang.String>);
method public void reportShortcutUsed(java.lang.String);

View File

@@ -10079,6 +10079,7 @@ package android.content.pm {
method public android.os.PersistableBundle getExtras();
method public java.lang.String getId();
method public android.content.Intent getIntent();
method public android.content.Intent getIntents();
method public long getLastChangedTimestamp();
method public java.lang.CharSequence getLongLabel();
method public java.lang.String getPackage();
@@ -10105,6 +10106,7 @@ package android.content.pm {
method public android.content.pm.ShortcutInfo.Builder setExtras(android.os.PersistableBundle);
method public android.content.pm.ShortcutInfo.Builder setIcon(android.graphics.drawable.Icon);
method public android.content.pm.ShortcutInfo.Builder setIntent(android.content.Intent);
method public android.content.pm.ShortcutInfo.Builder setIntents(android.content.Intent[]);
method public android.content.pm.ShortcutInfo.Builder setLongLabel(java.lang.CharSequence);
method public android.content.pm.ShortcutInfo.Builder setRank(int);
method public android.content.pm.ShortcutInfo.Builder setShortLabel(java.lang.CharSequence);
@@ -10122,6 +10124,7 @@ package android.content.pm {
method public java.util.List<android.content.pm.ShortcutInfo> getManifestShortcuts();
method public int getMaxShortcutCountPerActivity();
method public java.util.List<android.content.pm.ShortcutInfo> getPinnedShortcuts();
method public boolean isRateLimitingActive();
method public void removeAllDynamicShortcuts();
method public void removeDynamicShortcuts(java.util.List<java.lang.String>);
method public void reportShortcutUsed(java.lang.String);

View File

@@ -19,6 +19,7 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.TaskStackBuilder;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -919,6 +920,19 @@ public final class ShortcutInfo implements Parcelable {
return this;
}
/**
* Sets multiple intents instead of a single intent.
*
* @see Builder#setIntent(Intent)
* @see ShortcutInfo#getIntents()
* @see Context#startActivities(Intent[])
* @see TaskStackBuilder
*/
@NonNull
public Builder setIntents(@NonNull Intent[] intents) {
throw new RuntimeException("NOT SUPPORTED YET");
}
/**
* "Rank" of a shortcut, which is a non-negative value that's used by the launcher app
* to sort shortcuts.
@@ -1084,7 +1098,7 @@ public final class ShortcutInfo implements Parcelable {
}
/**
* Return the intent.
* Return the intent. (Or the last intent set with {@link Builder#setIntents(Intent[])}.
*
* <p>Launcher applications <b>cannot</b> see the intent. If a {@link ShortcutInfo} is
* obtained via {@link LauncherApps}, then this method will always return null.
@@ -1103,6 +1117,20 @@ public final class ShortcutInfo implements Parcelable {
return intent;
}
/**
* Return the intent set with {@link Builder#setIntents(Intent[])}.
*
* <p>Launcher applications <b>cannot</b> see the intents. If a {@link ShortcutInfo} is
* obtained via {@link LauncherApps}, then this method will always return null.
* Launchers can only start a shortcut intent with {@link LauncherApps#startShortcut}.
*
* @see Builder#setIntents(Intent[])
*/
@Nullable
public Intent getIntents() {
throw new RuntimeException("NOT SUPPORTED YET");
}
/**
* Return "raw" intent, which is the original intent without the extras.
* @hide

View File

@@ -613,6 +613,20 @@ public class ShortcutManager {
}
}
/**
* Return {@code true} when rate-limiting is active for the caller application.
*
* <p>See the class level javadoc for details.
*/
public boolean isRateLimitingActive() {
try {
return mService.getRemainingCallCount(mContext.getPackageName(), injectMyUserId())
== 0;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Return the max width for icons, in pixels.
*/

View File

@@ -17,7 +17,6 @@
package com.android.server.pm;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
@@ -30,7 +29,6 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.ILauncherApps;
import android.content.pm.IOnAppsChangedListener;
import android.content.pm.IPackageManager;
import android.content.pm.LauncherApps;
import android.content.pm.LauncherApps.ShortcutQuery;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
@@ -461,7 +459,8 @@ public class LauncherAppsService extends SystemService {
}
// Note the target activity doesn't have to be exported.
prepareIntentForLaunch(intent, sourceBounds);
intent.setSourceBounds(sourceBounds);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return startShortcutIntentAsPublisher(
intent, packageName, startActivityOptions, userId);
@@ -521,7 +520,9 @@ public class LauncherAppsService extends SystemService {
Intent launchIntent = new Intent(Intent.ACTION_MAIN);
launchIntent.addCategory(Intent.CATEGORY_LAUNCHER);
prepareIntentForLaunch(launchIntent, sourceBounds);
launchIntent.setSourceBounds(sourceBounds);
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
launchIntent.setPackage(component.getPackageName());
long ident = Binder.clearCallingIdentity();
@@ -562,13 +563,6 @@ public class LauncherAppsService extends SystemService {
}
}
private void prepareIntentForLaunch(@NonNull Intent launchIntent,
@Nullable Rect sourceBounds) {
launchIntent.setSourceBounds(sourceBounds);
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
}
@Override
public void showAppDetailsAsUser(ComponentName component, Rect sourceBounds,
Bundle opts, UserHandle user) throws RemoteException {

View File

@@ -1566,12 +1566,22 @@ public class ShortcutManagerTest2 extends BaseShortcutManagerTest {
ActivityManager.PROCESS_STATE_FOREGROUND_SERVICE);
runWithCaller(CALLING_PACKAGE_1, USER_0, () -> {
assertEquals(3, mManager.getRemainingCallCount());
assertFalse(mManager.isRateLimitingActive());
mManager.setDynamicShortcuts(list(makeShortcut("s")));
assertEquals(2, mManager.getRemainingCallCount());
assertFalse(mManager.isRateLimitingActive());
mManager.setDynamicShortcuts(list(makeShortcut("s")));
assertEquals(1, mManager.getRemainingCallCount());
assertFalse(mManager.isRateLimitingActive());
mManager.setDynamicShortcuts(list(makeShortcut("s")));
assertEquals(0, mManager.getRemainingCallCount());
assertTrue(mManager.isRateLimitingActive());
});
runWithCaller(CALLING_PACKAGE_2, USER_0, () -> {
assertEquals(3, mManager.getRemainingCallCount());
@@ -1581,6 +1591,7 @@ public class ShortcutManagerTest2 extends BaseShortcutManagerTest {
mManager.setDynamicShortcuts(list(makeShortcut("s")));
assertEquals(0, mManager.getRemainingCallCount());
assertTrue(mManager.isRateLimitingActive());
});
runWithCaller(CALLING_PACKAGE_3, USER_0, () -> {
MoreAsserts.assertNotEqual(3, mManager.getRemainingCallCount());
@@ -1590,6 +1601,7 @@ public class ShortcutManagerTest2 extends BaseShortcutManagerTest {
mManager.setDynamicShortcuts(list(makeShortcut("s")));
assertEquals(0, mManager.getRemainingCallCount());
assertTrue(mManager.isRateLimitingActive());
});
runWithCaller(CALLING_PACKAGE_4, USER_0, () -> {
MoreAsserts.assertNotEqual(3, mManager.getRemainingCallCount());
@@ -1599,6 +1611,7 @@ public class ShortcutManagerTest2 extends BaseShortcutManagerTest {
mManager.setDynamicShortcuts(list(makeShortcut("s")));
assertEquals(0, mManager.getRemainingCallCount());
assertTrue(mManager.isRateLimitingActive());
});
runWithCaller(CALLING_PACKAGE_1, USER_P0, () -> {
MoreAsserts.assertNotEqual(3, mManager.getRemainingCallCount());
@@ -1608,6 +1621,7 @@ public class ShortcutManagerTest2 extends BaseShortcutManagerTest {
mManager.setDynamicShortcuts(list(makeShortcut("s")));
assertEquals(0, mManager.getRemainingCallCount());
assertTrue(mManager.isRateLimitingActive());
});
runWithCaller(CALLING_PACKAGE_1, USER_10, () -> {
assertEquals(3, mManager.getRemainingCallCount());
@@ -1617,6 +1631,7 @@ public class ShortcutManagerTest2 extends BaseShortcutManagerTest {
mManager.setDynamicShortcuts(list(makeShortcut("s")));
assertEquals(3, mManager.getRemainingCallCount()); // Still 3!
assertFalse(mManager.isRateLimitingActive());
});
}