Commit Graph

236 Commits

Author SHA1 Message Date
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
Sunny Goyal
ce8c2017c1 Update AppWidget owners
Change-Id: I89d2fa5339a37c64e76698ed1aa3825d27f88097
Test: manual
2021-01-21 21:56:08 +00:00
Steven Ng
a401dc515c Add a new widget feature value, configuration_optional
If configuration_optional is present, the widget provides a default
configuration. The host may decide not to launch the provided
configuration activity.

Design doc: go/deferrable-widget-config

Test: Successfully built blueline-userdebug. Since this CL only adds
a new value for an existing field, no unit test will be added at this
point. Once we introduce unit tests for widget configurations xml, we
will add related unit tests.

Bug: 177977976
Change-Id: I507cba0b9b8900f9b9616d76c48eb0ed9c50ed72
2021-01-20 21:10:44 +00:00
Jeff Sharkey
a2c132d9c6 Hand-migration to TypedXml interface.
Previous changes have applied mechanical refactorings, but this change
hand-migrates the remaining logic which was too complex to identify.

This change should have no behavior change; famous last words.

Bug: 171832118
Test: manual
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: I85cd830eb6bfde18fca6e73ee7adfdc385a890de
2020-12-02 13:55:35 -07:00
Mathew Inwood
5d123b6775 Add maxTargetSdk restriction to unused APIs.
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.

Bug: 170729553
Test: Treehugger
Merged-In: I626caf7c1fe46c5ab1f39c2895b42a34319f771a
Change-Id: I54e5ecd11e76ca1de3c5893e3a98b0108e735413
2020-11-04 09:45:53 +00:00
Mathew Inwood
8e742f928e Add maxTargetSdk restriction to unused APIs.
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.

This is a resubmit of ag/12929664 with some APIs excluded that caused
test failures; see bugs 171886397, 171888296, 171864568.

APIs excluded:
Landroid/bluetooth/le/ScanRecord;->parseFromBytes([B)Landroid/bluetooth/le/ScanRecord;
Landroid/os/Process;->myPpid()I
Landroid/os/SharedMemory;->getFd()I
Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I

Bug: 170729553
Test: Treehugger
Change-Id: I8285daa8530260251ecad6f3f38f98e263629ca7
2020-10-29 11:51:12 +00:00
Hongwei Wang
050275cd83 Revert "Add maxTargetSdk restriction to unused APIs."
This reverts commit 72f07d6a8a.

Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testAppZygotePreload&testClass=android.app.cts.ServiceTest&atpConfigName=suite%2Ftest-mapping-presubmit-retry_cloud-tf&testModule=CtsAppTestCases&fkbb=6936597&lkbb=6936969&lkgb=6936551&testResults=true&branch=git_master&target=cf_x86_phone-userdebug>, bug b/171886397

Bug: 171886397
Change-Id: Ibe0f0430a3451477c1ee8ef56a596e91ea1e7672
2020-10-28 20:16:22 +00:00
Mathew Inwood
72f07d6a8a Add maxTargetSdk restriction to unused APIs.
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.

Bug: 170729553
Test: Treehugger
Change-Id: I4c8fd0006f950de9955242e93968fb0996ceb372
2020-10-27 15:46:07 +00:00
Pinyao Ting
5cb48cbc0d fix RuntimeException when inflating default layout for AdapterView-based widgets
Bug: 151901506
Test: manual
Change-Id: I71068b7d13783f658c02cc76ec50f40319e68160
2020-05-18 17:06:56 -07:00
Hui Yu
4803268229 Move noteAppWidgetTapped call into AppWidgetHostView.
RemoteViews is public API used out of scope of widget. The correct place
to call noteAppWidgetTapped is in AppWidgetHostView.

Fix: 153676411
Test: manual test, tap a widget, "adb shell dumpsys usagestats | grep
USER_INTERACTION" to oberserve USER_INTERACTION event sent to UsageStas, "adb shell dumpsys appops | grep appWidgetVisible" to observer appWidgetVisible flag.

Change-Id: Ic473211b91fd952dbb81b09b1e1568d6f69a0dd8
2020-04-15 22:06:12 -07:00
Hui Yu
3dc45fbc57 Update AppOps & UsageStats when app widget tapped.
When the app widget on the launcher is tapped on:
1. Update AppOps. AppOps treats the underlying app as foreground so the app can get while-in-use
permission.
2. Report a USER_INTERACTION event to UsageStats so UsageStats can
update mLastTimeUsed and mLastTimeVisible of this package.

Bug: 149043079
Test: manual test, tapped on a widget.
Change-Id: Ic8c91190881cf5dcf89f0f72cfd410b0c2e86bf6
2020-03-21 08:36:54 -07:00