diff --git a/res/values-iw/lineage_strings.xml b/res/values-iw/lineage_strings.xml
new file mode 100644
index 0000000000000000000000000000000000000000..64b745b58d82f3c4fc14d61593c86eae73132245
--- /dev/null
+++ b/res/values-iw/lineage_strings.xml
@@ -0,0 +1,18 @@
+
+
+
+ הוספת קיצור דרך למסך הפעלה
+
diff --git a/res/values-ug/lineage_strings.xml b/res/values-ug/lineage_strings.xml
new file mode 100644
index 0000000000000000000000000000000000000000..2173131575005db2ac3b090d54294263fa382b90
--- /dev/null
+++ b/res/values-ug/lineage_strings.xml
@@ -0,0 +1,18 @@
+
+
+
+ قوزغاتقۇچ تېزلەتمىسىنى قوش
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 89e40ac4cdc4dabf23778e5bc8b10c8b9c6858da..72abecbb5499bbf426a99d9b131fd7aae4ec085d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -551,7 +551,7 @@
Allow %1$s to access files in %2$s?
- This will let %1$s access current and future content stored in %2$s.
+ This will let "%1$s" access current and future content stored in %2$s.
Can\u2019t use this folder
diff --git a/src/com/android/documentsui/base/Shared.java b/src/com/android/documentsui/base/Shared.java
index 5ac9de4d731724dcffe68a03b8b5b54a29daea03..9f328be6995add615c932b2f17240a3fbf43596e 100644
--- a/src/com/android/documentsui/base/Shared.java
+++ b/src/com/android/documentsui/base/Shared.java
@@ -16,6 +16,9 @@
package com.android.documentsui.base;
+import static android.text.TextUtils.SAFE_STRING_FLAG_SINGLE_LINE;
+import static android.text.TextUtils.SAFE_STRING_FLAG_TRIM;
+
import static com.android.documentsui.base.SharedMinimal.TAG;
import android.app.Activity;
@@ -276,7 +279,7 @@ public final class Shared {
* @return the calling app name or general anonymous name if not found
*/
@NonNull
- public static String getCallingAppName(Activity activity) {
+ public static CharSequence getCallingAppName(Activity activity) {
final String anonymous = activity.getString(R.string.anonymous_application);
final String packageName = getCallingPackageName(activity);
if (TextUtils.isEmpty(packageName)) {
@@ -292,7 +295,12 @@ public final class Shared {
}
CharSequence result = pm.getApplicationLabel(ai);
- return TextUtils.isEmpty(result) ? anonymous : result.toString();
+ if (TextUtils.isEmpty(result)) {
+ return anonymous;
+ }
+
+ return TextUtils.makeSafeForPresentation(
+ result.toString(), 500, 0, SAFE_STRING_FLAG_TRIM | SAFE_STRING_FLAG_SINGLE_LINE);
}
/**
diff --git a/src/com/android/documentsui/dirlist/DirectoryFragment.java b/src/com/android/documentsui/dirlist/DirectoryFragment.java
index feaeb1cba713fa3b5dd774b9e9048e18d17444b7..88c867986af3a79329a02852d2b120d0e2b60fc8 100644
--- a/src/com/android/documentsui/dirlist/DirectoryFragment.java
+++ b/src/com/android/documentsui/dirlist/DirectoryFragment.java
@@ -1560,10 +1560,5 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
public ActionHandler getActionHandler() {
return mActions;
}
-
- @Override
- public String getCallingAppName() {
- return Shared.getCallingAppName(mActivity);
- }
}
}
diff --git a/src/com/android/documentsui/dirlist/DocumentsAdapter.java b/src/com/android/documentsui/dirlist/DocumentsAdapter.java
index 41ce73c8ca13207d4f5bc18787d57f032d092c8d..b32c15335bb65d021bb280fd443e7feb84d2c38f 100644
--- a/src/com/android/documentsui/dirlist/DocumentsAdapter.java
+++ b/src/com/android/documentsui/dirlist/DocumentsAdapter.java
@@ -90,7 +90,6 @@ public abstract class DocumentsAdapter extends RecyclerView.Adapter
+
+ @Before
+ fun setUp() {
+ MockitoAnnotations.openMocks(this)
+ whenever(mockActivity.resources).thenReturn(resources)
+ whenever(mockActivity.packageManager).thenReturn(pm)
+ whenever(resources.getString(R.string.anonymous_application)).thenReturn(ANONYMOUS_PACKAGE)
+ whenever(mockActivity.callingPackage).thenReturn(PACKAGE_NAME)
+ }
+
+ @Test
+ fun testNameIsSanitized() {
+ val info = ApplicationInfo()
+ whenever(pm.getApplicationInfo(PACKAGE_NAME, 0)).thenReturn(info)
+
+ whenever(pm.getApplicationLabel(eq(info))).thenReturn(testData.first)
+ assertEquals(Shared.getCallingAppName(mockActivity), testData.second)
+ }
+}