From 9a2e77c3cc6c068b6647e2597211a198dd3b9640 Mon Sep 17 00:00:00 2001 From: Annie Meng Date: Wed, 14 Feb 2018 18:01:51 +0000 Subject: [PATCH] Add TestApis for updateTransportAttributes GTS tests These TestApis are getters to access BackupManagerService transport attributes. This is to validate that BackupManager.updateTransportAttributes system api succeeds when testing in GTS (see ag/3615301). Bug: 72485407 Test: gts-tradefed run gts -m GtsBackupHostTestCases -t com.google.android.gts.backup.BackupManagerTransportAttributesHostSideTest Change-Id: I0edb1aa0fd776e062f800cf7a79de5cd2e2436df --- api/system-current.txt | 6 +- api/test-current.txt | 11 +++ .../android/app/backup/BackupManager.java | 87 +++++++++++++++++++ 3 files changed, 103 insertions(+), 1 deletion(-) diff --git a/api/system-current.txt b/api/system-current.txt index 2d3b65a19b262..25e3a4d10c73b 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -30,8 +30,8 @@ package android { field public static final java.lang.String BIND_RUNTIME_PERMISSION_PRESENTER_SERVICE = "android.permission.BIND_RUNTIME_PERMISSION_PRESENTER_SERVICE"; field public static final java.lang.String BIND_SETTINGS_SUGGESTIONS_SERVICE = "android.permission.BIND_SETTINGS_SUGGESTIONS_SERVICE"; field public static final java.lang.String BIND_TELEPHONY_DATA_SERVICE = "android.permission.BIND_TELEPHONY_DATA_SERVICE"; - field public static final java.lang.String BIND_TEXTCLASSIFIER_SERVICE = "android.permission.BIND_TEXTCLASSIFIER_SERVICE"; field public static final java.lang.String BIND_TELEPHONY_NETWORK_SERVICE = "android.permission.BIND_TELEPHONY_NETWORK_SERVICE"; + field public static final java.lang.String BIND_TEXTCLASSIFIER_SERVICE = "android.permission.BIND_TEXTCLASSIFIER_SERVICE"; field public static final java.lang.String BIND_TRUST_AGENT = "android.permission.BIND_TRUST_AGENT"; field public static final java.lang.String BIND_TV_REMOTE_SERVICE = "android.permission.BIND_TV_REMOTE_SERVICE"; field public static final java.lang.String BLUETOOTH_PRIVILEGED = "android.permission.BLUETOOTH_PRIVILEGED"; @@ -449,7 +449,11 @@ package android.app.backup { method public android.app.backup.RestoreSession beginRestoreSession(); method public void cancelBackups(); method public long getAvailableRestoreToken(java.lang.String); + method public android.content.Intent getConfigurationIntent(java.lang.String); method public java.lang.String getCurrentTransport(); + method public android.content.Intent getDataManagementIntent(java.lang.String); + method public java.lang.String getDataManagementLabel(java.lang.String); + method public java.lang.String getDestinationString(java.lang.String); method public boolean isAppEligibleForBackup(java.lang.String); method public boolean isBackupEnabled(); method public boolean isBackupServiceActive(android.os.UserHandle); diff --git a/api/test-current.txt b/api/test-current.txt index 4cfe4010397ee..9e750ff7cc0f6 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -167,6 +167,17 @@ package android.app.admin { } +package android.app.backup { + + public class BackupManager { + method public android.content.Intent getConfigurationIntent(java.lang.String); + method public android.content.Intent getDataManagementIntent(java.lang.String); + method public java.lang.String getDataManagementLabel(java.lang.String); + method public java.lang.String getDestinationString(java.lang.String); + } + +} + package android.app.usage { public class StorageStatsManager { diff --git a/core/java/android/app/backup/BackupManager.java b/core/java/android/app/backup/BackupManager.java index 6ec0969771c67..debc32bd83eb1 100644 --- a/core/java/android/app/backup/BackupManager.java +++ b/core/java/android/app/backup/BackupManager.java @@ -19,6 +19,7 @@ package android.app.backup; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SystemApi; +import android.annotation.TestApi; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -715,6 +716,92 @@ public class BackupManager { } } + /** + * Returns an {@link Intent} for the specified transport's configuration UI. + * This value is set by {@link #updateTransportAttributes(ComponentName, String, Intent, String, + * Intent, String)}. + * @param transportName The name of the registered transport. + * @hide + */ + @SystemApi + @TestApi + @RequiresPermission(android.Manifest.permission.BACKUP) + public Intent getConfigurationIntent(String transportName) { + if (sService != null) { + try { + return sService.getConfigurationIntent(transportName); + } catch (RemoteException e) { + Log.e(TAG, "getConfigurationIntent() couldn't connect"); + } + } + return null; + } + + /** + * Returns a {@link String} describing where the specified transport is sending data. + * This value is set by {@link #updateTransportAttributes(ComponentName, String, Intent, String, + * Intent, String)}. + * @param transportName The name of the registered transport. + * @hide + */ + @SystemApi + @TestApi + @RequiresPermission(android.Manifest.permission.BACKUP) + public String getDestinationString(String transportName) { + if (sService != null) { + try { + return sService.getDestinationString(transportName); + } catch (RemoteException e) { + Log.e(TAG, "getDestinationString() couldn't connect"); + } + } + return null; + } + + /** + * Returns an {@link Intent} for the specified transport's data management UI. + * This value is set by {@link #updateTransportAttributes(ComponentName, String, Intent, String, + * Intent, String)}. + * @param transportName The name of the registered transport. + * @hide + */ + @SystemApi + @TestApi + @RequiresPermission(android.Manifest.permission.BACKUP) + public Intent getDataManagementIntent(String transportName) { + if (sService != null) { + try { + return sService.getDataManagementIntent(transportName); + } catch (RemoteException e) { + Log.e(TAG, "getDataManagementIntent() couldn't connect"); + } + } + return null; + } + + /** + * Returns a {@link String} describing what the specified transport's data management intent is + * used for. + * This value is set by {@link #updateTransportAttributes(ComponentName, String, Intent, String, + * Intent, String)}. + * + * @param transportName The name of the registered transport. + * @hide + */ + @SystemApi + @TestApi + @RequiresPermission(android.Manifest.permission.BACKUP) + public String getDataManagementLabel(String transportName) { + if (sService != null) { + try { + return sService.getDataManagementLabel(transportName); + } catch (RemoteException e) { + Log.e(TAG, "getDataManagementLabel() couldn't connect"); + } + } + return null; + } + /* * We wrap incoming binder calls with a private class implementation that * redirects them into main-thread actions. This serializes the backup