Commit Graph

257 Commits

Author SHA1 Message Date
Sunny Goyal
45bdf7a065 Merge "Wrapping various apply parameters into a separate class" into tm-qpr-dev am: b4b3a8bdeb am: b4b25e4f9e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19531583

Change-Id: Ic6e6eda7ce96c0df0da665af0e32f75610981d08
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-08 16:56:53 +00:00
Sunny Goyal
b4b25e4f9e Merge "Wrapping various apply parameters into a separate class" into tm-qpr-dev am: b4b3a8bdeb
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19531583

Change-Id: I1c24d06db68910c8a99028eca57b233c7e6c5b0d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-08 16:39:36 +00:00
Sunny Goyal
6224d07127 Wrapping various apply parameters into a separate class
> This would allow us to easily extect the options
> Also passing the executor for async inflation. This will allow
  containing adapters to also be async if the parent View is using
  async inflation

Bug: 202766048
Test: Presubmit
Change-Id: I60a9b5db5f9b5f8d6e56521ee00de4be30decce6
2022-08-05 14:53:00 -07:00
Roman Kalukiewicz
94444f9720 Update javadocs for the AppWidget
Change-Id: Idc77ab02df172135c791dc96aba16726a497679c
2022-08-02 17:22:08 +00:00
TreeHugger Robot
9aeee58021 Merge "Fix a security issue in app widget service." into tm-qpr-dev am: 32871f6203 am: 72adc95014
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19294513

Change-Id: Ida5c523591f495d9ce4d0276c41de38b1549abbd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-15 02:31:58 +00:00
TreeHugger Robot
72adc95014 Merge "Fix a security issue in app widget service." into tm-qpr-dev am: 32871f6203
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19294513

Change-Id: I8fdb85ed6324be18de37ac860f2efa558955977a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-15 02:13:34 +00:00
Pinyao Ting
263d7d0ba8 Fix a security issue in app widget service.
Bug: 234013191
Test: atest RemoteViewsAdapterTest
Change-Id: Icd2eccb7a90124aca18a3dd463c3f79e3a595c20
2022-07-14 13:08:02 -07:00
Sihua Ma
1ae08fe75e Combining widget broadcasts
Combining broadcasts WIDGET_ENABLED and WIDGET_UPDATE into
WIDGET_ENABLE_AND_UPDATE to reduce response time at boot time

Test: Manually verified that some app widgets would function properly
Fix: 221890505
Change-Id: I6aff0f00464ec8628d2258d0d84dcd3c82258d57
2022-05-26 22:15:21 +00:00
TreeHugger Robot
eeb2a5dad9 Merge "Add API in AppWidgetServiceImpl" 2022-05-20 22:00:36 +00:00
Sihua Ma
0b51675e56 Add API in AppWidgetServiceImpl
A new function is created to notify the service of inheritance
information of the widget provider.

Test: N/A
Bug: 221890505
Change-Id: I5f43f8d6ecd66b54869bef58898b1d3809b43d9e
2022-05-20 19:56:59 +00:00
Pinyao Ting
12adb658a0 Update OWNERS for appwidgets
Test: manual
Change-Id: I2bb2ddc4bd94e9e80d606e5141f336550eab8c88
2022-05-17 22:59:24 +00:00
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