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

Commit 3c98e02d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Ied0d0a83,Id649a1ed

* changes:
  Add ability to pass user sentiment to assistant
  Add AndroidTest file for ExtServices
parents 080cc3d4 fd4099d7
Loading
Loading
Loading
Loading
+49 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ public final class NotificationStats implements Parcelable {
    /**
     * Notification has not been dismissed yet.
     */
    public static final int DISMISSAL_NOT_DISMISSED = -1;
    public static final int DISMISSAL_NOT_DISMISSED = -1000;
    /**
     * Notification has been dismissed from a {@link NotificationListenerService} or the app
     * itself.
@@ -71,6 +71,37 @@ public final class NotificationStats implements Parcelable {
     */
    public static final int DISMISSAL_SHADE = 3;

    /** @hide */
    @IntDef(prefix = { "DISMISS_SENTIMENT_" }, value = {
            DISMISS_SENTIMENT_UNKNOWN, DISMISS_SENTIMENT_NEGATIVE, DISMISS_SENTIMENT_NEUTRAL,
            DISMISS_SENTIMENT_POSITIVE
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface DismissalSentiment {}

    /**
     * No information is available about why this notification was dismissed, or the notification
     * isn't dismissed yet.
     */
    public static final int DISMISS_SENTIMENT_UNKNOWN = -1000;
    /**
     * The user indicated while dismissing that they did not like the notification.
     */
    public static final int DISMISS_SENTIMENT_NEGATIVE = 0;
    /**
     * The user didn't indicate one way or another how they felt about the notification while
     * dismissing it.
     */
    public static final int DISMISS_SENTIMENT_NEUTRAL = 1;
    /**
     * The user indicated while dismissing that they did like the notification.
     */
    public static final int DISMISS_SENTIMENT_POSITIVE = 2;


    private @DismissalSentiment
    int mDismissalSentiment = DISMISS_SENTIMENT_UNKNOWN;

    public NotificationStats() {
    }

@@ -82,6 +113,7 @@ public final class NotificationStats implements Parcelable {
        mViewedSettings = in.readByte() != 0;
        mInteracted = in.readByte() != 0;
        mDismissalSurface = in.readInt();
        mDismissalSentiment = in.readInt();
    }

    @Override
@@ -93,6 +125,7 @@ public final class NotificationStats implements Parcelable {
        dest.writeByte((byte) (mViewedSettings ? 1 : 0));
        dest.writeByte((byte) (mInteracted ? 1 : 0));
        dest.writeInt(mDismissalSurface);
        dest.writeInt(mDismissalSentiment);
    }

    @Override
@@ -212,6 +245,21 @@ public final class NotificationStats implements Parcelable {
        mDismissalSurface = dismissalSurface;
    }

    /**
     * Records whether the user indicated how they felt about a notification before or
     * during dismissal.
     */
    public void setDismissalSentiment(@DismissalSentiment int dismissalSentiment) {
        mDismissalSentiment = dismissalSentiment;
    }

    /**
     * Returns how the user indicated they felt about a notification before or during dismissal.
     */
    public @DismissalSentiment int getDismissalSentiment() {
        return mDismissalSentiment;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ interface IStatusBarService
            int uid, int initialPid, String message, int userId);
    void onClearAllNotifications(int userId);
    void onNotificationClear(String pkg, String tag, int id, int userId, String key,
            int dismissalSurface, in NotificationVisibility nv);
            int dismissalSurface, int dismissalSentiment, in NotificationVisibility nv);
    void onNotificationVisibilityChanged( in NotificationVisibility[] newlyVisibleKeys,
            in NotificationVisibility[] noLongerVisibleKeys);
    void onNotificationExpansionChanged(in String key, in boolean userAction, in boolean expanded);
+13 −9
Original line number Diff line number Diff line
@@ -316,7 +316,7 @@ public class Assistant extends NotificationAssistantService {
                saveFile();
            }
        } catch (Throwable e) {
            Slog.e(TAG, "Error occurred processing removal", e);
            Slog.e(TAG, "Error occurred processing removal of " + sbn, e);
        }
    }

@@ -327,6 +327,7 @@ public class Assistant extends NotificationAssistantService {

    @Override
    public void onNotificationsSeen(List<String> keys) {
        try {
            if (keys == null) {
                return;
            }
@@ -339,6 +340,9 @@ public class Assistant extends NotificationAssistantService {
                    mAgingHelper.onNotificationSeen(entry);
                }
            }
        } catch (Throwable e) {
            Slog.e(TAG, "Error occurred processing seen", e);
        }
    }

    @Override
+29 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2018 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.
-->
<configuration description="Runs Tests for ExtServices">
    <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
        <option name="test-file-name" value="ExtServicesUnitTests.apk" />
    </target_preparer>

    <option name="test-suite-tag" value="apct" />
    <option name="test-suite-tag" value="framework-base-presubmit" />
    <option name="test-tag" value="ExtServicesUnitTests" />
    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
        <option name="package" value="android.ext.services.tests.unit" />
        <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
        <option name="hidden-api-checks" value="false"/>
    </test>
</configuration>
 No newline at end of file
+3 −1
Original line number Diff line number Diff line
@@ -414,7 +414,9 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
            } else if (mListContainer.hasPulsingNotifications()) {
                dismissalSurface = NotificationStats.DISMISSAL_AOD;
            }
            mBarService.onNotificationClear(pkg, tag, id, userId, n.getKey(), dismissalSurface, nv);
            int dismissalSentiment = NotificationStats.DISMISS_SENTIMENT_NEUTRAL;
            mBarService.onNotificationClear(pkg, tag, id, userId, n.getKey(), dismissalSurface,
                    dismissalSentiment, nv);
            removeNotification(n.getKey(), null);

        } catch (RemoteException ex) {
Loading