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

Commit 8645879b authored by Gus Prevas's avatar Gus Prevas Committed by Android (Google) Code Review
Browse files

Merge "Extracts NotificationActivityStarter from NotificationPresenter."

parents 42055629 21437b3a
Loading
Loading
Loading
Loading
+1 −29
Original line number Original line Diff line number Diff line
@@ -15,9 +15,6 @@
 */
 */
package com.android.systemui.statusbar;
package com.android.systemui.statusbar;


import android.content.Intent;

import com.android.systemui.statusbar.notification.ActivityLaunchAnimator;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
@@ -38,12 +35,6 @@ public interface NotificationPresenter extends ExpandableNotificationRow.OnExpan
     */
     */
    boolean isPresenterFullyCollapsed();
    boolean isPresenterFullyCollapsed();


    /**
     * Runs the given intent. The presenter may want to run some animations or close itself when
     * this happens.
     */
    void startNotificationGutsIntent(Intent intent, int appUid, ExpandableNotificationRow row);

    /**
    /**
     * Refresh or remove lockscreen artwork from media metadata or the lockscreen wallpaper.
     * Refresh or remove lockscreen artwork from media metadata or the lockscreen wallpaper.
     */
     */
@@ -74,8 +65,7 @@ public interface NotificationPresenter extends ExpandableNotificationRow.OnExpan
    int getMaxNotificationsWhileLocked(boolean recompute);
    int getMaxNotificationsWhileLocked(boolean recompute);


    /**
    /**
     * True if the presenter
     * True if the presenter is currently locked.
     * @return
     */
     */
    default boolean isPresenterLocked() { return false; }
    default boolean isPresenterLocked() { return false; }


@@ -88,22 +78,4 @@ public interface NotificationPresenter extends ExpandableNotificationRow.OnExpan
     * @return true if the shade is collapsing.
     * @return true if the shade is collapsing.
     */
     */
    boolean isCollapsing();
    boolean isCollapsing();

    /**
     * @return true if the shade is collapsing to show an activity over the lock screen
     */
    default public boolean isCollapsingToShowActivityOverLockscreen() {
        return false;
    }

    /**
     * Get the {@link ActivityLaunchAnimator} from the presenter so it can be queried by
     * {@link com.android.systemui.statusbar.phone.StatusBar}
     * @return the current animator
     * @deprecated This is only here for now because StatusBar is still the ActivityLaunchAnimator
     * callback but shouldn't be.
     */
    default public ActivityLaunchAnimator getActivityLaunchAnimator() {
        return null;
    }
}
}
+2 −5
Original line number Original line Diff line number Diff line
@@ -111,7 +111,6 @@ public class NotificationRemoteInputManager implements Dumpable {
    private final KeyguardManager mKeyguardManager;
    private final KeyguardManager mKeyguardManager;


    protected RemoteInputController mRemoteInputController;
    protected RemoteInputController mRemoteInputController;
    protected NotificationPresenter mPresenter;
    protected NotificationLifetimeExtender.NotificationSafeToRemoveCallback
    protected NotificationLifetimeExtender.NotificationSafeToRemoveCallback
            mNotificationLifetimeFinishedCallback;
            mNotificationLifetimeFinishedCallback;
    protected IStatusBarService mBarService;
    protected IStatusBarService mBarService;
@@ -320,10 +319,8 @@ public class NotificationRemoteInputManager implements Dumpable {
        mKeyguardManager = context.getSystemService(KeyguardManager.class);
        mKeyguardManager = context.getSystemService(KeyguardManager.class);
    }
    }


    public void setUpWithPresenter(NotificationPresenter presenter,
    /** Initializes this component with the provided dependencies. */
            Callback callback,
    public void setUpWithCallback(Callback callback, RemoteInputController.Delegate delegate) {
            RemoteInputController.Delegate delegate) {
        mPresenter = presenter;
        mCallback = callback;
        mCallback = callback;
        mRemoteInputController = new RemoteInputController(delegate);
        mRemoteInputController = new RemoteInputController(delegate);
        mRemoteInputController.addCallback(new RemoteInputController.Callback() {
        mRemoteInputController.addCallback(new RemoteInputController.Callback() {
+39 −0
Original line number Original line Diff line number Diff line
/*
 * 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.
 */

package com.android.systemui.statusbar.notification;

import android.content.Intent;
import android.service.notification.StatusBarNotification;

import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;

/**
 * Component responsible for handling actions on a notification which cause activites to start.
 * (e.g. clicking on a notification, tapping on the settings icon in the notification guts)
 */
public interface NotificationActivityStarter {
    /** Called when the user clicks on the surface of a notification. */
    void onNotificationClicked(StatusBarNotification sbn, ExpandableNotificationRow row);

    /** Called when the user clicks on a button in the notification guts which fires an intent. */
    void startNotificationGutsIntent(Intent intent, int appUid,
            ExpandableNotificationRow row);

    default boolean isCollapsingToShowActivityOverLockscreen() {
        return false;
    }
}
+7 −10
Original line number Original line Diff line number Diff line
@@ -143,6 +143,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
    protected IStatusBarService mBarService;
    protected IStatusBarService mBarService;
    private NotificationPresenter mPresenter;
    private NotificationPresenter mPresenter;
    private Callback mCallback;
    private Callback mCallback;
    private NotificationActivityStarter mNotificationActivityStarter;
    protected PowerManager mPowerManager;
    protected PowerManager mPowerManager;
    private NotificationListenerService.RankingMap mLatestRankingMap;
    private NotificationListenerService.RankingMap mLatestRankingMap;
    protected HeadsUpManager mHeadsUpManager;
    protected HeadsUpManager mHeadsUpManager;
@@ -193,7 +194,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
                mBubbleController.collapseStack();
                mBubbleController.collapseStack();
            }
            }


            mCallback.onNotificationClicked(sbn, row);
            mNotificationActivityStarter.onNotificationClicked(sbn, row);
        }
        }


        private boolean isMenuVisible(ExpandableNotificationRow row) {
        private boolean isMenuVisible(ExpandableNotificationRow row) {
@@ -346,6 +347,11 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
        mOnAppOpsClickListener = mGutsManager::openGuts;
        mOnAppOpsClickListener = mGutsManager::openGuts;
    }
    }


    public void setNotificationActivityStarter(
            NotificationActivityStarter notificationActivityStarter) {
        mNotificationActivityStarter = notificationActivityStarter;
    }

    public NotificationData getNotificationData() {
    public NotificationData getNotificationData() {
        return mNotificationData;
        return mNotificationData;
    }
    }
@@ -1247,15 +1253,6 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
         */
         */
        void onNotificationRemoved(String key, StatusBarNotification old);
        void onNotificationRemoved(String key, StatusBarNotification old);



        /**
         * Called when a notification is clicked.
         *
         * @param sbn notification that was clicked
         * @param row row for that notification
         */
        void onNotificationClicked(StatusBarNotification sbn, ExpandableNotificationRow row);

        /**
        /**
         * Called when a new notification and row is created.
         * Called when a new notification and row is created.
         *
         *
+12 −9
Original line number Original line Diff line number Diff line
@@ -25,7 +25,6 @@ import android.app.NotificationChannel;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.net.Uri;
import android.net.Uri;
import android.os.ServiceManager;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserHandle;
@@ -42,13 +41,13 @@ import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.logging.nano.MetricsProto;
import com.android.systemui.Dependency;
import com.android.systemui.Dependency;
import com.android.systemui.Dumpable;
import com.android.systemui.Dumpable;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.statusbar.NotificationLifetimeExtender;
import com.android.systemui.statusbar.NotificationLifetimeExtender;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationPresenter;
import com.android.systemui.statusbar.NotificationPresenter;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.notification.NotificationActivityStarter;
import com.android.systemui.statusbar.notification.NotificationData;
import com.android.systemui.statusbar.notification.NotificationData;
import com.android.systemui.statusbar.notification.row.NotificationInfo.CheckSaveListener;
import com.android.systemui.statusbar.notification.row.NotificationInfo.CheckSaveListener;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
@@ -79,13 +78,13 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
            Dependency.get(StatusBarStateController.class);
            Dependency.get(StatusBarStateController.class);
    private final DeviceProvisionedController mDeviceProvisionedController =
    private final DeviceProvisionedController mDeviceProvisionedController =
            Dependency.get(DeviceProvisionedController.class);
            Dependency.get(DeviceProvisionedController.class);
    private final ActivityStarter mActivityStarter = Dependency.get(ActivityStarter.class);


    // which notification is currently being longpress-examined by the user
    // which notification is currently being longpress-examined by the user
    private NotificationGuts mNotificationGutsExposed;
    private NotificationGuts mNotificationGutsExposed;
    private NotificationMenuRowPlugin.MenuItem mGutsMenuItem;
    private NotificationMenuRowPlugin.MenuItem mGutsMenuItem;
    private NotificationSafeToRemoveCallback mNotificationLifetimeFinishedCallback;
    private NotificationSafeToRemoveCallback mNotificationLifetimeFinishedCallback;
    private NotificationPresenter mPresenter;
    private NotificationPresenter mPresenter;
    private NotificationActivityStarter mNotificationActivityStarter;
    private NotificationListContainer mListContainer;
    private NotificationListContainer mListContainer;
    private CheckSaveListener mCheckSaveListener;
    private CheckSaveListener mCheckSaveListener;
    private OnSettingsClickListener mOnSettingsClickListener;
    private OnSettingsClickListener mOnSettingsClickListener;
@@ -94,8 +93,6 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx


    public NotificationGutsManager(Context context) {
    public NotificationGutsManager(Context context) {
        mContext = context;
        mContext = context;
        Resources res = context.getResources();

        mAccessibilityManager = (AccessibilityManager)
        mAccessibilityManager = (AccessibilityManager)
                mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
                mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
    }
    }
@@ -109,6 +106,11 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
        mOnSettingsClickListener = onSettingsClick;
        mOnSettingsClickListener = onSettingsClick;
    }
    }


    public void setNotificationActivityStarter(
            NotificationActivityStarter notificationActivityStarter) {
        mNotificationActivityStarter = notificationActivityStarter;
    }

    public void onDensityOrFontScaleChanged(NotificationData.Entry entry) {
    public void onDensityOrFontScaleChanged(NotificationData.Entry entry) {
        setExposedGuts(entry.getGuts());
        setExposedGuts(entry.getGuts());
        bindGuts(entry.getRow());
        bindGuts(entry.getRow());
@@ -127,7 +129,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
        if (channel != null) {
        if (channel != null) {
            intent.putExtra(EXTRA_FRAGMENT_ARG_KEY, channel.getId());
            intent.putExtra(EXTRA_FRAGMENT_ARG_KEY, channel.getId());
        }
        }
        mPresenter.startNotificationGutsIntent(intent, appUid, row);
        mNotificationActivityStarter.startNotificationGutsIntent(intent, appUid, row);
    }
    }


    protected void startAppOpsSettingsActivity(String pkg, int uid, ArraySet<Integer> ops,
    protected void startAppOpsSettingsActivity(String pkg, int uid, ArraySet<Integer> ops,
@@ -138,12 +140,12 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
            } else {
            } else {
                Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
                Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
                intent.setData(Uri.fromParts("package", pkg, null));
                intent.setData(Uri.fromParts("package", pkg, null));
                mPresenter.startNotificationGutsIntent(intent, uid, row);
                mNotificationActivityStarter.startNotificationGutsIntent(intent, uid, row);
            }
            }
        } else if (ops.contains(OP_CAMERA) || ops.contains(OP_RECORD_AUDIO)) {
        } else if (ops.contains(OP_CAMERA) || ops.contains(OP_RECORD_AUDIO)) {
            Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSIONS);
            Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSIONS);
            intent.putExtra(Intent.EXTRA_PACKAGE_NAME, pkg);
            intent.putExtra(Intent.EXTRA_PACKAGE_NAME, pkg);
            mPresenter.startNotificationGutsIntent(intent, uid, row);
            mNotificationActivityStarter.startNotificationGutsIntent(intent, uid, row);
        }
        }
    }
    }


@@ -262,7 +264,8 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
                (View v, Intent intent) -> {
                (View v, Intent intent) -> {
                    mMetricsLogger.action(MetricsProto.MetricsEvent.ACTION_APP_NOTE_SETTINGS);
                    mMetricsLogger.action(MetricsProto.MetricsEvent.ACTION_APP_NOTE_SETTINGS);
                    guts.resetFalsingCheck();
                    guts.resetFalsingCheck();
                    mPresenter.startNotificationGutsIntent(intent, sbn.getUid(), row);
                    mNotificationActivityStarter.startNotificationGutsIntent(intent, sbn.getUid(),
                            row);
                };
                };
        boolean isForBlockingHelper = row.isBlockingHelperShowing();
        boolean isForBlockingHelper = row.isBlockingHelperShowing();


Loading