7171 '../../../prebuilts/tools/common/google-java-format/google-java-format' )
7272
7373# Miscellaneous constants
74- CHANGEID_FILE_NAME = 'synced_jetpack_changeid .txt'
74+ SHA_FILE_NAME = 'synced_jetpack_sha .txt'
7575
7676
7777class ExportToFramework :
@@ -133,7 +133,7 @@ def _TransformCommonCode(self, contents):
133133 flags = re .MULTILINE )
134134
135135 # Apply in-place replacements
136- return (contents
136+ contents = (contents
137137 .replace ('androidx.appsearch.app' , 'android.app.appsearch' )
138138 .replace (
139139 'androidx.appsearch.localstorage.' ,
@@ -161,12 +161,18 @@ def _TransformCommonCode(self, contents):
161161 .replace ('@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)' , '' )
162162 .replace ('Preconditions.checkNotNull(' , 'Objects.requireNonNull(' )
163163 .replace ('ObjectsCompat.' , 'Objects.' )
164+
164165 .replace ('/*@exportToFramework:CurrentTimeMillisLong*/' , '@CurrentTimeMillisLong' )
165166 .replace ('/*@exportToFramework:UnsupportedAppUsage*/' , '@UnsupportedAppUsage' )
166167 .replace ('<!--@exportToFramework:hide-->' , '@hide' )
167168 .replace ('// @exportToFramework:skipFile()' , '' )
168169 )
169170
171+ # Jetpack methods have the Async suffix, but framework doesn't. Strip the Async suffix
172+ # to allow the same documentation to compile for both.
173+ contents = re .sub (r'(#[a-zA-Z0-9_]+)Async}' , r'\1}' , contents )
174+ return contents
175+
170176 def _TransformTestCode (self , contents ):
171177 contents = (contents
172178 .replace ('androidx.appsearch.testutil.' , 'android.app.appsearch.testutil.' )
@@ -318,18 +324,18 @@ def ExportCode(self):
318324 self ._ExportImplCode ()
319325 self ._FormatWrittenFiles ()
320326
321- def WriteChangeIdFile (self , changeid ):
322- """Copies the changeid of the most recent public CL into a file on the framework side.
327+ def WriteShaFile (self , sha ):
328+ """Copies the git sha of the most recent public CL into a file on the framework side.
323329
324330 This file is used for tracking, to determine what framework is synced to.
325331
326- You must always provide a changeid of an exported, preferably even submitted CL . If you
327- abandon the CL pointed to by this changeid , the next person syncing framework will be unable
328- to find what CL it is synced to.
332+ You must always provide a sha of a submitted submitted git commit . If you abandon the CL
333+ pointed to by this sha , the next person syncing framework will be unable to find what CL it
334+ is synced to.
329335 """
330- file_path = os .path .join (self ._framework_appsearch_root , CHANGEID_FILE_NAME )
336+ file_path = os .path .join (self ._framework_appsearch_root , SHA_FILE_NAME )
331337 with open (file_path , 'w' ) as fh :
332- print (changeid , file = fh )
338+ print (sha , file = fh )
333339 print ('Wrote "%s"' % file_path )
334340
335341
@@ -339,6 +345,12 @@ def WriteChangeIdFile(self, changeid):
339345 sys .argv [0 ]),
340346 file = sys .stderr )
341347 sys .exit (1 )
348+ if sys .argv [2 ].startswith ('I' ):
349+ print ('Error: Git sha "%s" looks like a changeid. Please provide a git sha instead.' % (
350+ sys .argv [2 ]),
351+ file = sys .stderr )
352+ sys .exit (1 )
353+
342354 source_dir = os .path .normpath (os .path .dirname (sys .argv [0 ]))
343355 dest_dir = os .path .normpath (sys .argv [1 ])
344356 dest_dir = os .path .join (dest_dir , 'packages/modules/AppSearch' )
@@ -349,4 +361,4 @@ def WriteChangeIdFile(self, changeid):
349361 sys .exit (1 )
350362 exporter = ExportToFramework (source_dir , dest_dir )
351363 exporter .ExportCode ()
352- exporter .WriteChangeIdFile (sys .argv [2 ])
364+ exporter .WriteShaFile (sys .argv [2 ])
0 commit comments