Loading packages/SystemUI/src/com/android/systemui/ForegroundServiceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ public interface ForegroundServiceController { void onAppOpChanged(int code, int uid, String packageName, boolean active); /** * Gets active app ops for this user and package. * Gets active app ops for this user and package */ @Nullable ArraySet<Integer> getAppOps(int userId, String packageName); } packages/SystemUI/src/com/android/systemui/statusbar/AppOpsListener.java +1 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ public class AppOpsListener implements AppOpsManager.OnOpActiveChangedListener { public void onOpActiveChanged(int code, int uid, String packageName, boolean active) { mFsc.onAppOpChanged(code, uid, packageName, active); mPresenter.getHandler().post(() -> { mEntryManager.updateNotificationsForAppOps(code, uid, packageName, active); mEntryManager.updateNotificationsForAppOp(code, uid, packageName, active); }); } } packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +3 −16 Original line number Diff line number Diff line Loading @@ -383,8 +383,6 @@ public class NotificationData { } mGroupManager.onEntryAdded(entry); updateAppOps(entry); updateRankingAndSort(mRankingMap); } Loading @@ -403,25 +401,14 @@ public class NotificationData { updateRankingAndSort(ranking); } private void updateAppOps(Entry entry) { final int uid = entry.notification.getUid(); final String pkg = entry.notification.getPackageName(); ArraySet<Integer> activeOps = mFsc.getAppOps(entry.notification.getUserId(), pkg); if (activeOps != null) { int N = activeOps.size(); for (int i = 0; i < N; i++) { updateAppOp(activeOps.valueAt(i), uid, pkg, true); } } } public void updateAppOp(int appOp, int uid, String pkg, boolean showIcon) { public void updateAppOp(int appOp, int uid, String pkg, String key, boolean showIcon) { synchronized (mEntries) { final int N = mEntries.size(); for (int i = 0; i < N; i++) { Entry entry = mEntries.valueAt(i); if (uid == entry.notification.getUid() && pkg.equals(entry.notification.getPackageName())) { && pkg.equals(entry.notification.getPackageName()) && key.equals(entry.key)) { if (showIcon) { entry.mActiveAppOps.add(appOp); } else { Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java +20 −4 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.util.Log; import android.view.View; import android.view.ViewGroup; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.logging.MetricsLogger; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.util.NotificationMessagingUtil; Loading Loading @@ -665,6 +666,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. } // Add the expanded view and icon. mNotificationData.add(entry); tagForeground(entry.notification); updateNotifications(); } Loading Loading @@ -726,6 +728,19 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. mPendingNotifications.put(key, shadeEntry); } @VisibleForTesting protected void tagForeground(StatusBarNotification notification) { ArraySet<Integer> activeOps = mForegroundServiceController.getAppOps( notification.getUserId(), notification.getPackageName()); if (activeOps != null) { int N = activeOps.size(); for (int i = 0; i < N; i++) { updateNotificationsForAppOp(activeOps.valueAt(i), notification.getUid(), notification.getPackageName(), true); } } } @Override public void addNotification(StatusBarNotification notification, NotificationListenerService.RankingMap ranking) { Loading @@ -736,10 +751,11 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. } } public void updateNotificationsForAppOps(int appOp, int uid, String pkg, boolean showIcon) { if (mForegroundServiceController.getStandardLayoutKey( UserHandle.getUserId(uid), pkg) != null) { mNotificationData.updateAppOp(appOp, uid, pkg, showIcon); public void updateNotificationsForAppOp(int appOp, int uid, String pkg, boolean showIcon) { String foregroundKey = mForegroundServiceController.getStandardLayoutKey( UserHandle.getUserId(uid), pkg); if (foregroundKey != null) { mNotificationData.updateAppOp(appOp, uid, pkg, foregroundKey, showIcon); updateNotifications(); } } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/AppOpsListenerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ public class AppOpsListenerTest extends SysuiTestCase { mListener.onOpActiveChanged( AppOpsManager.OP_RECORD_AUDIO, TEST_UID, TEST_PACKAGE_NAME, true); waitForIdleSync(mHandler); verify(mEntryManager, times(1)).updateNotificationsForAppOps( verify(mEntryManager, times(1)).updateNotificationsForAppOp( AppOpsManager.OP_RECORD_AUDIO, TEST_UID, TEST_PACKAGE_NAME, true); } Loading Loading
packages/SystemUI/src/com/android/systemui/ForegroundServiceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ public interface ForegroundServiceController { void onAppOpChanged(int code, int uid, String packageName, boolean active); /** * Gets active app ops for this user and package. * Gets active app ops for this user and package */ @Nullable ArraySet<Integer> getAppOps(int userId, String packageName); }
packages/SystemUI/src/com/android/systemui/statusbar/AppOpsListener.java +1 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ public class AppOpsListener implements AppOpsManager.OnOpActiveChangedListener { public void onOpActiveChanged(int code, int uid, String packageName, boolean active) { mFsc.onAppOpChanged(code, uid, packageName, active); mPresenter.getHandler().post(() -> { mEntryManager.updateNotificationsForAppOps(code, uid, packageName, active); mEntryManager.updateNotificationsForAppOp(code, uid, packageName, active); }); } }
packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +3 −16 Original line number Diff line number Diff line Loading @@ -383,8 +383,6 @@ public class NotificationData { } mGroupManager.onEntryAdded(entry); updateAppOps(entry); updateRankingAndSort(mRankingMap); } Loading @@ -403,25 +401,14 @@ public class NotificationData { updateRankingAndSort(ranking); } private void updateAppOps(Entry entry) { final int uid = entry.notification.getUid(); final String pkg = entry.notification.getPackageName(); ArraySet<Integer> activeOps = mFsc.getAppOps(entry.notification.getUserId(), pkg); if (activeOps != null) { int N = activeOps.size(); for (int i = 0; i < N; i++) { updateAppOp(activeOps.valueAt(i), uid, pkg, true); } } } public void updateAppOp(int appOp, int uid, String pkg, boolean showIcon) { public void updateAppOp(int appOp, int uid, String pkg, String key, boolean showIcon) { synchronized (mEntries) { final int N = mEntries.size(); for (int i = 0; i < N; i++) { Entry entry = mEntries.valueAt(i); if (uid == entry.notification.getUid() && pkg.equals(entry.notification.getPackageName())) { && pkg.equals(entry.notification.getPackageName()) && key.equals(entry.key)) { if (showIcon) { entry.mActiveAppOps.add(appOp); } else { Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java +20 −4 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.util.Log; import android.view.View; import android.view.ViewGroup; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.logging.MetricsLogger; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.util.NotificationMessagingUtil; Loading Loading @@ -665,6 +666,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. } // Add the expanded view and icon. mNotificationData.add(entry); tagForeground(entry.notification); updateNotifications(); } Loading Loading @@ -726,6 +728,19 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. mPendingNotifications.put(key, shadeEntry); } @VisibleForTesting protected void tagForeground(StatusBarNotification notification) { ArraySet<Integer> activeOps = mForegroundServiceController.getAppOps( notification.getUserId(), notification.getPackageName()); if (activeOps != null) { int N = activeOps.size(); for (int i = 0; i < N; i++) { updateNotificationsForAppOp(activeOps.valueAt(i), notification.getUid(), notification.getPackageName(), true); } } } @Override public void addNotification(StatusBarNotification notification, NotificationListenerService.RankingMap ranking) { Loading @@ -736,10 +751,11 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. } } public void updateNotificationsForAppOps(int appOp, int uid, String pkg, boolean showIcon) { if (mForegroundServiceController.getStandardLayoutKey( UserHandle.getUserId(uid), pkg) != null) { mNotificationData.updateAppOp(appOp, uid, pkg, showIcon); public void updateNotificationsForAppOp(int appOp, int uid, String pkg, boolean showIcon) { String foregroundKey = mForegroundServiceController.getStandardLayoutKey( UserHandle.getUserId(uid), pkg); if (foregroundKey != null) { mNotificationData.updateAppOp(appOp, uid, pkg, foregroundKey, showIcon); updateNotifications(); } } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/AppOpsListenerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ public class AppOpsListenerTest extends SysuiTestCase { mListener.onOpActiveChanged( AppOpsManager.OP_RECORD_AUDIO, TEST_UID, TEST_PACKAGE_NAME, true); waitForIdleSync(mHandler); verify(mEntryManager, times(1)).updateNotificationsForAppOps( verify(mEntryManager, times(1)).updateNotificationsForAppOp( AppOpsManager.OP_RECORD_AUDIO, TEST_UID, TEST_PACKAGE_NAME, true); } Loading