Commit Graph

176 Commits

Author SHA1 Message Date
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
Sunny Goyal
5c022639d7 Adding support for async view loading in RemoteViewsAdapter
> When loadingView is no available, the FirstView is always
loaded on the background thread
> AppWidgetHostView only inflates on the background thread, if
the view has any costly operations

Test: TBD

Change-Id: I701caee7e4e6ba5972d0cf478cb57f8ec950da54
2016-09-29 16:59:02 -07:00
Sunny Goyal
6f84a27a75 Merge "Maintaining diff for all widget operations instead of just the Views update" into nyc-mr1-dev 2016-05-25 20:45:44 +00:00
Kenny Guy
af6ef8f6f9 Set accessibility string for suspended widgets.
Update the content description to mention the
widget is suspended.
Mark the remote views as not significant for
accessibility.

Bug: 28909714
Change-Id: I8804d41e520e2b4af7ade0fa8820ee7b2488bde5
2016-05-23 19:35:59 +01:00
Sunny Goyal
6d1b41d477 Maintaining diff for all widget operations instead of just the Views update
When the widget starts lisnening again, it receives all the pending updates
until that point (restricted to the requested widgetIds). When startListening
is called for the first time, the widgetIds is empty and it does not get
any updated. Further calls to startlisting will give the missed updates
for the bound widgets

Bug: 23892701
Change-Id: I3aa06d3e33a0861c19cfd5ced567d5bb3b93d906
2016-05-16 17:23:00 -07:00
Trevor Johns
682c24e228 Resolve merge conflicts of a5060ee to nyc-dev
This undoes the automerger skip which occured in
commit e740c84dc3 and
replays it as a standard (NOT -s ours) merge.

Change-Id: If5a47be26f73d6a0735c425cd66310a3e2a89086
2016-04-19 02:03:59 -07:00
Sunny Goyal
2857f1c783 Changing startListening to only fetch views which are bound
Also associating a lastUpdateTime with every widget. This allows
the host to query the widgets which were updated only after
the last stopListening call.

Change-Id: If9375cf2d8caa0ccca14b6649821d87ada1f3a84
2016-04-04 14:45:14 -07:00
Jeff Sharkey
f8880561e6 When system server goes down, crash apps more.
Similar to first patch, but now using new "rethrowFromSystemServer()"
method which internally translates DeadObjectException into
DeadSystemException.  New logic over in Log.printlns() now
suppresses the DeadSystemException stack traces, since they're
misleading and just added pressure to the precious log buffer space.

Add some extra RuntimeInit checks to suppress logging-about-logging
when the system server is dead.

Bug: 27364859
Change-Id: I05316b3e8e42416b30a56a76c09cd3113a018123
2016-02-27 17:17:01 -07:00
Sunny Goyal
a086f0436a Using AppWidgetHostView in RemoteViewsAdapter instead of managing the RemoteViews inflation itself
Change-Id: If6dd8a778096a07c58b543efe892bbffbe24098f
(cherry picked from commit 89699a2811)
2016-02-17 18:08:46 +00:00
Sunny Goyal
40dedd5a97 Merge "Added support for async inflation of RemoteViews" 2016-02-03 19:31:09 +00:00
Hyunyoung Song
4d1bf09339 Runtime exception on AppWidgetHostView should not cause crash to the hosting process.
b/26797293

Change-Id: I7e1efad7d5314141d21440bf8915c101e35c2adf
2016-02-01 13:51:39 -08:00
Sunny Goyal
dd292f4fab Added support for async inflation of RemoteViews
When enabled, the View inflation as well as some of the drawable
loading is done on the background thread.
It also assumes that all the views support inflation on the
background thread, which is true for the default views
supported by the platform

For ViewGroup opetations, it maintains a virtual view tree which
is used for findViewById. The final operations are applied on
the UI thread in the end.

Change-Id: Ib3ce55182ec04a344f2b2513981ee03afc8fa2e8
2016-01-11 15:15:42 -08:00
Hyunyoung Song
ccf6c68147 AppWidgetServiceImpl should use ParceledListSlice as return object
b/19904873

> Reason: to prevent TransactionTooLargeException from occuring when
binder transaction size goes over the limit.

Change-Id: I054cb161d235234f3ccdaadd70314163e690b0db
2015-06-17 15:23:31 -07:00
Amith Yamasani
e4a8da8ea2 Exclude bound app widgets from idle app list
Track package names of bound app widgets and use the list when
querying for idle apps.

Bug: 20066058
Change-Id: If8039397a061ef04bb13aa38d57cd7f0221f5fc7
2015-05-01 11:17:27 -07:00