Merge "Remove People Tile flag and clean up" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b4a4b46b7b
@@ -605,11 +605,6 @@
|
||||
<receiver android:name=".people.widget.PeopleSpaceWidgetPinnedReceiver"
|
||||
android:enabled="true"/>
|
||||
|
||||
<!-- Widget service -->
|
||||
<service android:name=".people.widget.PeopleSpaceWidgetService"
|
||||
android:permission="android.permission.BIND_REMOTEVIEWS"
|
||||
android:exported="false" />
|
||||
|
||||
<!-- ContentProvider that returns a People Tile preview for a given shortcut -->
|
||||
<provider
|
||||
android:name="com.android.systemui.people.PeopleProvider"
|
||||
|
||||
@@ -19,18 +19,15 @@ package com.android.systemui;
|
||||
import android.app.ActivityThread;
|
||||
import android.app.Application;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Process;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.Trace;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.util.TimingsTraceLog;
|
||||
import android.view.SurfaceControl;
|
||||
@@ -40,8 +37,6 @@ import com.android.systemui.dagger.ContextComponentHelper;
|
||||
import com.android.systemui.dagger.GlobalRootComponent;
|
||||
import com.android.systemui.dagger.SysUIComponent;
|
||||
import com.android.systemui.dump.DumpManager;
|
||||
import com.android.systemui.people.PeopleSpaceActivity;
|
||||
import com.android.systemui.people.widget.PeopleSpaceWidgetProvider;
|
||||
import com.android.systemui.shared.system.ThreadedRendererCompat;
|
||||
import com.android.systemui.util.NotificationChannels;
|
||||
|
||||
@@ -126,26 +121,6 @@ public class SystemUIApplication extends Application implements
|
||||
mServices[i].onBootCompleted();
|
||||
}
|
||||
}
|
||||
// If SHOW_PEOPLE_SPACE is true, enable People Space widget provider.
|
||||
// TODO(b/170396074): Migrate to new feature flag (go/silk-flags-howto)
|
||||
try {
|
||||
int showPeopleSpace = Settings.Global.getInt(context.getContentResolver(),
|
||||
Settings.Global.SHOW_PEOPLE_SPACE, 1);
|
||||
context.getPackageManager().setComponentEnabledSetting(
|
||||
new ComponentName(context, PeopleSpaceWidgetProvider.class),
|
||||
showPeopleSpace == 1
|
||||
? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
|
||||
: PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
context.getPackageManager().setComponentEnabledSetting(
|
||||
new ComponentName(context, PeopleSpaceActivity.class),
|
||||
showPeopleSpace == 1
|
||||
? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
|
||||
: PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.DONT_KILL_APP);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Error enabling People Space widget:", e);
|
||||
}
|
||||
}
|
||||
}, bootCompletedFilter);
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import android.content.pm.LauncherApps;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.ServiceManager;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@@ -58,7 +57,6 @@ public class PeopleSpaceActivity extends Activity {
|
||||
private Context mContext;
|
||||
private NotificationEntryManager mNotificationEntryManager;
|
||||
private int mAppWidgetId;
|
||||
private boolean mShowSingleConversation;
|
||||
|
||||
@Inject
|
||||
public PeopleSpaceActivity(NotificationEntryManager notificationEntryManager,
|
||||
@@ -84,15 +82,7 @@ public class PeopleSpaceActivity extends Activity {
|
||||
setTileViewsWithPriorityConversations();
|
||||
mAppWidgetId = getIntent().getIntExtra(EXTRA_APPWIDGET_ID,
|
||||
INVALID_APPWIDGET_ID);
|
||||
mShowSingleConversation = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.PEOPLE_SPACE_CONVERSATION_TYPE, 0) == 0;
|
||||
setResult(RESULT_CANCELED);
|
||||
// Finish the configuration activity immediately if a widget is added for multiple
|
||||
// conversations. If the mAppWidgetId is INVALID, then the activity wasn't launched as a
|
||||
// widget configuration activity.
|
||||
if (!mShowSingleConversation && mAppWidgetId != INVALID_APPWIDGET_ID) {
|
||||
finishActivity();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,7 +62,6 @@ import android.os.Parcelable;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.ContactsContract;
|
||||
import android.provider.Settings;
|
||||
import android.service.notification.ConversationChannelWrapper;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.text.TextUtils;
|
||||
@@ -170,8 +169,6 @@ public class PeopleSpaceUtils {
|
||||
Context context, INotificationManager notificationManager, IPeopleManager peopleManager,
|
||||
LauncherApps launcherApps, NotificationEntryManager notificationEntryManager)
|
||||
throws Exception {
|
||||
boolean showOnlyPriority = Settings.Global.getInt(context.getContentResolver(),
|
||||
Settings.Global.PEOPLE_SPACE_CONVERSATION_TYPE, 0) == 1;
|
||||
List<ConversationChannelWrapper> 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<ShortcutInfo> nonPriorityConversations = conversations.stream()
|
||||
.filter(c -> c.getNotificationChannel() == null
|
||||
|| !c.getNotificationChannel().isImportantConversation())
|
||||
.map(c -> c.getShortcutInfo());
|
||||
if (DEBUG) Log.d(TAG, "Add recent conversations");
|
||||
Stream<ShortcutInfo> nonPriorityConversations = conversations.stream()
|
||||
.filter(c -> c.getNotificationChannel() == null
|
||||
|| !c.getNotificationChannel().isImportantConversation())
|
||||
.map(c -> c.getShortcutInfo());
|
||||
|
||||
List<ConversationChannel> recentConversationsList =
|
||||
peopleManager.getRecentConversations().getList();
|
||||
Stream<ShortcutInfo> recentConversations = recentConversationsList
|
||||
.stream()
|
||||
.map(c -> c.getShortcutInfo());
|
||||
List<ConversationChannel> recentConversationsList =
|
||||
peopleManager.getRecentConversations().getList();
|
||||
Stream<ShortcutInfo> recentConversations = recentConversationsList
|
||||
.stream()
|
||||
.map(c -> c.getShortcutInfo());
|
||||
|
||||
Stream<ShortcutInfo> mergedStream = Stream.concat(nonPriorityConversations,
|
||||
recentConversations);
|
||||
List<PeopleSpaceTile> recentTiles =
|
||||
getSortedTiles(peopleManager, launcherApps, mergedStream);
|
||||
tiles.addAll(recentTiles);
|
||||
}
|
||||
Stream<ShortcutInfo> mergedStream = Stream.concat(nonPriorityConversations,
|
||||
recentConversations);
|
||||
List<PeopleSpaceTile> recentTiles =
|
||||
getSortedTiles(peopleManager, launcherApps, mergedStream);
|
||||
tiles.addAll(recentTiles);
|
||||
|
||||
tiles = augmentTilesFromVisibleNotifications(context, tiles, notificationEntryManager);
|
||||
return tiles;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<PeopleSpaceTile> 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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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(
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user