Commit Graph

157 Commits

Author SHA1 Message Date
Pierre Barbier de Reuille
f8960a0b31 Correct setting the RemoteView's provider id.
This seems to interfere with cross profile remote views otherwise. This
will also avoid changing the stored RemoteViews, or not providing an ID
if the RemoteViews is constructed by the host.

Fix: 187837525
Fix: 187867661
Test: atest ManagedProfileCrossProfileTest#testCrossProfileWidgets
Test: Manually with other apps, checking the colors do no flickr
Test: Check that uninstalling an app with a widget doesn't crash anymore
Change-Id: I7caa3f58d9b554e36f54e6b9d3b793c3ae5023ef
2021-05-17 16:57:50 +01:00
Stevie Kideckel
691ff96db6 Save/restore view states when reapplying RemoteViews for color changes
This ensures that adapters have their caches filles and other benefits
such as lists maintaining their scroll positions

Bug: 183503469
Test: validated with local app that service is not called on drag for
colors changing and that flicker is removed

Change-Id: I043d1d7a547b012f7a12eb555b35854a9bb7109b
2021-05-04 23:18:45 +01:00
Jackal Guo
c5a303f4a8 Apply package visibility to AppWidgetManager#getInstalledProviders
Package visibility should be applied to #getInstalledProviders as
what we did for similar APIs in PackageManager.

Bug: 180104057
Test: atest AppEnumerationTests
Change-Id: I50f471e6f71613e36cc1b137456a3ee0b23f6a38
2021-04-19 16:35:24 +08:00
Steven Ng
65eb127e6f Replace getResourceId default 0 with Resources.ID_NULL
Test: None

Bug: 181601209
Change-Id: I548947cd4f106baab7428f853cc5342668048476
2021-03-01 23:40:44 +00:00
Sunny Goyal
101fc2483f Merge "Stop listening to config changes in AppWidgetService" into sc-dev 2021-02-25 23:21:03 +00:00
Sunny Goyal
a1e184ebec Stop listening to config changes in AppWidgetService
Config chages are required to load the correct label. But
the label had been deprecated few years ago and hosts are
expected to load the label themselves
This avoids another reload just after unlock since the local
list is not prepared initially

Bug: 180867488
Test: Presubmit and CTS already passing
Change-Id: Iff4543bb62d06c81713b47b76330b2147a10386c
2021-02-24 15:18:10 -08:00
Alina Zaidi
1c9092d127 Adjust AppWidgetProviderInfo#getDescription to return CharSequence.
Also add more developer docs.

Test: atest AppWidgetServiceImplTest#testLoadDescription passed
Bug: b/180015383
Change-Id: Ie6fff9d880ba4721bf6babcd51acaa8fc9bd3cd9
2021-02-19 15:14:41 +00:00
TreeHugger Robot
b9806031ae Add new attributes for widget sizing controls.
Design doc: go/widget-sizing-api-dd

New attributes added:
* maxResizeWidth
* maxResizeHeight
* targetCellWidth
* targetCellHeight

Bug: 179807199
Test: atest FrameworksServicesTests:AppWidgetServiceImplTest
Change-Id: Icadc73da9bd010e42459735493f452cb892e5744
2021-02-17 10:55:01 +00:00
Steven Ng
cd5c9b0642 Add a layout attribute in widget metadata for widget preview
Test: atest FrameworksServicesTests:AppWidgetServiceImplTest. Newly
added test passed.

Bug: 179063291
Change-Id: I17cf97b580ac03d9688d82eeccd3a68e77287655
2021-02-08 14:09:06 +00:00
Sunny Goyal
4671a2d556 Simplifying disabled widget view genration
Removing creating and holding icon bitmaps in systemServer and
directly loading resources in the Host process

Bug: 178616010
Test: Verified View on device
Change-Id: I4abf616985d68ac48f55856bb90fa598a4cebe1c
2021-02-03 22:53:12 +00:00
TreeHugger Robot
f4e7856ce9 Merge "Lazily loading the widget providers to avoid loading app-resources on userUnlock" 2021-01-26 20:19:53 +00:00
Alina Zaidi
016e50a980 Include an attribute for description of the widget in the attributes file for AppWidgetProviderInfo.
Test: Instrumentation test added- AppWidgetServiceImplTest_testLoadDescription

Bug: 178460757

Change-Id: Ic9b9cd8c592936bbe421183f8715ba5d8f770742
2021-01-26 17:04:00 +00:00
Sunny Goyal
9912a46371 Lazily loading the widget providers to avoid loading app-resources on userUnlock
Bug: 177931115
Test: atest FrameworksServicesTests
Change-Id: I879b2b83b2d249b7175ab364a78a92bd3ec12f31
2021-01-25 11:45:49 -08:00
Jeff Sharkey
1ae7f40466 Merge "Update AppWidget owners" am: 8c9bf65b8b am: ea29396752 am: 0cfbc863f7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1556378

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I051e300cf34545ce632f64ef1dc7711f97c84599
2021-01-21 23:25:37 +00:00
Sunny Goyal
ce8c2017c1 Update AppWidget owners
Change-Id: I89d2fa5339a37c64e76698ed1aa3825d27f88097
Test: manual
2021-01-21 21:56:08 +00:00
Tim Murray
50ddd5856b AppWidgetServiceImpl: add mWidgetPackages lock
JobScheduler calls isBoundWidgetPackage(), but this can be extremely
slow while AppWidgetService is doing any meaningful work, causing
problems for the rest of the system. Remove that serialization by
moving mWidgetPackages behind its own lock.

Test: atest CtsAppWidgetTestCases
Bug: 161866124

Change-Id: Idae7d16d375dfd41f802ad193fa1ec939093c67a
2021-01-12 19:39:10 -08:00
Jeff Sharkey
a2c132d9c6 Hand-migration to TypedXml interface.
Previous changes have applied mechanical refactorings, but this change
hand-migrates the remaining logic which was too complex to identify.

This change should have no behavior change; famous last words.

Bug: 171832118
Test: manual
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: I85cd830eb6bfde18fca6e73ee7adfdc385a890de
2020-12-02 13:55:35 -07:00
Jeff Sharkey
8f43151721 Mechanically apply TypedXml refaster template.
This is a purely mechanical CL that applies the output of the
recently added refaster templates to help guide towards more
efficient TypedXml methods.  There is no behavior change.

Bug: 171832118
Test: manual
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: Ic95dd3de77c60482ad36b31706e6b701929f40b3
2020-11-30 20:45:40 -07:00
Jeff Sharkey
236c03b5c3 Mechanical refactoring to new typed XML classes.
Related changes are introducing new TypedXmlSerializer and
TypedXmlPullParser interfaces which offer efficient access to
primitive attributes.

Bug: 171832118
Test: manual
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: Ibd93f353ff3cb1f0b7073ebbeae17fe5194b046b
2020-11-30 20:45:25 -07:00
Jeff Sharkey
8099e30b73 Mechanical refactoring to new XML resolvers.
Related changes are introducing new TypedXmlSerializer and
TypedXmlPullParser interfaces which offer efficient access to
primitive attributes.

This change is a purely mechanical refactoring to prepare for
upcoming data format shifts, and has no behavior changes.

Bug: 171832118
Test: manual
Exempt-From-Owner-Approval: trivial no-op refactoring
Change-Id: Ib8045ddba489c254641d6331b64355709c3f6dd7
2020-11-13 14:48:32 -07:00
Jeff Sharkey
864524af17 Apply FLAG_IMMUTABLE to various PendingIntents.
Some careful spot-checking has revealed common cases where it's
reasonable to blanket apply the new FLAG_IMMUTABLE option to newly
created PendingIntents.  Specifically these situations:

-- Simple notification content clicks are immutable; there's no need
to communicate customized data back to the creator
-- Simple notification action clicks are immutable; there's no need
to communicate customized data back to the creator
-- Broadcast intents sent by AlarmManager are immutable; the system
dispatches them without customization.

Bug: 170165227, 170424283, 170425388, 170425877
Bug: 169791183, 170771965, 170226088, 170224928, 170767530
Test: none
Change-Id: I5ed68710d2ccad4635a30fd91136a9e6ad76a01d
2020-10-20 16:20:54 -06:00
Jeff Sharkey
f76ffeaff1 Merge changes from topic "oct6"
* changes:
  Upgrade AndroidFrameworkBinderIdentity to fatal.
  Tighten up Binder.clearCallingIdentity() usage.
  Tighten up Binder.clearCallingIdentity() usage.
  Tighten up Binder.clearCallingIdentity() usage.
2020-10-08 18:50:22 +00:00
Adam Bookatz
82194b8fe0 Use hasBadge instead of isManagedProfile
To determine whether a user has a badge, the
correct call is now hasBadge, rather than isManagedProfile.

Currently, the only user that actually can have a badge
is a managed profile, so this change is a no-op. In the future,
if further profile support is expanded, then hasBadge will
be correct.

Bug: 170249807
Test: Treehugger (this cl is a no-op)
Change-Id: I9144c4dc519936dfc5a2aeae0eb0bd91bea89db2
2020-10-06 15:04:16 -07:00
Jeff Sharkey
2d2e07e2ff Tighten up Binder.clearCallingIdentity() usage.
The recently added AndroidFrameworkBinderIdentity Error Prone checker
examines code to ensure that any cleared identities are restored to
avoid obscure security vulnerabilities.

This change is a purely mechanical refactoring that adds the "final"
keyword to the cleared identity to ensure that it's not accidentally
modified before eventually being cleared.  Here's the exact command
used to generate this CL:

$ find . -name "*.java" -exec sed -Ei \
    's/    (long \w+ = .+?clearCallingIdentity)/    final \1/' \
    {} \;

Bug: 155703208
Test: make
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: I832c9d70c3dfcd8d669cf71939d97837becc973a
2020-10-06 11:18:09 -06:00
Jeff Sharkey
4b5b0174d0 Merge changes from topic "sep11" am: c0b288133a am: 69e6f07347 am: 741c0a78cc am: da7478b570 am: 487d394296
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1426195

Change-Id: Id01f468b43fd5b2aada78608010625b392c1b647
2020-09-15 21:01:48 +00:00
Jeff Sharkey
4172f8a62c Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Test: none
Bug: 168334533
Exempt-From-Owner-Approval: docs updates
Change-Id: If75259aab72329f9f8b0e1972a96370ca5134e2c
2020-09-14 10:00:10 -06:00
Felipe Leme
837f8c1e8a Removed @Deprecated SystemService callback methods that take a userId.
This is just a plain refactoring: the removed methods in the changed
classes were called by default by the new methods in the superclass
(SystemService).

Test: m
Test: atest NotificationManagerServiceTest BackupManagerServiceRoboTest

Fixes: 161943081

Exempt-From-Owner-Approval: refactoring without side-effects

Change-Id: Ifd8df592eb4494cc0922b7e0b2ff20187b8a8b3e
2020-08-03 07:24:26 +00:00
Samuel Fufa
bc28ebb78c Resolve NPE on widget.provider.id
Test: existing tests should pass
Bug: 156120679
Change-Id: I88108ef6825d72561453d57253cd6d5a14951364
2020-05-12 15:37:22 -07:00
Hui Yu
4803268229 Move noteAppWidgetTapped call into AppWidgetHostView.
RemoteViews is public API used out of scope of widget. The correct place
to call noteAppWidgetTapped is in AppWidgetHostView.

Fix: 153676411
Test: manual test, tap a widget, "adb shell dumpsys usagestats | grep
USER_INTERACTION" to oberserve USER_INTERACTION event sent to UsageStas, "adb shell dumpsys appops | grep appWidgetVisible" to observer appWidgetVisible flag.

Change-Id: Ic473211b91fd952dbb81b09b1e1568d6f69a0dd8
2020-04-15 22:06:12 -07:00
Hui Yu
2001fbafec getDefaultHomeActivity() could return null ComponentName.
Bug: 153400018
Test: Manual test
Change-Id: I29d5a8f00563bdf88ab1f7a00d39d6a39a0ed44d
2020-04-09 16:48:53 -07:00
Hui Yu
3dc45fbc57 Update AppOps & UsageStats when app widget tapped.
When the app widget on the launcher is tapped on:
1. Update AppOps. AppOps treats the underlying app as foreground so the app can get while-in-use
permission.
2. Report a USER_INTERACTION event to UsageStats so UsageStats can
update mLastTimeUsed and mLastTimeVisible of this package.

Bug: 149043079
Test: manual test, tapped on a widget.
Change-Id: Ic8c91190881cf5dcf89f0f72cfd410b0c2e86bf6
2020-03-21 08:36:54 -07:00
Hui Yu
00a776682c Only check on launcher proc state when param visible is true.
When launcher moves away from TOP, param visible is false, should skip
the proc state check and move ahead to update AppOps.

Bug: 151835293
Test: Manual test, open another app and move launcher away from top
screen, observe AppOps is updated.

Change-Id: I4b1562994d205d7e5b0327b95cf59e08b91ae048
2020-03-18 15:28:44 -07:00
Suprabh Shukla
a5a576d905 Merge "Resolving a TODO in AppWidgetService" into rvc-dev 2020-02-26 07:25:36 +00:00
Suprabh Shukla
87cae2684d Resolving a TODO in AppWidgetService
Test: No code changes. Builds, boots.

Bug: 148035643
Change-Id: I15bc26b6e345aff421abbfd7604d1cbb36a38a0d
2020-02-24 22:57:12 +00:00
Samuel Fufa
1acbf7763b Fix widget restore flow
After restore, the app should set OPTION_APPWIDGET_RESTORE_COMPLETED to
true on its widgets followed by calling updateAppWidget to update views.

Bug:63667276
Test: Manual
Change-Id: Idb6fc63b0f894fca9e0470aaf335240fc124e2e9
2020-02-24 19:07:59 +00:00
Andrii Kulian
5877c7d6c0 Exempt-From-Owner-Approval: Report non-visual Context misuse
Make obtaining a visual service from non-visual Context instance
report a strict mode violation and print the stacktrace.

Make calling getDisplay() throw an exception if called on an instance
that is not associated with a display. For existing usages introduce
a new internal method that does not perform the verification until
the usages are properly fixed.

Bug: 128338354
Test: StrictModeTest#testIncorrectContextUse_GetSystemService
Test: StrictModeTest#testIncorrectContextUse_GetDisplay
Change-Id: Id25d590eca6e10066e55d7ed6436d3bc9e433beb
2020-02-20 01:29:25 +00:00
Andrii Kulian
e57f2dc246 Exempt-From-Owner-Approval: Fix usages of WindowManager.getDefaultDisplay() in f/b
Replace the existing usages of now-deprecated API
WindowManager.getDefaultDisplay() with WindowMetrics or
Context.getDisplay() in frameworks/base.

Bug: 128338354
Test: Build, auto test
Change-Id: I02d38a022c5e0e6e9d699f03d35b65d6c8126da9
2020-01-31 01:15:21 +00:00
Hui Yu
88910decff FGS background start restriction.
1. Background started foreground service shall not have
while-in-use permissions including location, camera and
microphone. Many exemptions have been applied including:
--FGS started by widget.
--FGS started by notification.
--FGS started by IME or other visible app.
--FGS started by ROOT_UID, SYSTEM_UID, NFC_UID.

2. Add a phenotype key KEY_DEFAULT_BACKGROUND_FGS_STARTS_RESTRICTION_ENABLED
to turn on/off this feature (default is on).

3. In dogfood, if a background started FGS with while-in-use permission
(any of location/camera/microphone) run into this restriction, the FGS
will not been granted these permission. we show a toast message to
alert user and ask them to write a bugreport using instruction at
go/r-bg-fgs-restriction. So we can have a statistic how many apps will
be impacted by this feature.
These is a flag Settings.Global.FOREGROUND_SERVICE_STARTS_LOGGING_ENABLED
to turn on/off the toast message (default is on, in dogfood)

Bug: 136219221
Test: atest android.app.cts.ActivityManagerProcessStateTest
atest android.app.cts.ActivityManagerApi29Test.java
atest android.app.cts.ActivityManagerFgsBgStartTest

Change-Id: Ibc8aaa6839a69136f9311bfacdbab9705b31b6a7
2020-01-24 20:58:47 -08:00
Suprabh Shukla
0cb5713fd7 Add an unsuspend button option to SuspendDialogInfo
The suspending app can specify if they want to unsuspend the app on
neutral button tap. This needs to be done by the system so as to
maintain continuity of the users activity tasks.
The system then also needs to communicate to the suspending app when
such an unsuspend has taken place so it can keep any of its internal
data consistent with the current state.

Test:  atest FrameworksServicesTests:PackageManagerSettingsTests
atest FrameworksServicesTests:SuspendDialogInfoTest
atest GtsSuspendAppsTestCases:SuspendPackagesTest

Bug: 134962563
Change-Id: I587b2643eb41519b82b8e2b371a466a9fb650d4b
2020-01-22 12:26:32 -08:00
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
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