зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1234629 - Part 0: Make Distribution look in /data/data/$PACKAGE/distribution last. r=rnewman
Call a distribution in /data/data/$PACKAGE/distribution a "data distribution". Right now we read data distributions only in response to writing them via another code path (extracting from APK, or downloading). We don't recognize a data distribution in the same way that we recognize a system distribution (in /system/.../distribution) in the Java code, simply because we don't look for it; and I haven't investigated, but I think that Gecko may in fact recognize a data distribution in this case. This patch simply recognizes data distributions after looking for other distributions. That way data distributions written by the bouncer APK are recognized and initialized, but not given precedence over other distribution channels. --HG-- extra : histedit_source : f2edefc209e653331b1afd731383e43b1e2cb320%2C3a5870bed776214d8656e530e4cb29fd7ddf02e8 extra : rebase_source : 7df42cfb75713b4630ed5e60583bcd9ab9612849 extra : commitid : HnKxkzVG9TW extra : source : 7a62e97f07c2c90d9f34c2c7de40f3cb193f6312 extra : amend_source : e581fa3a30abdeaa903be04e48a296c8da4ed482
This commit is contained in:
Родитель
8c29d35e3b
Коммит
9069995ab8
|
@ -463,11 +463,13 @@ public class Distribution {
|
|||
return true;
|
||||
}
|
||||
|
||||
// We try the install intent, then the APK, then the system directory.
|
||||
// We try to find the install intent, then the APK, then the system directory, and finally
|
||||
// an already copied distribution. Already copied might originate from the bouncer APK.
|
||||
final boolean distributionSet =
|
||||
checkIntentDistribution(referrer) ||
|
||||
copyAndCheckAPKDistribution() ||
|
||||
checkSystemDistribution();
|
||||
checkSystemDistribution() ||
|
||||
checkDataDistribution();
|
||||
|
||||
// If this is our first run -- and thus we weren't already in STATE_NONE or STATE_SET above --
|
||||
// and we didn't find a distribution already, then we should hold on to callbacks in case we
|
||||
|
|
|
@ -137,6 +137,8 @@ public class testDistribution extends ContentProviderTest {
|
|||
|
||||
// Pre-clear distribution pref, run basic preferences and en-US localized preferences Tests
|
||||
clearDistributionPref();
|
||||
clearDistributionFromDataData();
|
||||
|
||||
setTestLocale("en-US");
|
||||
try {
|
||||
initDistribution(mockPackagePath);
|
||||
|
@ -154,6 +156,7 @@ public class testDistribution extends ContentProviderTest {
|
|||
|
||||
// Pre-clear distribution pref, and run es-MX localized preferences Test
|
||||
clearDistributionPref();
|
||||
clearDistributionFromDataData();
|
||||
setTestLocale("es-MX");
|
||||
initDistribution(mockPackagePath);
|
||||
checkLocalizedPreferences("es-MX");
|
||||
|
@ -161,9 +164,11 @@ public class testDistribution extends ContentProviderTest {
|
|||
// Test the (stubbed) download interaction.
|
||||
setTestLocale("en-US");
|
||||
clearDistributionPref();
|
||||
clearDistributionFromDataData();
|
||||
doTestValidReferrerIntent();
|
||||
|
||||
clearDistributionPref();
|
||||
clearDistributionFromDataData();
|
||||
doTestInvalidReferrerIntent();
|
||||
}
|
||||
|
||||
|
@ -503,6 +508,22 @@ public class testDistribution extends ContentProviderTest {
|
|||
TestableDistribution.clearReferrerDescriptorForTesting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears any distribution found in /data/data.
|
||||
*/
|
||||
private void clearDistributionFromDataData() throws Exception {
|
||||
File dataDir = new File(mActivity.getApplicationInfo().dataDir);
|
||||
|
||||
// Recursively delete distribution files that Distribution.init copied to data directory.
|
||||
File distDir = new File(dataDir, "distribution");
|
||||
if (distDir.exists()) {
|
||||
mAsserter.dumpLog("Clearing distribution from " + distDir.getAbsolutePath());
|
||||
delete(distDir);
|
||||
} else {
|
||||
mAsserter.dumpLog("No distribution to clear from " + distDir.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
// TODO: Set up the content provider after setting the distribution.
|
||||
|
@ -527,10 +548,7 @@ public class testDistribution extends ContentProviderTest {
|
|||
File mockPackage = new File(dataDir, MOCK_PACKAGE);
|
||||
mAsserter.ok(mockPackage.delete(), "clean up mock package", "deleted " + mockPackage.getPath());
|
||||
|
||||
// Recursively delete distribution files that Distribution.init copied to data directory.
|
||||
File distDir = new File(dataDir, "distribution");
|
||||
delete(distDir);
|
||||
|
||||
clearDistributionFromDataData();
|
||||
clearDistributionPref();
|
||||
|
||||
super.tearDown();
|
||||
|
|
Загрузка…
Ссылка в новой задаче