导航菜单

页面标题

页面副标题

moonshot.企业版 v8.14.46 - BmobContentProvider.java 源代码

正在查看: moonshot.企业版 v8.14.46 应用的 BmobContentProvider.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package cn.bmob.v3.util;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.Binder;
import cn.bmob.v3.Bmob;
import cn.bmob.v3.helper.GsonUtil;
import cn.bmob.v3.http.BmobURL;
import cn.bmob.v3.http.bean.Init;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import kp1AiJpjqJHu1Tcnj96z.hX79Ew6mJdJrSjlkdwnl.zSFvmU2XOpXZrEfUxlHp.eu1n4Vdn1yKpcNjlf7lN.C3964;

public class BmobContentProvider extends ContentProvider {
    private static String AUTHORITY;
    private static Uri GAME_CONTENT_URI;
    private static Context mContext;
    private static SQLiteDatabase mDb;
    private static UriMatcher mUriMatcher;
    private static String table;

    public static ContentValues getContentValues() {
        ContentValues contentValues = new ContentValues();
        contentValues.put("_id", (Integer) 1);
        return contentValues;
    }

    public static Cursor getCursor() {
        Binder.getCallingPid();
        return Bmob.getApplicationContext().getContentResolver().query(GAME_CONTENT_URI, new String[]{BmobDbOpenHelper.SESSION_TOKEN, "user", BmobDbOpenHelper.API, BmobDbOpenHelper.FILE, BmobDbOpenHelper.PUSH, BmobDbOpenHelper.IO, "upyun", BmobDbOpenHelper.UY_VERSION, BmobDbOpenHelper.IGNORE_VERSIONS, BmobDbOpenHelper.INSTALLATION}, null, null, null);
    }

    public static String getFile() {
        Cursor cursor = getCursor();
        String fileUrl = BmobURL.getDefault().getFileUrl();
        if (cursor.moveToFirst()) {
            fileUrl = cursor.getString(cursor.getColumnIndex(BmobDbOpenHelper.FILE));
        }
        if (cursor != null) {
            cursor.close();
        }
        return fileUrl;
    }

    public static String getIO() {
        Cursor cursor = getCursor();
        String realTimeDataUrl = BmobURL.getDefault().getRealTimeDataUrl();
        if (cursor.moveToFirst()) {
            realTimeDataUrl = cursor.getString(cursor.getColumnIndex(BmobDbOpenHelper.IO));
        }
        if (cursor != null) {
            cursor.close();
        }
        return realTimeDataUrl;
    }

    public static String getIgnoreVersions() {
        Cursor cursor = getCursor();
        String string = cursor.moveToFirst() ? cursor.getString(cursor.getColumnIndex(BmobDbOpenHelper.IGNORE_VERSIONS)) : "";
        if (cursor != null) {
            cursor.close();
        }
        return string;
    }

    public static String getInstallation() {
        Cursor cursor = getCursor();
        String string = cursor.moveToFirst() ? cursor.getString(cursor.getColumnIndex(BmobDbOpenHelper.INSTALLATION)) : "";
        if (cursor != null) {
            cursor.close();
        }
        return string;
    }

    public static String getSessionToken() {
        Cursor cursor = getCursor();
        if (cursor == null) {
            return null;
        }
        String string = cursor.moveToFirst() ? cursor.getString(cursor.getColumnIndex(BmobDbOpenHelper.SESSION_TOKEN)) : "";
        cursor.close();
        return string;
    }

    public static String getUpyun() {
        Cursor cursor = getCursor();
        String string = cursor.moveToFirst() ? cursor.getString(cursor.getColumnIndex("upyun")) : "";
        if (cursor != null) {
            cursor.close();
        }
        return string;
    }

    public static int getUpyunVersion() {
        Cursor cursor = getCursor();
        int i = cursor.moveToFirst() ? cursor.getInt(cursor.getColumnIndex(BmobDbOpenHelper.UY_VERSION)) : -1;
        if (cursor != null) {
            cursor.close();
        }
        return i;
    }

    public static String getUser() {
        Cursor cursor = getCursor();
        if (cursor != null && cursor.moveToFirst()) {
            String string = cursor.getString(cursor.getColumnIndex("user"));
            cursor.close();
            if (string != null && !"".equals(string)) {
                if (string.startsWith("{")) {
                    return string;
                }
                ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(Base64Coder.decode(string));
                try {
                    CompatibleInputStream compatibleInputStream = new CompatibleInputStream(byteArrayInputStream);
                    Object readObject = compatibleInputStream.readObject();
                    compatibleInputStream.close();
                    byteArrayInputStream.close();
                    return GsonUtil.toJson(readObject);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }

    public static void initProvider(Context context) {
        mContext = context;
        table = "bmob";
        AUTHORITY = mContext.getPackageName() + ".BmobContentProvider";
        GAME_CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/bmob");
        UriMatcher uriMatcher = new UriMatcher(-1);
        mUriMatcher = uriMatcher;
        uriMatcher.addURI(AUTHORITY, "bmob", 0);
        mDb = new BmobDbOpenHelper(mContext).getWritableDatabase();
    }

    public static void removeLocalUser() {
        ContentValues contentValues = getContentValues();
        contentValues.put("user", "");
        updateProvider(contentValues);
    }

    public static void updateIgnoreVersions(String str) {
        ContentValues contentValues = getContentValues();
        contentValues.put(BmobDbOpenHelper.IGNORE_VERSIONS, str);
        updateProvider(contentValues);
    }

    public static void updateInit(Init init) {
        ContentValues contentValues = getContentValues();
        contentValues.put(BmobDbOpenHelper.API, init.getApi());
        contentValues.put(BmobDbOpenHelper.FILE, init.getFile());
        contentValues.put(BmobDbOpenHelper.PUSH, init.getPush());
        contentValues.put(BmobDbOpenHelper.IO, init.getIo());
        updateProvider(contentValues);
    }

    public static void updateInstallation(String str) {
        ContentValues contentValues = getContentValues();
        contentValues.put(BmobDbOpenHelper.INSTALLATION, str);
        updateProvider(contentValues);
    }

    public static void updateProvider(ContentValues contentValues) {
        Cursor cursor = getCursor();
        if (cursor == null) {
            return;
        }
        if (cursor.getCount() > 0) {
            Bmob.getApplicationContext().getContentResolver().update(GAME_CONTENT_URI, contentValues, "_id = ?", new String[]{C3964.f14999});
        } else {
            Bmob.getApplicationContext().getContentResolver().insert(GAME_CONTENT_URI, contentValues);
        }
        cursor.close();
    }

    public static void updateSessionToken(String str) {
        ContentValues contentValues = getContentValues();
        contentValues.put(BmobDbOpenHelper.SESSION_TOKEN, str);
        updateProvider(contentValues);
    }

    public static void updateUpyun(String str, int i) {
        ContentValues contentValues = getContentValues();
        contentValues.put("upyun", str);
        contentValues.put(BmobDbOpenHelper.UY_VERSION, Integer.valueOf(i));
        updateProvider(contentValues);
    }

    public static <T> void updateUser(String str, Class<T> cls) {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        try {
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
            objectOutputStream.writeObject(GsonUtil.toObject(str, cls));
            objectOutputStream.flush();
            byte[] byteArray = byteArrayOutputStream.toByteArray();
            objectOutputStream.close();
            byteArrayOutputStream.close();
            String str2 = new String(Base64Coder.encode(byteArray));
            ContentValues contentValues = getContentValues();
            contentValues.put("user", str2);
            updateProvider(contentValues);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public int delete(Uri uri, String str, String[] strArr) {
        mDb.delete(table, str, strArr);
        return 0;
    }

    @Override
    public String getType(Uri uri) {
        return null;
    }

    @Override
    public Uri insert(Uri uri, ContentValues contentValues) {
        mDb.insert(table, null, contentValues);
        mContext.getContentResolver().notifyChange(uri, null);
        return null;
    }

    @Override
    public boolean onCreate() {
        return false;
    }

    @Override
    public Cursor query(Uri uri, String[] strArr, String str, String[] strArr2, String str2) {
        SQLiteDatabase sQLiteDatabase = mDb;
        if (sQLiteDatabase == null) {
            return null;
        }
        return sQLiteDatabase.query("bmob", strArr, str, strArr2, null, str2, null);
    }

    @Override
    public int update(Uri uri, ContentValues contentValues, String str, String[] strArr) {
        mDb.update(table, contentValues, str, strArr);
        return 0;
    }
}