diff options
| author | 2024-11-11 11:36:40 -0800 | |
|---|---|---|
| committer | 2024-11-11 20:52:25 +0000 | |
| commit | edd252ce397dec4807fbb589990475b393453db9 (patch) | |
| tree | 08b46a981527877d68b39eff45b7dc570aa33c17 | |
| parent | d22f0f95a595674f79287dc9880da17612f4b0c3 (diff) | |
Remove legacy database upgrade paths in AppWidgetServiceImpl.
The database upgrades deal with the multi user change from Android 4 to 5.
No modern device can have a database with the old format and the code is
confusing, so needs to be removed.
Bug: 378518205
Test: AppWidgetServiceImplTest
Flag: EXEMPT code cleanup
Change-Id: I4cfb2d40ddb3b48a238b4d72e9355a4387faee2b
| -rw-r--r-- | services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java | 41 |
1 files changed, 6 insertions, 35 deletions
diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java index 261da4dc097f..0bd879b7568d 100644 --- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java +++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java @@ -187,11 +187,6 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku // Simple flag to enable/disable debug logging. private static final boolean DEBUG = Build.IS_DEBUGGABLE; - // String constants for XML schema migration related to changes in keyguard package. - private static final String OLD_KEYGUARD_HOST_PACKAGE = "android"; - private static final String NEW_KEYGUARD_HOST_PACKAGE = "com.android.keyguard"; - private static final int KEYGUARD_HOST_ID = 0x4b455947; - // Filename for app widgets state persisted on disk. private static final String STATE_FILENAME = "appwidgets.xml"; @@ -211,6 +206,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku private static final int UNKNOWN_USER_ID = -10; // Version of XML schema for app widgets. Bump if the stored widgets need to be upgraded. + // Version 1 introduced in 2014 - Android 5.0 private static final int CURRENT_VERSION = 1; // Every widget update request is associated which an increasing sequence number. This is @@ -4428,19 +4424,11 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku int version = fromVersion; - // Update 1: keyguard moved from package "android" to "com.android.keyguard" + // Update 1: From version 0 to 1, was used from Android 4 to Android 5. It updated the + // location of the keyguard widget database. No modern device will have db version 0. if (version == 0) { - HostId oldHostId = new HostId(Process.myUid(), - KEYGUARD_HOST_ID, OLD_KEYGUARD_HOST_PACKAGE); - - Host host = lookupHostLocked(oldHostId); - if (host != null) { - final int uid = getUidForPackage(NEW_KEYGUARD_HOST_PACKAGE, - UserHandle.USER_SYSTEM); // Keyguard explicitly runs as the system user - if (uid >= 0) { - host.id = new HostId(uid, KEYGUARD_HOST_ID, NEW_KEYGUARD_HOST_PACKAGE); - } - } + Slog.e(TAG, "Found widget database with version 0, this should not be possible," + + " forcing upgrade to version 1"); version = 1; } @@ -4450,25 +4438,8 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku } } - private static File getStateFile(int userId) { - return new File(Environment.getUserSystemDirectory(userId), STATE_FILENAME); - } - private static AtomicFile getSavedStateFile(int userId) { - File dir = Environment.getUserSystemDirectory(userId); - File settingsFile = getStateFile(userId); - // USER_SYSTEM is explicit here, the old file only ever existed for user 0. - if (!settingsFile.exists() && userId == UserHandle.USER_SYSTEM) { - if (!dir.exists()) { - dir.mkdirs(); - } - // Migrate old data - File oldFile = new File("/data/system/" + STATE_FILENAME); - // Method doesn't throw an exception on failure. Ignore any errors - // in moving the file (like non-existence) - oldFile.renameTo(settingsFile); - } - return new AtomicFile(settingsFile); + return new AtomicFile(new File(Environment.getUserSystemDirectory(userId), STATE_FILENAME)); } void onUserStopped(int userId) { |