Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 437fdf4d authored by Android Build Merger (Role)'s avatar Android Build Merger (Role) Committed by Android (Google) Code Review
Browse files

Merge changes Ic2864e8a,I3007735d into nyc-mr1-dev-plus-aosp

* changes:
  Merge \"Follow-up to multiple intents support\" into nyc-mr1-dev am: 7848856e
  Follow-up to multiple intents support am: 0eed441c
parents a1124e02 9e15977f
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -941,7 +941,8 @@ public final class ShortcutInfo implements Parcelable {
        }

        /**
         * Sets the intent of a shortcut.
         * Sets the intent of a shortcut.  Alternatively, {@link #setIntents(Intent[])} can be used
         * to launch an activity with other activities in the back stack.
         *
         * <p>This is a mandatory field when publishing a new shortcut with
         * {@link ShortcutManager#addDynamicShortcuts(List)} or
@@ -965,7 +966,9 @@ public final class ShortcutInfo implements Parcelable {
        }

        /**
         * Sets multiple intents instead of a single intent.
         * Sets multiple intents instead of a single intent, in order to launch an activity with
         * other activities in back stack.  Use {@link TaskStackBuilder} to build intents.
         * See the {@link ShortcutManager} javadoc for details.
         *
         * @see Builder#setIntent(Intent)
         * @see ShortcutInfo#getIntents()
+34 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.content.pm;
import android.annotation.NonNull;
import android.annotation.TestApi;
import android.annotation.UserIdInt;
import android.app.Activity;
import android.app.usage.UsageStatsManager;
import android.content.Context;
import android.content.Intent;
@@ -30,7 +31,7 @@ import com.android.internal.annotations.VisibleForTesting;
import java.util.List;

/**
 * ShortcutManager manages "launcher shortcuts" (or simply "shortcuts").  Shortcuts provide user
 * ShortcutManager manages "launcher shortcuts" (or simply "shortcuts").  Shortcuts provide users
 * with quick
 * ways to access activities other than the main activity from the launcher to users.  For example,
 * an email application may publish the "compose new email" action which will directly open the
@@ -183,6 +184,7 @@ import java.util.List;
 *       android:action=&quot;android.intent.action.VIEW&quot;
 *       android:targetPackage=&quot;com.example.myapplication&quot;
 *       android:targetClass=&quot;com.example.myapplication.ComposeActivity&quot; /&gt;
 *     &lt;!-- more intents can go here; see below --&gt;
 *     &lt;categories android:name=&quot;android.shortcut.conversation&quot; /&gt;
 *   &lt;/shortcut&gt;
 *   &lt;!-- more shortcut can go here --&gt;
@@ -209,9 +211,37 @@ import java.util.List;
 *
 *   <li>{@code intent} Intent to launch.  {@code android:action} is mandatory.
 *   See <a href="{@docRoot}guide/topics/ui/settings.html#Intents">Using intents</a> for the
 *   other supported tags.
 *   other supported tags.  Multiple intents can be provided for a single shortcut, so that
 *   an activity will be launched with other activities in the back stack.
 *   See {@link android.app.TaskStackBuilder} for details.
 * </ul>
 *
 * <h3>Shortcut Intents</h3>
 * Dynamic shortcuts can be published with any {@link Intent#addFlags Intent flags}.  Typically,
 * {@link Intent#FLAG_ACTIVITY_CLEAR_TASK} is specified possibly with other flags; otherwise,
 * if the application is already running, the application is simply brought to the foreground
 * and the target activity may not show up.
 *
 * <p>{@link ShortcutInfo.Builder#setIntents(Intent[])} can be used (instead of
 * {@link ShortcutInfo.Builder#setIntent(Intent)}) with
 * {@link android.app.TaskStackBuilder} in order to launch an activity with other activities
 * in the back stack, so that when the user presses the back key, a "parent" activity will be shown
 * instead of the user being navigated back to the launcher.
 *
 * <p>Manifest shortcuts can have multiple intents too to achieve the same effect.  In order to
 * specify multiple {@link Intent}s to a shortcut, simply list multiple &lt;intent&gt;s within
 * a single &lt;shortcut&gt;.  The last intent is what the user will see when a shortcut is
 * launched.
 *
 * <p>Manifest shortcuts <b>cannot</b> have custom intent flags.  The first intent of a manifest
 * shortcut will always have {@link Intent#FLAG_ACTIVITY_NEW_TASK} and
 * {@link Intent#FLAG_ACTIVITY_CLEAR_TASK} set.  This means, when the application is already
 * running, all the existing activities will be destroyed when a manifest shortcut is launched.
 * If this behavior is not desirable, one can use a "trampoline" activity (an activity
 * that starts another activity in {@link Activity#onCreate} and then calls
 * {@link Activity#finish()}) with {@code android:taskAffinity=""} in AndroidManifest.xml and point
 * at this activity in a manifest shortcut's intent.
 *
 * <h3>Updating Shortcuts v.s. Re-publishing New One with Different ID</h3>
 * In order to avoid users' confusion, {@link #updateShortcuts(List)} should not be used to update
 * a shortcut to something that is conceptually different.
@@ -267,6 +297,8 @@ import java.util.List;
 *   <li>When the user performs "inline reply" on a notification.
 * </ul>
 *
 * <p>When rate-limiting is active, {@link #isRateLimitingActive()} returns {@code true}.
 *
 * <h4>Resetting rate-limiting for testing</h4>
 *
 * If your application is rate-limited during development or testing, you can use the
+2 −3
Original line number Diff line number Diff line
@@ -459,9 +459,8 @@ public class LauncherAppsService extends SystemService {
            }
            // Note the target activity doesn't have to be exported.

            // TODO Use sourceBounds

            intents[0].addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intents[0].setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intents[0].setSourceBounds(sourceBounds);

            return startShortcutIntentsAsPublisher(
                    intents, packageName, startActivityOptions, userId);
+9 −4
Original line number Diff line number Diff line
@@ -842,12 +842,17 @@ public class ShortcutService extends IShortcutService.Stub {
        getLastResetTimeLocked();
    }

    @VisibleForTesting
    final File getUserFile(@UserIdInt int userId) {
        return new File(injectUserDataPath(userId), FILENAME_USER_PACKAGES);
    }

    private void saveUserLocked(@UserIdInt int userId) {
        final File path = new File(injectUserDataPath(userId), FILENAME_USER_PACKAGES);
        final File path = getUserFile(userId);
        if (DEBUG) {
            Slog.d(TAG, "Saving to " + path);
        }
        path.mkdirs();
        path.getParentFile().mkdirs();
        final AtomicFile file = new AtomicFile(path);
        FileOutputStream os = null;
        try {
@@ -890,7 +895,7 @@ public class ShortcutService extends IShortcutService.Stub {

    @Nullable
    private ShortcutUser loadUserLocked(@UserIdInt int userId) {
        final File path = new File(injectUserDataPath(userId), FILENAME_USER_PACKAGES);
        final File path = getUserFile(userId);
        if (DEBUG) {
            Slog.d(TAG, "Loading from " + path);
        }
@@ -1466,7 +1471,7 @@ public class ShortcutService extends IShortcutService.Stub {
     * Clean up / validate an incoming shortcut.
     * - Make sure all mandatory fields are set.
     * - Make sure the intent's extras are persistable, and them to set
     * {@link ShortcutInfo#mIntentPersistableExtras}.  Also clear its extras.
     * {@link ShortcutInfo#mIntentPersistableExtrases}.  Also clear its extras.
     * - Clear flags.
     *
     * TODO Detailed unit tests
+25 −0
Original line number Diff line number Diff line
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<!-- Copyright (C) 2016 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.
-->
<user locales="en-US" last-app-scan-time="3113976673">
    <package name="com.android.test.1" call-count="0" last-reset="1468976368772">
        <package-info version="25" last_udpate_time="1230796800000" />
        <shortcut id="manifest-shortcut-storage" activity="com.android.test.1/com.android.test.1.Settings" title="Storage" titleid="2131625197" titlename="storage_settings" textid="0" dmessageid="0" intent="#Intent;action=android.settings.INTERNAL_STORAGE_SETTINGS;end" timestamp="1469050672334" rank="4" flags="420" icon-res="2130837747" icon-resname="drawable/ic_shortcut_storage" >
            <intent-extras>
                <int name="key" value="12345" />
            </intent-extras>
        </shortcut>
    </package>
</user>
Loading