36 parser = argparse.ArgumentParser(
37 description='Checks Flutter Android library for forbidden imports'
38 )
39 parser.add_argument('--stamp', type=str, required=True)
40 parser.add_argument('--files', type=str, required=True, nargs='+')
41 args = parser.parse_args()
42
43 open(args.stamp, 'a').close()
44
45 bad_log_files = []
46 bad_trace_files = []
47 bad_version_codes_files = []
48
49 for file in args.files:
50 if (file.endswith(os.path.join('io', 'flutter', 'Log.java')) or
51 file.endswith(os.path.join('io', 'flutter', 'util', 'TraceSection.java')) or
52 file.endswith(os.path.join('io', 'flutter', 'Build.java'))):
53 continue
54 with open(file) as f:
55 contents = f.read()
56 if ANDROID_LOG_CLASS in contents:
57 bad_log_files.append(file)
58 if ANDROIDX_TRACE_CLASS in contents or ANDROID_TRACE_CLASS in contents:
59 bad_trace_files.append(file)
60 if ANDROID_BUILD_VERSION_CODE_CLASS in contents:
61 bad_version_codes_files.append(file)
62
63
64
65
66
67
68
69
70 has_bad_files =
CheckBadFiles(bad_log_files, ANDROID_LOG_CLASS,
72 bad_trace_files, 'android[x].tracing.Trace', FLUTTER_TRACE_CLASS
74 bad_version_codes_files, 'android.os.Build.VERSION_CODES',
75 'io.flutter.Build.API_LEVELS'
76 )
77
78 if has_bad_files:
79 return 1
80
81 return 0
82
83