Tencent / MMKV

An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX.
Other
17.42k stars 1.91k forks source link

关于MMKVHandler中onMMKVCRCCheckFail()未被回调的情况 #839

Closed ghost closed 2 years ago

ghost commented 2 years ago

The language of MMKV

Java

The version of MMKV

v1.2.11

The platform of MMKV

Android

The installation of MMKV

Maven

What's the issue?

写个demo测试,但onMMKVCRCCheckFail()未被回调。

先贴出我的代码: Activity:

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "DataRecoverTest";

    String mRootDir;
    MMKV mKV;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        String dir = getFilesDir().getAbsolutePath() + "/mmkv_datarecover_test";
        mRootDir = MMKV.initialize(this, dir);
    }

    /**
     * 注册错误回调
     * @param view
     */
    public void registerHandler(View view) {
        Log.d(TAG, "-----register Handler------");
        MMKV.registerHandler(new MMKVHandlerImpl());  //注册crc校验失败和文件长度不对时的回调
    }

    /**
     * 获取mmkv实例
     * @param view
     */
    public void getInstance(View view) {
        Log.d(TAG, "-----get Instance------");
        mKV = MMKV.mmkvWithID("dataRecoverTest1");
    }

    /**
     * 读取数据
     * @param view
     */
    public void readData(View view) {
        Log.d(TAG, "-----read data------");
        Log.d(TAG, "string: " + mKV.decodeString("string"));
        Log.d(TAG, "int: " + mKV.decodeInt("int"));
    }

    /**
     * 写入数据2
     * @param view
     */
    public void writeData2(View view) {
        Log.d(TAG, "-----write data2-----");
        mKV.encode("int", 20);
        Log.d(TAG, "int: " + mKV.decodeBool("int"));
    }

    /**
     * 写入数据1
     * @param view
     */
    public void writeData1(View view) {
        Log.d(TAG, "-----write data1------");
        mKV.encode("string", "Hello from mmkv");
        Log.d(TAG, "string: " + mKV.decodeString("string"));
    }

    /**
     * MMKVHandler的自定义实现
     */
    private class MMKVHandlerImpl implements MMKVHandler {

        @Override
        public MMKVRecoverStrategic onMMKVCRCCheckFail(String mmapID) {
            Log.d(TAG, "crc failed, onErrorRecover");
            return MMKVRecoverStrategic.OnErrorRecover;
        }

        @Override
        public MMKVRecoverStrategic onMMKVFileLengthError(String mmapID) {
            Log.d(TAG, "file length failed, onErrorRecover");
            return MMKVRecoverStrategic.OnErrorRecover;
        }

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

        @Override
        public void mmkvLog(MMKVLogLevel level, String file, int line, String function, String message) {

        }
    }
}

xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="写入数据1"
        android:onClick="writeData1"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="写入数据2"
        android:onClick="writeData2"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="读取数据"
        android:onClick="readData"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="获取mmkv实例"
        android:onClick="getInstance"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="注册错误回调"
        android:onClick="registerHandler"/>
</LinearLayout>

我的操作顺序是: (1)点”注册错误回调“button; (2)点“获取MMKV实例”button; (3)点“写入数据1”button; 这时mmkv文件为:
image (4) 修改mmkv文件为 image 并upload到根目录 (5) 点“读取数据”button: image

我想问的是:这时不应回调onMMKVCRCCheckFail吗?因为crc与当前mmkv文件的crc是不匹配的。

lingol commented 2 years ago

That error only checks on loading an MMKV instance. For your case, you could kill your App after step (3), and restart it before step (5).

ghost commented 2 years ago

ok,i will have a try later. i am now in hospitai.

lingol commented 2 years ago

Well, Good Heath to you.

ghost commented 2 years ago

你好,我按你的方式重新试了次,之前我看过MMKV::loadFromFile()和crc相关的部分逻辑,但结果和代码逻辑好像仍对不上。 Activity和xml的代码没变。

操作改成: (1)打开app; (2)点”注册错误回调“button; (3)点“获取MMKV实例”button; (4)点“写入数据1”button; 这时mmkv文件为: image (5) 关闭app; (6) 修改mmkv文件为 image 并upload到根目录 image (7) 打开app; (8) 点”注册错误回调“button; (9) 点“获取MMKV实例”button,显示 image image 此时mmkv文件为 image (10) 点“读取数据”button,显示 image

以上结果仍和我阅读的源码逻辑不同,因为在获取实例时当crc文件与当前mmkv文件计算出的crc不等时,就会回调onMMKVCRCCheckFail,但这里仍未回调 image

ghost commented 2 years ago

So did I something wrong with my code or my understanding of the source code? Or the source code itself is something wrong? please give a reply, thanks. It's urgent for me to write the scheme for my team to migrate from sp to mmkv and have a technical evaluation next week.

lingol commented 2 years ago

Sorry I missed your update last week. When you kill your App, did you kill it permanently? I mean is it possible the App still running in the background?

ghost commented 2 years ago

I add some lifecycle callbacks in code like below:

package com.example.mmkvtest.datarecovertest;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.example.mmkvtest.R;
import com.tencent.mmkv.MMKV;
import com.tencent.mmkv.MMKVHandler;
import com.tencent.mmkv.MMKVLogLevel;
import com.tencent.mmkv.MMKVRecoverStrategic;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "DataRecoverTest";

    String mRootDir;
    MMKV mKV;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Log.d(TAG, "onCreate");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.data_recover_test);

        String dir = getFilesDir().getAbsolutePath() + "/mmkv_datarecover_test";
        mRootDir = MMKV.initialize(this, dir);
        Log.d(TAG, "-----initialize------");
        Log.d(TAG, "rootDir=" + mRootDir);
    }

    @Override
    protected void onStart() {
        Log.d(TAG, "onStart");
        super.onStart();
    }

    @Override
    protected void onResume() {
        Log.d(TAG, "onResume");
        super.onResume();
    }

    @Override
    protected void onPause() {
        Log.d(TAG, "onPause");
        super.onPause();
    }

    @Override
    protected void onStop() {
        Log.d(TAG, "onStop");
        super.onStop();
    }

    @Override
    protected void onDestroy() {
        Log.d(TAG, "onDestroy");
        super.onDestroy();
    }

    /**
     * 注册错误回调
     * @param view
     */
    public void registerHandler(View view) {
        Log.d(TAG, "-----register Handler------");
        MMKV.registerHandler(new MMKVHandlerImpl());  //注册crc校验失败和文件长度不对时的回调
    }

    /**
     * 获取mmkv实例
     * @param view
     */
    public void getInstance(View view) {
        Log.d(TAG, "-----get Instance------");
        mKV = MMKV.mmkvWithID("dataRecoverTest1");
    }

    /**
     * 读取数据
     * @param view
     */
    public void readData(View view) {
        Log.d(TAG, "-----read data------");
        Log.d(TAG, "string: " + mKV.decodeString("string"));
        Log.d(TAG, "int: " + mKV.decodeInt("int"));
    }

    /**
     * 写入数据2
     * @param view
     */
    public void writeData2(View view) {
        Log.d(TAG, "-----write data2-----");
        mKV.encode("int", 20);
        Log.d(TAG, "int: " + mKV.decodeBool("int"));
    }

    /**
     * 写入数据1
     * @param view
     */
    public void writeData1(View view) {
        Log.d(TAG, "-----write data1------");
        mKV.encode("string", "Hello from mmkv");
        Log.d(TAG, "string: " + mKV.decodeString("string"));
    }

    /**
     * MMKVHandler的自定义实现
     */
    private class MMKVHandlerImpl implements MMKVHandler {

        @Override
        public MMKVRecoverStrategic onMMKVCRCCheckFail(String mmapID) {
            Log.d(TAG, "crc failed, onErrorRecover");
            return MMKVRecoverStrategic.OnErrorRecover;
        }

        @Override
        public MMKVRecoverStrategic onMMKVFileLengthError(String mmapID) {
            Log.d(TAG, "file length failed, onErrorRecover");
            return MMKVRecoverStrategic.OnErrorRecover;
        }

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

        @Override
        public void mmkvLog(MMKVLogLevel level, String file, int line, String function, String message) {

        }
    }
}

and follow the steps in image The log is as follows and still no crc failed callback: image

So what's your result in your environment with the step same as image?

ghost commented 2 years ago

as the log above, the app is permanently killed. and the 'onDestroy' with the image.

lingol commented 2 years ago

Can you provide logs from MMKV? Your log is not enough as they didn't provide the process number, nor did they provide the loading process of MMKV.

ghost commented 2 years ago

The log for the whole process is as below:

2022-03-07 12:13:35.938 17729-17849/? I/[0]DCS-BackgroundAppData: sendAppBgEvent: has no pkgName=com.example.mmkvtest
2022-03-07 12:13:35.939 18125-18285/? I/obrain: app forground called:com.example.mmkvtest
2022-03-07 12:13:35.939 12092-12111/com.example.mmkvtest D/ColorModeChangeItem: preExecute mColorMode=0,token=android.os.BinderProxy@7d5ebca
2022-03-07 12:13:35.939 12092-12092/com.example.mmkvtest W/xample.mmkvtes: DexFile /data/data/com.example.mmkvtest/code_cache/.studio/instruments-2ca9b3e0.jar is in boot class path but is not in a known location
2022-03-07 12:13:35.946 12092-12092/com.example.mmkvtest W/xample.mmkvtes: Redefining intrinsic method java.lang.Thread java.lang.Thread.currentThread(). This may cause the unexpected use of the original definition of java.lang.Thread java.lang.Thread.currentThread()in methods that have already been compiled.
2022-03-07 12:13:35.946 12092-12092/com.example.mmkvtest W/xample.mmkvtes: Redefining intrinsic method boolean java.lang.Thread.interrupted(). This may cause the unexpected use of the original definition of boolean java.lang.Thread.interrupted()in methods that have already been compiled.
2022-03-07 12:13:35.948 12092-12092/com.example.mmkvtest D/CompatibilityChangeReporter: Compat change id reported: 171979766; UID 10343; state: ENABLED
2022-03-07 12:13:35.948 12092-12092/com.example.mmkvtest I/oplus.android.OplusFrameworkFactoryImpl: get feature:IOplusAutoResolutionFeature
2022-03-07 12:13:35.948 12092-12092/com.example.mmkvtest I/oplus.android.OplusFrameworkFactoryImpl: getOplusAutoResolutionFeature
2022-03-07 12:12:19.144 1814-2816/? I/ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.mmkvtest/.datarecovertest.MainActivity bnds=[795,740][1047,1030] mCallingUid=10204} from uid 10204
2022-03-07 12:12:19.148 1814-2816/? I/OplusHansManager: unfreeze uid: 10343 com.example.mmkvtest pids: [11198] reason: Activity scene: LcdOn
2022-03-07 12:12:19.153 1814-2816/? D/TaskExtImpl: add ActivityRecord{aa9dccd u0 com.example.mmkvtest/.datarecovertest.MainActivity t2595} to mActivityRecordSum = Counter{ com.example.mmkvtest/.datarecovertest.MainActivity(1) }
2022-03-07 12:12:19.153 1814-2816/? D/ActivityTaskManager: getStartingWindowType: newTask=true, taskSwitch=true, processRunning=true, allowTaskSnapshot=true, activityCreated=false, snapshot=null, record:ActivityRecord{aa9dccd u0 com.example.mmkvtest/.datarecovertest.MainActivity t2595}
2022-03-07 12:12:19.161 1814-5659/? D/OplusSecurePayManager: resume secure pay app : com.example.mmkvtest
2022-03-07 12:12:19.161 1814-5659/? I/OplusHansManager: front pkg: com.example.mmkvtest, uid: 10343, prev pkg: com.android.launcher, prev uid: 10204
2022-03-07 12:12:19.161 1814-2064/? D/OplusSecurePayManager: startSecurePayIntent,pkgName:com.example.mmkvtest UserHandle.CURRENT=UserHandle{-2}, mCurrentUserId=0
2022-03-07 12:12:19.161 1814-5659/? I/ActivityTaskManager: The Process com.example.mmkvtest Already Exists in BG. So sending its PID: 11198
2022-03-07 12:12:19.162 1814-5659/? D/ColorDisplayServiceExtImpl: getWCGModeForAPP,packageName=com.example.mmkvtest,sSupportWCGManager=true,nRet=0
2022-03-07 12:12:19.164 1814-5659/? I/InputDispatcher: setFocusedApplication displayId=0 ActivityRecord{aa9dccd u0 com.example.mmkvtest/.datarecovertest.MainActivity t2595}
2022-03-07 12:12:19.165 1814-7252/? D/DCSEX-AppLaunchEventRecorder: onAppSwitch from = com.android.launcher to = com.example.mmkvtest
2022-03-07 12:12:19.165 1814-3564/? D/VRR [OPlusFrontAppManager]: OnAppSwitchObserver: onAppExit , info = OplusAppExitInfo = {  targetName = com.android.launcher hasResumingActivity = true resumingPackageName = com.example.mmkvtest resumingActivityName = com.example.mmkvtest.datarecovertest.MainActivity resumingWindowMode = 1 isResumingMultiApp = false isResumingFirstStart = false extension = Bundle[{taskId=2595, uid=10343}]}
2022-03-07 12:12:19.167 1814-3564/? I/OplusResourcePreloadManager: resume pkg: com.example.mmkvtest, uid:10343, prev pkg: com.android.launcher, prev uid: 10204
2022-03-07 12:12:19.167 1814-3564/? D/VRR [OPlusFrontAppManager]: OnAppSwitchObserver: onAppEnter , info = OplusAppEnterInfo = {  windowMode = 1 targetName = com.example.mmkvtest multiApp = false firstStart = false launchedFromPackage = com.android.launcher intent = Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.mmkvtest/.datarecovertest.MainActivity bnds=[795,740][1047,1030] mCallingUid=10204 } extension = Bundle[{taskId=2595, pid=11198, uid=10343}]}
2022-03-07 12:12:19.168 3781-28741/? W/Battery: ThermalControlUtils: mForegroundPkg=com.example.mmkvtest
2022-03-07 12:12:19.168 1814-2028/? D/VRR [OPlusRefreshRateService]: handleFrontAppChange pkgName: com.example.mmkvtest
2022-03-07 12:12:19.168 1814-2028/? D/VRR [OPlusExternalRefreshRateManager]: setFrontPackageName pkgName: com.example.mmkvtest CurPkgName: null
2022-03-07 12:12:19.168 1814-2028/? D/VRR [OPlusGameStatusManager]: setFrontPackageName pkgName: com.example.mmkvtest CurPkgName: null
2022-03-07 12:12:19.168 1814-2028/? D/VRR [OPlusGameStatusManager]: setGameStop: CurPkgNamecom.example.mmkvtest GameController: null
2022-03-07 12:12:19.171 18125-18285/? I/obrain: app forground called:com.example.mmkvtest
2022-03-07 12:12:19.173 1814-1958/? D/OplusKeepAliveManager: TOP_APP is ProcessRecord{166b866 11198:com.example.mmkvtest/u0a343} uid is 10343
2022-03-07 12:12:19.177 17729-17849/? I/[0]DCS-BackgroundAppData: sendAppBgEvent: has no pkgName=com.example.mmkvtest
2022-03-07 12:12:19.179 1814-1959/? D/OplusDisplayPolicy: com.example.mmkvtest, no change cutoutMode: 0
2022-03-07 12:12:19.185 1814-1959/? D/OplusDisplayPolicy: com.example.mmkvtest, no change cutoutMode: 0
2022-03-07 12:12:19.185 11198-11219/com.example.mmkvtest D/ColorModeChangeItem: preExecute mColorMode=0,token=android.os.BinderProxy@b782a22
2022-03-07 12:12:19.189 11198-11215/com.example.mmkvtest W/System: A resource failed to call close. 
2022-03-07 12:12:19.205 11198-11924/com.example.mmkvtest E/xample.mmkvtes: Loaded layer handle (4865805372229611831) for layer /my_product/lib64/libcolorx-loader.so
2022-03-07 12:12:19.205 11198-11924/com.example.mmkvtest E/xample.mmkvtes: Looking for entrypoint ColorX_Check
2022-03-07 12:12:19.205 11198-11924/com.example.mmkvtest E/xample.mmkvtes: Found ColorX_Check for /my_product/lib64/libcolorx-loader.so
2022-03-07 12:12:19.205 11198-11924/com.example.mmkvtest E/xample.mmkvtes: Check failed
2022-03-07 12:12:19.240 11198-11198/com.example.mmkvtest D/DataRecoverTest: onCreate
2022-03-07 12:12:19.259 11198-11198/com.example.mmkvtest I/oplus.android.OplusFrameworkFactoryImpl: Unknow feature:IOplusTextViewRTLUtilForUG
2022-03-07 12:12:19.267 1814-3960/? D/OplusAppListInterceptManager: shouldFilterTask::packageName = com.example.mmkvtest
2022-03-07 12:12:19.277 11198-11198/com.example.mmkvtest D/ScrollOptimizationHelper: can't find the config file for optimizaiton
2022-03-07 12:12:19.277 11198-11198/com.example.mmkvtest D/ScrollOptimizationHelper: will not debug for debug is false
2022-03-07 12:12:19.277 11198-11198/com.example.mmkvtest I/oplus.android.OplusFrameworkFactoryImpl: get feature:IOplusDynamicVsyncFeature
2022-03-07 12:12:19.277 11198-11198/com.example.mmkvtest I/oplus.android.OplusFrameworkFactoryImpl: get feature:IOplusDynamicVsyncFeature
2022-03-07 12:12:19.277 11198-11198/com.example.mmkvtest I/oplus.android.OplusFrameworkFactoryImpl: get feature:IOplusDynamicVsyncFeature
2022-03-07 12:12:19.292 11198-11198/com.example.mmkvtest W/xample.mmkvtes: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed)
2022-03-07 12:12:19.292 11198-11198/com.example.mmkvtest W/xample.mmkvtes: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed)
2022-03-07 12:12:19.294 11198-11198/com.example.mmkvtest E/OplusCustomizeRestrictionManager: sInstance is null, start a new sInstance
2022-03-07 12:12:19.328 11198-11198/com.example.mmkvtest I/MMKV: Enable checkProcessMode()
2022-03-07 12:12:19.329 11198-11198/com.example.mmkvtest I/MMKV: <native-bridge.cpp:104::JNI_OnLoad> current API level = 31, libc++_shared=0
2022-03-07 12:12:19.329 11198-11198/com.example.mmkvtest I/MMKV: <MMKV.cpp:165::initialize> version v1.2.12, page size 4096, arch arm64-v8a
2022-03-07 12:12:19.329 11198-11198/com.example.mmkvtest I/MMKV: <MMKV.cpp:176::initialize> armv8 AES instructions is supported
2022-03-07 12:12:19.329 11198-11198/com.example.mmkvtest I/MMKV: <MMKV.cpp:184::initialize> armv8 CRC32 instructions is supported
2022-03-07 12:12:19.329 11198-11198/com.example.mmkvtest I/MMKV: <MMKV.cpp:207::initializeMMKV> root dir: /data/user/0/com.example.mmkvtest/files/mmkv_datarecover_test
2022-03-07 12:12:19.329 11198-11198/com.example.mmkvtest D/DataRecoverTest: -----initialize------
2022-03-07 12:12:19.329 11198-11198/com.example.mmkvtest D/DataRecoverTest: rootDir=/data/user/0/com.example.mmkvtest/files/mmkv_datarecover_test
2022-03-07 12:12:19.330 11198-11198/com.example.mmkvtest D/DataRecoverTest: onStart
2022-03-07 12:12:19.331 11198-11198/com.example.mmkvtest D/DataRecoverTest: onResume
2022-03-07 12:12:19.334 11198-11198/com.example.mmkvtest D/OplusInputMethodUtil: init DEBUG to false, update DEBUG_IME to false
2022-03-07 12:12:19.334 11198-11198/com.example.mmkvtest D/OplusInputMethodUtil: init DEBUG to false, update DEBUG_IME to false
2022-03-07 12:12:19.345 11198-11198/com.example.mmkvtest I/OplusFeatureCache: Milliseconds spent on init(): 8
2022-03-07 12:12:19.346 11198-11198/com.example.mmkvtest I/OplusSlideAnimOptHelper: checkListMode: is blacklist mode = true
2022-03-07 12:12:19.347 11198-11198/com.example.mmkvtest D/OplusSlideAnimOptHelper: com.example.mmkvtest scrollEffectOpt enable = true
2022-03-07 12:12:19.354 11198-11921/com.example.mmkvtest D/ExtensionsLoader: createInstance(64bit) : createExtendedFactory
2022-03-07 12:12:19.354 11198-11921/com.example.mmkvtest E/ExtensionsLoader: dlopen failed: library "libhwuiextimpl.so" not found
2022-03-07 12:12:19.357 1814-5653/? D/OplusDisplayPolicy: com.example.mmkvtest, no change cutoutMode: 0
2022-03-07 12:12:19.372 1814-5653/? D/OplusDisplayPolicy: com.example.mmkvtest, no change cutoutMode: 0
2022-03-07 12:12:19.381 11198-11921/com.example.mmkvtest I/AdrenoGLES-0: QUALCOMM build                   : a286aa1529, Idfea88bc0a
    Build Date                       : 09/10/21
    OpenGL ES Shader Compiler Version: EV031.32.02.01
    Local Branch                     : 
    Remote Branch                    : 
    Remote Branch                    : 
    Reconstruct Branch               : 
2022-03-07 12:12:19.381 11198-11921/com.example.mmkvtest I/AdrenoGLES-0: Build Config                     : S P 10.0.5 AArch64
2022-03-07 12:12:19.381 11198-11921/com.example.mmkvtest I/AdrenoGLES-0: Driver Path                      : /vendor/lib64/egl/libGLESv2_adreno.so
2022-03-07 12:12:19.383 11198-11921/com.example.mmkvtest I/AdrenoGLES-0: PFP: 0x016dd091, ME: 0x00000000
2022-03-07 12:12:19.389 11198-11921/com.example.mmkvtest D/hw-ProcessState: Binder ioctl to enable oneway spam detection failed: Invalid argument
2022-03-07 12:12:19.409 1814-1959/? D/OplusStartingWindowManager: interceptRemoveStartingWindow activity.packageName=com.example.mmkvtest isSnapshot=false mStartingSurfaceRunnable=null
2022-03-07 12:12:19.409 1814-1959/? I/Quality: LaunchTime2.0: com.example.mmkvtest/.datarecovertest.MainActivity 2 253
2022-03-07 12:12:19.409 11198-11219/com.example.mmkvtest D/SurfaceComposerClient: VRR [FRTC] client handle [bufferId:18446744073709551615 framenumber:0] [ffffffff, ffffffff]
2022-03-07 12:12:19.409 1814-1959/? I/Quality: LaunchTime: com.example.mmkvtest/.datarecovertest.MainActivity 247 247
2022-03-07 12:12:19.412 1814-1955/? I/ActivityTaskManager: Displayed com.example.mmkvtest/.datarecovertest.MainActivity: +264ms
2022-03-07 12:12:19.412 1814-1959/? W/InputManager-JNI: Input channel object 'e260a2c Splash Screen com.example.mmkvtest (client)' was disposed without first being removed with the input manager!
2022-03-07 12:12:19.415 11198-11198/com.example.mmkvtest I/Quality: Skipped: false 6
2022-03-07 12:12:19.419 1814-3960/? I/FocusResolver: updateFocusedWindow, 162b597 com.example.mmkvtest/com.example.mmkvtest.datarecovertest.MainActivity on display 0, reason: Window became focusable. Previous reason: NOT_VISIBLE, result:   FocusedWindows:
        displayId=0, name='162b597 com.example.mmkvtest/com.example.mmkvtest.datarecovertest.MainActivity'
2022-03-07 12:12:19.428 1814-3960/? D/InputMethodManagerService: isSecurity: attribute.packageName=com.example.mmkvtest mCurMethodId=com.baidu.input_oppo/.ImeService
2022-03-07 12:12:19.576 1143-1143/? D/OplusLayer: ~Layer() sequence=6418, name=Surface(name=e260a2c Splash Screen com.example.mmkvtest)/@0x360c08f - animation-leash of window_animation#0
2022-03-07 12:12:19.576 1143-1143/? D/OplusLayer: ~Layer() sequence=6407, name=e260a2c Splash Screen com.example.mmkvtest#0
2022-03-07 12:12:19.577 1143-1143/? D/OplusLayer: ~Layer() sequence=6408, name=Splash Screen com.example.mmkvtest#0
2022-03-07 12:12:19.609 1814-5653/? I/OplusAppSwitchManagerService:  handleAppVisible , r = ActivityRecord{aa9dccd u0 com.example.mmkvtest/.datarecovertest.MainActivity t2595}
2022-03-07 12:12:22.766 11198-11198/com.example.mmkvtest D/DataRecoverTest: -----register Handler------
2022-03-07 12:12:24.048 11198-11198/com.example.mmkvtest I/Quality: Skipped: false 1
2022-03-07 12:12:24.085 11198-11198/com.example.mmkvtest D/DataRecoverTest: -----get Instance------
2022-03-07 12:12:24.086 11198-11198/com.example.mmkvtest I/MMKV: <MemoryFile.cpp:97::open> open fd[0x79], /data/user/0/com.example.mmkvtest/files/mmkv_datarecover_test/dataRecoverTest1
2022-03-07 12:12:24.086 11198-11198/com.example.mmkvtest I/MMKV: <MemoryFile.cpp:97::open> open fd[0x5d], /data/user/0/com.example.mmkvtest/files/mmkv_datarecover_test/dataRecoverTest1.crc
2022-03-07 12:12:24.086 11198-11198/com.example.mmkvtest I/MMKV: <MMKV_IO.cpp:81::loadFromFile> loading [dataRecoverTest1] with 0 actual size, file size 4096, InterProcess 0, meta info version:0
2022-03-07 12:12:24.086 11198-11198/com.example.mmkvtest I/MMKV: <MMKV_IO.cpp:130::loadFromFile> loaded [dataRecoverTest1] with 0 key-values
2022-03-07 12:12:24.182 3781-4820/? D/AppSwitchObserverHelper: packageName: com.example.mmkvtest,com.android.launcher
2022-03-07 12:12:26.375 11198-11198/com.example.mmkvtest D/DataRecoverTest: -----write data1------
2022-03-07 12:12:26.377 11198-11198/com.example.mmkvtest D/DataRecoverTest: string: Hello from mmkv
2022-03-07 12:12:50.801 1814-4285/? D/OplusAppListInterceptManager: shouldFilterTask::packageName = com.example.mmkvtest
2022-03-07 12:12:50.817 1814-3960/? I/OplusHansManager: front pkg: com.android.launcher, uid: 10204, prev pkg: com.example.mmkvtest, prev uid: 10343
2022-03-07 12:12:50.817 1814-3351/? I/OplusHansManager: uid=10343, pkg=com.example.mmkvtest enter SM
2022-03-07 12:12:50.817 1814-3351/? I/OplusHansManager: uid=10343, pkg=com.example.mmkvtest R enter()
2022-03-07 12:12:50.823 1814-3564/? D/VRR [OPlusFrontAppManager]: OnAppSwitchObserver: onAppExit , info = OplusAppExitInfo = {  targetName = com.example.mmkvtest hasResumingActivity = true resumingPackageName = com.android.launcher resumingActivityName = com.android.launcher.Launcher resumingWindowMode = 1 isResumingMultiApp = false isResumingFirstStart = false extension = Bundle[{taskId=5, uid=10204}]}
2022-03-07 12:12:50.823 1814-7252/? D/DCSEX-AppLaunchEventRecorder: onAppSwitch from = com.example.mmkvtest to = com.android.launcher
2022-03-07 12:12:50.823 1814-7252/? D/DCSEX-AppLaunchEventRecorder: recordExitApp = com.example.mmkvtest
2022-03-07 12:12:50.823 1814-2028/? D/VRR [OPlusExternalRefreshRateManager]: setFrontPackageName pkgName: null CurPkgName: com.example.mmkvtest
2022-03-07 12:12:50.823 1814-2028/? D/VRR [OPlusGameStatusManager]: setFrontPackageName pkgName: null CurPkgName: com.example.mmkvtest
2022-03-07 12:12:50.823 11198-11198/com.example.mmkvtest D/DataRecoverTest: onPause
2022-03-07 12:12:50.832 1814-3564/? I/OplusResourcePreloadManager: resume pkg: com.android.launcher, uid:10204, prev pkg: com.example.mmkvtest, prev uid: 10343
2022-03-07 12:12:51.315 11198-11198/com.example.mmkvtest D/DataRecoverTest: onStop
2022-03-07 12:12:51.335 1143-1143/? D/OplusLayer: ~Layer() sequence=6415, name=com.example.mmkvtest/com.example.mmkvtest.datarecovertest.MainActivity#0
2022-03-07 12:12:51.881 11198-11198/com.example.mmkvtest D/DataRecoverTest: onDestroy
2022-03-07 12:12:51.890 1814-1958/? I/ActivityManager: Killing 11198:com.example.mmkvtest/u0a343 (adj 905): remove task
2022-03-07 12:12:51.904 5053-5053/? I/Athena: OplusClearSystemService : F [10343][com.example.mmkvtest], userId: 0, reason: 40
2022-03-07 12:12:51.905 1814-2241/? I/ActivityManager: Force stopping com.example.mmkvtest appid=10343 user=0: from pid 5053
2022-03-07 12:12:51.906 1814-4519/? I/OplusHansManager: onUidGone(), 10343 com.example.mmkvtest exit SM
2022-03-07 12:12:51.906 1814-3351/? I/OplusHansManager: uid=10343, pkg=com.example.mmkvtest R exit SM
2022-03-07 12:12:51.906 1814-3351/? I/OplusHansManager: uid=10343, pkg=com.example.mmkvtest R exit()
2022-03-07 12:12:51.907 1814-2241/? W/ActivityTaskManager: Force removing ActivityRecord{aa9dccd u0 com.example.mmkvtest/.datarecovertest.MainActivity t2595 f}}: app died, no saved state
2022-03-07 12:12:51.907 1814-1970/? W/UsageStatsService: Unexpected activity event reported! (com.example.mmkvtest/com.example.mmkvtest.datarecovertest.MainActivity event : 23 instanceId : 103617527)
2022-03-07 12:12:51.907 1814-2241/? W/InputManager-JNI: Input channel object '162b597 com.example.mmkvtest/com.example.mmkvtest.datarecovertest.MainActivity (client)' was disposed without first being removed with the input manager!
2022-03-07 12:12:51.908 17729-18020/? I/[0]DCS-BackgroundAppData: sendAppBgEvent: has no pkgName=com.example.mmkvtest
2022-03-07 12:12:51.910 1814-2241/? D/TaskExtImpl: remove ActivityRecord{aa9dccd u0 com.example.mmkvtest/.datarecovertest.MainActivity t-1 f}} to mActivityRecordSum = Counter{ }
2022-03-07 12:12:51.911 1143-1143/? D/OplusLayer: ~Layer() sequence=6414, name=162b597 com.example.mmkvtest/com.example.mmkvtest.datarecovertest.MainActivity#0
2022-03-07 12:12:51.913 1814-2241/? D/AthenaKillerManagerService: Force stopping [10343]com.example.mmkvtest(0), o-kill(40)
2022-03-07 12:12:51.913 1814-1814/? I/PhoneWindowManagerExtImpl: KeyLockModeReceiver KeyLockMode: 0 ProcessName: com.example.mmkvtest
2022-03-07 12:12:51.919 1143-1143/? D/OplusLayer: ~Layer() sequence=6406, name=ActivityRecord{aa9dccd u0 com.example.mmkvtest/.datarecovertest.MainActivity#0
2022-03-07 12:12:55.867 3781-4820/? D/AppSwitchObserverHelper: packageName: com.android.launcher,com.example.mmkvtest
2022-03-07 12:13:35.806 3455-4235/? I/iopgp: Iopgp: TRANSACTION_IOPGP_ON_KEY_DOWN sequence_id = 74 pkg_name = com.example.mmkvtest ret = 0
2022-03-07 12:13:35.858 3455-4235/? I/iopgp: Iopgp: TRANSACTION_IOPGP_ON_INTENT_STARTED sequence_id = 74 pkg_name = com.example.mmkvtest class_name = com.example.mmkvtest.datarecovertest.MainActivity
2022-03-07 12:13:35.858 1814-4041/? I/ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.mmkvtest/.datarecovertest.MainActivity bnds=[797,742][1049,1032] mCallingUid=10204} from uid 10204
2022-03-07 12:13:35.864 1814-4041/? D/TaskExtImpl: add ActivityRecord{b36e525 u0 com.example.mmkvtest/.datarecovertest.MainActivity t2596} to mActivityRecordSum = Counter{ com.example.mmkvtest/.datarecovertest.MainActivity(1) }
2022-03-07 12:13:35.865 1814-4041/? D/ActivityTaskManager: getStartingWindowType: newTask=true, taskSwitch=true, processRunning=false, allowTaskSnapshot=true, activityCreated=false, snapshot=null, record:ActivityRecord{b36e525 u0 com.example.mmkvtest/.datarecovertest.MainActivity t2596}
2022-03-07 12:13:35.872 1814-5652/? D/OplusSecurePayManager: resume secure pay app : com.example.mmkvtest
2022-03-07 12:13:35.872 1814-2064/? D/OplusSecurePayManager: startSecurePayIntent,pkgName:com.example.mmkvtest UserHandle.CURRENT=UserHandle{-2}, mCurrentUserId=0
2022-03-07 12:13:35.872 1814-5652/? I/OplusHansManager: front pkg: com.example.mmkvtest, uid: 10343, prev pkg: com.android.launcher, prev uid: 10204
2022-03-07 12:13:35.882 1814-1959/? D/OplusDisplayPolicy: com.example.mmkvtest, no change cutoutMode: 0
2022-03-07 12:13:35.889 1814-1959/? D/OplusDisplayPolicy: com.example.mmkvtest, no change cutoutMode: 0
2022-03-07 12:13:35.891 1814-1977/? I/ActivityManager: Start proc 12092:com.example.mmkvtest/u0a343 for pre-top-activity {com.example.mmkvtest/com.example.mmkvtest.datarecovertest.MainActivity}
2022-03-07 12:13:35.898 12092-12092/? I/xample.mmkvtes: Late-enabling -Xcheck:jni
2022-03-07 12:13:35.911 12092-12092/? E/xample.mmkvtes: Unknown bits set in runtime_flags: 0x40000000
2022-03-07 12:13:35.924 1814-4041/? D/ColorDisplayServiceExtImpl: getWCGModeForAPP,packageName=com.example.mmkvtest,sSupportWCGManager=true,nRet=0
2022-03-07 12:13:35.925 1814-4041/? I/OplusAppSwitchManagerService: appswitch hasProcess ActivityRecord{b36e525 u0 com.example.mmkvtest/.datarecovertest.MainActivity t2596}
2022-03-07 12:13:35.925 1814-4041/? I/OplusAppSwitchManagerService: appswitch hasProcess ActivityRecord{b36e525 u0 com.example.mmkvtest/.datarecovertest.MainActivity t2596}
2022-03-07 12:13:35.925 1814-4041/? I/InputDispatcher: setFocusedApplication displayId=0 ActivityRecord{b36e525 u0 com.example.mmkvtest/.datarecovertest.MainActivity t2596}
2022-03-07 12:13:35.925 1814-7252/? D/DCSEX-AppLaunchEventRecorder: onAppSwitch from = com.android.launcher to = com.example.mmkvtest
2022-03-07 12:13:35.925 1814-3564/? D/VRR [OPlusFrontAppManager]: OnAppSwitchObserver: onAppExit , info = OplusAppExitInfo = {  targetName = com.android.launcher hasResumingActivity = true resumingPackageName = com.example.mmkvtest resumingActivityName = com.example.mmkvtest.datarecovertest.MainActivity resumingWindowMode = 1 isResumingMultiApp = false isResumingFirstStart = true extension = Bundle[{taskId=2596, uid=10343}]}
2022-03-07 12:13:35.927 1814-1958/? D/OplusKeepAliveManager: TOP_APP is ProcessRecord{d7698c6 12092:com.example.mmkvtest/u0a343} uid is 10343
2022-03-07 12:13:35.929 1814-3564/? I/OplusResourcePreloadManager: resume pkg: com.example.mmkvtest, uid:10343, prev pkg: com.android.launcher, prev uid: 10204
2022-03-07 12:13:35.929 1814-3564/? D/VRR [OPlusFrontAppManager]: OnAppSwitchObserver: onAppEnter , info = OplusAppEnterInfo = {  windowMode = 1 targetName = com.example.mmkvtest multiApp = false firstStart = true launchedFromPackage = com.android.launcher intent = Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.mmkvtest/.datarecovertest.MainActivity bnds=[797,742][1049,1032] mCallingUid=10204 } extension = Bundle[{taskId=2596, pid=12092, uid=10343}]}
2022-03-07 12:13:35.930 1814-2028/? D/VRR [OPlusRefreshRateService]: handleFrontAppChange pkgName: com.example.mmkvtest
2022-03-07 12:13:35.930 1814-2028/? D/VRR [OPlusExternalRefreshRateManager]: setFrontPackageName pkgName: com.example.mmkvtest CurPkgName: null
2022-03-07 12:13:35.930 1814-2028/? D/VRR [OPlusGameStatusManager]: setFrontPackageName pkgName: com.example.mmkvtest CurPkgName: null
2022-03-07 12:13:35.930 1814-2028/? D/VRR [OPlusGameStatusManager]: setGameStop: CurPkgNamecom.example.mmkvtest GameController: null
2022-03-07 12:13:35.931 3781-14885/? W/Battery: ThermalControlUtils: mForegroundPkg=com.example.mmkvtest
2022-03-07 12:13:35.973 1814-4041/? D/OplusAppListInterceptManager: shouldFilterTask::packageName = com.example.mmkvtest
2022-03-07 12:13:36.015 12092-12092/com.example.mmkvtest I/Quality: LaunchTime2.0: com.example.mmkvtest createOrUpdateClassLoaderLocked took time: 45
2022-03-07 12:13:36.030 12092-12092/com.example.mmkvtest D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2022-03-07 12:13:36.030 12092-12092/com.example.mmkvtest D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2022-03-07 12:13:36.037 12092-12092/com.example.mmkvtest I/Quality: BindApplication: com.example.mmkvtest
2022-03-07 12:13:36.048 12092-12120/com.example.mmkvtest E/xample.mmkvtes: Loaded layer handle (4181925639593081449) for layer /my_product/lib64/libcolorx-loader.so
2022-03-07 12:13:36.048 12092-12120/com.example.mmkvtest E/xample.mmkvtes: Looking for entrypoint ColorX_Check
2022-03-07 12:13:36.048 12092-12120/com.example.mmkvtest E/xample.mmkvtes: Found ColorX_Check for /my_product/lib64/libcolorx-loader.so
2022-03-07 12:13:36.048 12092-12120/com.example.mmkvtest E/xample.mmkvtes: Check failed
2022-03-07 12:13:36.076 12092-12092/com.example.mmkvtest D/DataRecoverTest: onCreate
2022-03-07 12:13:36.092 12092-12092/com.example.mmkvtest I/oplus.android.OplusFrameworkFactoryImpl: Unknow feature:IOplusTextViewRTLUtilForUG
2022-03-07 12:13:36.107 12092-12092/com.example.mmkvtest D/ScrollOptimizationHelper: can't find the config file for optimizaiton
2022-03-07 12:13:36.107 12092-12092/com.example.mmkvtest D/ScrollOptimizationHelper: will not debug for debug is false
2022-03-07 12:13:36.107 12092-12092/com.example.mmkvtest I/oplus.android.OplusFrameworkFactoryImpl: get feature:IOplusDynamicVsyncFeature
2022-03-07 12:13:36.107 12092-12092/com.example.mmkvtest I/oplus.android.OplusFrameworkFactoryImpl: get feature:IOplusDynamicVsyncFeature
2022-03-07 12:13:36.107 12092-12092/com.example.mmkvtest I/oplus.android.OplusFrameworkFactoryImpl: get feature:IOplusDynamicVsyncFeature
2022-03-07 12:13:36.122 12092-12092/com.example.mmkvtest W/xample.mmkvtes: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed)
2022-03-07 12:13:36.122 12092-12092/com.example.mmkvtest W/xample.mmkvtes: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed)
2022-03-07 12:13:36.124 12092-12092/com.example.mmkvtest E/OplusCustomizeRestrictionManager: sInstance is null, start a new sInstance
2022-03-07 12:13:36.154 12092-12092/com.example.mmkvtest I/MMKV: Enable checkProcessMode()
2022-03-07 12:13:36.155 12092-12092/com.example.mmkvtest I/MMKV: <native-bridge.cpp:104::JNI_OnLoad> current API level = 31, libc++_shared=0
2022-03-07 12:13:36.155 12092-12092/com.example.mmkvtest I/MMKV: <MMKV.cpp:165::initialize> version v1.2.12, page size 4096, arch arm64-v8a
2022-03-07 12:13:36.155 12092-12092/com.example.mmkvtest I/MMKV: <MMKV.cpp:176::initialize> armv8 AES instructions is supported
2022-03-07 12:13:36.155 12092-12092/com.example.mmkvtest I/MMKV: <MMKV.cpp:184::initialize> armv8 CRC32 instructions is supported
2022-03-07 12:13:36.155 12092-12092/com.example.mmkvtest I/MMKV: <MMKV.cpp:207::initializeMMKV> root dir: /data/user/0/com.example.mmkvtest/files/mmkv_datarecover_test
2022-03-07 12:13:36.155 12092-12092/com.example.mmkvtest D/DataRecoverTest: -----initialize------
2022-03-07 12:13:36.155 12092-12092/com.example.mmkvtest D/DataRecoverTest: rootDir=/data/user/0/com.example.mmkvtest/files/mmkv_datarecover_test
2022-03-07 12:13:36.156 12092-12092/com.example.mmkvtest D/DataRecoverTest: onStart
2022-03-07 12:13:36.157 12092-12092/com.example.mmkvtest D/DataRecoverTest: onResume
2022-03-07 12:13:36.160 12092-12092/com.example.mmkvtest D/OplusInputMethodUtil: init DEBUG to false, update DEBUG_IME to false
2022-03-07 12:13:36.160 12092-12092/com.example.mmkvtest D/OplusInputMethodUtil: init DEBUG to false, update DEBUG_IME to false
2022-03-07 12:13:36.171 12092-12092/com.example.mmkvtest I/OplusFeatureCache: Milliseconds spent on init(): 8
2022-03-07 12:13:36.172 12092-12092/com.example.mmkvtest I/OplusSlideAnimOptHelper: checkListMode: is blacklist mode = true
2022-03-07 12:13:36.172 12092-12092/com.example.mmkvtest D/OplusSlideAnimOptHelper: com.example.mmkvtest scrollEffectOpt enable = true
2022-03-07 12:13:36.180 12092-12118/com.example.mmkvtest D/ExtensionsLoader: createInstance(64bit) : createExtendedFactory
2022-03-07 12:13:36.180 12092-12118/com.example.mmkvtest E/ExtensionsLoader: dlopen failed: library "libhwuiextimpl.so" not found
2022-03-07 12:13:36.183 1814-3701/? D/OplusDisplayPolicy: com.example.mmkvtest, no change cutoutMode: 0
2022-03-07 12:13:36.199 1814-3701/? D/OplusDisplayPolicy: com.example.mmkvtest, no change cutoutMode: 0
2022-03-07 12:13:36.207 12092-12118/com.example.mmkvtest I/AdrenoGLES-0: QUALCOMM build                   : a286aa1529, Idfea88bc0a
    Build Date                       : 09/10/21
    OpenGL ES Shader Compiler Version: EV031.32.02.01
    Local Branch                     : 
    Remote Branch                    : 
    Remote Branch                    : 
    Reconstruct Branch               : 
2022-03-07 12:13:36.207 12092-12118/com.example.mmkvtest I/AdrenoGLES-0: Build Config                     : S P 10.0.5 AArch64
2022-03-07 12:13:36.207 12092-12118/com.example.mmkvtest I/AdrenoGLES-0: Driver Path                      : /vendor/lib64/egl/libGLESv2_adreno.so
2022-03-07 12:13:36.209 12092-12118/com.example.mmkvtest I/AdrenoGLES-0: PFP: 0x016dd091, ME: 0x00000000
2022-03-07 12:13:36.215 12092-12118/com.example.mmkvtest D/hw-ProcessState: Binder ioctl to enable oneway spam detection failed: Invalid argument
2022-03-07 12:13:36.234 12092-12111/com.example.mmkvtest D/SurfaceComposerClient: VRR [FRTC] client handle [bufferId:18446744073709551615 framenumber:0] [ffffffff, ffffffff]
2022-03-07 12:13:36.234 1814-1959/? D/OplusStartingWindowManager: interceptRemoveStartingWindow activity.packageName=com.example.mmkvtest isSnapshot=false mStartingSurfaceRunnable=null
2022-03-07 12:13:36.234 1814-1959/? I/Quality: LaunchTime2.0: com.example.mmkvtest/.datarecovertest.MainActivity 1 367
2022-03-07 12:13:36.235 1814-1959/? I/Quality: LaunchTime: com.example.mmkvtest/.datarecovertest.MainActivity 362 362
2022-03-07 12:13:36.236 1814-1955/? I/ActivityTaskManager: Displayed com.example.mmkvtest/.datarecovertest.MainActivity: +377ms
2022-03-07 12:13:36.237 1814-1959/? W/InputManager-JNI: Input channel object 'dc5be9b Splash Screen com.example.mmkvtest (client)' was disposed without first being removed with the input manager!
2022-03-07 12:13:36.241 1814-3652/? I/FocusResolver: updateFocusedWindow, ae2344b com.example.mmkvtest/com.example.mmkvtest.datarecovertest.MainActivity on display 0, reason: Window became focusable. Previous reason: NOT_VISIBLE, result:   FocusedWindows:
        displayId=0, name='ae2344b com.example.mmkvtest/com.example.mmkvtest.datarecovertest.MainActivity'
2022-03-07 12:13:36.241 12092-12092/com.example.mmkvtest I/Quality: Skipped: false 5
2022-03-07 12:13:36.248 1814-2241/? D/InputMethodManagerService: isSecurity: attribute.packageName=com.example.mmkvtest mCurMethodId=com.baidu.input_oppo/.ImeService
2022-03-07 12:13:36.283 1814-3701/? I/OplusAppSwitchManagerService:  handleAppVisible , r = ActivityRecord{b36e525 u0 com.example.mmkvtest/.datarecovertest.MainActivity t2596}
2022-03-07 12:13:36.399 1143-1143/? D/OplusLayer: ~Layer() sequence=6444, name=Surface(name=dc5be9b Splash Screen com.example.mmkvtest)/@0x992e1c3 - animation-leash of window_animation#0
2022-03-07 12:13:36.399 1143-1143/? D/OplusLayer: ~Layer() sequence=6433, name=dc5be9b Splash Screen com.example.mmkvtest#0
2022-03-07 12:13:36.400 1143-1143/? D/OplusLayer: ~Layer() sequence=6434, name=Splash Screen com.example.mmkvtest#0
2022-03-07 12:13:37.948 12092-12108/com.example.mmkvtest W/System: A resource failed to call close. 
2022-03-07 12:13:37.948 12092-12108/com.example.mmkvtest W/System: A resource failed to call close. 
2022-03-07 12:13:40.941 3781-4820/? D/AppSwitchObserverHelper: packageName: com.example.mmkvtest,com.android.launcher
2022-03-07 12:13:41.391 12139-12139/com.heytap.smarthome I/MMKV: Enable checkProcessMode()
2022-03-07 12:13:41.403 12139-12139/com.heytap.smarthome I/MMKV: <native-bridge.cpp:104::JNI_OnLoad> current API level = 31, libc++_shared=0
2022-03-07 12:13:41.403 12139-12139/com.heytap.smarthome I/MMKV: <MMKV.cpp:165::initialize> version v1.2.11, page size 4096, arch arm64-v8a
2022-03-07 12:13:41.403 12139-12139/com.heytap.smarthome I/MMKV: <MMKV.cpp:176::initialize> armv8 AES instructions is supported
2022-03-07 12:13:41.403 12139-12139/com.heytap.smarthome I/MMKV: <MMKV.cpp:184::initialize> armv8 CRC32 instructions is supported
2022-03-07 12:13:41.403 12139-12139/com.heytap.smarthome I/MMKV: <MMKV.cpp:207::initializeMMKV> root dir: /data/user/0/com.heytap.smarthome/files/mmkv
2022-03-07 12:13:41.404 12139-12139/com.heytap.smarthome D/SmartHome.MMKV: rootDir=/data/user/0/com.heytap.smarthome/files/mmkv
2022-03-07 12:13:41.404 12139-12139/com.heytap.smarthome D/SmartHome.sp2mmkvtest: spName=com.heytap.smarthome_app
2022-03-07 12:13:41.405 12139-12139/com.heytap.smarthome I/MMKV: <MemoryFile.cpp:97::open> open fd[0x50], /data/user/0/com.heytap.smarthome/files/mmkv/com.heytap.smarthome_app
2022-03-07 12:13:41.405 12139-12139/com.heytap.smarthome I/MMKV: <MemoryFile.cpp:97::open> open fd[0x51], /data/user/0/com.heytap.smarthome/files/mmkv/com.heytap.smarthome_app.crc
2022-03-07 12:13:41.405 12139-12139/com.heytap.smarthome I/MMKV: <MMKV_IO.cpp:81::loadFromFile> loading [com.heytap.smarthome_app] with 42 actual size, file size 4096, InterProcess 0, meta info version:3
2022-03-07 12:13:41.405 12139-12139/com.heytap.smarthome I/MMKV: <MMKV_IO.cpp:86::loadFromFile> loading [com.heytap.smarthome_app] with crc 4050618280 sequence 2 version 3
2022-03-07 12:13:41.405 12139-12139/com.heytap.smarthome I/MMKV: <MMKV_IO.cpp:130::loadFromFile> loaded [com.heytap.smarthome_app] with 1 key-values
2022-03-07 12:13:41.413 12139-12139/com.heytap.smarthome D/SmartHome.sp2mmkvtest: spName=com.heytap.smarthome_main_prefs
2022-03-07 12:13:41.413 12139-12139/com.heytap.smarthome I/MMKV: <MemoryFile.cpp:97::open> open fd[0x52], /data/user/0/com.heytap.smarthome/files/mmkv/com.heytap.smarthome_main_prefs
2022-03-07 12:13:41.413 12139-12139/com.heytap.smarthome I/MMKV: <MemoryFile.cpp:97::open> open fd[0x53], /data/user/0/com.heytap.smarthome/files/mmkv/com.heytap.smarthome_main_prefs.crc
2022-03-07 12:13:41.413 12139-12139/com.heytap.smarthome I/MMKV: <MMKV_IO.cpp:81::loadFromFile> loading [com.heytap.smarthome_main_prefs] with 115 actual size, file size 4096, InterProcess 0, meta info version:3
2022-03-07 12:13:41.413 12139-12139/com.heytap.smarthome I/MMKV: <MMKV_IO.cpp:86::loadFromFile> loading [com.heytap.smarthome_main_prefs] with crc 2184119916 sequence 1 version 3
2022-03-07 12:13:41.413 12139-12139/com.heytap.smarthome I/MMKV: <MMKV_IO.cpp:130::loadFromFile> loaded [com.heytap.smarthome_main_prefs] with 4 key-values
2022-03-07 12:13:41.430 12139-12139/com.heytap.smarthome D/SmartHome.sp2mmkvtest: spName=upgrade_info
2022-03-07 12:13:41.430 12139-12139/com.heytap.smarthome I/MMKV: <MemoryFile.cpp:97::open> open fd[0x54], /data/user/0/com.heytap.smarthome/files/mmkv/upgrade_info
2022-03-07 12:13:41.430 12139-12139/com.heytap.smarthome I/MMKV: <MemoryFile.cpp:97::open> open fd[0x55], /data/user/0/com.heytap.smarthome/files/mmkv/upgrade_info.crc
2022-03-07 12:13:41.430 12139-12139/com.heytap.smarthome I/MMKV: <MMKV_IO.cpp:81::loadFromFile> loading [upgrade_info] with 0 actual size, file size 4096, InterProcess 0, meta info version:1
2022-03-07 12:13:41.430 12139-12139/com.heytap.smarthome I/MMKV: <MMKV_IO.cpp:130::loadFromFile> loaded [upgrade_info] with 0 key-values
2022-03-07 12:13:41.436 12139-12139/com.heytap.smarthome D/SmartHome.sp2mmkvtest: spName=dynamic_load_configs
2022-03-07 12:13:41.436 12139-12139/com.heytap.smarthome I/MMKV: <MemoryFile.cpp:97::open> open fd[0x56], /data/user/0/com.heytap.smarthome/files/mmkv/dynamic_load_configs
2022-03-07 12:13:41.436 12139-12139/com.heytap.smarthome I/MMKV: <MemoryFile.cpp:97::open> open fd[0x57], /data/user/0/com.heytap.smarthome/files/mmkv/dynamic_load_configs.crc
2022-03-07 12:13:41.436 12139-12139/com.heytap.smarthome I/MMKV: <MMKV_IO.cpp:81::loadFromFile> loading [dynamic_load_configs] with 0 actual size, file size 4096, InterProcess 0, meta info version:1
2022-03-07 12:13:41.436 12139-12139/com.heytap.smarthome I/MMKV: <MMKV_IO.cpp:130::loadFromFile> loaded [dynamic_load_configs] with 0 key-values
2022-03-07 12:13:41.442 12139-12139/com.heytap.smarthome D/SmartHome.sp2mmkvtest: spName=com.heytap.smarthome_big_prefs
2022-03-07 12:13:41.442 12139-12139/com.heytap.smarthome I/MMKV: <MemoryFile.cpp:97::open> open fd[0x58], /data/user/0/com.heytap.smarthome/files/mmkv/com.heytap.smarthome_big_prefs
2022-03-07 12:13:41.442 12139-12139/com.heytap.smarthome I/MMKV: <MemoryFile.cpp:97::open> open fd[0x59], /data/user/0/com.heytap.smarthome/files/mmkv/com.heytap.smarthome_big_prefs.crc
2022-03-07 12:13:41.442 12139-12139/com.heytap.smarthome I/MMKV: <MMKV_IO.cpp:81::loadFromFile> loading [com.heytap.smarthome_big_prefs] with 0 actual size, file size 4096, InterProcess 0, meta info version:1
2022-03-07 12:13:41.442 12139-12139/com.heytap.smarthome I/MMKV: <MMKV_IO.cpp:130::loadFromFile> loaded [com.heytap.smarthome_big_prefs] with 0 key-values
2022-03-07 12:13:41.918 12092-12092/com.example.mmkvtest D/DataRecoverTest: -----register Handler------
2022-03-07 12:13:49.669 12092-12092/com.example.mmkvtest D/DataRecoverTest: -----get Instance------
2022-03-07 12:13:49.669 12092-12092/com.example.mmkvtest I/MMKV: <MemoryFile.cpp:97::open> open fd[0x4a], /data/user/0/com.example.mmkvtest/files/mmkv_datarecover_test/dataRecoverTest1
2022-03-07 12:13:49.669 12092-12092/com.example.mmkvtest I/MMKV: <MemoryFile.cpp:97::open> open fd[0x6b], /data/user/0/com.example.mmkvtest/files/mmkv_datarecover_test/dataRecoverTest1.crc
2022-03-07 12:13:49.669 12092-12092/com.example.mmkvtest E/MMKV: <MMKV.cpp:395::checkFileCRCValid> check crc [dataRecoverTest1] fail, crc32:1724902607, m_crcDigest:287494659
2022-03-07 12:13:49.669 12092-12092/com.example.mmkvtest I/MMKV: <MMKV_IO.cpp:81::loadFromFile> loading [dataRecoverTest1] with 4 actual size, file size 4096, InterProcess 0, meta info version:3
2022-03-07 12:13:49.669 12092-12092/com.example.mmkvtest I/MMKV: <MMKV_IO.cpp:86::loadFromFile> loading [dataRecoverTest1] with crc 1285129681 sequence 1 version 3
2022-03-07 12:13:49.669 12092-12092/com.example.mmkvtest I/MMKV: <MMKV_IO.cpp:130::loadFromFile> loaded [dataRecoverTest1] with 0 key-values
2022-03-07 12:13:55.475 12092-12092/com.example.mmkvtest D/DataRecoverTest: -----read data------
2022-03-07 12:13:55.475 12092-12092/com.example.mmkvtest D/DataRecoverTest: string: null
2022-03-07 12:13:55.475 12092-12092/com.example.mmkvtest D/DataRecoverTest: int: 0
lingol commented 2 years ago

According to the logs, MMKV already detects the error.

2022-03-07 12:13:49.669 12092-12092/com.example.mmkvtest E/MMKV: check crc [dataRecoverTest1] fail, crc32:1724902607, m_crcDigest:287494659

But it didn't call any error handler. Maybe it's the auto-recovery logic making the decision. You might override the .crc file as well, to corrupt the info for auto-recovery inside it.

lingol commented 2 years ago

One more thing, never call MMKV.initialize() in your MainActivity, MMKV.registerHandler() as well. Because the MainActivity will destroy & recreate more than once. Do it in your MainApplication.

ghost commented 2 years ago

According to the logs, MMKV already detects the error.

2022-03-07 12:13:49.669 12092-12092/com.example.mmkvtest E/MMKV: MMKV.cpp:395::checkFileCRCValid check crc [dataRecoverTest1] fail, crc32:1724902607, m_crcDigest:287494659

But it didn't call any error handler. Maybe it's the auto-recovery logic making the decision. You might override the .crc file as well, to corrupt the info for auto-recovery inside it.

你的意思是.crc文件中有保存是否自动恢复的字段,让我在kill app后修改该字段?我看了源码这个结构 image 代表crc文件结构,是哪个字段?

ghost commented 2 years ago

I think I need to study the source code for registerHandler() and related logic, wait.

lingol commented 2 years ago

Short answer: just delete the crc file. Long answer: it's m_lastConfirmedMetaInfo. The logic is https://github.com/Tencent/MMKV/blob/master/Core/MMKV_IO.cpp#L181 .

ghost commented 2 years ago

thanks, I delete the crc file and the onMMKVCRCCheckFail() is called. 有2个问题请教下:

  1. 我之前读过这块lambda源码 image 但不太能理解,网上也很少有分析这段逻辑。感觉还是要理解清楚之后好解决问题,请问有什么建议吗?
  2. 我直接把mmkv整个仓库git clone下来,目前在Android Studio中C层的代码没法建立和java层一样的交叉引用,所以只能全局搜索keyword来学习,有什么方法能建立交叉引用呢?
lingol commented 2 years ago

The issue is solved. Those further questions you asked, well, what you need to do is learn NDK development.