Skip to content

Commit 54289b8

Browse files
author
Amith Yamasani
committed
Fix cache deletion for secondary users
Bug: 7249419 Change-Id: Idbc0f9994508059ebf5055aea961b87e08b3673a
1 parent c56e560 commit 54289b8

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

cmds/installd/commands.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,11 @@ int clone_persona_data(uid_t src_persona, uid_t target_persona, int copy)
271271
return 0;
272272
}
273273

274-
int delete_cache(const char *pkgname)
274+
int delete_cache(const char *pkgname, uid_t persona)
275275
{
276276
char cachedir[PKG_PATH_MAX];
277277

278-
if (create_pkg_path(cachedir, pkgname, CACHE_DIR_POSTFIX, 0))
278+
if (create_pkg_path(cachedir, pkgname, CACHE_DIR_POSTFIX, persona))
279279
return -1;
280280

281281
/* delete contents, not the directory, no exceptions */

cmds/installd/installd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static int do_free_cache(char **arg, char reply[REPLY_MAX]) /* TODO int:free_siz
7272

7373
static int do_rm_cache(char **arg, char reply[REPLY_MAX])
7474
{
75-
return delete_cache(arg[0]); /* pkgname */
75+
return delete_cache(arg[0], atoi(arg[1])); /* pkgname, userid */
7676
}
7777

7878
static int do_get_size(char **arg, char reply[REPLY_MAX])
@@ -142,7 +142,7 @@ struct cmdinfo cmds[] = {
142142
{ "rename", 2, do_rename },
143143
{ "fixuid", 3, do_fixuid },
144144
{ "freecache", 1, do_free_cache },
145-
{ "rmcache", 1, do_rm_cache },
145+
{ "rmcache", 2, do_rm_cache },
146146
{ "getsize", 5, do_get_size },
147147
{ "rmuserdata", 2, do_rm_user_data },
148148
{ "movefiles", 0, do_movefiles },

cmds/installd/installd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ int delete_user_data(const char *pkgname, uid_t persona);
199199
int make_user_data(const char *pkgname, uid_t uid, uid_t persona);
200200
int delete_persona(uid_t persona);
201201
int clone_persona_data(uid_t src_persona, uid_t target_persona, int copy);
202-
int delete_cache(const char *pkgname);
202+
int delete_cache(const char *pkgname, uid_t persona);
203203
int move_dex(const char *src, const char *dst);
204204
int rm_dex(const char *path);
205205
int protect(char *pkgname, gid_t gid);

services/java/com/android/server/pm/Installer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,12 @@ public int fixUid(String name, int uid, int gid) {
254254
return execute(builder.toString());
255255
}
256256

257-
public int deleteCacheFiles(String name) {
257+
public int deleteCacheFiles(String name, int userId) {
258258
StringBuilder builder = new StringBuilder("rmcache");
259259
builder.append(' ');
260260
builder.append(name);
261+
builder.append(' ');
262+
builder.append(userId);
261263
return execute(builder.toString());
262264
}
263265

services/java/com/android/server/pm/PackageManagerService.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8540,11 +8540,10 @@ private boolean deleteApplicationCacheFilesLI(String packageName, int userId) {
85408540
Slog.w(TAG, "Package " + packageName + " has no applicationInfo.");
85418541
return false;
85428542
}
8543-
// TODO: Pass userId to deleteCacheFiles
8544-
int retCode = mInstaller.deleteCacheFiles(packageName);
8543+
int retCode = mInstaller.deleteCacheFiles(packageName, userId);
85458544
if (retCode < 0) {
85468545
Slog.w(TAG, "Couldn't remove cache files for package: "
8547-
+ packageName);
8546+
+ packageName + " u" + userId);
85488547
return false;
85498548
}
85508549
return true;

0 commit comments

Comments
 (0)