Commit 27d98c86 authored by paulmiller's avatar paulmiller Committed by Commit bot

Roll internal Google Play Services (Chromium part)

BUG=613768

Review-Url: https://codereview.chromium.org/2063703004
Cr-Commit-Position: refs/heads/master@{#400736}
parent c017b5d0
......@@ -67,9 +67,6 @@ from play_services import utils
from pylib.utils import argparse_utils
M2_PKG_PATH = os.path.join('com', 'google', 'android', 'gms')
def main():
parser = argparse.ArgumentParser(description=(
"Prepares the Google Play services split client libraries before usage "
......@@ -168,11 +165,16 @@ def _MakeWritable(dir_path):
os.chmod(os.path.join(root, path), st.st_mode | stat.S_IWUSR)
# E.g. turn "base_1p" into "base"
def _RemovePartySuffix(client):
return client[:-3] if client[-3:] == '_1p' else client
def _ImportFromAars(config, tmp_paths, repo):
for client in config.clients:
aar_name = '%s-%s.aar' % (client, config.sdk_version)
aar_path = os.path.join(repo, M2_PKG_PATH, client,
config.sdk_version, aar_name)
client_name = _RemovePartySuffix(client)
aar_name = 'client_' + client + '.aar'
aar_path = os.path.join(repo, client_name, aar_name)
aar_out_path = os.path.join(tmp_paths['imported_clients'], client)
_ExtractAll(aar_path, aar_out_path)
......@@ -203,18 +205,34 @@ def _ProcessResources(config, tmp_paths, repo):
LOCALIZED_VALUES_BASE_NAME = 'values-'
locale_whitelist = set(config.locale_whitelist)
glob_pattern = os.path.join(tmp_paths['imported_clients'], '*', 'res', '*')
for res_dir in glob.glob(glob_pattern):
dir_name = os.path.basename(res_dir)
# The directory structure here is:
# <imported_clients temp dir>/<client name>_1p/res/<res type>/<res file>.xml
for client_dir in os.listdir(tmp_paths['imported_clients']):
client_prefix = _RemovePartySuffix(client_dir) + '_'
if dir_name.startswith('drawable'):
shutil.rmtree(res_dir)
res_path = os.path.join(tmp_paths['imported_clients'], client_dir, 'res')
if not os.path.isdir(res_path):
continue
if dir_name.startswith(LOCALIZED_VALUES_BASE_NAME):
dir_locale = dir_name[len(LOCALIZED_VALUES_BASE_NAME):]
if dir_locale not in locale_whitelist:
shutil.rmtree(res_dir)
for res_type in os.listdir(res_path):
res_type_path = os.path.join(res_path, res_type)
if res_type.startswith('drawable'):
shutil.rmtree(res_type_path)
continue
if res_type.startswith(LOCALIZED_VALUES_BASE_NAME):
dir_locale = res_type[len(LOCALIZED_VALUES_BASE_NAME):]
if dir_locale not in locale_whitelist:
shutil.rmtree(res_type_path)
continue
if res_type.startswith('values'):
# Beginning with v3, resource file names are not necessarily unique, and
# would overwrite each other when merged at build time. Prefix each
# "values" resource file with its client name.
for res_file in os.listdir(res_type_path):
os.rename(os.path.join(res_type_path, res_file),
os.path.join(res_type_path, client_prefix + res_file))
# Reimport files from the whitelist.
for res_path in config.resource_whitelist:
......
......@@ -552,6 +552,10 @@ if (enable_java_templates) {
_proguard_jar_path = "//third_party/proguard/lib/proguard.jar"
}
_output_jar_path = invoker.output_jar_path
_input_jars_paths = []
if (defined(invoker.input_jars_paths)) {
_input_jars_paths += invoker.input_jars_paths
}
inputs = [
_proguard_jar_path,
]
......@@ -585,6 +589,9 @@ if (enable_java_templates) {
"--classpath",
_rebased_android_sdk_jar,
]
foreach(c, _input_jars_paths) {
args += [ "--classpath=" + c ]
}
if (proguard_verbose) {
args += [ "--verbose" ]
}
......@@ -808,7 +815,12 @@ if (enable_java_templates) {
template("process_java_prebuilt") {
set_sources_assignment_filter([])
forward_variables_from(invoker, [ "testonly" ])
forward_variables_from(invoker,
[
"testonly",
"input_jars_paths",
])
assert(!defined(input_jars_paths) || input_jars_paths != [] || true) # Mark as used
assert(invoker.build_config != "")
_build_config = invoker.build_config
......@@ -1603,7 +1615,10 @@ if (enable_java_templates) {
[
"jar_excluded_patterns",
"strip_resource_classes",
"input_jars_paths",
])
assert(!defined(input_jars_paths) || input_jars_paths != [] || true) # Mark as used
visibility = [
":$_ijar_target_name",
":$_template_name",
......
......@@ -710,7 +710,7 @@ public class IntentHandler {
return true;
}
if (ExternalAuthUtils.getInstance().isGoogleSigned(
context.getPackageManager(), ApiCompatibilityUtils.getCreatorPackage(token))) {
context, ApiCompatibilityUtils.getCreatorPackage(token))) {
return true;
}
return false;
......
......@@ -96,16 +96,15 @@ public class ExternalAuthUtils {
* @return whether the currently running application is signed with Google keys.
*/
public boolean isChromeGoogleSigned(Context context) {
return isGoogleSigned(
context.getApplicationContext().getPackageManager(), context.getPackageName());
return isGoogleSigned(context, context.getPackageName());
}
/**
* Returns whether the call is originating from a Google-signed package.
* @param pm Package manager to use for getting package related info.
* @param appContext the current context.
* @param packageName The package name to inquire about.
*/
public boolean isGoogleSigned(PackageManager pm, String packageName) {
public boolean isGoogleSigned(Context context, String packageName) {
// This is overridden in a subclass.
return false;
}
......@@ -129,7 +128,7 @@ public class ExternalAuthUtils {
for (String packageName : callingPackages) {
if (!TextUtils.isEmpty(packageToMatch) && !packageName.equals(packageToMatch)) continue;
matchFound = true;
if ((shouldBeGoogleSigned && !isGoogleSigned(pm, packageName))
if ((shouldBeGoogleSigned && !isGoogleSigned(context, packageName))
|| (shouldBeSystem && !isSystemBuild(pm, packageName))) {
return false;
}
......@@ -216,7 +215,7 @@ public class ExternalAuthUtils {
public boolean canUseFirstPartyGooglePlayServices(
Context context, UserRecoverableErrorHandler userRecoverableErrorHandler) {
return canUseGooglePlayServices(context, userRecoverableErrorHandler)
&& isGoogleSigned(context.getPackageManager(), context.getPackageName());
&& isChromeGoogleSigned(context);
}
/**
......
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