87 Commits

Author SHA1 Message Date
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
349b412b4b Preventing widgets from exceeding Bitmap memory limit
> Moving the size check to a comman place so that it is executed in
all related code
> Fixing size calculation when views are merged as a result of partial
update

Test: Manually tested with a dummy app
Bug: 31790171
Change-Id: Id0ea776796f156455d2cba31c8392d4875116949
2016-11-14 17:19:25 -08:00
Winson
f59c50c4ab Fixing typo in dump log. am: b43ba86811 am: 1de1a3bfcc
am: fc4a87580f

Change-Id: Id813187a627f795627a491cfe736f6e70d3e318a
2016-08-30 01:20:12 +00:00
Winson
fc4a87580f Fixing typo in dump log. am: b43ba86811
am: 1de1a3bfcc

Change-Id: I0ccfedd4bc9028ab150792ba974a1f70912ef631
2016-08-26 01:29:06 +00:00
Jeff Sharkey
73ea0ae15f Fix bugs around manager fetching.
A recent patch started returning "null" when a Binder service
required to provide a manager wasn't yet registered.

This fixes four locations where that new logging was triggered: in
two cases by adjusting the fetching ordering, and in two other cases
by only fetching when the device supports the manager.

Bug: 28634953
Change-Id: I84dbccffa4ac760c10a2bbcb234f21272bfecb91
2016-08-11 09:44:34 -06:00
joonyoung.cho
19acc9023a Merge "fix safeMode status in AppWidgetService" am: 78a72f0698 am: cbd4ad1f7e am: 5a3034f8ff
am: 2f51366c1a

Change-Id: I64ed50a3f2d6fa20650c047bda0da1ad0cd292f4
2016-08-08 22:25:20 +00:00
joonyoung.cho
2f51366c1a Merge "fix safeMode status in AppWidgetService" am: 78a72f0698 am: cbd4ad1f7e
am: 5a3034f8ff

Change-Id: Iaefa29636ecc0367c3ad40d06a5e2099c9e506f4
2016-08-08 22:14:43 +00:00
joonyoung.cho
cbd4ad1f7e Merge "fix safeMode status in AppWidgetService"
am: 78a72f0698

Change-Id: I21559690f6371102cf48132d8930343923d60011
2016-08-08 21:53:34 +00:00
Treehugger Robot
78a72f0698 Merge "fix safeMode status in AppWidgetService" 2016-08-08 21:36:46 +00:00
Winson
b43ba86811 Fixing typo in dump log.
Change-Id: I94c381acb9a1748770231e714b93875097850e0d
2016-08-02 14:53:55 -07:00
Rubin Xu
36c0136177 Merge \\"Guard against null object in scheduleNotifyUpdateAppWidgetLocked\\" into nyc-mr1-dev am: 26504a611a
am: 9d1e68ab1b

Change-Id: Ib09e0a5ba83959ef9ea418066c7ad16b1ab2238c
2016-07-12 17:01:30 +00:00
Rubin Xu
1bd6452e0f Guard against null object in scheduleNotifyUpdateAppWidgetLocked
Bug: 30085290
Change-Id: I4f12e1def98dff7e50b4d25a7d23e81bdbe0b7bd
2016-07-12 16:05:59 +01:00
Jeff Sharkey
7a1f2cbb4f Merge \\"Snapshot RemoteViews before releasing lock.\\" into nyc-mr1-dev am: ffc0d5153c
am: 18d0841650

Change-Id: Iad6d527d6e0a81c127b7836e231044aeb40f065c
2016-07-07 17:57:00 +00:00
Jeff Sharkey
8a918b13a8 Snapshot RemoteViews before releasing lock.
The MSG_NOTIFY_UPDATE_APP_WIDGET message is sent asynchronously,
meaning it tries sending RemoteViews without the lock held, possibly
while another Binder thread is trying to mutate it.

Fix this by creating a copy for the thread to safely dispatch.

Bug: 29889779
Change-Id: I341fbbf89abee97a66cd67f1dd2a728282b68bfa
2016-07-06 17:39:21 -06:00
Nicolas Prevot
709a63d9c0 Show policy transparency screen if adding an account is not allowed.
If DISALLOW_MODIFY_ACCOUNTS has been set by a profile/device owner,
or account management is disabled:
When an app tries to add an account, show the policy transparency screen.

BUG:26762383
Change-Id: I721220c37c74493020f5a1be1f15731e9863a1de
2016-06-27 14:10:38 +01:00
Tony Mak
95d0d631ba Merge \"Allow stopping user to access AppWidgetService API\" into nyc-dev
am: ab8d4cf645

Change-Id: I2280fae9d85594ad0fde5d552ff07b0d4e0c6158
2016-06-17 17:09:22 +00:00
Tony Mak
c460856d7b Merge \\"Allow stopping user to access AppWidgetService API\\" into nyc-dev am: ab8d4cf645
am: 44864e5c12

Change-Id: I718e396108f3e5518d8e121edb7c47d2af6e6b29
2016-06-17 13:36:30 +00:00
Tony Mak
63966b3e12 Allow stopping user to access AppWidgetService API
We now have isUserRunning && isUserKeyUnlockedisUserUnlocked instead of
having isUserUnlockingOrUnlocked. The difference is
we now allow stopping unlocked user to access the API.

Testing:
Write a simple widget which keep calling AppWidgetManager API in a loop.

1. In non-FBE mode, place the widget to launcher.
   Turn off work mode. No crash is observed.
2. Repeat 1 in FBE mode with separated work challenge.
3. Repeat 1 in FBE mode with no separated work challenge
4. Repeat 2 and reboot the device. Unlock work profile, widget is shown
5. Repeat 3, reboot device, widget is shown after rebot


Change-Id: I2fa9f602dcb0befff41fc6b145e9855e82d8d7a8
Fix: 29264823
2016-06-16 14:57:00 +01: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
Winson
57c9e16d04 Process user events from service lifecycle callbacks.
- Instead of waiting for the broadcast to start loading the user’s 
  widgets, handle them in the service callbacks to ensure the app widget
  update broadcasts are enqueued earlier.

Bug: 27262341
Change-Id: I095abe5e15fe46412d00438986f7a9aee50872ca
2016-05-24 20:00:50 +00: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
Fyodor Kupolov
e09a623bc0 Return from onUserUnlocked if user is no longer unlocked
User can be removed or stopped by the time broadcast is delivered.

Bug: 28582351
Change-Id: I26f1a37a1ed61694679afff458c91438ee4e78cb
2016-05-04 17:48:41 -07:00
Fyodor Kupolov
4d01f61e7b Do not enforce unlocked state when there is no caller
Do not enforce unlocked state when running on the background thread. User can
be in the stopping state or removed by the time the message is being processed.

Bug: 28471878
Change-Id: I1862849661d93b424a07ea94e80563bea7a94ce5
2016-04-29 17:27:16 -07:00
Jeff Sharkey
ce18c81677 Introduce "unlocking" vs "unlocked" nuance.
There is a narrow window of time during user unlock where we're
reconciling user storage and dispatching the "unlock" status to
various internal system services.  While in this "unlocking" state,
apps need to be told that the user still isn't actually "unlocked"
so they don't try making calls to AccountManager, etc.

The majority of internal services are interested in merging together
both the "unlocking" and "unlocked" state, so update them.

Clarify naming in AccountManagerService to make it clear that a local
list is being used, which mirrors the naming in MountService.

To match UX/PM requested behavior, move PRE_BOOT_COMPLETED dispatch
after the user is unlocked, but block BOOT_COMPLETED dispatch until
after all PRE_BOOT receivers are finished to avoid ANRs.

Bug: 28040947, 28164677
Change-Id: I57af2351633d9159f4483f19657ce0b62118d1ce
2016-04-28 10:51:39 -06:00
Rubin Xu
b2cc8e25c0 Fix widget not being masked when freshly added.
Bug: 26721345
Change-Id: I6bc7142c6f488b8666651330039abac27782bda9
2016-04-13 17:21:07 +01:00
Fyodor Kupolov
7f98aa4aa9 Added getProfileIds method returning array of userIds
Previously many usages of UserManager.getProfiles and getEnabledProfiles
were only using ids of returned users. Given that the list of users needs
to be parceled and unparceled for Binder calls, returning array of ids
minimizes memory usage and serialization time.

A new method getProfileIds was introduced which returns an array of userIds.
Existing method calls were updated where appropriate.

Bug: 27705805
Change-Id: Ic5d5decd77567ba0f749e48837a2c6fa10e812c0
2016-04-07 16:41:57 -07:00
Rubin Xu
0c9dd5b98a Clear caller identity when calling createConfirmDeviceCredentialIntent
Bug: 27893870
Change-Id: I9edcd170432f8a2bd852a5fa78ab868201093dcf
2016-04-06 11:54:59 +01:00
Sunny Goyal
60c74e836f Merge "Changing startListening to only fetch views which are bound" into nyc-dev 2016-04-05 18:53:18 +00: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
Rubin Xu
e95057ade1 Split ACTION_MANAGED_PROFILE_AVAILABILITY_CHANGED into two.
Add more comment to EXTRA_QUIET_MODE

Bug: 27532254
Change-Id: I68a217561afca8b87f523c62393cdad097d5b75d
2016-04-04 16:08:47 +01:00
Andrei Stingaceanu
efc4a344a1 AfW - suspend apps - API polish
* renamed getPackageSuspended => isPackageSuspended
* does not return false for an error, instead throws
  NameNotFoundException if the package could not be
  found, or if there is an unknown RemoteException,
  wraps it in a RuntimeException and rethrows.

Bug: 27532430
Bug: 22776761
Change-Id: Iee00600089b1c0556a3312b10456826464fa8f9f
2016-03-29 14:49:21 +00:00
Jeff Sharkey
1af4a7b5bf Skip app widget config changes when user locked.
Bug: 27377050
Change-Id: Ic63b06159cf59106b4e7bc62ec5f3e89d47321c5
2016-03-21 13:07:35 -06:00
Jeff Sharkey
8a372a0a28 Refactoring FBE APIs based on council feedback.
Mostly consists of removing the word "encryption" from most APIs,
since we can't actually make promises about the data being encrypted.

Bug: 27531029
Change-Id: Iace9d7c4e64716abf86ed11847c40f3947e1d625
2016-03-17 14:49:08 -06:00
Sudheer Shanka
7a9c34bd7a Show admin support dialog if app is suspended.
Bug: 26922950
Change-Id: I21f048873244df52d14910cc01a658af476d9149
2016-03-15 10:40:04 -07:00
Jeff Sharkey
d5896630f6 Move more PM calls to ParceledListSlice.
Since the data returned by these calls can grow unbounded based on
various GET flags, we need to switch 'em over.

Bug: 27391893
Change-Id: Ie849ca30dbaaa91158da4c83675657715629a0ee
2016-03-04 16:31:34 -07:00
Rubin Xu
484eea70df Merge "Fix widget icon and tap behaviour." into nyc-dev 2016-03-02 17:48:06 +00:00
Kenny Guy
8267e8241f Don't clear widget providers from stopped profiles.
Stopped profiles may have a parent still running
hosting widgets so providers should remain.

Bug: 26842832
Change-Id: I3ef97222fcfa5b183744033ece133115b3c146c1
2016-03-01 12:18:03 +00:00
Rubin Xu
5580622231 Fix widget icon and tap behaviour.
Do not show badge icon when the suspended package is not inside
a managed profile. Tapping on a masked widget should bring up the
relevant dialog similar to tapping on the app's launcher icon.

Bug: 26948327
Bug: 26924217
Change-Id: I2bf7ac718e55063bc8ea66573e89a62a97b91ff2
2016-02-26 18:16:36 +00:00
Kenny Guy
63f4ef0b7d Don't load profile widgets until parent is unlocked.
Wait for parent user to be unlocked before attempting
to load widgets for a user.
Fixes issue with profile being unlocked and AppWidgetServiceImpl
thinking it has loaded parents widgets while locked and
therefore not seeing any widgets.

Bug: 27037962
Change-Id: Ice9c5e6e1dd062a622c5f984eeb3531de893f9be
2016-02-23 14:55:01 +00:00
Kenny Guy
33f9a9c21a Allow widget hosts to see widgets from locked profiles.
Avoid launchers removing widgets by handling case
where a widget host is in an unlocked parent user and
widget providers are in a locked managed profile.
For this case allow launcher to see the widgets from
non-crypto aware widget providers.
Mask out widgets from locked profiles.
Fix issue with widgets not being masked when adding
new widgets when user is locked / quiet or package
is suspended.

Bug: 26721345
Bug: 27037962
Change-Id: I60b5bd934c1547110e374ab4eefbee6aade37dc6
2016-02-19 14:31:29 +00:00
Andrei Stingaceanu
355b232d79 Suspend packages - new API for retrieving the suspended status
Instead of always rebuilding the full ApplicationInfo for a
package when callers are only interested in the suspended status
add a new fast API in Packagemanager (which only checks the
suspended user setting for the requested package and returns
a boolean) and change the appropriate caller code too.

Bug: 26794775
Bug: 22776761
Change-Id: Ide8428ef734479360d5a8a75fd8e0ed8ddf2da7a
2016-02-16 14:57:29 +00:00
Rubin Xu
d09020576f Mask widgets for suspended packages.
Bug: 22776761
Change-Id: I271257e765a2297c780ac2bd37426d8fb451e5d9
2016-02-01 22:06:06 +00:00
Jeff Sharkey
cd65448ccd Even more PackageManager caller triage.
Finish moving all UID/GID callers to single AIDL method that requires
callers to provide flags.

Triage AppWidgets and PrintServices, which currently can only live on
internal storage; we should revisit that later.

Fix two bugs where we'd drop pending install sessions and persisted
Uri grants for apps installed on external storage.

Bug: 26471205
Change-Id: I66fdfc737fda0042050d81ff8839de55c2b4effd
2016-01-08 18:35:54 -07:00
Jeff Sharkey
0999c0d6e9 Make printing framework encryption-aware.
Only create UserState objects when a user has been unlocked, meaning
we can connect to the spooler.  Ignore package events that occur
while a user is locked, since we'll kick off updateIfNeededLocked()
when that user is eventually unlocked.

In all other cases, throw if someone tries obtaining UserState for
a still-locked user.  This should help catch any edge cases in the
system, and communicate clearly through public APIs that printing
isn't available until the user is unlocked.

Bug: 26246836
Change-Id: If15744621890baee206d355484fe20933afc65d8
2015-12-17 15:12:26 -07:00
Jeff Sharkey
af6ec296ec Make AppWidgets encryption-aware.
Only parse and load AppWidget configuration details after a user has
been unlocked.  Yell loudly if someone accidentally tries loading
data for a locked user.

Tidy up protected broadcast logic a bit more to handle persistent
processes.  Add backwards compatible behavior for APPWIDGET_UPDATE
broadcast simliar to APPWIDGET_CONFIGURE, since some apps are sending
it to themselves.

Add hidden USER_HANDLE extra to a handful of broadcasts to make
logic more consistent.

Bug: 26247049, 26219971
Change-Id: I54e4f2e343488571f9baa1a316962f41186c1a2c
2015-12-17 14:24:21 -07:00
Rubin Xu
cc52ce4bc4 Mask work widgets if work profile is in quiet mode.
If a work profile is in quiet mode, mask widgets belonging to that profile
with a generic RemoteView.

Bug: 22541941
Change-Id: I3baa179630af497afa02b32f236d2bdaa4a75904
2015-12-15 16:45:02 +00:00
Christopher Tate
67507d9f9d Drop binder identity before setting widget provider refresh alarm
Bug 25607336

Change-Id: I645b79c01206baa548d1d58cf9712ac1768e3b5b
2015-11-12 16:21:05 -08:00
Kenny Guy
b27fdb33c4 Merge "Don't remove widget providers when whitelist changes." 2015-09-18 15:47:33 +00:00
Kenny Guy
415f111335 Don't remove widget providers when whitelist changes.
When a widget provider is removed from the whitelist
of widgets that work across profiles just remove the
currently bound widgets don't remove the provider.
This allows the provider to be added back to the whitelist
or to be used from widget hosts within the profile.

Bug: 21180997
Change-Id: I5d3a81fb088092b65cc4e8e158be4a292c5c8288
2015-09-18 12:35:53 +01:00
Xiaohui Chen
7c69636c9a Cleanup USER_OWNER in various services
Bug: 19913735
Change-Id: I980370bab18e1b9ccf4043eed2b9fd721a940f72
2015-09-16 09:56:14 -07:00