Refresh legacy permission state right before writing.

This was done for writing all the package settings, but not when
writing runtime permissions only, so we need to do the same thing
before we eventually migrate to new persistence.

This is a resubmission of ag/12960409, and this time we are only
refreshing the state before the actual disk write, instead of whenever
a write is (asynchronously) scheduled.

Bug: 171755668
Bug: 172297495
Test: manual
Test: atest MultiUserPerfTests
Change-Id: I0c69b6a28ea795c6682e28a26be4cac5b644c70b
This commit is contained in:
Hai Zhang
2020-11-06 16:42:33 -08:00
parent bbecd0e7e6
commit f9c011501f
2 changed files with 12 additions and 0 deletions

View File

@@ -5390,6 +5390,8 @@ public final class Settings {
mHandler.removeMessages(userId);
mWriteScheduled.delete(userId);
mPermissionDataProvider.writeLegacyPermissionStateTEMP();
int version = mVersions.get(userId, INITIAL_VERSION);
String fingerprint = mFingerprints.get(userId);

View File

@@ -61,4 +61,14 @@ public interface LegacyPermissionDataProvider {
*/
@NonNull
int[] getGidsForUid(int uid);
/**
* This method should be in PermissionManagerServiceInternal, however it is made available here
* as well to avoid serious performance regression in writePermissionSettings(), which seems to
* be a hot spot and we should delay calling this method until wre are actually writing the
* file, instead of every time an async write is requested.
*
* @see PermissionManagerServiceInternal#writeLegacyPermissionStateTEMP()
*/
void writeLegacyPermissionStateTEMP();
}