From 7acb0306549d15d756aca1628fddc91a9bfc354a Mon Sep 17 00:00:00 2001 From: Mark Renouf Date: Tue, 12 Sep 2023 19:57:07 -0400 Subject: Remove obsolete code left over from the system process None of this is necessary now that the activity is running in a normal application process. The 'name-based' version of getSharedPreferences works fine. Bug: 300157408 Flag: EXEMPT Test: manually; share content, long-press to pin/unpin; verify across usages and reboots Change-Id: Id056cd377babf397b323b40c52614cd326d5c79e --- .../src/com/android/intentresolver/ChooserActivity.java | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/intentresolver/ChooserActivity.java b/java/src/com/android/intentresolver/ChooserActivity.java index 0101c046..ebe6f04b 100644 --- a/java/src/com/android/intentresolver/ChooserActivity.java +++ b/java/src/com/android/intentresolver/ChooserActivity.java @@ -51,11 +51,9 @@ import android.database.Cursor; import android.graphics.Insets; import android.net.Uri; import android.os.Bundle; -import android.os.Environment; import android.os.SystemClock; import android.os.UserHandle; import android.os.UserManager; -import android.os.storage.StorageManager; import android.service.chooser.ChooserTarget; import android.util.Log; import android.util.Slog; @@ -100,7 +98,6 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import dagger.hilt.android.AndroidEntryPoint; -import java.io.File; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.text.Collator; @@ -421,19 +418,7 @@ public class ChooserActivity extends Hilt_ChooserActivity implements } static SharedPreferences getPinnedSharedPrefs(Context context) { - // The code below is because in the android:ui process, no one can hear you scream. - // The package info in the context isn't initialized in the way it is for normal apps, - // so the standard, name-based context.getSharedPreferences doesn't work. Instead, we - // build the path manually below using the same policy that appears in ContextImpl. - // This fails silently under the hood if there's a problem, so if we find ourselves in - // the case where we don't have access to credential encrypted storage we just won't - // have our pinned target info. - final File prefsFile = new File(new File( - Environment.getDataUserCePackageDirectory(StorageManager.UUID_PRIVATE_INTERNAL, - context.getUserId(), context.getPackageName()), - "shared_prefs"), - PINNED_SHARED_PREFS_NAME + ".xml"); - return context.getSharedPreferences(prefsFile, MODE_PRIVATE); + return context.getSharedPreferences(PINNED_SHARED_PREFS_NAME, MODE_PRIVATE); } @Override -- cgit v1.2.3-59-g8ed1b