124 Commits

Author SHA1 Message Date
Suprabh Shukla
3267035ba6 Deferring cross-profile animation after the dialog
The animation is deferred until a cross-profile activity
is started from the dialog.

Test: Manual:
1. Install any app that uses cross profile API
2. Suspend the app in one profile only
3. Navigate to the profile instance from within the app

Fixes: 144840723
Change-Id: Ia86708c1c4d708e2bae454b4cfe1ba8d4b413c5c
2019-12-19 17:12:47 -08:00
Jiyong Park
bae2e90796 Add filegroups for services.* libraries
... in preparation for creating a stub library from services.jar

Bug: 139391334
Test: m
Change-Id: Ifd6cfc77acf2284804a2f64011c2733b5c222369
2019-11-17 14:05:08 +09:00
Suprabh Shukla
d3278449d7 Allowing more than one app to suspend apps
We want to allow wellbeing apps to suspend in managed profiles.
This requires changing the internal data design of package-suspend
state to allow more than one suspending package, each with their
own parameters, namely - dialog info, app extras and launcher extras.

Also, removed the restriction of using setPackagesSuspendedAsUser when a
PO/DO exists

Test: atest com.android.server.pm.PackageUserStateTest
atest com.android.server.pm.PackageManagerSettingsTests
atest com.android.server.wm.ActivityStartInterceptorTest
atest GtsSuspendAppsTestCases

Bug: 138812320
Change-Id: If1263142fc9e6687e95af9b8d71ba8eff0c0fae9
2019-09-25 17:11:17 -07:00
Samuel Fufa
59ef5e98f3 Setup OnAppWidgetRemoved on framework
Test: Manual
Bug:140140567
Change-Id: I3033b83ff8f55938b5cd898c7e30bb2259af9c5f
2019-09-10 17:34:23 -07:00
Suprabh Shukla
389cb6f54a Suspending app can customize intercepting dialog
The suspending app has more context about why a particular app was
suspended by the user, but we do not want to delegate the interception
of the suspended activity out of the system.
Hence allowing it further customizations to the dialog to make
it clearer.

Test: atest com.android.server.pm.SuspendDialogInfoTest \
com.android.server.pm.SuspendPackagesTest \
com.android.server.pm.PackageUserStateTest \
com.android.server.pm.PackageManagerSettingsTests \
com.android.server.am.ActivityStartInterceptorTest

atest GtsSuspendAppsPermissionTestCases GtsSuspendAppsTestCases

Bug: 112486945
Bug: 113150060
Change-Id: If9f4d14587a2b75bb572e7984a90e300a2c72d16
2018-10-12 16:02:53 -07:00
Christopher Tate
fb2f70a6ed Fix widget manager / alarm manager deadlock
Don't hold locks while manipulating alarms within the app widget
server, because the joint dependencies on activity manager locking
cause problems.

Change-Id: Ic7a09e6938277df7201be515f9785f326552f166
Bug: 115894687
Test: manual (repeated rebooting including with alarms forced)
2018-09-19 11:31:08 -07:00
Christopher Tate
88dc93f1cc 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
2018-08-10 10:54:00 -07:00
TreeHugger Robot
dee2a78db6 Merge "Prevent instant apps to host app widgets" into pi-dev 2018-05-15 19:05:08 +00:00
Svet Ganov
00f103e1d8 Prevent instant apps to host app widgets
Test: Added: AppWidgetTest#testInstantAppsCannotProvideAppWidgets
      Added: AppWidgetTest#testInstantAppsCannotHostAppWidgets
      Pass: cts-tradefed run cts -m CtsAppWidgetTestCases
      Pass: cts-tradefed run cts-instant -m CtsAppWidgetTestCases

bug:79663649

Change-Id: If5a97bd058e3f1b6fc70e45027e5f40af8228e77
2018-05-13 23:17:38 -07:00
Suprabh Shukla
1ab90a2ed5 Fixing user tap on suspended widget
Widgets get masked with separate remove views when suspended. Need to
update them with the correct pending intent. Moved around the logic
creating the suspended alert activity to make it reusable.

Test: Manually, "pm suspend <app-with-widget>", followed by tap on
widget
Existing tests pass:
atest GtsSuspendAppsTestCases
atest com.android.server.am.ActivityStartInterceptorTest

Bug: 79474038
Change-Id: Ic75ee762434bf92c54bda307e9cb6018f94a914c
2018-05-11 14:24:54 -07:00
Sunny Goyal
425520d9c5 Desaturating the icon disabled on app widgets for a suspended app
Bug: 76454418
Test: Verified preview for a disabled widget on device
Change-Id: Ie5903c547bbb642c2fe72ddcb2a50e428f6832be
2018-05-09 15:41:57 -07: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
TreeHugger Robot
b8f2728a78 Merge "Prevent reporting fake package name - framework" 2017-12-09 19:51:00 +00: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
Colin Cross
e0b2ee52d2 Convert services to Android.bp
See build/soong/README.md for more information.

Test: m checkbuild
Exempt-From-Owner-Approval: trivial conversion
Change-Id: I417409281c928ea667d937090d2a0d9d72a449a2
2017-12-08 21:00:15 +00: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
67b00a04ad Fixing same pending update being sent every time startListening is called
if there was no widget update in-between

Bug: 67736800
Test: Added corresponding test in AppWidgetServiceImplTest
Change-Id: Ib3213f8f79ac11ed05b317e25110d7e37561b837
2017-10-12 11:41:27 -07:00
Takamasa Kuramitsu
dae28d59a9 Merge "Add checking values not to save illegal value to appwidgets.xml" am: 941d4b2135 am: 1807cb4a88
am: 3583e1f079

Change-Id: Ic1c8ccd34433201b73066d9fb016aa03b1cefa4a
2017-09-22 02:49:30 +00:00
Takamasa Kuramitsu
d6da1e3ee2 Add checking values not to save illegal value to appwidgets.xml
Symptom:
All AppWidgets on Home screen disppear after appwidgets.xml updated
with invalid value.

Root cause:
The issue occurs when size information of an AppWidget is set to 0
via AppWidgetHostView#updateAppWidgetSize() API.
Since width and height are taken positive padding, so they become
negative number and are sent to
AppWidgetServiceImpl#updateAppWidgetOptions().
In updateAppWidgetOptions(), convert values by
Integer.toHexString() to save widget parameters to appwidgets.xml,
but negative numbers become illegal values for Integer.parseInt().
After device is rebooted, widgets cannot be reloaded because parsing
appwidgets.xml fail by NumberFormatException at Integer.parseInt().

Solution:
When writing the widget's info to appwidgets.xml, check the size
parameters and replace with 0 if they're negative value.

Bug: 65705916

Change-Id: I48f69fbf081201a176ea1093094ba6cdb120e5f5
2017-09-19 16:27:24 +09:00
Fyodor Kupolov
37b966d5bd Handle onUnlockUser on fg thread
AppWidgetService.onUserUnlocked can block ActivityManager thread
for 500+ ms. The code is guarded by mLock, so it's safe to simply
offload it to the worker thread without additional synchronization.

Test: Setup widgets/rebooted the device and unlocked
Test: Create/switch to guest user + setup widgets
Bug: 63389529
Change-Id: Ib3bc76f79bdbc707c0ac270d7fc35c8b27af9af0
2017-07-24 18:44:33 +00:00
Jeff Sharkey
1c7736d2a7 Add tracing for UserState and a few services.
Both BackupManager and AppWidgetManager internals are taking a long
time to process user unlock events, so add tracing details.  Also add
general tracing to show all UserState changes.

Bug: 32859180
Test: builds, boots
Change-Id: I82f4f7220ccb695941acd6bc45cd67a5fae8a4d2
2017-07-06 11:55:44 -06:00
Christopher Tate
b98bcce37c Fix #38218977 : NPE restoring widget mappings
Remember that we might not be able to resolve historical
widget provider references, so don't access them unchecked.

Test: manual
Change-Id: I01c6c68461b6d15aa8fee402a4bfb0f21bf1ddbb
2017-05-11 15:39:34 -07:00
Fyodor Kupolov
1406fb72ec Prevent crashes when user is stopping
Added defensive checks to prevent sporadic crashes due to various race
conditions when user is stopped:
* onPackageBroadcastReceived - moved the check inside the synchronized block.
  This guarantees that onUserStopped (that also grabs mLock) is not yet
  called and we can proceed.
* stopListening - Since it is invoked before onUserStopped callback, we can call
  ensureGroupStateLoadedLocked(userId, false). The state will be subsequently cleaned
  up in the onUserStopped.

Test: manual user switching + SecondaryUserContentResolverTest and
      ManagedUserContentResolverTest
Fixes: 37472670
Fixes: 36890589

Change-Id: I44d0a0c004e9c3e6cfb37a24cb8a5b6f20a42f13
2017-05-05 14:12:29 -07:00
Tony Wickham
8fdf051346 Merge "Add AppWidgetManager#getInstalledProvidersForPackage()" into oc-dev 2017-04-05 17:37:15 +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
fe9a53bc45 Consistent dump() permission checking.
This change introduces new methods on DumpUtils that can check if the
caller has DUMP and/or PACKAGE_USAGE_STATS access.  It then moves all
existing dump() methods to use these checks so that we emit
consistent error messages.

Test: cts-tradefed run commandAndExit cts-dev -m CtsSecurityTestCases -t android.security.cts.ServicePermissionsTest
Bug: 32806790
Change-Id: Iaff6b9506818ee082b1e169c89ebe1001b3bfeca
2017-04-02 22:29:07 -06: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
Jeff Sharkey
22e32236ec AppWidgetManager shouldn't use StorageManager.
It's probably looking to detect both STATE_RUNNING_UNLOCKING and
STATE_RUNNING_UNLOCKED, so it should use isUserUnlockingOrUnlocked()
instead of trying to peek at the low-level CE key status.

Test: builds, boots
Bug: 29534661
Change-Id: I6aca1721f88ced65abf3bb7cbab550c4dbe27fb7
2017-02-24 10:21:58 -07:00
Mario Bertschler
86882f4587 App Widget Service with dump in protobuf format
Test: This protobuf format is validated as a CTS test
Bug: 33088921
Change-Id: I9d2a983052ade06cd3a13857b7e7f9e3d9bc275e
2017-02-01 10:58:31 -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
9010bc5b27 Using an increasing request counter instead of system uptime to avoid duplicates when sorting pending updates. am: 88959dccac
am: 7abfb108c9

Change-Id: I807c91625cf4a63c644392bbff6a8e9f84368aee
2017-01-18 01:56:35 +00:00
Sunny Goyal
7abfb108c9 Using an increasing request counter instead of system uptime to avoid duplicates when sorting pending updates.
am: 88959dccac

Change-Id: I535504ab5f70cd786973761b88d5e8e8bbec3ba8
2017-01-18 01:51:31 +00:00
Sunny Goyal
88959dccac Using an increasing request counter instead of system uptime to avoid duplicates
when sorting pending updates.

Test: Manually tested on device
Bug: 33655829
Change-Id: Ifd11cbc29bfaf30ad2d552af1d38d0d4413b70ab
2017-01-10 11:30:01 -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
1d138e5919 Preventing widgets from exceeding Bitmap memory limit
am: 4f05d8d76b

Change-Id: I0174a7e8cc8b228d7cbf2c0403f0a022eff34194
2016-12-07 19:20:02 +00:00
Sunny Goyal
4f05d8d76b 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
(cherry picked from commit 349b412b4ba93e6ab835e3f0c45a998979339b4f)
2016-11-15 05:22:04 +00: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