Make the default user the current user (not 0)

In #clearValuesAndCheck, values are placed in the value map based on a
key that depends on the current user. When these values are checked
in #call, it uses default user 0 (unless CALL_METHOD_USER_KEY is
populated).

Considering we don't even use getStringForUser when checking the values,
it seems to make sense to check against the userId used to set the
values in #clearValuesAndCheck.

Test: atest TestableSettingsProviderTest
Change-Id: I0ee9313b1394515d9405344482dc1779d15c0819
This commit is contained in:
Heemin Seog
2019-10-24 09:36:34 -07:00
parent 7fe119504e
commit ed590eec31

View File

@@ -14,6 +14,8 @@
package android.testing;
import static org.junit.Assert.assertEquals;
import android.content.ContentProviderClient;
import android.content.Context;
import android.os.Bundle;
@@ -25,8 +27,6 @@ import android.util.Log;
import java.util.HashMap;
import static org.junit.Assert.*;
/**
* Allows calls to android.provider.Settings to be tested easier.
*
@@ -71,7 +71,7 @@ public class TestableSettingsProvider extends MockContentProvider {
public Bundle call(String method, String arg, Bundle extras) {
// Methods are "GET_system", "GET_global", "PUT_secure", etc.
final int userId = extras.getInt(Settings.CALL_METHOD_USER_KEY, 0);
final int userId = extras.getInt(Settings.CALL_METHOD_USER_KEY, UserHandle.myUserId());
final String[] commands = method.split("_", 2);
final String op = commands[0];
final String table = commands[1];