12ANDROID_LOG_CLASS =
'android.util.Log'
13FLUTTER_LOG_CLASS =
'io.flutter.Log'
15ANDROIDX_TRACE_CLASS =
'androidx.tracing.Trace'
16ANDROID_TRACE_CLASS =
'android.tracing.Trace'
17FLUTTER_TRACE_CLASS =
'io.flutter.util.TraceSection'
19ANDROID_BUILD_VERSION_CODE_CLASS =
'VERSION_CODES'
25 print(
'Illegal import %s detected in the following files:' % bad_class)
26 for bad_file
in bad_files:
27 print(
' - ' + bad_file)
28 print(
'Use %s instead.' % good_class)
36 parser = argparse.ArgumentParser(
37 description=
'Checks Flutter Android library for forbidden imports'
39 parser.add_argument(
'--stamp', type=str, required=
True)
40 parser.add_argument(
'--files', type=str, required=
True, nargs=
'+')
41 args = parser.parse_args()
43 open(args.stamp,
'a').close()
47 bad_version_codes_files = []
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'))):
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)
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'
84if __name__ ==
'__main__':
def CheckBadFiles(bad_files, bad_class, good_class)
def print(*args, **kwargs)