summaryrefslogtreecommitdiff
path: root/java/src/com
diff options
context:
space:
mode:
author Joshua Trask <joshtrask@google.com> 2023-03-13 19:57:27 +0000
committer Joshua Trask <joshtrask@google.com> 2023-03-14 15:01:18 +0000
commit961d141bc72743ee8c42ce21bb6b0e5e01b30c4c (patch)
treec6e03189e14ca37a925c8deaafafd1483575a722 /java/src/com
parente7f8555d956c8bf5f338a182d8023b2740edc389 (diff)
Stop sharing framework strings from unbundled Java
This kind of sharing was a relic of unbundling, and is known to cause inscrutable failures (e.g. b/270760957) when the unbundled tests were run on a device with an out-of-date framework version. We've already hard-forked (duplicated into the IntentResolver package) most string resources, and this CL addresses the remainder, w/ exceptions: 1. Layout XML and other resource files may not have the same compatibility issues, so I've left them unchanged or now; we may need to make a similar change to those files in the future. 2. I left one string, `com.android.internal.R.string.copy`, because I don't think we'd ever want to diverge from the system value and it's currently exported in the frameworks `public-final.xml` resource (so there's no risk of binary-incompatibility issues). In some cases, the resource-sharing wasn't apparent due to file-level imports of `com.android.internal.R`; I removed those imports (so that all the unbundled code loads resources from the `intentresolver` package by default) and converted the non-string resource references to explicitly reference the framework symbols by fully-qualified name. This only addresses string resources and may be inadequate to prevent all regressions in the class of b/270760957, and view ID resources are particularly concerning because it wouldn't be straightforward to fix them by an analogous "hard-fork" process. In fact, an earlier workaround (removed in ag/20065287) had separate cases specifically to address resource sharing for strings vs. view IDs, so we may expect to need some fix there. If we encounter similar regressions based on the view IDs (and don't have any better ideas), we may be able to reinstate the workaround from ag/20065287 (just for the view IDs; strings should never need the old workaround now). Bug: 270760957 Test: `atest IntentResolverUnitTests`, before and after adding a new placeholder string resource at the top of frameworks' `strings.xml`. Prior to this CL, that modification would've caused the tests to start failing unless the framework was rebuilt (e.g. by `mp droid`). Change-Id: Ifaf069124ba677a79517894d7aba847c5d869b74
Diffstat (limited to 'java/src/com')
-rw-r--r--java/src/com/android/intentresolver/ChooserActionFactory.java2
-rw-r--r--java/src/com/android/intentresolver/ChooserRequestParameters.java3
-rw-r--r--java/src/com/android/intentresolver/IntentForwarderActivity.java4
-rw-r--r--java/src/com/android/intentresolver/NoAppsAvailableEmptyStateProvider.java1
-rw-r--r--java/src/com/android/intentresolver/ResolverActivity.java66
-rw-r--r--java/src/com/android/intentresolver/WorkProfilePausedEmptyStateProvider.java1
6 files changed, 35 insertions, 42 deletions
diff --git a/java/src/com/android/intentresolver/ChooserActionFactory.java b/java/src/com/android/intentresolver/ChooserActionFactory.java
index 947155f3..82103b39 100644
--- a/java/src/com/android/intentresolver/ChooserActionFactory.java
+++ b/java/src/com/android/intentresolver/ChooserActionFactory.java
@@ -386,7 +386,7 @@ public final class ChooserActionFactory implements ChooserContentPreviewUi.Actio
final DisplayResolveInfo dri = DisplayResolveInfo.newDisplayResolveInfo(
originalIntent,
ri,
- context.getString(com.android.internal.R.string.screenshot_edit),
+ context.getString(R.string.screenshot_edit),
"",
resolveIntent,
null);
diff --git a/java/src/com/android/intentresolver/ChooserRequestParameters.java b/java/src/com/android/intentresolver/ChooserRequestParameters.java
index 3d99e475..dbd72a1f 100644
--- a/java/src/com/android/intentresolver/ChooserRequestParameters.java
+++ b/java/src/com/android/intentresolver/ChooserRequestParameters.java
@@ -310,8 +310,7 @@ public class ChooserRequestParameters {
requestedTitle = null;
}
- int defaultTitleRes =
- (requestedTitle == null) ? com.android.internal.R.string.chooseActivity : 0;
+ int defaultTitleRes = (requestedTitle == null) ? R.string.chooseActivity : 0;
return Pair.create(requestedTitle, defaultTitleRes);
}
diff --git a/java/src/com/android/intentresolver/IntentForwarderActivity.java b/java/src/com/android/intentresolver/IntentForwarderActivity.java
index 78240250..5e8945f1 100644
--- a/java/src/com/android/intentresolver/IntentForwarderActivity.java
+++ b/java/src/com/android/intentresolver/IntentForwarderActivity.java
@@ -162,13 +162,13 @@ public class IntentForwarderActivity extends Activity {
private String getForwardToPersonalMessage() {
return getSystemService(DevicePolicyManager.class).getResources().getString(
FORWARD_INTENT_TO_PERSONAL,
- () -> getString(com.android.internal.R.string.forward_intent_to_owner));
+ () -> getString(R.string.forward_intent_to_owner));
}
private String getForwardToWorkMessage() {
return getSystemService(DevicePolicyManager.class).getResources().getString(
FORWARD_INTENT_TO_WORK,
- () -> getString(com.android.internal.R.string.forward_intent_to_work));
+ () -> getString(R.string.forward_intent_to_work));
}
private boolean isIntentForwarderResolveInfo(ResolveInfo resolveInfo) {
diff --git a/java/src/com/android/intentresolver/NoAppsAvailableEmptyStateProvider.java b/java/src/com/android/intentresolver/NoAppsAvailableEmptyStateProvider.java
index c1373f4b..d424f295 100644
--- a/java/src/com/android/intentresolver/NoAppsAvailableEmptyStateProvider.java
+++ b/java/src/com/android/intentresolver/NoAppsAvailableEmptyStateProvider.java
@@ -31,7 +31,6 @@ import android.stats.devicepolicy.nano.DevicePolicyEnums;
import com.android.intentresolver.AbstractMultiProfilePagerAdapter.EmptyState;
import com.android.intentresolver.AbstractMultiProfilePagerAdapter.EmptyStateProvider;
import com.android.intentresolver.AbstractMultiProfilePagerAdapter.MyUserIdProvider;
-import com.android.internal.R;
import java.util.List;
diff --git a/java/src/com/android/intentresolver/ResolverActivity.java b/java/src/com/android/intentresolver/ResolverActivity.java
index d224299e..a240968b 100644
--- a/java/src/com/android/intentresolver/ResolverActivity.java
+++ b/java/src/com/android/intentresolver/ResolverActivity.java
@@ -237,47 +237,43 @@ public class ResolverActivity extends FragmentActivity implements
private enum ActionTitle {
VIEW(Intent.ACTION_VIEW,
- com.android.internal.R.string.whichViewApplication,
- com.android.internal.R.string.whichViewApplicationNamed,
- com.android.internal.R.string.whichViewApplicationLabel),
+ R.string.whichViewApplication,
+ R.string.whichViewApplicationNamed,
+ R.string.whichViewApplicationLabel),
EDIT(Intent.ACTION_EDIT,
- com.android.internal.R.string.whichEditApplication,
- com.android.internal.R.string.whichEditApplicationNamed,
- com.android.internal.R.string.whichEditApplicationLabel),
+ R.string.whichEditApplication,
+ R.string.whichEditApplicationNamed,
+ R.string.whichEditApplicationLabel),
SEND(Intent.ACTION_SEND,
- com.android.internal.R.string.whichSendApplication,
- com.android.internal.R.string.whichSendApplicationNamed,
- com.android.internal.R.string.whichSendApplicationLabel),
+ R.string.whichSendApplication,
+ R.string.whichSendApplicationNamed,
+ R.string.whichSendApplicationLabel),
SENDTO(Intent.ACTION_SENDTO,
- com.android.internal.R.string.whichSendToApplication,
- com.android.internal.R.string.whichSendToApplicationNamed,
- com.android.internal.R.string.whichSendToApplicationLabel),
+ R.string.whichSendToApplication,
+ R.string.whichSendToApplicationNamed,
+ R.string.whichSendToApplicationLabel),
SEND_MULTIPLE(Intent.ACTION_SEND_MULTIPLE,
- com.android.internal.R.string.whichSendApplication,
- com.android.internal.R.string.whichSendApplicationNamed,
- com.android.internal.R.string.whichSendApplicationLabel),
+ R.string.whichSendApplication,
+ R.string.whichSendApplicationNamed,
+ R.string.whichSendApplicationLabel),
CAPTURE_IMAGE(MediaStore.ACTION_IMAGE_CAPTURE,
- com.android.internal.R.string.whichImageCaptureApplication,
- com.android.internal.R.string.whichImageCaptureApplicationNamed,
- com.android.internal.R.string.whichImageCaptureApplicationLabel),
+ R.string.whichImageCaptureApplication,
+ R.string.whichImageCaptureApplicationNamed,
+ R.string.whichImageCaptureApplicationLabel),
DEFAULT(null,
- com.android.internal.R.string.whichApplication,
- com.android.internal.R.string.whichApplicationNamed,
- com.android.internal.R.string.whichApplicationLabel),
+ R.string.whichApplication,
+ R.string.whichApplicationNamed,
+ R.string.whichApplicationLabel),
HOME(Intent.ACTION_MAIN,
- com.android.internal.R.string.whichHomeApplication,
- com.android.internal.R.string.whichHomeApplicationNamed,
- com.android.internal.R.string.whichHomeApplicationLabel);
+ R.string.whichHomeApplication,
+ R.string.whichHomeApplicationNamed,
+ R.string.whichHomeApplicationLabel);
// titles for layout that deals with http(s) intents
- public static final int BROWSABLE_TITLE_RES =
- com.android.internal.R.string.whichOpenLinksWith;
- public static final int BROWSABLE_HOST_TITLE_RES =
- com.android.internal.R.string.whichOpenHostLinksWith;
- public static final int BROWSABLE_HOST_APP_TITLE_RES =
- com.android.internal.R.string.whichOpenHostLinksWithApp;
- public static final int BROWSABLE_APP_TITLE_RES =
- com.android.internal.R.string.whichOpenLinksWithApp;
+ public static final int BROWSABLE_TITLE_RES = R.string.whichOpenLinksWith;
+ public static final int BROWSABLE_HOST_TITLE_RES = R.string.whichOpenHostLinksWith;
+ public static final int BROWSABLE_HOST_APP_TITLE_RES = R.string.whichOpenHostLinksWithApp;
+ public static final int BROWSABLE_APP_TITLE_RES = R.string.whichOpenLinksWithApp;
public final String action;
public final int titleRes;
@@ -1361,13 +1357,13 @@ public class ResolverActivity extends FragmentActivity implements
private String getForwardToPersonalMsg() {
return getSystemService(DevicePolicyManager.class).getResources().getString(
FORWARD_INTENT_TO_PERSONAL,
- () -> getString(com.android.internal.R.string.forward_intent_to_owner));
+ () -> getString(R.string.forward_intent_to_owner));
}
private String getForwardToWorkMsg() {
return getSystemService(DevicePolicyManager.class).getResources().getString(
FORWARD_INTENT_TO_WORK,
- () -> getString(com.android.internal.R.string.forward_intent_to_work));
+ () -> getString(R.string.forward_intent_to_work));
}
/**
@@ -1544,7 +1540,7 @@ public class ResolverActivity extends FragmentActivity implements
return getSystemService(DevicePolicyManager.class).getResources().getString(
RESOLVER_WORK_PROFILE_NOT_SUPPORTED,
() -> getString(
- com.android.internal.R.string.activity_resolver_work_profiles_support,
+ R.string.activity_resolver_work_profiles_support,
launcherName),
launcherName);
}
diff --git a/java/src/com/android/intentresolver/WorkProfilePausedEmptyStateProvider.java b/java/src/com/android/intentresolver/WorkProfilePausedEmptyStateProvider.java
index 0333039b..2f3dfbd5 100644
--- a/java/src/com/android/intentresolver/WorkProfilePausedEmptyStateProvider.java
+++ b/java/src/com/android/intentresolver/WorkProfilePausedEmptyStateProvider.java
@@ -29,7 +29,6 @@ import android.stats.devicepolicy.nano.DevicePolicyEnums;
import com.android.intentresolver.AbstractMultiProfilePagerAdapter.EmptyState;
import com.android.intentresolver.AbstractMultiProfilePagerAdapter.EmptyStateProvider;
import com.android.intentresolver.AbstractMultiProfilePagerAdapter.OnSwitchOnWorkSelectedListener;
-import com.android.internal.R;
/**
* Chooser/ResolverActivity empty state provider that returns empty state which is shown when