Commit 7bc2e1a7 authored by Joshua Pawlicki's avatar Joshua Pawlicki Committed by Commit Bot

Remove account reporting from Android Omaha client

The profile sign-in state is reported via UMA and can be accessed at
go/chrome-sync-signin (Googlers only, sorry).

The number of Google accounts on the device is no longer relevant, since
Play Store can update Chrome without a Google Account on modern devices.

Bug: 1110338
Change-Id: I130f2a6b3edffd1f1f730dbaad0f65784f9fb5e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2346725
Commit-Queue: Tommy Nyquist <nyquist@chromium.org>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Auto-Submit: Joshua Pawlicki <waffles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804080}
parent c99955a5
...@@ -16,17 +16,8 @@ import androidx.annotation.VisibleForTesting; ...@@ -16,17 +16,8 @@ import androidx.annotation.VisibleForTesting;
import org.xmlpull.v1.XmlSerializer; import org.xmlpull.v1.XmlSerializer;
import org.chromium.base.BuildInfo; import org.chromium.base.BuildInfo;
import org.chromium.base.Log;
import org.chromium.base.task.PostTask;
import org.chromium.chrome.browser.identity.SettingsSecureBasedIdentificationGenerator; import org.chromium.chrome.browser.identity.SettingsSecureBasedIdentificationGenerator;
import org.chromium.chrome.browser.identity.UniqueIdentificationGeneratorFactory; import org.chromium.chrome.browser.identity.UniqueIdentificationGeneratorFactory;
import org.chromium.chrome.browser.init.ChromeBrowserInitializer;
import org.chromium.chrome.browser.init.ProcessInitializationHandler;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.signin.IdentityServicesProvider;
import org.chromium.components.signin.AccountManagerFacadeProvider;
import org.chromium.components.signin.identitymanager.IdentityManager;
import org.chromium.content_public.browser.UiThreadTaskTraits;
import org.chromium.ui.base.DeviceFormFactor; import org.chromium.ui.base.DeviceFormFactor;
import java.io.IOException; import java.io.IOException;
...@@ -108,12 +99,6 @@ public abstract class RequestGenerator { ...@@ -108,12 +99,6 @@ public abstract class RequestGenerator {
serializer.attribute(null, "lang", getLanguage()); serializer.attribute(null, "lang", getLanguage());
serializer.attribute(null, "installage", String.valueOf(installAge)); serializer.attribute(null, "installage", String.valueOf(installAge));
serializer.attribute(null, "ap", getAdditionalParameters()); serializer.attribute(null, "ap", getAdditionalParameters());
// <code>_numaccounts</code> is actually number of profiles, which is always one for
// Chrome Android.
serializer.attribute(null, "_numaccounts", "1");
serializer.attribute(null, "_numgoogleaccountsondevice",
String.valueOf(getNumGoogleAccountsOnDevice()));
serializer.attribute(null, "_numsignedin", String.valueOf(getNumSignedIn()));
serializer.attribute( serializer.attribute(
null, "_dl_mgr_disabled", String.valueOf(getDownloadManagerState())); null, "_dl_mgr_disabled", String.valueOf(getDownloadManagerState()));
...@@ -194,48 +179,6 @@ public abstract class RequestGenerator { ...@@ -194,48 +179,6 @@ public abstract class RequestGenerator {
return applicationLabel + ";" + brand + ";" + model; return applicationLabel + ";" + brand + ";" + model;
} }
/**
* Returns the number of accounts on the device, bucketed into:
* 0 accounts, 1 account, or 2+ accounts.
*
* @return Number of accounts on the device, bucketed as above.
*/
@VisibleForTesting
public int getNumGoogleAccountsOnDevice() {
// RequestGenerator may be invoked from JobService or AlarmManager (through OmahaService),
// so have to make sure AccountManagerFacade instance is initialized.
// TODO(waffles@chromium.org): Ideally, this should be asynchronous.
int numAccounts = 0;
try {
PostTask.runSynchronously(UiThreadTaskTraits.DEFAULT,
() -> ProcessInitializationHandler.getInstance().initializePreNative());
numAccounts = AccountManagerFacadeProvider.getInstance().tryGetGoogleAccounts().size();
} catch (Exception e) {
Log.e(TAG, "Cannot get number of accounts.", e);
}
return numAccounts < 2 ? numAccounts : 2;
}
/**
* Determine number of accounts signed in.
*/
@VisibleForTesting
public int getNumSignedIn() {
try {
return PostTask.runSynchronously(UiThreadTaskTraits.DEFAULT, () -> {
// The native needs to be loaded for the usage of IdentityManager.
ChromeBrowserInitializer.getInstance().handleSynchronousStartup();
// We only have a single account.
IdentityManager identityManager = IdentityServicesProvider.get().getIdentityManager(
Profile.getLastUsedRegularProfile());
return identityManager.hasPrimaryAccount() ? 1 : 0;
});
} catch (Exception e) {
Log.e(TAG, "Cannot get number of signed in accounts:", e);
}
return 0;
}
/** /**
* Returns DownloadManager system service enabled state as * Returns DownloadManager system service enabled state as
* -1 - manager state unknown * -1 - manager state unknown
......
...@@ -23,7 +23,6 @@ import org.chromium.base.test.util.Feature; ...@@ -23,7 +23,6 @@ import org.chromium.base.test.util.Feature;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.omaha.MockRequestGenerator; import org.chromium.chrome.test.omaha.MockRequestGenerator;
import org.chromium.chrome.test.omaha.MockRequestGenerator.DeviceType; import org.chromium.chrome.test.omaha.MockRequestGenerator.DeviceType;
import org.chromium.chrome.test.omaha.MockRequestGenerator.SignedInStatus;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
...@@ -89,8 +88,8 @@ public class OmahaBaseTest { ...@@ -89,8 +88,8 @@ public class OmahaBaseTest {
@Override @Override
protected RequestGenerator createRequestGenerator(Context context) { protected RequestGenerator createRequestGenerator(Context context) {
mMockGenerator = new MockRequestGenerator(context, mMockGenerator = new MockRequestGenerator(
mIsOnTablet ? DeviceType.TABLET : DeviceType.HANDSET, SignedInStatus.FALSE); context, mIsOnTablet ? DeviceType.TABLET : DeviceType.HANDSET);
return mMockGenerator; return mMockGenerator;
} }
......
...@@ -29,7 +29,6 @@ import org.chromium.chrome.test.ChromeJUnit4ClassRunner; ...@@ -29,7 +29,6 @@ import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.omaha.AttributeFinder; import org.chromium.chrome.test.omaha.AttributeFinder;
import org.chromium.chrome.test.omaha.MockRequestGenerator; import org.chromium.chrome.test.omaha.MockRequestGenerator;
import org.chromium.chrome.test.omaha.MockRequestGenerator.DeviceType; import org.chromium.chrome.test.omaha.MockRequestGenerator.DeviceType;
import org.chromium.chrome.test.omaha.MockRequestGenerator.SignedInStatus;
import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule; import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule;
import org.chromium.components.signin.identitymanager.IdentityManager; import org.chromium.components.signin.identitymanager.IdentityManager;
...@@ -86,7 +85,7 @@ public class RequestGeneratorTest { ...@@ -86,7 +85,7 @@ public class RequestGeneratorTest {
UniqueIdentificationGeneratorFactory.clearGeneratorMapForTest(); UniqueIdentificationGeneratorFactory.clearGeneratorMapForTest();
// Creating a RequestGenerator should register the identification generator. // Creating a RequestGenerator should register the identification generator.
new MockRequestGenerator(context, DeviceType.HANDSET, SignedInStatus.FALSE); new MockRequestGenerator(context, DeviceType.HANDSET);
// Verify the identification generator exists and is of the correct type. // Verify the identification generator exists and is of the correct type.
UniqueIdentificationGenerator instance = UniqueIdentificationGeneratorFactory.getInstance( UniqueIdentificationGenerator instance = UniqueIdentificationGeneratorFactory.getInstance(
...@@ -98,88 +97,35 @@ public class RequestGeneratorTest { ...@@ -98,88 +97,35 @@ public class RequestGeneratorTest {
@SmallTest @SmallTest
@Feature({"Omaha"}) @Feature({"Omaha"})
public void testHandsetXMLCreationWithInstall() { public void testHandsetXMLCreationWithInstall() {
createAndCheckXML(DeviceType.HANDSET, SignedInStatus.FALSE, true); createAndCheckXML(DeviceType.HANDSET, true);
} }
@Test @Test
@SmallTest @SmallTest
@Feature({"Omaha"}) @Feature({"Omaha"})
public void testHandsetXMLCreationWithoutInstall() { public void testHandsetXMLCreationWithoutInstall() {
createAndCheckXML(DeviceType.HANDSET, SignedInStatus.FALSE, false); createAndCheckXML(DeviceType.HANDSET, false);
} }
@Test @Test
@SmallTest @SmallTest
@Feature({"Omaha"}) @Feature({"Omaha"})
public void testTabletXMLCreationWithInstall() { public void testTabletXMLCreationWithInstall() {
createAndCheckXML(DeviceType.TABLET, SignedInStatus.FALSE, true); createAndCheckXML(DeviceType.TABLET, true);
} }
@Test @Test
@SmallTest @SmallTest
@Feature({"Omaha"}) @Feature({"Omaha"})
public void testTabletXMLCreationWithoutInstall() { public void testTabletXMLCreationWithoutInstall() {
createAndCheckXML(DeviceType.TABLET, SignedInStatus.FALSE, false); createAndCheckXML(DeviceType.TABLET, false);
}
@Test
@SmallTest
@Feature({"Omaha"})
public void testIsSignedIn() {
createAndCheckXML(DeviceType.HANDSET, SignedInStatus.TRUE, false);
}
@Test
@SmallTest
@Feature({"Omaha"})
public void testIsNotSignedIn() {
createAndCheckXML(DeviceType.HANDSET, SignedInStatus.FALSE, false);
}
@Test
@SmallTest
@Feature({"Omaha"})
public void testNoGoogleAccountsRetrieved() {
RequestGenerator generator =
createAndCheckXML(DeviceType.HANDSET, SignedInStatus.TRUE, false);
Assert.assertEquals(0, generator.getNumGoogleAccountsOnDevice());
}
@Test
@SmallTest
@Feature({"Omaha"})
public void testOneGoogleAccountRetrieved() {
RequestGenerator generator = createAndCheckXML(DeviceType.HANDSET, SignedInStatus.TRUE,
false, new Account("clanktester@this.com", "com.google"));
Assert.assertEquals(1, generator.getNumGoogleAccountsOnDevice());
}
@Test
@SmallTest
@Feature({"Omaha"})
public void testTwoGoogleAccountsRetrieved() {
RequestGenerator generator = createAndCheckXML(DeviceType.HANDSET, SignedInStatus.TRUE,
false, new Account("clanktester@gmail.com", "com.google"),
new Account("googleguy@elsewhere.com", "com.google"));
Assert.assertEquals(2, generator.getNumGoogleAccountsOnDevice());
}
@Test
@SmallTest
@Feature({"Omaha"})
public void testThreeGoogleAccountsExist() {
RequestGenerator generator = createAndCheckXML(DeviceType.HANDSET, SignedInStatus.TRUE,
false, new Account("clanktester@gmail.com", "com.google"),
new Account("googleguy@elsewhere.com", "com.google"),
new Account("ImInATest@gmail.com", "com.google"));
Assert.assertEquals(2, generator.getNumGoogleAccountsOnDevice());
} }
/** /**
* Checks that the XML is being created properly. * Checks that the XML is being created properly.
*/ */
private RequestGenerator createAndCheckXML(DeviceType deviceType, SignedInStatus signInStatus, private RequestGenerator createAndCheckXML(
boolean sendInstallEvent, Account... accounts) { DeviceType deviceType, boolean sendInstallEvent, Account... accounts) {
Context targetContext = InstrumentationRegistry.getTargetContext(); Context targetContext = InstrumentationRegistry.getTargetContext();
AdvancedMockContext context = new AdvancedMockContext(targetContext); AdvancedMockContext context = new AdvancedMockContext(targetContext);
...@@ -199,8 +145,7 @@ public class RequestGeneratorTest { ...@@ -199,8 +145,7 @@ public class RequestGeneratorTest {
long installAge = 42; long installAge = 42;
int dateLastActive = 4088; int dateLastActive = 4088;
MockRequestGenerator generator = MockRequestGenerator generator = new MockRequestGenerator(context, deviceType);
new MockRequestGenerator(context, deviceType, signInStatus);
String xml = null; String xml = null;
try { try {
...@@ -241,12 +186,6 @@ public class RequestGeneratorTest { ...@@ -241,12 +186,6 @@ public class RequestGeneratorTest {
checkForAttributeAndValue(xml, "request", "userid", "{" + generator.getDeviceID() + "}"); checkForAttributeAndValue(xml, "request", "userid", "{" + generator.getDeviceID() + "}");
checkForAttributeAndValue(xml, "app", "_numaccounts", "1");
checkForAttributeAndValue(xml, "app", "_numgoogleaccountsondevice",
String.valueOf(generator.getNumGoogleAccountsOnDevice()));
checkForAttributeAndValue(
xml, "app", "_numsignedin", String.valueOf(generator.getNumSignedIn()));
return generator; return generator;
} }
......
...@@ -14,8 +14,6 @@ public class MockRequestGenerator extends RequestGenerator { ...@@ -14,8 +14,6 @@ public class MockRequestGenerator extends RequestGenerator {
HANDSET, TABLET HANDSET, TABLET
} }
public enum SignedInStatus { TRUE, FALSE }
public static final String UUID_PHONE = "uuid_phone"; public static final String UUID_PHONE = "uuid_phone";
public static final String UUID_TABLET = "uuid_tablet"; public static final String UUID_TABLET = "uuid_tablet";
public static final String SERVER_URL = "http://totallylegitserver.com"; public static final String SERVER_URL = "http://totallylegitserver.com";
...@@ -29,13 +27,9 @@ public class MockRequestGenerator extends RequestGenerator { ...@@ -29,13 +27,9 @@ public class MockRequestGenerator extends RequestGenerator {
private final boolean mIsOnTablet; private final boolean mIsOnTablet;
private final boolean mIsSignedIn; public MockRequestGenerator(Context context, DeviceType deviceType) {
public MockRequestGenerator(
Context context, DeviceType deviceType, SignedInStatus signInStatus) {
super(context); super(context);
mIsOnTablet = deviceType == DeviceType.TABLET; mIsOnTablet = deviceType == DeviceType.TABLET;
mIsSignedIn = signInStatus == SignedInStatus.TRUE;
} }
@Override @Override
...@@ -78,11 +72,6 @@ public class MockRequestGenerator extends RequestGenerator { ...@@ -78,11 +72,6 @@ public class MockRequestGenerator extends RequestGenerator {
return LANGUAGE; return LANGUAGE;
} }
@Override
public int getNumSignedIn() {
return mIsSignedIn ? 1 : 0;
}
@Override @Override
public String getAdditionalParameters() { public String getAdditionalParameters() {
return ADDITIONAL_PARAMETERS; return ADDITIONAL_PARAMETERS;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment