Commit Graph

155 Commits

Author SHA1 Message Date
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
Svetoslav
976e8bd201 Allow adding widgets from user profiles.
The goal of this change is to enable support for appwidget from
user profiles to the user main profile. A user profile is a user
which is associated as a child of the main user profile. For example,
a user may have a personal (parent) and corporate (child) profile.
The device policy should be able to control whether adding a widget
from a child profile and given packages is allowed. This change
assumes that all packages from managed profiles are white listed.
Another change will add the device policy changes.

Change-Id: I267260b55d74c48b112a29979a9f59eef7a8194e
2014-08-05 20:57:20 +00:00
Christopher Tate
c04e9aa916 Widget restore documentation tweaks
- Fix broken Javadoc @see directives
- Linkify AppWidgetProvider in the documentation for the new
  ACTION_APPWIDGET_RESTORED broadcast
- Minor content edits

Bug 15022842

Change-Id: Ia7d4ad5be476c260492e1be5d83e21f6943a6847
2014-05-28 17:56:53 -07:00
Winson Chung
da5b84c8d3 Exposing the API to support widgets in Recents.
Change-Id: I2d53f226dbc328f0dbda7006eac647c6468c6b36
2014-05-05 14:33:44 -07:00
Winson Chung
f7bca430d9 Adding ability to load a search widget into Recents.
Change-Id: Ie17d9b9a47c979774b39a37e87f75d9dadc79ad9
2014-05-02 18:45:40 -07:00
Christopher Tate
adfe8b86e9 App widget backup/restore infrastructure
Backup/restore now supports app widgets.

An application involved with app widgets, either hosting or publishing,
now has associated data in its backup dataset related to the state of
widget instantiation on the ancestral device.  That data is processed
by the OS during restore so that the matching widget instances can be
"automatically" regenerated.

To take advantage of this facility, widget-using apps need to do two
things:  first, implement a backup agent and store whatever widget
state they need to properly deal with them post-restore (e.g. the
widget instance size & location, for a host); and second, implement
handlers for new AppWidgetManager broadcasts that describe how to
translate ancestral-dataset widget id numbers to the post-restore
world.  Note that a host or provider doesn't technically need to
store *any* data on its own via its agent; it just needs to opt in
to the backup/restore process by publishing an agent.  The OS will
then store a small amount of data on behalf of each widget-savvy
app within the backup dataset, and act on that data at restore time.

The broadcasts are AppWidgetManager.ACTION_APPWIDGET_RESTORED and
ACTION_APPWIDGET_HOST_RESTORED, and have three associated extras:

    EXTRA_APPWIDGET_OLD_IDS
    EXTRA_APPWIDGET_IDS
    EXTRA_HOST_ID [for the host-side broadcast]

The first two are same-sized arrays of integer widget IDs.  The
_OLD_IDS values are the widget IDs as known to the ancestral device.
The _IDS array holds the corresponding widget IDs in the new post-
restore environment.  The app should simply update the stored
widget IDs in its bookkeeping to the new values, and things are
off and running.  The HOST_ID extra, as one might expect, is the
app-defined host ID value of the particular host instance which
has just been restored.

The broadcasts are sent following the conclusion of the overall
restore pass.  This is because the restore might have occurred in a
tightly restricted lifecycle environment without content providers
or the package's custom Application class.  The _RESTORED broadcast,
however, is always delivered into a normal application environment,
so that the app can use its content provider etc as expected.

*All* widget instances that were processed over the course of the
system restore are indicated in the _RESTORED broadcast, even if
the backing provider or host is not yet installed.  The widget
participant is responsible for understanding that these are
promises that might be fulfilled later rather than necessarily
reflecting the immediate presentable widget state.  (Remember
that following a cloud restore, apps may be installed piecemeal
over a lengthy period of time.)  Telling the hosts up front
about all intended widget instances allows them to show placeholder
UI or similarly useful information rather than surprising the user
with piecemeal unexpected appearances.

The AppWidgetProvider helper class has been updated to add a new
callback, onRestored(...), invoked when the _RESTORED broadcast
is received.  The call to onRestored() is immediately followed by
an invocation of onUpdate() for the affected widgets because
they will need to have their RemoteViews regenerated under the
new ID values.

Bug 10622506
Bug 10707117

Change-Id: Ie0007cdf809600b880d91989c00c3c3b8a4f988b
2014-03-20 12:30:51 -07:00
John Spurlock
8a985d24ce Tabs -> spaces in frameworks/base.
Change-Id: I5a84e8e93ac99b5ed0212b37bf66efa5e53864be
2014-02-25 09:49:29 -05:00
John Spurlock
6090995951 Remove unused imports from frameworks/base.
Change-Id: Ia1f99bd2c1105b0b0f70aa614f1f4a67b2840906
2013-11-20 11:31:47 -05:00
Winson Chung
5dd75a35ee am 18748035: am 379517b0: Merge "Fixing issue where AppWidgetHost.onProvidersChanged() was not being called. (Bug 9270309)" into jb-mr2-dev
* commit '18748035bbced3b6246b802ab07ee58859a29b0c':
  Fixing issue where AppWidgetHost.onProvidersChanged() was not being called. (Bug 9270309)
2013-06-05 11:50:47 -07:00
Winson Chung
eeb4ff4d13 Fixing issue where AppWidgetHost.onProvidersChanged() was not being called. (Bug 9270309)
Change-Id: I6cfb8e0c586fad7360a07f98e1280a954f62e5e1
2013-06-04 14:25:28 -07:00
John Spurlock
84a369c33b Fix awkward wording in AppWidgetManager docs.
Change-Id: Ia06221f75898ab53f97852880bf2a7ec49b4f489
2013-06-03 11:38:48 -04:00
John Spurlock
77624cd71f Fix awkward wording in AppWidgetManager docs.
Change-Id: I6d1e180be666b3d88e88f357e8d79f6bbc0c9857
2013-06-03 09:47:01 -04:00