31 Commits

Author SHA1 Message Date
Mark Punzalan
6c3d2f7b7d Trigger newly-registered callbacks with events from currently active
translations.

Bug: 192331240
Test: atest android.translation.cts.UiTranslationManagerTest
Test: Manually on device:
  1. Kill Gboard
  2. Open translatable Chat conversation, wait for Live Translate
  4. Focus on chat input
  5. Auto-translate on Gboard is opened, and debug logs show
     "TranslationManagerServiceImpl: Triggering callback for..."

Change-Id: Ida82a947491e8157fac5cd43939d6d358fbe6c7b
2022-03-30 05:35:46 +00:00
Mark Punzalan
49525ccb14 Add package name to all UiTranslationStateCallback methods.
This will be used by clients such as Gboard to ensure they are
responding to translation events for the correct activity. Ideally we
would include the activity token, in case there are multiple activities
being translated in an app, but that isn't supported right now and it
requires changes to EditorInfo (in Input Method Framework) to get the
activity token.

Also fixed an issue where the callback methods are invoked twice when
the IME itself is the translated app is registering a callback for
itself. Note: This happens in UiTranslationManagerTest where the test
activity and IME have the same uid, but shouldn't happen outside of
tests.

Bug: 223979041
Test: atest CtsTranslationTestCases
Change-Id: Id99f501b065b92fe3358c2ae525175ad3ea4b119
2022-03-19 05:28:21 +00:00
Joanne Chung
5c1e5f7193 Merge "Update team OWNERS file." am: e96070ac89 am: 114d0c7773 am: 1bb2f28548
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1982066

Change-Id: Ic8c77290b4d8e2d6cf8353a793b75cf71990a7a1
2022-02-16 05:24:07 +00:00
Felipe Leme
cfd8bb1da6 Deprecated "legacy" options for Activity.dump()
These 3 options (--autofill, --contentcapture, and --tranlation)
are now available as '--dump-dumpable DUMPABLE' (where DUMPABLE is
AutofillManager, ContentCaptureManager, and UiTranslationController
respectively).

Test: adb shell am start com.android.settings && adb shell dumpsys activity com.android.settings --autofill
Test: m -j update-api

Bug: 149254050

Change-Id: Iaf9040a4afcd87d32c60e32d19aaca8e1d2c817a
2022-02-14 09:52:52 -08:00
Joanne Chung
b00f0d6c95 Update team OWNERS file.
Bug: 177641730
Test: n/a
Change-Id: If4ecc7326dc229d8807e1497c5e3e2ef0637680f
2022-02-14 14:51:12 +08:00
Joanne Chung
bb612abccd Notify onFinished when activity is destroyed.
Bug: 184901144
Test: manual
Test: atest UiTranslationManagerTest

Change-Id: Ife6883b6e4b84ad3994b83683b9dfe3af6df91af
2021-07-01 13:14:54 +08:00
Joanne Chung
6aed3fe12c Callback translation usages for registered translation app.
Apps developers may track the translation usage on their apps, the
system provides UiTranslationStateCallback if the apps registered.

Bug: 184901144
Test: atest UiTranslationManagerTest

Change-Id: I3265d4b587c81b74c6beae881cd3ff3034de9852
2021-06-28 18:48:44 +08:00
Joanne Chung
94b6e6515c Dump the last Activity information when dumpsys translation
When bugreport dumps Activity information, it will dump translation
related information. But it adds -v parameter, the bugreport will
only dump visible task's top Activity. If message apps go to the
background, we cannot find our expected information. We try to let
translation dumpsys to dump the last Activity information if the
Activity isn't destroyed yet, e.g. go to background.

Bug: 187889345
Test: open chat app and back home then dumpsys translation. Let
Activity destroyed and make sure no Activity dump.

Change-Id: Ie5b935696a74ca3f298c5e6e5994fa659389e198
2021-06-08 12:17:27 +08:00
Joanne Chung
4c3b7e9a62 Fix ServicePermissionsTest#testDumpProtected
The translation system service should verify the caller holds
Permission#DUMP before dumpping the log.

Bug: 186756551
Test: atest ServicePermissionsTest#testDumpProtected
Test: atest CtsTranslationTestCases
Test: manual dumpsys translation

Change-Id: Ic1ea90d9467d5ac25353f08374ce157c60976b8e
2021-05-19 11:45:21 +08:00
Ahaan Ugale
f765882432 Pipe UiTranslationSpec through to the UiTranslationController.
And use it to conditionally enable content padding for requested views.

Fix: 179693024
Test: atest android.translation.cts.UiTranslationManagerTest
Test: adb shell dumpsys activity <ACTIVITY> --translation
Change-Id: I23fb29a60525d736f2dcf9d11b548c62332c412c
2021-05-12 11:47:15 -07:00
Ahaan Ugale
2434a92049 Merge "Translate: API for content padding." into sc-dev 2021-04-26 15:17:26 +00:00
Joanne Chung
2fcdb2cf9f API feedback: TranslationCapability APIs refinement.
- updates APIs naming and uses Consumer<TranslationCapability>
  instead of PendingIntent
- Implements the propagating capability updates in the client side

Bug: 176208267
Test: manual.
Test: atest CtsTranslationTestCases

Change-Id: I171c908b529e2ef300e4bbd55c1565b33a25c1e5
2021-04-26 18:10:49 +08:00
Ahaan Ugale
8dc9a795e0 Translate: API for content padding.
This allows controlling the content padding behavior needed with some
apps for compatibility reasons.
(see I9d7db5d2bc200e4042baf3267796f00cfc298f19)

The flag is currently the only property in the new UiTranslationSpec
value type, but more properties can be added in the future (such as
animation specifications).

Bug: 179693024
Test: manual
CTS-Coverage-Bug: 182990474
Change-Id: I11052cddb59c928b22ad9ad16e3c9b092da4b907
2021-04-26 01:14:02 -07:00
TreeHugger Robot
efc7e4c0f0 Merge "Add api to propagating translation capability updates." into sc-dev 2021-04-23 00:39:27 +00:00
Adam He
e5c140a59d Add api to propagating translation capability updates.
This change adda the apia in the TranslationService that allows to
update the TranslationCapability to the registered clients. This
change doesn't contain the register part in the TranslationManager,
the change will be done on the next change.

Bug: 176208267
Test: atest CtsTranslationTestCases
Test: manual verification
CTS-Coverage-Bug: 182990474

Change-Id: Iec7b3dc30f99985415162394d0e64d8e825ea5d9
2021-04-22 14:54:21 -07:00
Adam He
528059b7be Merge "API feedback: change language from String to ULocale." into sc-dev 2021-04-21 20:44:02 +00:00
Adam He
e565d31bce API feedback: change language from String to ULocale.
Bug: 176208267
Bug: 184685163
Test: atest CtsTranslationTestCases
Change-Id: I10310f4980d4b9d869eb76542e0327420ad2f9de
2021-04-20 18:23:13 -07:00
Joanne Chung
108cec2f17 Remove the deprecated APIs in UiTranslationManager.
We introduced some APIs for initial demo but we dropped these APIs.
To avoid to break the client app, we keep the API until the client
moves to new APIs. It's ok to delete these API now.

Bug: 185448758
Test: manual
Test: atest android.translation.cts.UiTranslationManagerTest

Change-Id: I5ea71d4658246f52610e1f62412d60c6c58bb31e
2021-04-20 14:00:36 +00:00
Joanne Chung
dd0224162c Add API to get the PendingIntent for translation settings Activity
Bug: 176208267

Test: manual test with sample app
Test: atest CtsTranslationTestCases

Change-Id: I00416cf9cb63d522b9d8a448be3533b89b753aa0
2021-03-23 23:51:46 +08:00
Adam He
7c3a6e37a2 Add API for TranslationContext
* TranslationContext holds source/dest specs, replacing spec pairs in
methods.
* TranslationCapability holds information on the translation models, as well
as a helper method to generate a TranslationContext for creating
translators.
* TCapability is meant to hold information about the translation models, and
provide information/flag on what the translator can support, versus the
TContext which will indicate exactly which supported flags should be
used and activated by the models.
* Added TM.getTranslationCapabilities, and add/remove TCapabilityUpdateListener

Bug: 176208267
Test: atest CtsTranslationTestCases
Change-Id: I2ab7a3eadcbbc9e13f8f33bf9c51cda69f30fdb7
2021-03-22 11:38:50 -07:00
Ahaan Ugale
93b9882eb8 Revert "Revert "Add UiTranslationStateCallback.""
This reverts commit 7c8010211de045cd54b655e7005a94d680f5c8db.

Reason for revert: Original change broke the build. This is a clean
revert. The next change in the relation chain here fixes the error.

Bug: 177500482
Bug: 182896753
Test: mmma frameworks/base/ RUN_ERROR_PRONE=true
CTS-Coverage-Bug: 182853869
Change-Id: I0a0ce22feb2e54769103f8f4eecbffe425099412
2021-03-17 07:55:59 +00:00
Martijn Coenen
7c8010211d Revert "Add UiTranslationStateCallback."
This reverts commit 30704c1b853cb23564bf7f3f68baa80ddc5e91e8.

Reason for revert: breaks errorprone, b/182896753

Change-Id: I05f4e2dba321bc77713be701f76b07c66cb0d103
2021-03-16 15:04:08 +00:00
Ahaan Ugale
30704c1b85 Add UiTranslationStateCallback.
This is primarily intended for Input Methods, so they can offer
complementary translation experiences to the UI Translation.

But it could also be useful to the applications being translated too, so
it's added to UiTranslationManager.

The states are intentionally different from the ones in the View API -
these are about the UI Translation feature lifecycle, whereas the View
states are about the display states (shown/hidden).

Bug: 177500482
Test: manual - with a sample IME
CTS-Coverage-Bug: 182853869
Change-Id: I8255e18c29a229c8ea3b89098b76124ee8955bdc
2021-03-16 03:28:00 +00:00
Joanne Chung
ffcd1fd11e Add TEST_MAPPING for translation.
Bug: 179047265
Test: atest --test-mapping
frameworks/base/core/java/android/view/translation

Change-Id: Ic33c60deea74ca58b1cc5a0c338f51245fac1293
2021-03-05 22:44:53 +08:00
Joanne Chung
19006134b3 Update UiTranslationManager APIs to use contentcapture token parameter
1. Update UiTranslationManager APIs to use ActivityId parameter
2. Keep old APIs definition until AiAi is ready for new APIs.

Bug: 177789967
Test: manual. Local add test app in allow list, and get token from local
content capture service and use it in UiTranslationManager api.

Change-Id: I96aa5704600fd9b81eff7a2f42eefe78a43112da
2021-03-02 22:06:30 +08:00
Joanne Chung
7e3f7d1061 Merge "Add shell commands and dump information for Translation" into sc-dev 2021-03-02 11:39:07 +00:00
Joanne Chung
3a907ab1eb Add shell commands and dump information for Translation
1. Add shell command to allow a temporary override of the
TranslationService that helps e2e CTS tests.
2. Add permission to allow the shell call the UiTranslationManager
APIs for the tests.
3. Dump translation systemservice and activity translation related
information to help debugging

We don't want to leak translation feature now, so we submit the
change about Shell in internal branch.

Bug: 179047265
Test: manual.
1. Switch to temp TranslationService by "adb shell cmd transformer set
<myTranslationService> 12000" and make sure only the same app can
access the APIs when switching to the temp service.
2. adb shell dumpsys transformer
3. adb shell dumpsys activity <myactivity> --translation
(We set "transformer" now to prevent feature leak, the final value is
translation)

Change-Id: I2573b7ea226bd805a951f8346d5370d9c9776364
2021-02-26 11:13:39 +00:00
Bob Badour
d59495855e [LSC] Add LOCAL_LICENSE_KINDS to frameworks/base
Added SPDX-license-identifier-Apache-2.0 to:
  apct-tests/perftests/contentcapture/Android.bp
  apct-tests/perftests/inputmethod/Android.bp
  apex/appsearch/Android.bp
  apex/appsearch/framework/Android.bp
  apex/appsearch/service/Android.bp
  apex/appsearch/testing/Android.bp
  apex/jobscheduler/service/jni/Android.bp
  apex/media/service/Android.bp
  cmds/abx/Android.bp
  cmds/uinput/Android.bp
  cmds/uinput/jni/Android.bp
  core/tests/GameManagerTests/Android.bp
  core/tests/batterystatstests/BatteryStatsLoadTests/Android.bp
  core/tests/batterystatstests/BatteryStatsViewer/Android.bp
  core/tests/devicestatetests/Android.bp
  libs/WindowManager/Shell/tests/flicker/Android.bp
  libs/WindowManager/Shell/tests/flicker/test-apps/flickerapp/Android.bp
  libs/androidfw/fuzz/cursorwindow_fuzzer/Android.bp
  native/android/tests/activitymanager/UidImportanceHelperApps/Android.bp
  native/android/tests/activitymanager/nativeTests/Android.bp
  packages/SettingsLib/BannerMessagePreference/Android.bp
  packages/SettingsLib/CollapsingToolbarBaseActivity/Android.bp
  packages/SettingsLib/EmergencyNumber/Android.bp
  packages/SettingsLib/FooterPreference/Android.bp
  packages/SettingsLib/MainSwitchPreference/Android.bp
  packages/SettingsLib/TopIntroPreference/Android.bp
  packages/SettingsLib/UsageProgressBarPreference/Android.bp
  packages/overlays/AccentColorAmethystOverlay/Android.bp
  packages/overlays/AccentColorAquamarineOverlay/Android.bp
  packages/overlays/AccentColorBlackOverlay/Android.bp
  packages/overlays/AccentColorCarbonOverlay/Android.bp
  packages/overlays/AccentColorCinnamonOverlay/Android.bp
  packages/overlays/AccentColorGreenOverlay/Android.bp
  packages/overlays/AccentColorOceanOverlay/Android.bp
  packages/overlays/AccentColorOrchidOverlay/Android.bp
  packages/overlays/AccentColorPaletteOverlay/Android.bp
  packages/overlays/AccentColorPurpleOverlay/Android.bp
  packages/overlays/AccentColorSandOverlay/Android.bp
  packages/overlays/AccentColorSpaceOverlay/Android.bp
  packages/overlays/AccentColorTangerineOverlay/Android.bp
  packages/overlays/DisplayCutoutEmulationCornerOverlay/Android.bp
  packages/overlays/DisplayCutoutEmulationDoubleOverlay/Android.bp
  packages/overlays/DisplayCutoutEmulationHoleOverlay/Android.bp
  packages/overlays/DisplayCutoutEmulationNarrowOverlay/Android.bp
  packages/overlays/DisplayCutoutEmulationTallOverlay/Android.bp
  packages/overlays/DisplayCutoutEmulationWaterfallOverlay/Android.bp
  packages/overlays/DisplayCutoutEmulationWideOverlay/Android.bp
  packages/overlays/FontNotoSerifSourceOverlay/Android.bp
  packages/overlays/IconPackCircularAndroidOverlay/Android.bp
  packages/overlays/IconPackCircularLauncherOverlay/Android.bp
  packages/overlays/IconPackCircularSettingsOverlay/Android.bp
  packages/overlays/IconPackCircularSystemUIOverlay/Android.bp
  packages/overlays/IconPackCircularThemePickerOverlay/Android.bp
  packages/overlays/IconPackFilledAndroidOverlay/Android.bp
  packages/overlays/IconPackFilledLauncherOverlay/Android.bp
  packages/overlays/IconPackFilledSettingsOverlay/Android.bp
  packages/overlays/IconPackFilledSystemUIOverlay/Android.bp
  packages/overlays/IconPackFilledThemePickerOverlay/Android.bp
  packages/overlays/IconPackKaiAndroidOverlay/Android.bp
  packages/overlays/IconPackKaiLauncherOverlay/Android.bp
  packages/overlays/IconPackKaiSettingsOverlay/Android.bp
  packages/overlays/IconPackKaiSystemUIOverlay/Android.bp
  packages/overlays/IconPackKaiThemePickerOverlay/Android.bp
  packages/overlays/IconPackRoundedAndroidOverlay/Android.bp
  packages/overlays/IconPackRoundedLauncherOverlay/Android.bp
  packages/overlays/IconPackRoundedSettingsOverlay/Android.bp
  packages/overlays/IconPackRoundedSystemUIOverlay/Android.bp
  packages/overlays/IconPackRoundedThemePickerOverlay/Android.bp
  packages/overlays/IconPackSamAndroidOverlay/Android.bp
  packages/overlays/IconPackSamLauncherOverlay/Android.bp
  packages/overlays/IconPackSamSettingsOverlay/Android.bp
  packages/overlays/IconPackSamSystemUIOverlay/Android.bp
  packages/overlays/IconPackSamThemePickerOverlay/Android.bp
  packages/overlays/IconPackVictorAndroidOverlay/Android.bp
  packages/overlays/IconPackVictorLauncherOverlay/Android.bp
  packages/overlays/IconPackVictorSettingsOverlay/Android.bp
  packages/overlays/IconPackVictorSystemUIOverlay/Android.bp
  packages/overlays/IconPackVictorThemePickerOverlay/Android.bp
  packages/overlays/IconShapeHeartOverlay/Android.bp
  packages/overlays/IconShapePebbleOverlay/Android.bp
  packages/overlays/IconShapeRoundedRectOverlay/Android.bp
  packages/overlays/IconShapeSquareOverlay/Android.bp
  packages/overlays/IconShapeSquircleOverlay/Android.bp
  packages/overlays/IconShapeTaperedRectOverlay/Android.bp
  packages/overlays/IconShapeTeardropOverlay/Android.bp
  packages/overlays/IconShapeVesselOverlay/Android.bp
  packages/overlays/NavigationBarMode2ButtonOverlay/Android.bp
  packages/overlays/NavigationBarMode3ButtonOverlay/Android.bp
  packages/overlays/NavigationBarModeGesturalOverlay/Android.bp
  packages/overlays/NavigationBarModeGesturalOverlayExtraWideBack/Android.bp
  packages/overlays/NavigationBarModeGesturalOverlayNarrowBack/Android.bp
  packages/overlays/NavigationBarModeGesturalOverlayWideBack/Android.bp
  packages/overlays/OneHandedModeGesturalOverlay/Android.bp
  packages/services/CameraExtensionsProxy/Android.bp
  services/core/java/com/android/server/speech/Android.bp
  services/musicrecognition/Android.bp
  services/searchui/Android.bp
  services/smartspace/Android.bp
  services/tests/PackageManagerServiceTests/host/libs/IntentVerifyUtils/Android.bp
  services/tests/PackageManagerServiceTests/host/test-apps/DeviceSide/Android.bp
  services/tests/PackageManagerServiceTests/host/test-apps/IntentVerifier/Android.bp
  services/tests/PackageManagerServiceTests/host/test-apps/IntentVerifierTarget/Android.bp
  services/tests/PackageManagerServiceTests/host/test-apps/UsesStaticLibrary/Android.bp
  services/tests/PackageManagerServiceTests/unit/Android.bp
  services/tests/inprocesstests/Android.bp
  services/tests/mockingservicestests/jni/Android.bp
  services/tests/servicestests/test-apps/PackageParsingTestManifests/Android.bp
  services/texttospeech/Android.bp
  services/translation/Android.bp
  tests/BatteryStatsPerfTest/Android.bp
  tests/FlickerTests/test-apps/Android.bp
  tests/Input/Android.bp
  tests/SilkFX/Android.bp
  tests/SurfaceViewBufferTests/Android.bp
  tests/UpdatableSystemFontTest/Android.bp
  tests/UpdatableSystemFontTest/testdata/Android.bp
  tests/benchmarks/internal/Android.bp
  tools/powerstats/Android.bp
  tools/processors/intdef_mappings/Android.bp
  tools/xmlpersistence/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I1b8d155a26a1a589a38abedea5f7f366e00346c6
2021-02-23 13:18:34 -08:00
Joanne Chung
9107e213a6 Find the activity to notify Ui translation state
The implementation after receiving UiTranslatinManager calls. The
implementation after receiving state change will on the follow up
changes.

Bug: 172969740
Test: manual. Use a sample code to call the APIs, the methods are
called as expected.

Change-Id: Ic41c994055b4c580e2bff75313b6498db51b6130
2021-01-22 17:35:41 +08:00
Ahaan Ugale
feb36772c7 Add APIs that can notify client ui translation state.
The initial APIs for ui translation. There is no implementation in
this change, we will implement it in the next CL.

Bug: 172969740
Bug: 176871912
Test: manual. build pass and build success.

Change-Id: I4ae0bc7a695076a87bed73e458396312d87f48c5
2021-01-19 19:09:23 +08:00
Adam He
2653f23d47 Initial layout of translation related APIs.
The initial translation related APIs. The APIs and the implementation
will be revised in the follow up changes. The service register will
on the next changes.

Bug: 173243538
Bug: 176208267
Test: manual verification (build)

Change-Id: Ib7b39e1b548bc6663a81482fa335632e8da18d6a
2021-01-12 21:08:05 +08:00