Commit Graph

189 Commits

Author SHA1 Message Date
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
Samuel Fufa
ab848f9fb8 AppWidgetManager option documentation
Bug: 151157829
Test: n/a
Change-Id: Ia6b86eaf2cbc6543854b88ee112c687590d50c1f
2020-03-10 22:47:19 +00:00
Samuel Fufa
1acbf7763b Fix widget restore flow
After restore, the app should set OPTION_APPWIDGET_RESTORE_COMPLETED to
true on its widgets followed by calling updateAppWidget to update views.

Bug:63667276
Test: Manual
Change-Id: Idb6fc63b0f894fca9e0470aaf335240fc124e2e9
2020-02-24 19:07:59 +00:00
Artur Satayev
c895b1b450 Use new UnsupportedAppUsage annotation.
Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library.

Bug: 145132366
Test: m && diff unsupportedappusage_index.csv
Change-Id: I8789f8499d4dca08580672e9e45ed9a7026dd686
2019-12-18 16:37:37 +00:00
Samuel Fufa
59ef5e98f3 Setup OnAppWidgetRemoved on framework
Test: Manual
Bug:140140567
Change-Id: I3033b83ff8f55938b5cd898c7e30bb2259af9c5f
2019-09-10 17:34:23 -07:00
Jeff Sharkey
9e8f83db6d All Parcelable CREATOR fields are @NonNull.
If they were null, then the Parcelable would fail to work.

Bug: 126726802
Test: manual
Change-Id: I7929ffa2f20e5de1c8e68e8263cca99496e9d014
Exempt-From-Owner-Approval: Trivial API annotations
2019-02-28 23:29:04 -07:00
Sunny Goyal
40da899d4c Removing SDK check when getting default widget padding
This avoids packageManager call everytime a widget updates and
on swipe up

Test: Everything compiles
Change-Id: I58e8613b7a8c9d27fb9293e623ccb274edab82d3
2019-02-22 00:07:28 +00:00
Sunny Goyal
ae65598b66 Updating the comments as per API feedback
Bug: 122549181
Test: N/A
Change-Id: I46d6f98c7cd644cad79b1aad973621222657b113
2019-01-08 16:45:12 -08:00
Sunny Goyal
c12d31c3b5 Adding API to specify a dark text specific layout in app-widgets
Bug: 109954539
Test: atest CtsAppWidgetTestCases
Change-Id: I785931469888a09685c45949afcf2e3633233c60
2018-12-04 02:33:53 -08:00
Sunny Goyal
983e4065fb Starting the default activity when an app widget's
default/fallback view is clicked

Bug: 119142325
Test: Verfied on device
Change-Id: I5ac39b77cdd0a46f8c66dcec289cec78746e67cf
2018-11-09 13:24:39 -08:00
Sunny Goyal
43c970436d Adding shared element transitions support in AppWidgets
Bug: 113071278
Test: atest frameworks/base/core/tests/coretests/src/android/widget/RemoteViewsTest.java
Change-Id: I0d7698faa8d9e61913b55d34de8b7cfbb32863b1
2018-10-29 17:04:33 -07:00
Andreas Gampe
cf42e434d9 Merge "Framework: Remove a nonsensical substring(0)" am: 98627fa455
am: 67dffedd92

Change-Id: Ibdac1bdc69d8f02823343b0d39b690de51da6802
2018-09-11 10:34:11 -07:00
Andreas Gampe
214c76cd70 Framework: Remove a nonsensical substring(0)
String.substring(0) will return the same String instance. There is
also no reason to make a copy.

Found by errorprone.

Bug: 114129741
Test: m
Change-Id: Ic089f04efc3c73f70aa15a132d62ac665c8b8f4c
2018-09-05 16:58:45 -07:00
Christopher Tate
af1d1b5504 Merge "Send widget registration broadcasts before BOOT_COMPLETE" into pi-dev
am: d412914643

Change-Id: I0d5d57c75cbfce35208607a6a8d1d51607a9b40a
2018-08-20 16:55:41 -07:00
Christopher Tate
2ec961dad3 Send widget registration broadcasts before BOOT_COMPLETE
Widget presence in the home app is important for usability, but it
depends on a broadcast-based handshake at boot time.  This handshake
occurring after the BOOT_COMPLETED broadcast was initiated means
that in practice widgets may not become available for literal
minutes following unlock, as it can take this long for the
boot-complete broadcast to clear and let the systen proceed with
dispatch of the widget handshakes.

We address this by hoisting the widget setup broadcast to occur
just *before* the boot-completed broadcast, rather than as part
of general listener reaction to the global "this user has been
unlocked" notification.

Bug: 76154638
Test: manual (note broadcast ordering following boot)
Change-Id: I7c1a9f7a84fee71f71d2dcd52362a29c2436b01d
Merged-In: Ibd97268f995ec673f21d8f5df257041cf61a058d
2018-08-14 17:03:41 -07:00
Mathew Inwood
b5962ae431 Add @UnsupportedAppUsage annotations
For packages:
  android.appwidget

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: I738f99248aaabe0ef29533e339ae7c5721384d52
Merged-In: Idbddc50320e7df92e0f260c1e309e5390b502d28
2018-08-09 15:15:57 +01:00
Rajeev Kumar
c1778c6dad Add a condition in AppWidgetHost to honor config_enableAppWidgetService.
Bug: 74039047
Test: make cts-verifier -j32
Change-Id: Iaca4e043443efeb695ebfd57c605e5cc1516a49a
(cherry picked from commit 3c9e79ea78)
2018-04-05 22:24:14 +00:00
Sunny Goyal
0b417b9b04 Updating javadoc for updateAppWidgetProviderInfo API
Bug: 74838920
Test: N/A
Change-Id: I531676900fbf8d60ef7050c86a570112ff1ad476
2018-03-20 10:04:28 -07:00
Sunny Goyal
e7712ad4dd Updating java doc for requestPinAppWidget
Bug: 74435565
Test: N/A
Change-Id: Iae290e411929c817721f481301f8fb057ebe7b2c
2018-03-17 21:24:35 +00:00
Sunny Goyal
363fa2d5fb Adding IntDef annotations to some flag based properties
Bug: 74408961
Test: N/A
Change-Id: I4320c5e265b52338eb2f4b2e5ea80ea05b9ca28f
2018-03-15 12:01:33 -07:00
Jeff Sharkey
98af2e4fec Add RequiresFeature annotation.
Certain APIs require that a device have a specific feature to operate
correctly, so start annotating them.

Test: builds, boots
Bug: 72284763
Change-Id: Ie2f30284bdfdb6acc4067f434eba3b5433837606
Exempt-From-Owner-Approval: simple annotations
2018-02-16 20:45:22 +00:00
Jeff Sharkey
ad357d1839 Pass in the user defined by Context.
The majority of Manager-style classes already use Context.getUserId()
when making calls into the OS, so clean up the remaining callers to
unify behind this strategy.

This gives @SystemApi developers a nice clean interface to interact
across user boundaries, instead of manually adding "AsUser" or
"ForUser" method variants, which would quickly become unsustainable.

Test: builds, boots
Bug: 72863821
Exempt-From-Owner-Approval: trivial changes
Change-Id: Ib772ec4438e57a2ad4950821b9432f9842998451
2018-02-03 02:11:45 +00:00
Sunny Goyal
9080cf2781 Adding support for overriding app-awidget properties at runtime
This would allow apps to customize the behaviour/appearance of a widget based
on the app state

Test: atest CtsAppWidgetTestCases:UpdateProviderInfoTest
Bug: 63931362
Change-Id: I1eef705975c2310af7311b74acc23c089fb6d1ec
2018-01-08 11:39:22 -08:00
Svet Ganov
240aed987c Prevent reporting fake package name - framework
Test: added AccessibilityEndToEndTest#testPackageNameCannotBeFaked
      cts-tradefed run cts -m CtsAccessibilityServiceTestCases
      cts-tradefed run cts -m CtsAccessibilityTestCases

bug:69981755

Change-Id: I13304efbee10d1affa087e9c8bc4ec237643283e
2017-12-09 09:04:24 -08:00
Sunny Goyal
f5e0fd78fd Adding widgetFeatures so that a provider can indicate a set of
supported features

Bug: 63931362
Bug: 36537581
Test: Added CTS for new APIs
Change-Id: I2bd3278bfdf40d88fc8e6f72bfbc7505c64accff
2017-12-05 16:23:46 -08:00
Sunny Goyal
7241abd584 Removing some system binder calls in AppWidgetHostView
> Using the AppWidgetProviderInfo for applicationInfo instead of getting
  it from packageNamager
> Sending ProviderInfo update when the package is suspended/unsuspended so
  that the provider info on client side is always up-to-date

Bug: 67865199
Test: Manually tested on device
Change-Id: Id44facc30b4c3cc01e155eba9feeb541997fc816
2017-10-25 10:25:45 -07:00
Sunny Goyal
e1273ebbb7 Binding to the RemoteViewsService directly from the host
The host passes an IServiceConnection to the AppWidgetManager which
is used to bind to the RemoteViewsService. This allows the host to
recieve the connection callbacks directly instead of proxying it via
the AppWidgetManager. The host is also responsible for unbinding to
the service.

Bug: 26481160
Test: adb shell \
  am instrument -w -e class android.widget.RemoteViewsAdapterTest \
  com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner

Change-Id: Iac400095a319c3a43714c82fda7516be1ccc68af
2017-10-20 16:43:23 -07:00
Sunny Goyal
aa86f2b9c0 Using bundle instead of a custom class for SaveInstanceState
Also removing the crossfade effect option which has been disabled since the start

Test: N/A
Change-Id: I0c5dcf0d81d8a0a60f4cf202b63a3b9aafcee98e
2017-09-21 02:46:22 +00:00
Sunny Goyal
0ec83525cf Suppressing spammy logs when widget inflation fails
Test: N/A
Bug: 63061304
Change-Id: I6696856efb3999e2ad2a947604411c163f9d11c1
2017-08-31 20:12:36 +00:00
Elijah Taylor
6022aa57d3 Fix crashes in AppWidgetHost when app_widgets is not supported
Even though an app is supposed to declare android.software.app_widgets
when relying on the widgets API, some apps still use this API without
declaring the feature.  Previously AppWidgetHost relied on having an
AppWidgetService available, without checking for feature development
before dereferencing the service.

This stubs out the AppWidgetHost interface when the app_widgets feature
is not available.

Bug: 28847209
Test: run nova launcher, observe no crash

Change-Id: Idaf46de990fffa6c6a03562f8e097c0a6a320c8a
(cherry picked from commit 0536802defc7df6edb22e076b1147d0d919da0f8)
2017-06-23 09:54:09 -07:00
Jeff Sharkey
d86b8fea43 Annotate @SystemApi with required permissions.
Most @SystemApi methods should be protected with system (or higher)
permissions, so annotate common methods with @RequiresPermission to
make automatic verification easier.

Verification is really only relevant when calling into system
services (where permissions checking can happen on the other side of
a Binder call), so annotate managers with the new @SystemService
annotation, which is now automatically documented.

This is purely a docs change; no logic changes are being made.

Test: make -j32 update-api && make -j32 offline-sdk-docs
Bug: 62263906
Change-Id: I2554227202d84465676aa4ab0dd336b5c45fc651
2017-06-05 13:27:11 -06:00
Adam Lesinski
9553fb3240 Add ResourceId validation helper method
An invalid, 'null' resource ID is defined as 0. Apps often use -1.

Add a helper method that makes checking valid IDs easy and more
centralized.

Eventually make it public API.

Bug: 38393777
Test: manual
Change-Id: I969ec4a45e86bdab3d7f57d357d475b77c7f8a78
2017-05-24 15:39:23 -07:00
Adam Lesinski
360182156a Valid resource IDs may be negative
Package IDs greater than 0x7f are interpreted as negative
numbers in Java's signed integer. The proper check for existence of
a resource ID is that it is not 0.

Bug: 37498913
Test: none
Change-Id: I446fb6abb514bf7cf2d0dcbfbd81dd5718cd2cb4
2017-04-28 12:48:36 -07:00
Tony Wickham
d3427ae78f Address API Review comments
- throw NullPointerException if the package name is null; there’s
  already a method with the specified null behavior.
- Return value of this method should be @NonNull - return an empty
  list. Document this.

Test: Unit test on AppWidgetServiceImplTest
$ runtest --path=services/tests/servicestests/src/com/android/server/appwidget/AppWidgetServiceImplTest.java

Bug: 37544056
Change-Id: I047a8e7c4e519ef7c5deddaca0d1ad931dc91343
2017-04-24 15:27:36 -07:00
TreeHugger Robot
82629345c8 Merge "Renaming setAsyncExecutor to setExecutor" into oc-dev 2017-04-21 00:31:11 +00:00
Sunny Goyal
0ddf6aa0a4 Renaming setAsyncExecutor to setExecutor
Bug: 37534990
Test: Tests updated
Change-Id: I9ea467d05b4ac4d96c23d53750727096a511686d
2017-04-20 15:27:08 -07:00
Sunny Goyal
edfdb67ee9 Adding API AppWidgetHost.getAppWidgetIds() to get active widgets of the host
Bug: 37435178
Test: Added CTS
Change-Id: I621247e0887b3931bfb92431d94f97507a303e5c
2017-04-18 12:48:49 -07:00
Makoto Onuki
7c7fbf6f45 getApplicationInfo() should throw NameNotFoundException
... instead of returning null.

Bug: 37324177

Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest1 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest2 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest3 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest4 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest5 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest6 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest7 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest8 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest9 -w com.android.frameworks.servicestests
Test: adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest10 -w com.android.frameworks.servicestests

Change-Id: I7f9f3729ee0eef6b342e4711379e02516559472c
2017-04-14 23:24:35 +00:00
Tony Wickham
a41da04b2d Add AppWidgetManager#getInstalledProvidersForPackage()
This allows more fine-grained control than getting all installed
providers for a user, when you might only want to check for a particular
package. For instance, Launcher can use this API to surface widgets per
app without having to ask for all the widgets.

Test: Unit test on AppWidgetServiceImplTest
$ runtest --path=services/tests/servicestests/src/com/android/server/appwidget/AppWidgetServiceImplTest.java

Bug: 34940468
Change-Id: I182bf1c012d31182024422fc4a63f57f151c3ee5
2017-04-04 14:13:01 -07:00
Jeff Sharkey
32ee8eefd7 Create new BroadcastBehavior annotation.
This will be used to help document the expected behavior of various
broadcast actions defined by the OS.

Also add logic to PackageParser that will then yell at developers
whose manifests are making bad assumptions about which broadcasts
they'll receive.

Test: builds, boots
Bug: 35925551
Change-Id: I059c2bf8aa3ce53d9ff18dcc263db7620cd14bd6
2017-03-08 20:19:31 -07:00
Sunny Goyal
4ad6b57700 Adding support for passing arbitrary extras when requesting to pin a widget.
Also defining an extra constant for widget preview which can be used by
developers to provide a snapshot of the widget with the pin request

Bug: 35811129
Test: All exisiting tests passing
 for f in 1 2 3 4 5 6 7 8 9 10; do \
   adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest$f \
      -w com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner; \
        done;

 adb shell am instrument -e class com.android.server.appwidget.AppWidgetServiceImplTest \
   -w com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Change-Id: Id854bd28468a5bf0416ff1a1b19c44d850016f32
2017-03-01 16:58:21 -08:00
Sunny Goyal
7f7372ae2a Adding AppWidgetManager.isRequestPinAppWidgetSupported
Launchers can choose to implement support pin shortcut or pin appwidget
or both by specifying different actions in the intent filter

Test: Automated tests and CTS
Bug: 34174006
Change-Id: I4456dbb943cfba11d465556f0732f0ed629ab3ba
2017-01-24 17:26:14 -08:00
Sunny Goyal
970d4b4626 Fixing dimensions for AppWidgetProviderInfo not getting updated properly
for PinItemRequest

Test: Manually tested on device
Change-Id: I7bbf7e93e052ef25c2a4a98ff0795ef500f68cc0
2017-01-19 15:12:47 -08:00
Makoto Onuki
a59e4503a1 Merge "Update the javadoc on requestPinShortcut() about multiple..." 2017-01-11 18:13:04 +00:00
Sunny Goyal
256dac14e2 Merge "Adding API to allow async inflaiton of AppWidget" 2017-01-11 01:19:33 +00:00
Makoto Onuki
db3b10a95e Update the javadoc on requestPinShortcut() about multiple...
requests in a row form the same app.

Bug 34175917
Test: Javadoc change only; presubmit test.

Change-Id: Ibf33010dbd9080c557112e15efcadd30d95b121f
2017-01-10 15:43:20 -08:00
Sunny Goyal
f960248951 Adding API to allow async inflaiton of AppWidget
Test: Manual and unit tests
adb shell am instrument -e class android.widget.AppWidgetHostViewTest -w com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner

Bug: 22839968
Change-Id: Id9cb56619653f43b9f755c881f5d0936375f9c87
2017-01-09 10:52:10 -08:00
Sunny Goyal
87a563e070 AppWidgetManager: direct add widget support.
Test: Manual test and all the unit tests:
adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest1 -w com.android.frameworks.servicestests
... to test9
adb shell am instrument -e class com.android.server.appwidget.AppWidgetServiceImplTest -w com.android.frameworks.servicestests

Bug 32404406
Change-Id: Icd6d4cbd25d9cdf4508da725d95d6401cc3a46a7
2017-01-03 13:28:56 -08:00