diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index d3d7a95dd32c3..338aa3a2c9794 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -605,11 +605,6 @@ - - - conversations = notificationManager.getConversations( false).getList(); @@ -184,25 +181,23 @@ public class PeopleSpaceUtils { priorityConversations); // Sort and then add recent and non priority conversations to tiles list. - if (!showOnlyPriority) { - if (DEBUG) Log.d(TAG, "Add recent conversations"); - Stream nonPriorityConversations = conversations.stream() - .filter(c -> c.getNotificationChannel() == null - || !c.getNotificationChannel().isImportantConversation()) - .map(c -> c.getShortcutInfo()); + if (DEBUG) Log.d(TAG, "Add recent conversations"); + Stream nonPriorityConversations = conversations.stream() + .filter(c -> c.getNotificationChannel() == null + || !c.getNotificationChannel().isImportantConversation()) + .map(c -> c.getShortcutInfo()); - List recentConversationsList = - peopleManager.getRecentConversations().getList(); - Stream recentConversations = recentConversationsList - .stream() - .map(c -> c.getShortcutInfo()); + List recentConversationsList = + peopleManager.getRecentConversations().getList(); + Stream recentConversations = recentConversationsList + .stream() + .map(c -> c.getShortcutInfo()); - Stream mergedStream = Stream.concat(nonPriorityConversations, - recentConversations); - List recentTiles = - getSortedTiles(peopleManager, launcherApps, mergedStream); - tiles.addAll(recentTiles); - } + Stream mergedStream = Stream.concat(nonPriorityConversations, + recentConversations); + List recentTiles = + getSortedTiles(peopleManager, launcherApps, mergedStream); + tiles.addAll(recentTiles); tiles = augmentTilesFromVisibleNotifications(context, tiles, notificationEntryManager); return tiles; diff --git a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java index fa7b7b33dff6d..4ad685eae1078 100644 --- a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java +++ b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetManager.java @@ -45,7 +45,6 @@ import android.os.Bundle; import android.os.ServiceManager; import android.os.UserHandle; import android.preference.PreferenceManager; -import android.provider.Settings; import android.service.notification.NotificationListenerService; import android.service.notification.StatusBarNotification; import android.util.Log; @@ -129,12 +128,8 @@ public class PeopleSpaceWidgetManager { } if (DEBUG) Log.d(TAG, "updating " + widgetIds.length + " widgets"); - boolean showSingleConversation = Settings.Global.getInt(mContext.getContentResolver(), - Settings.Global.PEOPLE_SPACE_CONVERSATION_TYPE, 0) == 0; - if (showSingleConversation) { - synchronized (mLock) { - updateSingleConversationWidgets(widgetIds); - } + synchronized (mLock) { + updateSingleConversationWidgets(widgetIds); } } catch (Exception e) { Log.e(TAG, "Exception: " + e); @@ -227,11 +222,6 @@ public class PeopleSpaceWidgetManager { public void updateWidgetsWithNotificationChanged(StatusBarNotification sbn, PeopleSpaceUtils.NotificationAction notificationAction) { if (DEBUG) Log.d(TAG, "updateWidgetsWithNotificationChanged called"); - boolean showSingleConversation = Settings.Global.getInt(mContext.getContentResolver(), - Settings.Global.PEOPLE_SPACE_CONVERSATION_TYPE, 0) == 0; - if (!showSingleConversation) { - return; - } try { String sbnShortcutId = sbn.getShortcutId(); if (sbnShortcutId == null) { diff --git a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetRemoteViewsFactory.java b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetRemoteViewsFactory.java deleted file mode 100644 index 87b2a15d1c55c..0000000000000 --- a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetRemoteViewsFactory.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) 2020 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.people.widget; - -import android.app.INotificationManager; -import android.app.people.IPeopleManager; -import android.app.people.PeopleSpaceTile; -import android.content.Context; -import android.content.Intent; -import android.content.pm.LauncherApps; -import android.content.pm.PackageManager; -import android.os.ServiceManager; -import android.util.Log; -import android.widget.RemoteViews; -import android.widget.RemoteViewsService; - -import com.android.systemui.Dependency; -import com.android.systemui.R; -import com.android.systemui.people.PeopleSpaceTileView; -import com.android.systemui.people.PeopleSpaceUtils; -import com.android.systemui.statusbar.notification.NotificationEntryManager; - -import java.util.ArrayList; -import java.util.List; - -/** People Space Widget RemoteViewsFactory class. */ -public class PeopleSpaceWidgetRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory { - private static final String TAG = "PeopleSpaceWRVFactory"; - private static final boolean DEBUG = PeopleSpaceUtils.DEBUG; - - private IPeopleManager mPeopleManager; - private INotificationManager mNotificationManager; - private NotificationEntryManager mNotificationEntryManager; - private PackageManager mPackageManager; - private LauncherApps mLauncherApps; - private List mTiles = new ArrayList<>(); - private Context mContext; - - public PeopleSpaceWidgetRemoteViewsFactory(Context context, Intent intent) { - this.mContext = context; - } - - @Override - public void onCreate() { - if (DEBUG) Log.d(TAG, "onCreate called"); - mNotificationManager = INotificationManager.Stub.asInterface( - ServiceManager.getService(Context.NOTIFICATION_SERVICE)); - mNotificationEntryManager = Dependency.get(NotificationEntryManager.class); - mPackageManager = mContext.getPackageManager(); - mPeopleManager = IPeopleManager.Stub.asInterface( - ServiceManager.getService(Context.PEOPLE_SERVICE)); - mLauncherApps = mContext.getSystemService(LauncherApps.class); - setTileViewsWithPriorityConversations(); - } - - /** - * Retrieves all priority conversations and sets a {@link PeopleSpaceTileView}s for each - * priority conversation. - */ - private void setTileViewsWithPriorityConversations() { - try { - mTiles = PeopleSpaceUtils.getTiles(mContext, mNotificationManager, - mPeopleManager, mLauncherApps, mNotificationEntryManager); - } catch (Exception e) { - Log.e(TAG, "Couldn't retrieve conversations", e); - } - } - - @Override - public void onDataSetChanged() { - if (DEBUG) Log.d(TAG, "onDataSetChanged called"); - setTileViewsWithPriorityConversations(); - } - - @Override - public void onDestroy() { - mTiles.clear(); - } - - @Override - public int getCount() { - return mTiles.size(); - } - - @Override - public RemoteViews getViewAt(int i) { - if (DEBUG) Log.d(TAG, "getViewAt called, index: " + i); - - RemoteViews personView = new RemoteViews(mContext.getPackageName(), - R.layout.people_space_widget_item); - try { - PeopleSpaceTile tile = mTiles.get(i); - - String status = PeopleSpaceUtils.getLastInteractionString(mContext, - tile.getLastInteractionTimestamp()); - - personView.setTextViewText(R.id.status, status); - personView.setTextViewText(R.id.name, tile.getUserName().toString()); - - personView.setImageViewBitmap( - R.id.package_icon, - PeopleSpaceUtils.convertDrawableToBitmap( - mPackageManager.getApplicationIcon(tile.getPackageName()) - ) - ); - personView.setImageViewIcon(R.id.person_icon, tile.getUserIcon()); - - Intent fillInIntent = new Intent(); - fillInIntent.putExtra(PeopleSpaceWidgetProvider.EXTRA_TILE_ID, tile.getId()); - fillInIntent.putExtra( - PeopleSpaceWidgetProvider.EXTRA_PACKAGE_NAME, tile.getPackageName()); - fillInIntent.putExtra(PeopleSpaceWidgetProvider.EXTRA_USER_HANDLE, - tile.getUserHandle()); - personView.setOnClickFillInIntent(R.id.item, fillInIntent); - } catch (Exception e) { - Log.e(TAG, "Couldn't retrieve shortcut information", e); - } - return personView; - } - - @Override - public RemoteViews getLoadingView() { - return null; - } - - @Override - public int getViewTypeCount() { - return 1; - } - - @Override - public long getItemId(int i) { - return i; - } - - @Override - public boolean hasStableIds() { - return true; - } -} diff --git a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetService.java b/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetService.java deleted file mode 100644 index c0e43473d0697..0000000000000 --- a/packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetService.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2020 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.people.widget; -import android.content.Intent; -import android.util.Log; -import android.widget.RemoteViewsService; - -import com.android.systemui.people.PeopleSpaceUtils; - -/** People Space Widget Service class. */ -public class PeopleSpaceWidgetService extends RemoteViewsService { - private static final String TAG = "PeopleSpaceWidgetSvc"; - private static final boolean DEBUG = PeopleSpaceUtils.DEBUG; - - @Override - public RemoteViewsFactory onGetViewFactory(Intent intent) { - if (DEBUG) Log.d(TAG, "onGetViewFactory called"); - return new PeopleSpaceWidgetRemoteViewsFactory(this.getApplicationContext(), intent); - } -} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt index dff97a6791647..fd5128a8213ae 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/init/NotificationsControllerImpl.kt @@ -17,7 +17,6 @@ package com.android.systemui.statusbar.notification.init import android.content.Context -import android.provider.Settings import android.service.notification.StatusBarNotification import com.android.systemui.dagger.SysUISingleton import com.android.systemui.people.widget.PeopleSpaceWidgetManager @@ -132,11 +131,7 @@ class NotificationsControllerImpl @Inject constructor( entryManager.attach(notificationListener) } - val showPeopleSpace = Settings.Global.getInt(context.contentResolver, - Settings.Global.SHOW_PEOPLE_SPACE, 1) - if (showPeopleSpace == 1) { - peopleSpaceWidgetManager.attach(notificationListener) - } + peopleSpaceWidgetManager.attach(notificationListener) } override fun dump( diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java index 9185cd6426f7a..ee98a591c8a03 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleSpaceUtilsTest.java @@ -67,7 +67,6 @@ import android.net.Uri; import android.os.Bundle; import android.os.UserHandle; import android.provider.ContactsContract; -import android.provider.Settings; import android.service.notification.ConversationChannelWrapper; import android.service.notification.StatusBarNotification; import android.testing.AndroidTestingRunner; @@ -234,8 +233,6 @@ public class PeopleSpaceUtilsTest extends SysuiTestCase { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - Settings.Global.putInt(mContext.getContentResolver(), - Settings.Global.PEOPLE_SPACE_CONVERSATION_TYPE, 0); int[] widgetIdsArray = {WIDGET_ID_WITH_SHORTCUT, WIDGET_ID_WITHOUT_SHORTCUT}; mOptions = new Bundle(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java index 5834aef4ba78b..7090e781a316c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java @@ -60,7 +60,6 @@ import android.graphics.drawable.Icon; import android.net.Uri; import android.os.Bundle; import android.os.UserHandle; -import android.provider.Settings; import android.service.notification.StatusBarNotification; import android.testing.AndroidTestingRunner; @@ -176,9 +175,6 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { verify(mListenerService).addNotificationHandler(mListenerCaptor.capture()); NotificationHandler serviceListener = requireNonNull(mListenerCaptor.getValue()); mNoMan.addListener(serviceListener); - // Default to single People tile widgets. - Settings.Global.putInt(mContext.getContentResolver(), - Settings.Global.PEOPLE_SPACE_CONVERSATION_TYPE, 0); clearStorage(); setStorageForTile(SHORTCUT_ID, TEST_PACKAGE_A, WIDGET_ID_WITH_SHORTCUT); @@ -304,8 +300,6 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase { @Test public void testDoNotUpdateNotificationPostedIfDifferentPackageName() throws Exception { - Settings.Global.putInt(mContext.getContentResolver(), - Settings.Global.PEOPLE_SPACE_CONVERSATION_TYPE, 0); int[] widgetIdsArray = {WIDGET_ID_WITH_SHORTCUT, WIDGET_ID_WITHOUT_SHORTCUT}; when(mAppWidgetManager.getAppWidgetIds(any())).thenReturn(widgetIdsArray);