summaryrefslogtreecommitdiff
path: root/core/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/com')
-rw-r--r--core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java2
-rw-r--r--core/java/com/android/internal/app/ChooserActivity.java78
-rw-r--r--core/java/com/android/internal/app/ChooserListAdapter.java13
-rw-r--r--core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java9
-rw-r--r--core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java16
-rw-r--r--core/java/com/android/internal/policy/PhoneWindow.java2
6 files changed, 54 insertions, 66 deletions
diff --git a/core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java b/core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java
index 0d16cc49ea3c..26af61520593 100644
--- a/core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java
+++ b/core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java
@@ -188,7 +188,7 @@ class AppPredictionServiceResolverComparator extends AbstractResolverComparator
}
Integer rank = mTargetRanks.get(name);
if (rank == null) {
- Log.w(TAG, "Score requested for unknown component.");
+ Log.w(TAG, "Score requested for unknown component. Did you call compute yet?");
return 0f;
}
int consecutiveSumOfRanks = (mTargetRanks.size() - 1) * (mTargetRanks.size()) / 2;
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index ac8f9e8424b7..18091896cc28 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -162,6 +162,9 @@ public class ChooserActivity extends ResolverActivity implements
private AppPredictor mWorkAppPredictor;
private boolean mShouldDisplayLandscape;
+ private static final int MAX_TARGETS_PER_ROW_PORTRAIT = 4;
+ private static final int MAX_TARGETS_PER_ROW_LANDSCAPE = 8;
+
@UnsupportedAppUsage
public ChooserActivity() {
}
@@ -823,8 +826,6 @@ public class ChooserActivity extends ResolverActivity implements
queryDirectShareTargets(chooserListAdapter, true);
return;
}
- final List<DisplayResolveInfo> driList =
- getDisplayResolveInfos(chooserListAdapter);
final List<ShortcutManager.ShareShortcutInfo> shareShortcutInfos =
new ArrayList<>();
@@ -852,7 +853,7 @@ public class ChooserActivity extends ResolverActivity implements
new ComponentName(
appTarget.getPackageName(), appTarget.getClassName())));
}
- sendShareShortcutInfoList(shareShortcutInfos, driList, resultList,
+ sendShareShortcutInfoList(shareShortcutInfos, chooserListAdapter, resultList,
chooserListAdapter.getUserHandle());
};
}
@@ -904,7 +905,7 @@ public class ChooserActivity extends ResolverActivity implements
adapter,
getPersonalProfileUserHandle(),
/* workProfileUserHandle= */ null,
- isSendAction(getTargetIntent()));
+ isSendAction(getTargetIntent()), getMaxTargetsPerRow());
}
private ChooserMultiProfilePagerAdapter createChooserMultiProfilePagerAdapterForTwoProfiles(
@@ -933,7 +934,7 @@ public class ChooserActivity extends ResolverActivity implements
selectedProfile,
getPersonalProfileUserHandle(),
getWorkProfileUserHandle(),
- isSendAction(getTargetIntent()));
+ isSendAction(getTargetIntent()), getMaxTargetsPerRow());
}
private int findSelectedProfile() {
@@ -1761,7 +1762,7 @@ public class ChooserActivity extends ResolverActivity implements
case ChooserListAdapter.TARGET_CALLER:
case ChooserListAdapter.TARGET_STANDARD:
cat = MetricsEvent.ACTION_ACTIVITY_CHOOSER_PICKED_APP_TARGET;
- value -= currentListAdapter.getSelectableServiceTargetCount();
+ value -= currentListAdapter.getSurfacedTargetInfo().size();
numCallerProvided = currentListAdapter.getCallerTargetCount();
getChooserActivityLogger().logShareTargetSelected(
SELECTION_TYPE_APP,
@@ -1971,32 +1972,6 @@ public class ChooserActivity extends ResolverActivity implements
}
}
- private List<DisplayResolveInfo> getDisplayResolveInfos(ChooserListAdapter adapter) {
- // Need to keep the original DisplayResolveInfos to be able to reconstruct ServiceResultInfo
- // and use the old code path. This Ugliness should go away when Sharesheet is refactored.
- List<DisplayResolveInfo> driList = new ArrayList<>();
- int targetsToQuery = 0;
- for (int i = 0, n = adapter.getDisplayResolveInfoCount(); i < n; i++) {
- final DisplayResolveInfo dri = adapter.getDisplayResolveInfo(i);
- if (adapter.getScore(dri) == 0) {
- // A score of 0 means the app hasn't been used in some time;
- // don't query it as it's not likely to be relevant.
- continue;
- }
- driList.add(dri);
- targetsToQuery++;
- // TODO(b/121287224): Do we need this here? (similar to queryTargetServices)
- if (targetsToQuery >= SHARE_TARGET_QUERY_PACKAGE_LIMIT) {
- if (DEBUG) {
- Log.d(TAG, "queryTargets hit query target limit "
- + SHARE_TARGET_QUERY_PACKAGE_LIMIT);
- }
- break;
- }
- }
- return driList;
- }
-
@VisibleForTesting
protected void queryDirectShareTargets(
ChooserListAdapter adapter, boolean skipAppPredictionService) {
@@ -2014,14 +1989,13 @@ public class ChooserActivity extends ResolverActivity implements
if (filter == null) {
return;
}
- final List<DisplayResolveInfo> driList = getDisplayResolveInfos(adapter);
AsyncTask.execute(() -> {
Context selectedProfileContext = createContextAsUser(userHandle, 0 /* flags */);
ShortcutManager sm = (ShortcutManager) selectedProfileContext
.getSystemService(Context.SHORTCUT_SERVICE);
List<ShortcutManager.ShareShortcutInfo> resultList = sm.getShareTargets(filter);
- sendShareShortcutInfoList(resultList, driList, null, userHandle);
+ sendShareShortcutInfoList(resultList, adapter, null, userHandle);
});
}
@@ -2058,7 +2032,7 @@ public class ChooserActivity extends ResolverActivity implements
private void sendShareShortcutInfoList(
List<ShortcutManager.ShareShortcutInfo> resultList,
- List<DisplayResolveInfo> driList,
+ ChooserListAdapter chooserListAdapter,
@Nullable List<AppTarget> appTargets, UserHandle userHandle) {
if (appTargets != null && appTargets.size() != resultList.size()) {
throw new RuntimeException("resultList and appTargets must have the same size."
@@ -2084,10 +2058,10 @@ public class ChooserActivity extends ResolverActivity implements
// for direct share targets. After ShareSheet is refactored we should use the
// ShareShortcutInfos directly.
boolean resultMessageSent = false;
- for (int i = 0; i < driList.size(); i++) {
+ for (int i = 0; i < chooserListAdapter.getDisplayResolveInfoCount(); i++) {
List<ShortcutManager.ShareShortcutInfo> matchingShortcuts = new ArrayList<>();
for (int j = 0; j < resultList.size(); j++) {
- if (driList.get(i).getResolvedComponentName().equals(
+ if (chooserListAdapter.getDisplayResolveInfo(i).getResolvedComponentName().equals(
resultList.get(j).getTargetComponent())) {
matchingShortcuts.add(resultList.get(j));
}
@@ -2102,7 +2076,8 @@ public class ChooserActivity extends ResolverActivity implements
final Message msg = Message.obtain();
msg.what = ChooserHandler.SHORTCUT_MANAGER_SHARE_TARGET_RESULT;
- msg.obj = new ServiceResultInfo(driList.get(i), chooserTargets, null, userHandle);
+ msg.obj = new ServiceResultInfo(chooserListAdapter.getDisplayResolveInfo(i),
+ chooserTargets, null, userHandle);
msg.arg1 = shortcutType;
mChooserHandler.sendMessage(msg);
resultMessageSent = true;
@@ -2660,7 +2635,7 @@ public class ChooserActivity extends ResolverActivity implements
// and b/150936654
recyclerView.setAdapter(gridAdapter);
((GridLayoutManager) recyclerView.getLayoutManager()).setSpanCount(
- gridAdapter.getMaxTargetsPerRow());
+ getMaxTargetsPerRow());
}
UserHandle currentUserHandle = mChooserMultiProfilePagerAdapter.getCurrentUserHandle();
@@ -2825,9 +2800,7 @@ public class ChooserActivity extends ResolverActivity implements
@Override // ChooserListCommunicator
public int getMaxRankedTargets() {
- return mChooserMultiProfilePagerAdapter.getCurrentRootAdapter() == null
- ? ChooserGridAdapter.MAX_TARGETS_PER_ROW_PORTRAIT
- : mChooserMultiProfilePagerAdapter.getCurrentRootAdapter().getMaxTargetsPerRow();
+ return getMaxTargetsPerRow();
}
@Override // ChooserListCommunicator
@@ -3176,6 +3149,13 @@ public class ChooserActivity extends ResolverActivity implements
}
}
+ int getMaxTargetsPerRow() {
+ int maxTargets = MAX_TARGETS_PER_ROW_PORTRAIT;
+ if (mShouldDisplayLandscape) {
+ maxTargets = MAX_TARGETS_PER_ROW_LANDSCAPE;
+ }
+ return maxTargets;
+ }
/**
* Adapter for all types of items and targets in ShareSheet.
* Note that ranked sections like Direct Share - while appearing grid-like - are handled on the
@@ -3204,9 +3184,6 @@ public class ChooserActivity extends ResolverActivity implements
private static final int VIEW_TYPE_CALLER_AND_RANK = 5;
private static final int VIEW_TYPE_FOOTER = 6;
- private static final int MAX_TARGETS_PER_ROW_PORTRAIT = 4;
- private static final int MAX_TARGETS_PER_ROW_LANDSCAPE = 8;
-
private static final int NUM_EXPANSIONS_TO_HIDE_AZ_LABEL = 20;
ChooserGridAdapter(ChooserListAdapter wrappedAdapter) {
@@ -3255,14 +3232,6 @@ public class ChooserActivity extends ResolverActivity implements
return false;
}
- int getMaxTargetsPerRow() {
- int maxTargets = MAX_TARGETS_PER_ROW_PORTRAIT;
- if (mShouldDisplayLandscape) {
- maxTargets = MAX_TARGETS_PER_ROW_LANDSCAPE;
- }
- return maxTargets;
- }
-
/**
* Hides the list item content preview.
* <p>Not to be confused with the sticky content preview which is above the
@@ -3632,8 +3601,7 @@ public class ChooserActivity extends ResolverActivity implements
position -= getSystemRowCount() + getProfileRowCount();
final int serviceCount = mChooserListAdapter.getServiceTargetCount();
- final int serviceRows = (int) Math.ceil((float) serviceCount
- / ChooserListAdapter.MAX_SERVICE_TARGETS);
+ final int serviceRows = (int) Math.ceil((float) serviceCount / getMaxRankedTargets());
if (position < serviceRows) {
return position * getMaxTargetsPerRow();
}
diff --git a/core/java/com/android/internal/app/ChooserListAdapter.java b/core/java/com/android/internal/app/ChooserListAdapter.java
index 00b5cb646bca..570066807f16 100644
--- a/core/java/com/android/internal/app/ChooserListAdapter.java
+++ b/core/java/com/android/internal/app/ChooserListAdapter.java
@@ -82,8 +82,6 @@ public class ChooserListAdapter extends ResolverListAdapter {
private static final int MAX_SERVICE_TARGET_APP = 8;
private static final int DEFAULT_DIRECT_SHARE_RANKING_SCORE = 1000;
- static final int MAX_SERVICE_TARGETS = 8;
-
/** {@link #getBaseScore} */
public static final float CALLER_TARGET_SCORE_BOOST = 900.f;
/** {@link #getBaseScore} */
@@ -130,10 +128,10 @@ public class ChooserListAdapter extends ResolverListAdapter {
super(context, payloadIntents, null, rList, filterLastUsed,
resolverListController, chooserListCommunicator, false);
- createPlaceHolders();
mMaxShortcutTargetsPerApp =
context.getResources().getInteger(R.integer.config_maxShortcutTargetsPerApp);
mChooserListCommunicator = chooserListCommunicator;
+ createPlaceHolders();
mSelectableTargetInfoCommunicator = selectableTargetInfoCommunicator;
if (initialIntents != null) {
@@ -227,7 +225,7 @@ public class ChooserListAdapter extends ResolverListAdapter {
mParkingDirectShareTargets.clear();
mPendingChooserTargetService.clear();
mShortcutComponents.clear();
- for (int i = 0; i < MAX_SERVICE_TARGETS; i++) {
+ for (int i = 0; i < mChooserListCommunicator.getMaxRankedTargets(); i++) {
mServiceTargets.add(mPlaceHolderTargetInfo);
}
}
@@ -382,7 +380,7 @@ public class ChooserListAdapter extends ResolverListAdapter {
public int getServiceTargetCount() {
if (mChooserListCommunicator.isSendAction(mChooserListCommunicator.getTargetIntent())
&& !ActivityManager.isLowRamDeviceStatic()) {
- return Math.min(mServiceTargets.size(), MAX_SERVICE_TARGETS);
+ return Math.min(mServiceTargets.size(), mChooserListCommunicator.getMaxRankedTargets());
}
return 0;
@@ -847,7 +845,8 @@ public class ChooserListAdapter extends ResolverListAdapter {
int currentSize = mServiceTargets.size();
final float newScore = chooserTargetInfo.getModifiedScore();
- for (int i = 0; i < Math.min(currentSize, MAX_SERVICE_TARGETS); i++) {
+ for (int i = 0; i < Math.min(currentSize, mChooserListCommunicator.getMaxRankedTargets());
+ i++) {
final ChooserTargetInfo serviceTarget = mServiceTargets.get(i);
if (serviceTarget == null) {
mServiceTargets.set(i, chooserTargetInfo);
@@ -858,7 +857,7 @@ public class ChooserListAdapter extends ResolverListAdapter {
}
}
- if (currentSize < MAX_SERVICE_TARGETS) {
+ if (currentSize < mChooserListCommunicator.getMaxRankedTargets()) {
mServiceTargets.add(chooserTargetInfo);
return true;
}
diff --git a/core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java b/core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java
index 3a65a324f9d6..dd837fc2194c 100644
--- a/core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java
+++ b/core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java
@@ -39,17 +39,19 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd
private final ChooserProfileDescriptor[] mItems;
private final boolean mIsSendAction;
private int mBottomOffset;
+ private int mMaxTargetsPerRow;
ChooserMultiProfilePagerAdapter(Context context,
ChooserActivity.ChooserGridAdapter adapter,
UserHandle personalProfileUserHandle,
UserHandle workProfileUserHandle,
- boolean isSendAction) {
+ boolean isSendAction, int maxTargetsPerRow) {
super(context, /* currentPage */ 0, personalProfileUserHandle, workProfileUserHandle);
mItems = new ChooserProfileDescriptor[] {
createProfileDescriptor(adapter)
};
mIsSendAction = isSendAction;
+ mMaxTargetsPerRow = maxTargetsPerRow;
}
ChooserMultiProfilePagerAdapter(Context context,
@@ -58,7 +60,7 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd
@Profile int defaultProfile,
UserHandle personalProfileUserHandle,
UserHandle workProfileUserHandle,
- boolean isSendAction) {
+ boolean isSendAction, int maxTargetsPerRow) {
super(context, /* currentPage */ defaultProfile, personalProfileUserHandle,
workProfileUserHandle);
mItems = new ChooserProfileDescriptor[] {
@@ -66,6 +68,7 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd
createProfileDescriptor(workAdapter)
};
mIsSendAction = isSendAction;
+ mMaxTargetsPerRow = maxTargetsPerRow;
}
private ChooserProfileDescriptor createProfileDescriptor(
@@ -114,7 +117,7 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd
ChooserActivity.ChooserGridAdapter chooserGridAdapter =
getItem(pageIndex).chooserGridAdapter;
GridLayoutManager glm = (GridLayoutManager) recyclerView.getLayoutManager();
- glm.setSpanCount(chooserGridAdapter.getMaxTargetsPerRow());
+ glm.setSpanCount(mMaxTargetsPerRow);
glm.setSpanSizeLookup(
new GridLayoutManager.SpanSizeLookup() {
@Override
diff --git a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java
index b4cd145ca374..40c21bddf41b 100644
--- a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java
+++ b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java
@@ -428,6 +428,22 @@ public final class SystemUiDeviceConfigFlags {
*/
public static final String SCREENSHOT_KEYCHORD_DELAY = "screenshot_keychord_delay";
+ /**
+ * (boolean) Whether to use an ML model for the Back Gesture.
+ */
+ public static final String USE_BACK_GESTURE_ML_MODEL = "use_back_gesture_ml_model";
+
+ /**
+ * (string) The name of the ML model for Back Gesture.
+ */
+ public static final String BACK_GESTURE_ML_MODEL_NAME = "back_gesture_ml_model_name";
+
+ /**
+ * (float) Threshold for Back Gesture ML model prediction.
+ */
+ public static final String BACK_GESTURE_ML_MODEL_THRESHOLD = "back_gesture_ml_model_threshold";
+
+
private SystemUiDeviceConfigFlags() {
}
}
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java
index 046981cf2e8f..d90a0225608d 100644
--- a/core/java/com/android/internal/policy/PhoneWindow.java
+++ b/core/java/com/android/internal/policy/PhoneWindow.java
@@ -1510,11 +1510,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
if (drawable != mBackgroundDrawable) {
mBackgroundDrawable = drawable;
if (mDecor != null) {
+ mDecor.startChanging();
mDecor.setWindowBackground(drawable);
if (mBackgroundFallbackDrawable != null) {
mDecor.setBackgroundFallback(drawable != null ? null :
mBackgroundFallbackDrawable);
}
+ mDecor.finishChanging();
}
}
}