xref: /aosp_15_r20/external/golang-protobuf/android/android.go (revision 1c12ee1efe575feb122dbf939ff15148a3b3e8f2)
1*1c12ee1eSDan Willemsen// Package android provides android-specific extensions to the upstream module.
2*1c12ee1eSDan Willemsenpackage android
3*1c12ee1eSDan Willemsen
4*1c12ee1eSDan Willemsenimport "google.golang.org/protobuf/internal/detrand"
5*1c12ee1eSDan Willemsen
6*1c12ee1eSDan Willemsen// DisableRand disables the randomness introduced into JSON and Text encodings.
7*1c12ee1eSDan Willemsen// This function is not concurrent-safe and must be called during program init.
8*1c12ee1eSDan Willemsen//
9*1c12ee1eSDan Willemsen// This does not guarantee long term stability of the JSON/Text encodings, but
10*1c12ee1eSDan Willemsen// that isn't necessary in Soong or similar build tools. They are only
11*1c12ee1eSDan Willemsen// interested in longer stable periods, as any change in the output may
12*1c12ee1eSDan Willemsen// introduce significant extra building during incremental builds. That price
13*1c12ee1eSDan Willemsen// is expected when upgrading library versions (and will be paid then even
14*1c12ee1eSDan Willemsen// without a format change, as the reader and writer packages will often both
15*1c12ee1eSDan Willemsen// change), but is not desired when changing other parts of the executables.
16*1c12ee1eSDan Willemsen//
17*1c12ee1eSDan Willemsen// See https://github.com/golang/protobuf/issues/1121 for more discussion.
18*1c12ee1eSDan Willemsenfunc DisableRand() {
19*1c12ee1eSDan Willemsen	detrand.Disable()
20*1c12ee1eSDan Willemsen}
21