Skip to content

Commit

Permalink
Roll internal Google Play Services (Chromium part)
Browse files Browse the repository at this point in the history
BUG=613768

TBR=jbudorick@chromium.org,agrieve@chromium.org,mariakhomenko@chromium.org
NOTRY=true

(skipping trybots because previous, identical patch
passed CQ, and because this is needed to fix the tree)

Review-Url: https://codereview.chromium.org/2088073002
Cr-Commit-Position: refs/heads/master@{#401419}
  • Loading branch information
paulmiller authored and Commit bot committed Jun 22, 2016
1 parent 5e5173a commit c319999
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 24 deletions.
50 changes: 34 additions & 16 deletions build/android/play_services/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@
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 "
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down
17 changes: 16 additions & 1 deletion build/config/android/internal_rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,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,
]
Expand Down Expand Up @@ -586,6 +590,9 @@ if (enable_java_templates) {
"--classpath",
_rebased_android_sdk_jar,
]
foreach(c, _input_jars_paths) {
args += [ "--classpath=" + c ]
}
if (proguard_verbose) {
args += [ "--verbose" ]
}
Expand Down Expand Up @@ -809,7 +816,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
Expand Down Expand Up @@ -1604,7 +1616,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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ public static boolean isIntentChromeOrFirstParty(Intent intent, Context context)
return true;
}
if (ExternalAuthUtils.getInstance().isGoogleSigned(
context.getPackageManager(), ApiCompatibilityUtils.getCreatorPackage(token))) {
context, ApiCompatibilityUtils.getCreatorPackage(token))) {
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,15 @@ public boolean isSystemBuild(PackageManager pm, String packageName) {
* @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;
}
Expand All @@ -129,7 +128,7 @@ private boolean isCallerValid(Context context, int authRequirements, String pack
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;
}
Expand Down Expand Up @@ -216,7 +215,7 @@ public void run() {
public boolean canUseFirstPartyGooglePlayServices(
Context context, UserRecoverableErrorHandler userRecoverableErrorHandler) {
return canUseGooglePlayServices(context, userRecoverableErrorHandler)
&& isGoogleSigned(context.getPackageManager(), context.getPackageName());
&& isChromeGoogleSigned(context);
}

/**
Expand Down

0 comments on commit c319999

Please sign in to comment.