Commit Graph

166 Commits

Author SHA1 Message Date
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
John Spurlock
08c7116ab9 Remove unused imports in frameworks/base.
Change-Id: I031443de83f93eb57a98863001826671b18f3b17
2015-02-28 14:47:49 -05:00
Alan Viverette
a54956a0bc Fix accessibility delegation
Ensures that delegate code is run last. Previously, calling the super
method from an accessibility delegate set on a widget would only run
code in the widget's parent. Next, the delegate code would run. Finally,
the widget's code would run. As a result, the widget code would override
any data supplied by the delegate.

By moving all overridden code to internal methods, we ensure that the
call chain for super includes the widget's parent code followed by the
widget's code. The delegate code will always run last.

BUG: 17641433
Change-Id: Ib9d403156c1fc4fb04f65f3c126d1277a44b3740
2015-01-07 16:05:02 -08:00
Svetoslav
7643f7e399 Avoid non-static innner classes that are passed over via IPC.
Change-Id: Ic14565c135b1f2ba50fa57462738b8dbc0e73301
2014-12-18 02:04:46 +00:00
Winson Chung
7a96f3c917 Removing context ref from AppWidgetHost. (Bug 18769791)
Change-Id: Ieec1314ece219c178c140e572b031c94e83b8a93
2014-12-17 11:07:24 -08:00
Winson Chung
ee0b12161a Generalizing Recents widget category to Search box. (Bug 17334589)
Change-Id: Id62398255799844cc89affcb4bafc86b6479dad0
2014-09-04 17:13:17 +02:00
Svet Ganov
5771ad7bc7 RemoteViews service not unbound.
We are checking whether an app can access an app widget
based on the calling uid and the package name. The package
is mostly to make sure that hosts in different apps do
not accidentally interfere whereas the security is enforced
by the uid.

When remote views adapter binds and unbinds to a remote
views serivce it was passing the package of the context we
create to load resources for the widget instead the package
of the host. Now it is passing the host package and also
we are checking if the caller of bind remove serivce API
is in uid that has the host package - this makes it
consistent with elsewhere.

bug:17226052

Change-Id: I2b0b6669e3dc027037b7481c2871cedabd642433
2014-08-24 20:02:47 -07:00
Sunny Goyal
0308d9a860 Fixing wrong tag usage
Change-Id: I4cb0084a89cc079383d666ad1c5711d96ea81ebe
2014-08-15 17:39:54 -07:00
Sunny Goyal
092e196274 Returning null when preview image is not available for AppWidgetProviderInfo
The default application icon generally has a different aspect ratio that a
preview image, and cannot transparently be  used in place of the image.
Returning null will allow the apps to handle the case as they see fit.

Change-Id: Ie6e8e16dd7b4e58b222187a81c62d27eccab45a9
2014-08-15 13:02:59 -07:00
Svetoslav
8e1d299da2 Polish the new cross-profile app widget APIs
bug:14991269

Change-Id: I5996f8c69a3d151ff1ecd8f19403dd606f588150
2014-08-08 20:35:59 +00:00
Svetoslav
c71c42fdb2 Polish of the app widgets cross-profiles feature.
1. Added API for badging an arbitrary drawable at a given location.

2. Updated the icon and previewImage deprecation as they are no longer
   returning a badged drawable. The methods to load the icon and the
   preview are now just making it easier for a developer to get the
   drawables.

3. Fixed a bug in AppWidgetServiceImpl leading to a crash when a user
   is removed.

4. Fixed a bug in AppWidgetHost which was unnecessarily caching its
   package name and having code paths where the cached value was not
   populated when calling into the system.

bug:14991269

Change-Id: I50d011a6597d88814715d5ec04ee67815e8ce0bd
2014-08-07 00:12:27 +00:00