diff options
| author | 2017-04-19 17:13:41 -0400 | |
|---|---|---|
| committer | 2017-04-20 10:58:40 -0400 | |
| commit | f85fc967655be97202b8c47596083dd18f950718 (patch) | |
| tree | 70dd423543efe8cd0b84b7f9e2c6781aea54f9ea | |
| parent | 38323f50c7f92491d7a7a89768275e0460370ab6 (diff) | |
Fix when instant app notif is showing
Test: manual
Change-Id: If17eddad60f8207fecf9518430a280261bde5b30
Fixes: 37107497
3 files changed, 109 insertions, 54 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/DockedStackExistsListener.java b/packages/SystemUI/src/com/android/systemui/DockedStackExistsListener.java new file mode 100644 index 000000000000..c38288299597 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/DockedStackExistsListener.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2017 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; + +import android.os.RemoteException; +import android.util.Log; +import android.view.IDockedStackListener; +import android.view.WindowManagerGlobal; + +import java.util.function.Consumer; + +/** + * Utility wrapper to listen for whether or not a docked stack exists, to be + * used for things like the different overview icon in that mode. + */ +public class DockedStackExistsListener extends IDockedStackListener.Stub { + + private static final String TAG = "DockedStackExistsListener"; + + private final Consumer<Boolean> mCallback; + + private DockedStackExistsListener(Consumer<Boolean> callback) { + mCallback = callback; + } + + @Override + public void onDividerVisibilityChanged(boolean visible) throws RemoteException { + } + + @Override + public void onDockedStackExistsChanged(final boolean exists) throws RemoteException { + mCallback.accept(exists); + } + + @Override + public void onDockedStackMinimizedChanged(boolean minimized, long animDuration, + boolean isHomeStackResizable) throws RemoteException { + } + + @Override + public void onAdjustedForImeChanged(boolean adjustedForIme, long animDuration) + throws RemoteException { + } + + @Override + public void onDockSideChanged(int newDockSide) throws RemoteException { + } + + public static void register(Consumer<Boolean> callback) { + try { + WindowManagerGlobal.getWindowManagerService().registerDockedStackListener( + new DockedStackExistsListener(callback)); + } catch (RemoteException e) { + Log.e(TAG, "Failed registering docked stack exists listener", e); + } + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index a5d7c57206be..1fd329cb1971 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -47,6 +47,7 @@ import android.view.inputmethod.InputMethodManager; import android.widget.FrameLayout; import com.android.systemui.Dependency; +import com.android.systemui.DockedStackExistsListener; import com.android.systemui.R; import com.android.systemui.RecentsComponent; import com.android.systemui.plugins.PluginListener; @@ -566,40 +567,10 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener); - try { - WindowManagerGlobal.getWindowManagerService().registerDockedStackListener(new Stub() { - @Override - public void onDividerVisibilityChanged(boolean visible) throws RemoteException { - } - - @Override - public void onDockedStackExistsChanged(final boolean exists) throws RemoteException { - mHandler.post(new Runnable() { - @Override - public void run() { - mDockedStackExists = exists; - updateRecentsIcon(); - } - }); - } - - @Override - public void onDockedStackMinimizedChanged(boolean minimized, long animDuration, - boolean isHomeStackResizable) throws RemoteException { - } - - @Override - public void onAdjustedForImeChanged(boolean adjustedForIme, long animDuration) - throws RemoteException { - } - - @Override - public void onDockSideChanged(int newDockSide) throws RemoteException { - } - }); - } catch (RemoteException e) { - Log.e(TAG, "Failed registering docked stack exists listener", e); - } + DockedStackExistsListener.register(exists -> mHandler.post(() -> { + mDockedStackExists = exists; + updateRecentsIcon(); + })); } void updateRotatedViews() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java index 5910557b539b..47c6362dde6f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java @@ -16,17 +16,11 @@ package com.android.systemui.statusbar.phone; -import android.app.ActivityManager; +import android.app.*; import android.app.ActivityManager.StackId; import android.app.ActivityManager.StackInfo; -import android.app.AlarmManager; import android.app.AlarmManager.AlarmClockInfo; -import android.app.AppGlobals; -import android.app.Notification; import android.app.Notification.Action; -import android.app.NotificationManager; -import android.app.PendingIntent; -import android.app.SynchronousUserSwitchObserver; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -55,6 +49,7 @@ import com.android.internal.messages.nano.SystemMessageProto.SystemMessage; import com.android.internal.telephony.IccCardConstants; import com.android.internal.telephony.TelephonyIntents; import com.android.systemui.Dependency; +import com.android.systemui.DockedStackExistsListener; import com.android.systemui.R; import com.android.systemui.SysUiServiceProvider; import com.android.systemui.qs.tiles.DndTile; @@ -132,6 +127,7 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks, private boolean mZenVisible; private boolean mVolumeVisible; private boolean mCurrentUserSetup; + private boolean mDockedStackExists; private boolean mManagedProfileIconVisible = false; private boolean mManagedProfileInQuietMode = false; @@ -248,6 +244,10 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks, noMan.cancel(notification.getTag(), notification.getId()); } } + DockedStackExistsListener.register(exists -> { + mDockedStackExists = exists; + updateForegroundInstantApps(); + }); } public void destroy() { @@ -495,23 +495,18 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks, IPackageManager pm = AppGlobals.getPackageManager(); mCurrentNotifs.clear(); try { + ArraySet<Integer> stacksToCheck = new ArraySet<>(); int[] STACKS_TO_CHECK = new int[]{ StackId.FULLSCREEN_WORKSPACE_STACK_ID, StackId.DOCKED_STACK_ID, }; - for (int i = 0; i < STACKS_TO_CHECK.length; i++) { - StackInfo info = ActivityManager.getService().getStackInfo(STACKS_TO_CHECK[i]); - if (info == null || info.topActivity == null) continue; - String pkg = info.topActivity.getPackageName(); - if (!hasNotif(notifs, pkg, info.userId)) { - // TODO: Optimize by not always needing to get application info. - // Maybe cache non-ephemeral packages? - ApplicationInfo appInfo = pm.getApplicationInfo(pkg, - PackageManager.MATCH_UNINSTALLED_PACKAGES, info.userId); - if (appInfo.isInstantApp()) { - postEphemeralNotif(pkg, info.userId, appInfo, noMan); - } - } + int focusedId = ActivityManager.getService().getFocusedStackId(); + if (focusedId == StackId.FULLSCREEN_WORKSPACE_STACK_ID + || focusedId == StackId.FULLSCREEN_WORKSPACE_STACK_ID) { + checkStack(StackId.FULLSCREEN_WORKSPACE_STACK_ID, notifs, noMan, pm); + } + if (mDockedStackExists) { + checkStack(StackId.DOCKED_STACK_ID, notifs, noMan, pm); } } catch (RemoteException e) { e.rethrowFromSystemServer(); @@ -521,6 +516,26 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks, new UserHandle(v.second))); } + private void checkStack(int stackId, ArraySet<Pair<String, Integer>> notifs, + NotificationManager noMan, IPackageManager pm) { + try { + StackInfo info = ActivityManager.getService().getStackInfo(stackId); + if (info == null || info.topActivity == null) return; + String pkg = info.topActivity.getPackageName(); + if (!hasNotif(notifs, pkg, info.userId)) { + // TODO: Optimize by not always needing to get application info. + // Maybe cache non-ephemeral packages? + ApplicationInfo appInfo = pm.getApplicationInfo(pkg, + PackageManager.MATCH_UNINSTALLED_PACKAGES, info.userId); + if (appInfo.isInstantApp()) { + postEphemeralNotif(pkg, info.userId, appInfo, noMan); + } + } + } catch (RemoteException e) { + e.rethrowFromSystemServer(); + } + } + private void postEphemeralNotif(String pkg, int userId, ApplicationInfo appInfo, NotificationManager noMan) { final Bundle extras = new Bundle(); |