Commit Graph

246 Commits

Author SHA1 Message Date
Pierre Barbier de Reuille
3abdfaaa8a Prevent recycling if the color mapping changed.
It was done in a weird way by "forgetting" the layoutId. It's now done
explicitly, which should make it more robust in the future.

Fix: 205265677
Test: Manually
Change-Id: Ie8b88a2b17e8f680f14fa19a485cd91853d90142
2021-11-09 14:55:39 +00:00
Pierre Barbier de Reuille
206066b6cc Check if a view can be recycled in async case.
When implementing the code, it seems this was forgotten :( If the view
id of the root of the RemoteViews is changed, currently, the top-level
view will be re-used, which is an error.

Bug: 181985606
Test: atest android.widget.cts.RemoteViewsRecyclingTest
Change-Id: I5a8addb08f597ec574e3ed49d1318771e4c7c767
2021-10-28 14:51:39 +00:00
Pierre Barbier de Reuille
acfcc90ebd Check if APK paths are valid right before creating the context.
The check has to be done in RemoteViews and in AppWidgetHostView right
before creating the context used to inflate the app widget. Further, the
APK is cached potentially in two places: in the APK with code and the
APK without codes, so both places are updated if present.

Test: manual, see bug for details
Fix: 202369942

Change-Id: I5718f67711a3332a942d3c037eef7f30379549a4
2021-10-25 08:20:10 +00:00
Pierre Barbier de Reuille
d156c87685 Restore the creation of the remote context in sync inflation.
This was mistakenly removed in Android S (in ag/13732454) and could
cause issues if the top-level layout parameters are defined using
resources defined in the AppWidget's package.

Also add some safeguard to avoid crashing if the AppWidgetProviderInfo
doesn't contain a ProviderInfo (which can happen if it's not created by
the system).

Fix: 201744899
Test: Existing CTS tests
Change-Id: Ibb4f2c26a6258ec2c68a7fd1fafe3e5fe3551109
2021-10-01 08:40:56 +00:00
Pierre Barbier de Reuille
ffd750b5fc Correct documentation of AppWidgetProviderInfo
All the dimensions are in pixel, not dp. The conversion from complex
value to pixel is done in AppWidgetProviderInfo#updateDimensions.

Fix: 199524613
Test: N/A
Change-Id: Ifdc90e7338ade8494d90e567fc95500b650c4ebb
2021-09-13 21:33:58 +00:00
Ryan Mitchell
a57b0e9c4e Revert "Revert "Apply overlay updates to widget provider info""
Bug: 15332156
Bug: 195649929
This reverts commit 471720cccf.

Change-Id: Ifa89ae43613add1137ddeca4cb40543a3a01d6a7
2021-08-09 13:15:12 -07:00
Patrick Baumann
e2c96ac3ad Merge "Revert "Apply overlay updates to widget provider info"" into sc-dev 2021-08-05 18:07:10 +00:00
Patrick Baumann
471720cccf Revert "Apply overlay updates to widget provider info"
This reverts commit 0bf76b6296.

Bug: 193866093
Fixes: 195267626
Reason for revert: b/195267626

Change-Id: I598a99f761e66d8bedbb0745d488ccc35fff9201
2021-08-04 20:05:36 +00:00
Ryan Mitchell
f56550282e Merge "Apply overlay updates to widget provider info" into sc-dev 2021-07-30 16:04:00 +00:00
Ryan Mitchell
0bf76b6296 Apply overlay updates to widget provider info
When Runtime Resource Overlays (RROs) are applied to an application,
the ApplicationInfo of the app in package manager is updated to have
overlay paths. Widgets create the context used to inflate their
remote views using a snapshot of the ApplicationInfo of the widget
provider. This snapshot is taken when the widget RemoteView is
initially created and sent to system server.

This change updates the snapshot of the widget provider ApplicationInfo
with the new overlay paths and notifies apps hosting widgets to
re-inflate their remote views in order to have RROs apply to widgets
correctly.

Bug: 193866093
Test: Repeatedly change wallpaper & style color to a "basic" color
      and go back to launcher to observe overlay correct color is
      applied
Change-Id: I0b9b8c0d32d83a52e9ea5bc8ba1635cf99e4b921
2021-07-29 16:02:54 +00:00
Pierre Barbier de Reuille
92a04f15eb Use the current padding instead of the default one during layout.
Bug: 191612352
Test: Manually, adding extra logs, checking with/without changed padding.
Change-Id: I7bc03602fe5e6e9085f0d187e6d2a11d2f15dcca
2021-07-01 14:01:58 +01:00
Ryan Mitchell
350c2669d6 Revert^3 "Deprecate Context#createApplicationContext"
This reverts commit cb5a80ea57.

Reason for revert: Was not the cause of the test failure

Fixes: 186622527
Test: atest FrameworksCoreTests:ContextTest
Change-Id: I705854f080200f0465d94a7754e710f05a3ec92c
2021-06-30 15:53:45 +00:00
Paul Hobbs
cb5a80ea57 Revert^2 "Deprecate Context#createApplicationContext"
Bug: 192242649

5a41b45a85

Change-Id: Idcebd68e0079e7e87de04ae25069b3a9ff72093c
2021-06-29 20:06:45 +00:00
Ryan Mitchell
5a41b45a85 Revert "Deprecate Context#createApplicationContext"
This reverts commit c54ebba25b.

Bug: 188059515
Test: atest FrameworksCoreTests:ContextTest
Change-Id: I986563142dac135281889e811e6e5219d728d5d1
2021-06-22 22:30:38 -07:00
Pierre Barbier de Reuille
78808a5951 Update the documentation of AppWidgetManager
AppWidgetManager#bindAppWidgetIdIfAllowed sends a broadcast when
successful, but this is currently not documented. The behavior was
introduced in 2014 by a change in the AppWidgetServiceImpl.

Bug: 189334092
Test: N/A (documentation only)
Change-Id: Iba83b89fd60c7f658a1fe911a260b666638fb020
2021-05-27 16:22:24 +01:00
TreeHugger Robot
ee438f960a Merge "Deprecate Context#createApplicationContext" into sc-dev 2021-05-19 15:35:09 +00:00
Ryan Mitchell
c54ebba25b Deprecate Context#createApplicationContext
If an application caches an ApplicationInfo and uses it to call
Context#createApplicationContext, the app will not get the most recent
version of the overlays for that application. To make things worse, the
LoadedApk stored in ActivityThread#mResourcePackages is updated using
the old ApplicationInfo causing further uses of the cached LoadedApk to
return outdated information.

Deprecate Context#createApplicationContext, convert all internal uses
to Context#createPackageContext(String packageName, ...) and log
whenever any one calls Context#createApplicationContext with an
outdated ApplicationInfo to detect debug issues in using old infos.

Bug: 188059515
Test: change wallpaper and observe widgets get reloaded with most
      recent overlays
Change-Id: I2aeefa8c0e66264859109975a54c4f73f76ad710
2021-05-18 09:07:58 -07:00
Pierre Barbier de Reuille
6bb5335193 Test color mapping equivalent in O(n)
Relies on the ordering in SparseIntArray, as it's documented as ordered.

Bug: 187852819
Test: Manual
Change-Id: I3942a7f3826c173d99544ac0b4f81266b4ca3cc1
2021-05-13 10:27:19 +01:00
Pierre Barbier de Reuille
6a3f83e786 Check colors actually change for App Widget
If new colors are set but do not change, do not re-inflate the App
Widget.

Bug: 187852819
Test: Added logs and added a widget, moved it to see
Change-Id: I672ee7984cab8966f79d839494ac8a7b91679102
2021-05-13 00:12:15 +01:00
Steven Ng
19b0627ae6 Merge "Print the full exception upon widgets inflation error" into sc-dev 2021-05-07 09:08:18 +00:00
Steven Ng
c7e22233dc Print the full exception upon widgets inflation error
Test: none
Bug: 184750539
Change-Id: If026cc09dc9f96f1443b7b6e73e0e4f219050183
2021-05-06 22:45:11 +01:00
Pierre Barbier de Reuille
6d82bd39e7 Merge "Save/restore view states when reapplying RemoteViews for color changes" into sc-dev 2021-05-06 18:54:54 +00:00
Stevie Kideckel
691ff96db6 Save/restore view states when reapplying RemoteViews for color changes
This ensures that adapters have their caches filles and other benefits
such as lists maintaining their scroll positions

Bug: 183503469
Test: validated with local app that service is not called on drag for
colors changing and that flicker is removed

Change-Id: I043d1d7a547b012f7a12eb555b35854a9bb7109b
2021-05-04 23:18:45 +01:00
Alina Zaidi
54c9d7e9cb Add null check in AppWidgetProvider#loadDescription before calling
CharSequence#toString()

Bug: 186789881
Test: Not needed for a null check.
Change-Id: I015ba5943ca3aa218048fe2d11ebd501b5ddab07
2021-05-04 19:07:36 +00:00
Cyrus Boadway
5fbb1a6f9d Add hidden setter for AppWidgetHost's InteractionHandler
This will allow Quickstep launchers, e.g. NexusLauncher, to
provide a custom interaction handler.

Bug: 169042867
Test: manual testing

Change-Id: Id70cb463e2671e32ea9f52f06487ac63fcf57e0d
2021-04-13 10:32:50 +00:00
Sunny Goyal
289411c5bf Updating AppWidgetProviderInfo API
Bug: 184537397
Test: Presubmit
Change-Id: I3e634b5bd761a566d6b08519ac58ffdbee2b1e59
2021-04-05 15:27:42 -07:00
Lucas Dupin
c1615dffe1 Merge "Update system palette APIs" into sc-dev 2021-03-22 16:57:17 +00:00
Lucas Dupin
6110d25881 Update system palette APIs
UX landed on a format where we have 2 neutral palettes, and 3 accent
palettes. It's the ideal format to play with elevation and hue rotation,
in order to have a more vibrant and less muddy UI.

Fixes: 181986389
Bug: 173553055
Test: atest SystemPalette
Test: atest ThemeOverlayControllerTest
Test: atest ThemeOverlayApplierTest
Test: atest DeviceDefaultThemeTest
Change-Id: I80d3f7d1cc92e97efcb40fe6dc9f09918321d273
2021-03-20 14:50:26 -07:00
Pierre Barbier de Reuille
96059b47a9 Correct recycling to take setViewId into account.
Views shouldn't be recycled if the view id is changed as the identity
of the view is then altered.

Second pass: this has been further tested by adding/removing AppWidgets
on a test phone.

Bug: 181985606
Test: atest CtsWidgetTestCases:RemoteViewsTest
Test: atest CtsWidgetTestCases:RemoteViewsRecyclingTest
Test: atest CtsInputMethodTestCases:android.view.inputmethod.cts.InputConnectionBlockingMethodTest
Change-Id: I8924c02f7f0223458f556a07a3dfdc96b4ce612e
2021-03-19 16:29:37 +00:00
Greg Kaiser
b96f77af78 Revert "Correct recycling to take setViewId into account."
This reverts commit 308a272289.

Bug: 183104573
Test: Install from Play Store with the screen off on wembley, and the device doesn't crash when the screen turns back on.

Change-Id: I289fcafc6685c4ede295e8d6916a54da9bac1ad5
2021-03-18 15:28:46 -07:00
Pierre Barbier de Reuille
308a272289 Correct recycling to take setViewId into account.
Views shouldn't be recycled if the view id is changed as the identity
of the view is then altered.

Bug: 181985606
Test: atest CtsWidgetTestCases:RemoteViewsTest
Test: atest CtsWidgetTestCases:RemoteViewsRecyclingTest
Change-Id: I68415087297312eb2c1985d272be2ac535507c2a
2021-03-17 11:20:36 +00:00
Yogisha Dixit
1dfe5cf462 Merge "Fix flag value for configuration_optional widget feature." into sc-dev 2021-03-12 17:51:10 +00:00
Pierre Barbier de Reuille
4554bcd1bc Correct invalidation of layout when new color resources are provided.
The mViewMode variable is only used if there is no RemoteViews object.
But we still want to update the colors in that case.

Bug: 179783721
Test: atest CtsWidgetTestCases:android.widget.cts.RemoteViewsThemeColorsTest
Change-Id: I078d21422a6300e7aaecb0baa2a49b9e14cae9e9
2021-03-09 22:13:23 +00:00
Pierre Barbier de Reuille
3e443e6b24 Correct API for new sizes in App Widgets.
This follow recommendations from the API council review.

Based on those recommendations: I updated the API and updated the
comments to make the function behavior clearer.

Bug: 181611658
Test: atest android.widget.cts.RemoteViewsSizeMapTest
Test: Local widget to check rendering
Change-Id: Ie9fcedbc7b18b83f6d1220f99240f264e53e3649
2021-03-04 23:27:08 +00:00
Yogisha Dixit
cb4c7c1286 Fix flag value for configuration_optional widget feature.
The flag value should be 4 and not 3 so that we can use bitwise
operations to determine the existence of a flag.

For example, we want to use the following to determine if a widget is
reconfigurable:
(providerInfo.widgetFeatures & WIDGET_FEATURE_RECONFIGURABLE) != 0
But if the value of WIDGET_FEATURE_CONFIGURATION_OPTIONAL is 3, the
above check would fail.

Test: atest FrameworksServicesTests:AppWidgetServiceImplTest, atest
CtsAppWidgetTestCases
Bug: 177977976

Change-Id: I15d4baae5e17acb9a0b936485a53f9b3359d65ca
2021-03-03 20:53:45 +00:00
Pierre Barbier de Reuille
4e14c35736 Merge "Framework implementation of go/widgets-dynamic-colors" into sc-dev 2021-02-24 20:16:40 +00:00
Alina Zaidi
bfefff4115 Merge "Adjust AppWidgetProviderInfo#getDescription to return CharSequence." into sc-dev 2021-02-24 20:01:39 +00:00
Pierre Barbier de Reuille
4219de7ded Framework implementation of go/widgets-dynamic-colors
Bug: 179783721
Test: atest CtsWidgetTestCases:android.widget.cts.RemoteViewsThemeColorsTest
Change-Id: I622e79ed8738dc862790191bf9fcf44b0af35c8e
2021-02-24 15:13:29 +00:00
Kholoud Mohamed
c3406718ef Merge "Expose setBindAppWidgetPermission as a testAPI" into sc-dev 2021-02-24 10:24:25 +00:00
Alina Zaidi
1c9092d127 Adjust AppWidgetProviderInfo#getDescription to return CharSequence.
Also add more developer docs.

Test: atest AppWidgetServiceImplTest#testLoadDescription passed
Bug: b/180015383
Change-Id: Ie6fff9d880ba4721bf6babcd51acaa8fc9bd3cd9
2021-02-19 15:14:41 +00:00
Stevie Kideckel
90362ddd27 Merge "Add checked change APIs to RemoteViews" into sc-dev 2021-02-19 09:48:25 +00:00
Stevie Kideckel
289da0b787 Add checked change APIs to RemoteViews
Bug: 179245670
Test: built sample app to use APIs with and without collections, atest
Change-Id: I5474bfb7dc15d559867063d1d8516b8ca2ef9755
2021-02-17 12:01:28 +00:00
TreeHugger Robot
b9806031ae Add new attributes for widget sizing controls.
Design doc: go/widget-sizing-api-dd

New attributes added:
* maxResizeWidth
* maxResizeHeight
* targetCellWidth
* targetCellHeight

Bug: 179807199
Test: atest FrameworksServicesTests:AppWidgetServiceImplTest
Change-Id: Icadc73da9bd010e42459735493f452cb892e5744
2021-02-17 10:55:01 +00:00
Pierre Barbier de Reuille
d7541b8990 Framework changes for go/widget-size-specification
Update the framework to:

1 - Allow creating RemoteViews with a mapping from size to layouts
2 - Use the closes sized layout in any given situation
3 - Allow the launher to specify the current size when inflating a
    remote views

Bug: 179025145
Test: atest android.widget.cts.RemoteViewsSizeMapTest
Change-Id: Icf98d01bd0cf8b48c47555a1af6acb498b46b1a4
2021-02-16 21:24:11 +00:00
kholoud mohamed
2836f984d0 Expose setBindAppWidgetPermission as a testAPI
This is needed to replace usage of the adb shell
command 'appwidget grantbind' in some cts tests with
TestAPIs.

Bug: 180328483
Test: N/A
Change-Id: Ie74149c2045e19261c77da2ffa757a803cc61d95
2021-02-15 17:33:55 +00:00
Steven Ng
cd5c9b0642 Add a layout attribute in widget metadata for widget preview
Test: atest FrameworksServicesTests:AppWidgetServiceImplTest. Newly
added test passed.

Bug: 179063291
Change-Id: I17cf97b580ac03d9688d82eeccd3a68e77287655
2021-02-08 14:09:06 +00:00
Sunny Goyal
7152080c07 Adding APIs to get manifest entries for Launcher activities and widgets
and getting resources for a particular config

This would allow fetching display infos for the activity in a particular
config independent of system config.

Bug: 156154533
Test: Included CTS
Change-Id: Ie245d685fb21444c10a88b4ca86dc7ff08e2b599
Merged-In: Ie245d685fb21444c10a88b4ca86dc7ff08e2b599
2021-02-01 17:35:23 +00:00
Alina Zaidi
016e50a980 Include an attribute for description of the widget in the attributes file for AppWidgetProviderInfo.
Test: Instrumentation test added- AppWidgetServiceImplTest_testLoadDescription

Bug: 178460757

Change-Id: Ic9b9cd8c592936bbe421183f8715ba5d8f770742
2021-01-26 17:04:00 +00:00
Steven Ng
d8d8acfd9f Merge "Add a new widget feature value, configuration_optional" 2021-01-26 11:05:07 +00:00
Jeff Sharkey
1ae7f40466 Merge "Update AppWidget owners" am: 8c9bf65b8b am: ea29396752 am: 0cfbc863f7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1556378

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I051e300cf34545ce632f64ef1dc7711f97c84599
2021-01-21 23:25:37 +00:00