Loading core/java/android/content/pm/LauncherApps.java +9 −0 Original line number Diff line number Diff line Loading @@ -167,10 +167,17 @@ public class LauncherApps { */ public static final int FLAG_CACHE_BUBBLE_SHORTCUTS = 1; /** * Cache shortcuts which are used in People Tile. * @hide */ public static final int FLAG_CACHE_PEOPLE_TILE_SHORTCUTS = 2; /** @hide */ @IntDef(flag = false, prefix = { "FLAG_CACHE_" }, value = { FLAG_CACHE_NOTIFICATION_SHORTCUTS, FLAG_CACHE_BUBBLE_SHORTCUTS, FLAG_CACHE_PEOPLE_TILE_SHORTCUTS }) @Retention(RetentionPolicy.SOURCE) public @interface ShortcutCacheFlags {} Loading Loading @@ -1179,6 +1186,7 @@ public class LauncherApps { * <ul> * <li>{@link #FLAG_CACHE_NOTIFICATION_SHORTCUTS} * <li>{@link #FLAG_CACHE_BUBBLE_SHORTCUTS} * <li>{@link #FLAG_CACHE_PEOPLE_TILE_SHORTCUTS} * </ul> * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. Loading Loading @@ -1209,6 +1217,7 @@ public class LauncherApps { * <ul> * <li>{@link #FLAG_CACHE_NOTIFICATION_SHORTCUTS} * <li>{@link #FLAG_CACHE_BUBBLE_SHORTCUTS} * <li>{@link #FLAG_CACHE_PEOPLE_TILE_SHORTCUTS} * </ul> * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. Loading core/java/android/content/pm/ShortcutInfo.java +9 −1 Original line number Diff line number Diff line Loading @@ -129,6 +129,12 @@ public final class ShortcutInfo implements Parcelable { /** @hide */ public static final int FLAG_HAS_ICON_URI = 1 << 15; /** * TODO(b/155135057): This is a quick and temporary fix for b/155135890. ShortcutService doesn't * need to be aware of the outside world. Replace this with a more extensible solution. * @hide */ public static final int FLAG_CACHED_PEOPLE_TILE = 1 << 29; /** * TODO(b/155135057): This is a quick and temporary fix for b/155135890. ShortcutService doesn't Loading @@ -138,7 +144,8 @@ public final class ShortcutInfo implements Parcelable { public static final int FLAG_CACHED_BUBBLES = 1 << 30; /** @hide */ public static final int FLAG_CACHED_ALL = FLAG_CACHED_NOTIFICATIONS | FLAG_CACHED_BUBBLES; public static final int FLAG_CACHED_ALL = FLAG_CACHED_NOTIFICATIONS | FLAG_CACHED_BUBBLES | FLAG_CACHED_PEOPLE_TILE; /** @hide */ @IntDef(flag = true, prefix = { "FLAG_" }, value = { Loading @@ -159,6 +166,7 @@ public final class ShortcutInfo implements Parcelable { FLAG_HAS_ICON_URI, FLAG_CACHED_NOTIFICATIONS, FLAG_CACHED_BUBBLES, FLAG_CACHED_PEOPLE_TILE }) @Retention(RetentionPolicy.SOURCE) public @interface ShortcutFlags {} Loading packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.java +20 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.systemui.people; import static android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_ID; import static android.appwidget.AppWidgetManager.INVALID_APPWIDGET_ID; import static com.android.systemui.people.PeopleSpaceUtils.getUserHandle; import android.app.Activity; import android.app.INotificationManager; import android.app.people.IPeopleManager; Loading @@ -39,6 +41,7 @@ import com.android.internal.logging.UiEventLoggerImpl; import com.android.systemui.R; import com.android.systemui.statusbar.notification.NotificationEntryManager; import java.util.Collections; import java.util.List; import javax.inject.Inject; Loading @@ -49,6 +52,7 @@ import javax.inject.Inject; public class PeopleSpaceActivity extends Activity { private static final String TAG = "PeopleSpaceActivity"; private static final boolean DEBUG = PeopleSpaceUtils.DEBUG; private ViewGroup mPeopleSpaceLayout; private IPeopleManager mPeopleManager; Loading Loading @@ -134,22 +138,34 @@ public class PeopleSpaceActivity extends Activity { /** Stores the user selected configuration for {@code mAppWidgetId}. */ private void storeWidgetConfiguration(PeopleSpaceTile tile) { if (PeopleSpaceUtils.DEBUG) { if (DEBUG) { Log.d(TAG, "Put " + tile.getUserName() + "'s shortcut ID: " + tile.getId() + " for widget ID: " + mAppWidgetId); } } PeopleSpaceUtils.setStorageForTile(mContext, tile, mAppWidgetId); int[] widgetIds = new int[mAppWidgetId]; // TODO: Populate new widget with existing conversation notification, if there is any. PeopleSpaceUtils.updateSingleConversationWidgets(mContext, widgetIds, mAppWidgetManager, mPeopleManager); if (mLauncherApps != null) { try { if (DEBUG) Log.d(TAG, "Caching shortcut for PeopleTile: " + tile.getId()); mLauncherApps.cacheShortcuts(tile.getPackageName(), Collections.singletonList(tile.getId()), getUserHandle(tile), LauncherApps.FLAG_CACHE_PEOPLE_TILE_SHORTCUTS); } catch (Exception e) { Log.w(TAG, "Exception caching shortcut:" + e); } } finishActivity(); } /** Finish activity with a successful widget configuration result. */ private void finishActivity() { if (PeopleSpaceUtils.DEBUG) Log.d(TAG, "Widget added!"); if (DEBUG) Log.d(TAG, "Widget added!"); mUiEventLogger.log(PeopleSpaceUtils.PeopleSpaceWidgetEvent.PEOPLE_SPACE_WIDGET_ADDED); setActivityResult(RESULT_OK); finish(); Loading packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java +12 −2 Original line number Diff line number Diff line Loading @@ -287,7 +287,7 @@ public class PeopleSpaceUtils { SharedPreferences.Editor widgetEditor = widgetSp.edit(); widgetEditor.putString(PeopleSpaceUtils.PACKAGE_NAME, tile.getPackageName()); widgetEditor.putString(PeopleSpaceUtils.SHORTCUT_ID, tile.getId()); int userId = UserHandle.getUserHandleForUid(tile.getUid()).getIdentifier(); int userId = getUserId(tile); widgetEditor.putInt(PeopleSpaceUtils.USER_ID, userId); widgetEditor.apply(); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); Loading Loading @@ -634,7 +634,7 @@ public class PeopleSpaceUtils { private static Long getLastInteraction(IPeopleManager peopleManager, PeopleSpaceTile tile) { try { int userId = UserHandle.getUserHandleForUid(tile.getUid()).getIdentifier(); int userId = getUserId(tile); String pkg = tile.getPackageName(); return peopleManager.getLastInteraction(pkg, userId, tile.getId()); } catch (Exception e) { Loading Loading @@ -883,4 +883,14 @@ public class PeopleSpaceUtils { public static String getKey(String shortcutId, String packageName, int userId) { return shortcutId + "/" + userId + "/" + packageName; } /** Returns the userId associated with a {@link PeopleSpaceTile} */ public static int getUserId(PeopleSpaceTile tile) { return getUserHandle(tile).getIdentifier(); } /** Returns the {@link UserHandle} associated with a {@link PeopleSpaceTile} */ public static UserHandle getUserHandle(PeopleSpaceTile tile) { return UserHandle.getUserHandleForUid(tile.getUid()); } } No newline at end of file packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetProvider.java +30 −1 Original line number Diff line number Diff line Loading @@ -16,13 +16,20 @@ package com.android.systemui.people.widget; import static com.android.systemui.people.PeopleSpaceUtils.PACKAGE_NAME; import static com.android.systemui.people.PeopleSpaceUtils.SHORTCUT_ID; import static com.android.systemui.people.PeopleSpaceUtils.USER_ID; import android.app.PendingIntent; import android.app.people.IPeopleManager; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.LauncherApps; import android.os.ServiceManager; import android.os.UserHandle; import android.provider.Settings; import android.util.Log; import android.widget.RemoteViews; Loading @@ -32,6 +39,8 @@ import com.android.internal.logging.UiEventLoggerImpl; import com.android.systemui.R; import com.android.systemui.people.PeopleSpaceUtils; import java.util.Collections; /** People Space Widget Provider class. */ public class PeopleSpaceWidgetProvider extends AppWidgetProvider { private static final String TAG = "PeopleSpaceWidgetPvd"; Loading Loading @@ -88,11 +97,31 @@ public class PeopleSpaceWidgetProvider extends AppWidgetProvider { @Override public void onDeleted(Context context, int[] appWidgetIds) { super.onDeleted(context, appWidgetIds); LauncherApps launcherApps = context.getSystemService(LauncherApps.class); for (int widgetId : appWidgetIds) { if (DEBUG) Log.d(TAG, "Widget removed"); mUiEventLogger.log(PeopleSpaceUtils.PeopleSpaceWidgetEvent.PEOPLE_SPACE_WIDGET_DELETED); if (launcherApps != null) { SharedPreferences widgetSp = context.getSharedPreferences(String.valueOf(widgetId), Context.MODE_PRIVATE); String packageName = widgetSp.getString(PACKAGE_NAME, null); String shortcutId = widgetSp.getString(SHORTCUT_ID, null); int userId = widgetSp.getInt(USER_ID, -1); if (packageName != null && shortcutId != null && userId != -1) { try { if (DEBUG) Log.d(TAG, "Uncaching shortcut for PeopleTile: " + shortcutId); launcherApps.uncacheShortcuts(packageName, Collections.singletonList(shortcutId), UserHandle.of(userId), LauncherApps.FLAG_CACHE_PEOPLE_TILE_SHORTCUTS); } catch (Exception e) { Log.d(TAG, "Exception uncaching shortcut:" + e); } } } PeopleSpaceUtils.removeStorageForTile(context, widgetId); } } } Loading
core/java/android/content/pm/LauncherApps.java +9 −0 Original line number Diff line number Diff line Loading @@ -167,10 +167,17 @@ public class LauncherApps { */ public static final int FLAG_CACHE_BUBBLE_SHORTCUTS = 1; /** * Cache shortcuts which are used in People Tile. * @hide */ public static final int FLAG_CACHE_PEOPLE_TILE_SHORTCUTS = 2; /** @hide */ @IntDef(flag = false, prefix = { "FLAG_CACHE_" }, value = { FLAG_CACHE_NOTIFICATION_SHORTCUTS, FLAG_CACHE_BUBBLE_SHORTCUTS, FLAG_CACHE_PEOPLE_TILE_SHORTCUTS }) @Retention(RetentionPolicy.SOURCE) public @interface ShortcutCacheFlags {} Loading Loading @@ -1179,6 +1186,7 @@ public class LauncherApps { * <ul> * <li>{@link #FLAG_CACHE_NOTIFICATION_SHORTCUTS} * <li>{@link #FLAG_CACHE_BUBBLE_SHORTCUTS} * <li>{@link #FLAG_CACHE_PEOPLE_TILE_SHORTCUTS} * </ul> * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. Loading Loading @@ -1209,6 +1217,7 @@ public class LauncherApps { * <ul> * <li>{@link #FLAG_CACHE_NOTIFICATION_SHORTCUTS} * <li>{@link #FLAG_CACHE_BUBBLE_SHORTCUTS} * <li>{@link #FLAG_CACHE_PEOPLE_TILE_SHORTCUTS} * </ul> * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. Loading
core/java/android/content/pm/ShortcutInfo.java +9 −1 Original line number Diff line number Diff line Loading @@ -129,6 +129,12 @@ public final class ShortcutInfo implements Parcelable { /** @hide */ public static final int FLAG_HAS_ICON_URI = 1 << 15; /** * TODO(b/155135057): This is a quick and temporary fix for b/155135890. ShortcutService doesn't * need to be aware of the outside world. Replace this with a more extensible solution. * @hide */ public static final int FLAG_CACHED_PEOPLE_TILE = 1 << 29; /** * TODO(b/155135057): This is a quick and temporary fix for b/155135890. ShortcutService doesn't Loading @@ -138,7 +144,8 @@ public final class ShortcutInfo implements Parcelable { public static final int FLAG_CACHED_BUBBLES = 1 << 30; /** @hide */ public static final int FLAG_CACHED_ALL = FLAG_CACHED_NOTIFICATIONS | FLAG_CACHED_BUBBLES; public static final int FLAG_CACHED_ALL = FLAG_CACHED_NOTIFICATIONS | FLAG_CACHED_BUBBLES | FLAG_CACHED_PEOPLE_TILE; /** @hide */ @IntDef(flag = true, prefix = { "FLAG_" }, value = { Loading @@ -159,6 +166,7 @@ public final class ShortcutInfo implements Parcelable { FLAG_HAS_ICON_URI, FLAG_CACHED_NOTIFICATIONS, FLAG_CACHED_BUBBLES, FLAG_CACHED_PEOPLE_TILE }) @Retention(RetentionPolicy.SOURCE) public @interface ShortcutFlags {} Loading
packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.java +20 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.systemui.people; import static android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_ID; import static android.appwidget.AppWidgetManager.INVALID_APPWIDGET_ID; import static com.android.systemui.people.PeopleSpaceUtils.getUserHandle; import android.app.Activity; import android.app.INotificationManager; import android.app.people.IPeopleManager; Loading @@ -39,6 +41,7 @@ import com.android.internal.logging.UiEventLoggerImpl; import com.android.systemui.R; import com.android.systemui.statusbar.notification.NotificationEntryManager; import java.util.Collections; import java.util.List; import javax.inject.Inject; Loading @@ -49,6 +52,7 @@ import javax.inject.Inject; public class PeopleSpaceActivity extends Activity { private static final String TAG = "PeopleSpaceActivity"; private static final boolean DEBUG = PeopleSpaceUtils.DEBUG; private ViewGroup mPeopleSpaceLayout; private IPeopleManager mPeopleManager; Loading Loading @@ -134,22 +138,34 @@ public class PeopleSpaceActivity extends Activity { /** Stores the user selected configuration for {@code mAppWidgetId}. */ private void storeWidgetConfiguration(PeopleSpaceTile tile) { if (PeopleSpaceUtils.DEBUG) { if (DEBUG) { Log.d(TAG, "Put " + tile.getUserName() + "'s shortcut ID: " + tile.getId() + " for widget ID: " + mAppWidgetId); } } PeopleSpaceUtils.setStorageForTile(mContext, tile, mAppWidgetId); int[] widgetIds = new int[mAppWidgetId]; // TODO: Populate new widget with existing conversation notification, if there is any. PeopleSpaceUtils.updateSingleConversationWidgets(mContext, widgetIds, mAppWidgetManager, mPeopleManager); if (mLauncherApps != null) { try { if (DEBUG) Log.d(TAG, "Caching shortcut for PeopleTile: " + tile.getId()); mLauncherApps.cacheShortcuts(tile.getPackageName(), Collections.singletonList(tile.getId()), getUserHandle(tile), LauncherApps.FLAG_CACHE_PEOPLE_TILE_SHORTCUTS); } catch (Exception e) { Log.w(TAG, "Exception caching shortcut:" + e); } } finishActivity(); } /** Finish activity with a successful widget configuration result. */ private void finishActivity() { if (PeopleSpaceUtils.DEBUG) Log.d(TAG, "Widget added!"); if (DEBUG) Log.d(TAG, "Widget added!"); mUiEventLogger.log(PeopleSpaceUtils.PeopleSpaceWidgetEvent.PEOPLE_SPACE_WIDGET_ADDED); setActivityResult(RESULT_OK); finish(); Loading
packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java +12 −2 Original line number Diff line number Diff line Loading @@ -287,7 +287,7 @@ public class PeopleSpaceUtils { SharedPreferences.Editor widgetEditor = widgetSp.edit(); widgetEditor.putString(PeopleSpaceUtils.PACKAGE_NAME, tile.getPackageName()); widgetEditor.putString(PeopleSpaceUtils.SHORTCUT_ID, tile.getId()); int userId = UserHandle.getUserHandleForUid(tile.getUid()).getIdentifier(); int userId = getUserId(tile); widgetEditor.putInt(PeopleSpaceUtils.USER_ID, userId); widgetEditor.apply(); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); Loading Loading @@ -634,7 +634,7 @@ public class PeopleSpaceUtils { private static Long getLastInteraction(IPeopleManager peopleManager, PeopleSpaceTile tile) { try { int userId = UserHandle.getUserHandleForUid(tile.getUid()).getIdentifier(); int userId = getUserId(tile); String pkg = tile.getPackageName(); return peopleManager.getLastInteraction(pkg, userId, tile.getId()); } catch (Exception e) { Loading Loading @@ -883,4 +883,14 @@ public class PeopleSpaceUtils { public static String getKey(String shortcutId, String packageName, int userId) { return shortcutId + "/" + userId + "/" + packageName; } /** Returns the userId associated with a {@link PeopleSpaceTile} */ public static int getUserId(PeopleSpaceTile tile) { return getUserHandle(tile).getIdentifier(); } /** Returns the {@link UserHandle} associated with a {@link PeopleSpaceTile} */ public static UserHandle getUserHandle(PeopleSpaceTile tile) { return UserHandle.getUserHandleForUid(tile.getUid()); } } No newline at end of file
packages/SystemUI/src/com/android/systemui/people/widget/PeopleSpaceWidgetProvider.java +30 −1 Original line number Diff line number Diff line Loading @@ -16,13 +16,20 @@ package com.android.systemui.people.widget; import static com.android.systemui.people.PeopleSpaceUtils.PACKAGE_NAME; import static com.android.systemui.people.PeopleSpaceUtils.SHORTCUT_ID; import static com.android.systemui.people.PeopleSpaceUtils.USER_ID; import android.app.PendingIntent; import android.app.people.IPeopleManager; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.LauncherApps; import android.os.ServiceManager; import android.os.UserHandle; import android.provider.Settings; import android.util.Log; import android.widget.RemoteViews; Loading @@ -32,6 +39,8 @@ import com.android.internal.logging.UiEventLoggerImpl; import com.android.systemui.R; import com.android.systemui.people.PeopleSpaceUtils; import java.util.Collections; /** People Space Widget Provider class. */ public class PeopleSpaceWidgetProvider extends AppWidgetProvider { private static final String TAG = "PeopleSpaceWidgetPvd"; Loading Loading @@ -88,11 +97,31 @@ public class PeopleSpaceWidgetProvider extends AppWidgetProvider { @Override public void onDeleted(Context context, int[] appWidgetIds) { super.onDeleted(context, appWidgetIds); LauncherApps launcherApps = context.getSystemService(LauncherApps.class); for (int widgetId : appWidgetIds) { if (DEBUG) Log.d(TAG, "Widget removed"); mUiEventLogger.log(PeopleSpaceUtils.PeopleSpaceWidgetEvent.PEOPLE_SPACE_WIDGET_DELETED); if (launcherApps != null) { SharedPreferences widgetSp = context.getSharedPreferences(String.valueOf(widgetId), Context.MODE_PRIVATE); String packageName = widgetSp.getString(PACKAGE_NAME, null); String shortcutId = widgetSp.getString(SHORTCUT_ID, null); int userId = widgetSp.getInt(USER_ID, -1); if (packageName != null && shortcutId != null && userId != -1) { try { if (DEBUG) Log.d(TAG, "Uncaching shortcut for PeopleTile: " + shortcutId); launcherApps.uncacheShortcuts(packageName, Collections.singletonList(shortcutId), UserHandle.of(userId), LauncherApps.FLAG_CACHE_PEOPLE_TILE_SHORTCUTS); } catch (Exception e) { Log.d(TAG, "Exception uncaching shortcut:" + e); } } } PeopleSpaceUtils.removeStorageForTile(context, widgetId); } } }