Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

android 开发源码不知道原因为啥记录很多classindex

最近看别人写android 源码是用okhttp3 websocket 写的源码,但是每个类都有

    static {
        Covode.recordClassIndex(128699);
    }

类似这种加载类的static 方法,这里面的数字有什么用呢?我看了这个里面的源码(recordClassIndex)是往消息队列里面增加数据,但是不知和这里的class 有什么关系呢?为啥每个class 都有个static > recordClassIndex

package com.bytedance.covode.number;

import android.content.Context;
import java.io.File;

public abstract class Covode {

    public static class a {
        com.bytedance.covode.a.a a = new com.bytedance.covode.a.a();
        boolean b;

        public final a a(boolean z) {
            this.b = z;
            return this;
        }

        public final a a(String str) {
            this.a.a = str;
            return this;
        }

        public final a b(boolean z) {
            this.a.c = z;
            return this;
        }

        public a(Context context) {
            this.a.b = context;
        }
    }

    public interface b {
        boolean a(File file);
    }

    private static CovodeNumberImpl getImpl() {
        return CovodeNumberImpl.a;
    }

    public abstract boolean report(b bVar);

    public abstract boolean start(a aVar);

    public static boolean reportCollections(b bVar) {
        return getImpl().report(bVar);
    }

    public static boolean startCollecting(a aVar) {
        return getImpl().start(aVar);
    }

    public static void recordClassIndex(int i) {
        CovodeNumberImpl impl = getImpl();
        if (impl.b == null) {
            if (CovodeNumberImpl.c != null) {
                a aVar = CovodeNumberImpl.c;
                if (aVar.c) {
                    if (i < 32767) {
                        aVar.b.add(Short.valueOf((short) i));
                    } else {
                        aVar.a.add(Integer.valueOf(i));
                    }
                }
            }
        } else if (impl.b.b) {
            impl.recordClassIndexToFile(i);
        }
    }
}
package com.bytedance.ies.geckoclient.network;

import android.util.Pair;
import com.bytedance.covode.number.Covode;
import java.util.List;

public interface INetwork {
    static {
        Covode.recordClassIndex(36111);
    }

    String doGet(String str) throws Exception;

    String doPost(String str, String str2) throws Exception;

    String doPost(String str, List<Pair<String, String>> list) throws Exception;

    boolean downloadFile(String str, String str2) throws Exception;
}

    public static void recordClassIndex(int i) {
        CovodeNumberImpl impl = getImpl();
        if (impl.b == null) {
            if (CovodeNumberImpl.c != null) {
                a aVar = CovodeNumberImpl.c;
                if (aVar.c) {
                    if (i < 32767) {
                        aVar.b.add(Short.valueOf((short) i));
                    } else {
                        aVar.a.add(Integer.valueOf(i));
                    }
                }
            }
        } else if (impl.b.b) {
            impl.recordClassIndexToFile(i);
        }
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...