zhunk пре 6 месеци
родитељ
комит
9ec93a8293

+ 2 - 0
app_bzy_armhf_7/android/AndroidManifest.xml

@@ -3,6 +3,8 @@
     <!-- Enable instant app support -->
     <!-- <module dist:instant="true"/> -->
     <application android:allowBackup="true" android:allowNativeHeapPointerTagging="false" android:hardwareAccelerated="true" android:extractNativeLibs="true" android:name="com.felgo.helper.FelgoApplication" android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:theme="@style/AppTheme" android:preserveLegacyExternalStorage="true" android:requestLegacyExternalStorage="true">
+        <!-- ========== 全志A133P特定OpenGL配置 ========== -->
+        <meta-data android:name="android.opengl.ESVersion" android:value="0x00020000"/>
         <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="com.felgo.helper.FelgoActivity" android:exported="true" android:launchMode="singleTop" android:label="@string/app_name" android:screenOrientation="landscape" android:excludeFromRecents="true" android:taskAffinity="com.yfkj.bzyv1">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>

+ 136 - 2
app_bzy_armhf_7/android/src/com/yfkj/bzyv1/MyQtActivity.java

@@ -5,6 +5,9 @@ import com.felgo.helper.FelgoActivity;
 import android.view.WindowManager;
 import android.util.Log;
 import android.content.pm.PackageManager;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
 
 public class MyQtActivity extends FelgoActivity {
     private static Activity currentActivity;
@@ -17,9 +20,19 @@ public class MyQtActivity extends FelgoActivity {
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
+        // ========== 关键:在super.onCreate之前就清理缓存 ==========
+        // 这是防止花屏的最重要步骤
+        Log.d("MyQtActivity", "===== START: Pre-clearing all caches BEFORE onCreate =====");
+        clearAllCaches(this);
+        Log.d("MyQtActivity", "===== END: Pre-clearing all caches =====");
+        
         super.onCreate(savedInstanceState);
         currentActivity = this;
         
+        // ========== 再次清理(确保彻底)==========
+        Log.d("MyQtActivity", "===== Second cache clearing pass =====");
+        clearAllCaches(this);
+        
         // 初始化权限管理
         initPermissions();
     }
@@ -128,6 +141,127 @@ public class MyQtActivity extends FelgoActivity {
     public static Activity getCurrentActivity() {
         return currentActivity;
     }
-
-
+    
+    @Override
+    protected void onDestroy() {
+        Log.d("MyQtActivity", "===== onDestroy: Final cache clearing =====");
+        clearAllCaches(this);
+        super.onDestroy();
+    }
+    
+    @Override
+    protected void onPause() {
+        super.onPause();
+        Log.d("MyQtActivity", "===== onPause: Clearing caches =====");
+        clearAllCaches(this);
+    }
+    
+    // ========== 全志A133P专用:彻底清理所有缓存 ==========
+    public static void clearAllCaches(Activity activity) {
+        try {
+            Log.d("CacheCleaner", "Starting comprehensive cache clearing...");
+            
+            // ========== 1. 清理应用缓存目录 ==========
+            File cacheDir = activity.getCacheDir();
+            if (cacheDir != null && cacheDir.exists()) {
+                deleteDirectory(cacheDir);
+                Log.d("CacheCleaner", "Cleared app cache dir: " + cacheDir.getAbsolutePath());
+            }
+            
+            // ========== 2. 清理代码缓存目录 ==========
+            File codeCacheDir = activity.getCodeCacheDir();
+            if (codeCacheDir != null && codeCacheDir.exists()) {
+                deleteDirectory(codeCacheDir);
+                Log.d("CacheCleaner", "Cleared code cache dir: " + codeCacheDir.getAbsolutePath());
+            }
+            
+            // ========== 3. 清理外部缓存目录 ==========
+            File externalCacheDir = activity.getExternalCacheDir();
+            if (externalCacheDir != null && externalCacheDir.exists()) {
+                deleteDirectory(externalCacheDir);
+                Log.d("CacheCleaner", "Cleared external cache dir: " + externalCacheDir.getAbsolutePath());
+            }
+            
+            // ========== 4. 清理数据目录中的特定缓存 ==========
+            File dataDir = activity.getFilesDir().getParentFile();
+            if (dataDir != null && dataDir.exists()) {
+                List<String> cacheSubdirs = new ArrayList<String>();
+                cacheSubdirs.add("cache");
+                cacheSubdirs.add("code_cache");
+                cacheSubdirs.add("app_texturecache");
+                cacheSubdirs.add("app_qmlcache");
+                cacheSubdirs.add("app_qt_shader_cache");
+                cacheSubdirs.add("app_rhi_cache");
+                cacheSubdirs.add("app_scenegraph_cache");
+                cacheSubdirs.add("app_shader_cache");
+                // cacheSubdirs.add("shared_prefs");  // 注意:这会清除SharedPreferences,暂时禁用
+                
+                for (String subdir : cacheSubdirs) {
+                    File dir = new File(dataDir, subdir);
+                    if (dir.exists()) {
+                        deleteDirectory(dir);
+                        Log.d("CacheCleaner", "Cleared cache subdir: " + dir.getAbsolutePath());
+                    }
+                }
+            }
+            
+            // ========== 5. 清理整个应用数据目录(谨慎!)==========
+            // 警告:这会清除所有数据,包括用户设置和数据库
+            // 只在需要完全重置时启用
+            // clearApplicationData(activity);
+            
+            Log.d("CacheCleaner", "Cache clearing completed successfully!");
+            
+        } catch (Exception e) {
+            Log.e("CacheCleaner", "Error clearing caches: " + e.getMessage(), e);
+        }
+    }
+    
+    // ========== 递归删除目录 ==========
+    private static boolean deleteDirectory(File dir) {
+        if (dir == null || !dir.exists()) {
+            return true;
+        }
+        
+        boolean success = true;
+        
+        File[] files = dir.listFiles();
+        if (files != null) {
+            for (File file : files) {
+                if (file.isDirectory()) {
+                    success = success && deleteDirectory(file);
+                } else {
+                    success = success && file.delete();
+                }
+            }
+        }
+        
+        success = success && dir.delete();
+        return success;
+    }
+    
+    // ========== 清理整个应用数据(谨慎使用)==========
+    public static void clearApplicationData(Activity activity) {
+        try {
+            Log.w("CacheCleaner", "===== WARNING: Clearing ALL application data! =====");
+            
+            File dataDir = activity.getFilesDir().getParentFile();
+            if (dataDir != null && dataDir.exists()) {
+                String[] children = dataDir.list();
+                if (children != null) {
+                    for (String child : children) {
+                        // 不删除lib目录
+                        if (!"lib".equals(child)) {
+                            deleteDirectory(new File(dataDir, child));
+                        }
+                    }
+                }
+            }
+            
+            Log.w("CacheCleaner", "===== All application data cleared! =====");
+            
+        } catch (Exception e) {
+            Log.e("CacheCleaner", "Error clearing application data: " + e.getMessage(), e);
+        }
+    }
 }

+ 151 - 9
app_bzy_armhf_7/main.cpp

@@ -276,12 +276,147 @@ QStringList m_permissions = {
     "android.permission.WAKE_LOCK",
     "android.permission.VIBRATE"
 };
+// ========== 全志A133P缓存清理函数(关键)==========
+void clearAllCaches() {
+#ifndef WIN32
+    QDir dir;
+    
+    // ========== 1. 标准缓存位置 ==========
+    QStringList cacheLocations = {
+        QStandardPaths::writableLocation(QStandardPaths::CacheLocation),
+        QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation),
+        QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation),
+        QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
+    };
+    
+    // ========== 2. Android特定缓存位置 ==========
+    cacheLocations << QDir::homePath() + "/.cache";
+    cacheLocations << QDir::homePath() + "/.local/share";
+    
+    // ========== 3. 所有需要清理的缓存目录 ==========
+    QStringList cacheDirs = {
+        "qmlsc", "qml", "rhi", "scenegraph", "shaders", "pipelines",
+        "graphicsshadercache", "QtShaderCache", "QtQuick", "cache",
+        "Qt", "shadercache", "textures", "graphics", "RenderCache",
+        "ShaderCache", "TextureCache"
+    };
+    
+    QStringList cacheFileFilters = {"*.qmlc", "*.jsc", "*.cache", "*.tmp"};
+    
+    // ========== 4. 遍历并清理 ==========
+    for (const QString &cachePath : cacheLocations) {
+        QDir cacheDir(cachePath);
+        if (cacheDir.exists()) {
+            qDebug() << "Scanning cache location:" << cachePath;
+            
+            // 清理指定目录
+            for (const QString &subDir : cacheDirs) {
+                QDir sub(cacheDir.filePath(subDir));
+                if (sub.exists()) {
+                    sub.removeRecursively();
+                    qDebug() << "Cleared cache directory:" << sub.absolutePath();
+                }
+            }
+            
+            // 清理匹配的缓存文件
+            cacheDir.setNameFilters(cacheFileFilters);
+            QStringList files = cacheDir.entryList(QDir::Files);
+            for (const QString &file : files) {
+                cacheDir.remove(file);
+                qDebug() << "Removed cache file:" << cacheDir.filePath(file);
+            }
+        }
+    }
+    
+    // ========== 5. 清理临时文件 ==========
+    QDir tempDir(QDir::tempPath());
+    if (tempDir.exists()) {
+        QStringList filters;
+        filters << "Qt*" << "qml*" << "shader*" << "rhi*";
+        tempDir.setNameFilters(filters);
+        QStringList tempFiles = tempDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
+        for (const QString &tempFile : tempFiles) {
+            QFileInfo info(tempDir.filePath(tempFile));
+            if (info.isDir()) {
+                QDir(tempDir.filePath(tempFile)).removeRecursively();
+            } else {
+                tempDir.remove(tempFile);
+            }
+            qDebug() << "Removed temp file/dir:" << tempDir.filePath(tempFile);
+        }
+    }
+    
+    qDebug() << "All caches cleared successfully!";
+#endif
+}
+
 int main(int argc, char *argv[])
 {
-    //sendBroadcastFromQt("service");
+#if 0
+    // ========== 第一阶段:在任何Qt对象创建前先清理所有缓存 ==========
+    // 这是解决"第一次正常,第二次花屏"的关键!
+    clearAllCaches();
+    
+    // ========== 全志A133P ARM32渲染修复(终极版)==========
+    // 在QGuiApplication创建前设置环境变量
+    
+    // ========== 核心图形API配置 ==========
+    qputenv("QSG_RHI_BACKEND", "opengl");
+    qputenv("QSG_RENDERING_BACKEND", "opengl");
+    qputenv("QT_QUICK_BACKEND", "opengl");
+    
+    // ========== OpenGL ES版本强制配置(全志A133P关键)==========
+    qputenv("QT_OPENGL_FORCE_GLES2", "1");    // 强制使用OpenGL ES 2.0
+    qputenv("QT_OPENGL_NO_ES3", "1");         // 禁用OpenGL ES 3.0
+    qputenv("QT_OPENGL_NO_ES31", "1");        // 禁用OpenGL ES 3.1
+    qputenv("QT_OPENGL_NO_ES32", "1");        // 禁用OpenGL ES 3.2
+    
+    // ========== 渲染循环配置 ==========
+    qputenv("QSG_RENDER_LOOP", "basic");      // 使用basic渲染循环,ARM32更稳定
+    
+    // ========== 颜色格式配置(解决花屏关键)==========
+    qputenv("QT_OPENGL_NO_BGRA", "1");
+    qputenv("QT_QPA_EGLFS_FORCE888", "1");     // 强制24位色深
+    
+    // ========== 缓冲和缓存禁用(避免ARM32兼容性问题)==========
+    qputenv("QSG_DISABLE_DEPTH_BUFFER", "1");  // 禁用深度缓冲
+    qputenv("QSG_DISABLE_STENCIL_BUFFER", "1"); // 禁用模板缓冲
+    qputenv("QSG_DISABLE_ATLAS", "1");         // 禁用纹理图集
+    qputenv("QSG_DISABLE_MIPMAP", "1");        // 禁用MIP映射
+    
+    // ========== 所有类型的缓存完全禁用 ==========
+    qputenv("QML_DISABLE_DISK_CACHE", "1");   // 禁用QML磁盘缓存
+    qputenv("QML_FORCE_DISK_CACHE", "0");
+    qputenv("QSG_RHI_DISABLE_PIPELINE_CACHE", "1");  // 禁用RHI管线缓存
+    qputenv("QT_GL_USE_DISK_SHADER_CACHE", "0");     // 禁用磁盘着色器缓存
+    qputenv("QSG_DISTANCEFIELD_CACHE_SIZE", "0");    // 禁用距离场缓存
+    qputenv("QSG_TEXTURE_CACHE_SIZE", "0");          // 禁用纹理缓存
+    qputenv("QSG_SHADER_CACHE_SIZE", "0");           // 禁用着色器缓存
+    
+    // ========== 更多缓存禁用设置 ==========
+    qputenv("QT_DISABLE_SHADER_CACHE", "1");         // 禁用Qt着色器缓存
+    qputenv("QT_DISABLE_OPENGL_SHADER_CACHE", "1");  // 禁用OpenGL着色器缓存
+    qputenv("QSG_DISABLE_VBO_CACHE", "1");           // 禁用VBO缓存
+    
+    // ========== 渲染风格和质量(降低为最兼容级别)==========
+    qputenv("QSG_SIMPLE_STYLE", "1");         // 使用简单渲染风格
+    qputenv("QT_QUICK_CONTROLS_STYLE", "Basic");
+    qputenv("QSG_ANTIALIASING_METHOD", "disabled");  // 禁用抗锯齿
+    
+    // ========== 调试和信息输出 ==========
+    qputenv("QSG_INFO", "1");
+    qputenv("QSG_VISUALIZE", "0");
+    
+    // ========== 软件渲染器禁用(确保使用硬件加速)==========
+    qputenv("QSG_SOFTWARE_RENDERER", "0");
+    
+    // ========== EGL配置优化(全志A133P特定)==========
+    qputenv("QT_QPA_EGLFS_ALWAYS_SET_MODE", "1");
+    qputenv("QT_QPA_EGLFS_INTEGRATION", "none");
+#endif
     // ========== Android权限申请 ==========
     // 在应用启动时申请所有必要的权限
-    
+
     // 使用正确的API逐个申请权限
     for (const QString &permission : m_permissions) {
         QtAndroidPrivate::checkPermission(permission);
@@ -291,6 +426,20 @@ int main(int argc, char *argv[])
 
     sendBroadcastFromQt("sleep");
     QGuiApplication app(argc, argv);
+
+    // ========== 第二阶段:QGuiApplication创建后再次清理缓存 ==========
+    // 有些缓存只有在QGuiApplication创建后才能正确访问
+    clearAllCaches();
+    LOG("Second cache clear completed!");
+    
+    // ========== 全志A133P窗口配置优化(关键) ==========
+    QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
+    LOG("Graphics API forced: OpenGL");
+    QQuickWindow::setDefaultAlphaBuffer(false);  // 禁用透明缓冲
+    //QQuickWindow::setPersistentOpenGLContext(false);  // 不使用持久化GL上下文
+    QQuickWindow::setSceneGraphBackend("opengl");
+
+    
     MyCppClass myCppClass;
 
 #if WIN32
@@ -652,13 +801,6 @@ int main(int argc, char *argv[])
     QObject::connect(gps_start,&GPSInfo::position_success,[&](){
         emit serialThread.gpsSuccess();
     });
-    QtAndroidPrivate::checkPermission("android.permission.READ_PHONE_STATE");
-
-    QtAndroidPrivate::requestPermission("android.permission.READ_PHONE_STATE");
-
-    QtAndroidPrivate::checkPermission("android.permission.CAMERA");
-
-    QtAndroidPrivate::requestPermission("android.permission.CAMERA");
     return app.exec();
 }
 #include "main.moc"

Разлика између датотеке није приказан због своје велике величине
+ 214 - 173
app_bzy_armhf_7/qml/Main.qml


+ 2 - 2
app_bzy_armhf_7/qml/pages/HomePage.qml

@@ -243,8 +243,8 @@ AppPage {
           width: parent.width *0.995
           height: parent.height*0.1
           Rectangle {
-              anchors.fill: parent
-              //anchors.fill: parent
+              width: parent.width
+              height: parent.height
               color: app.cardColor
               radius: 2
               // 使用Item作为容器,设置固定位置和大小

+ 1 - 3
app_bzy_armhf_7/qml/pages/LoginPage.qml

@@ -23,7 +23,7 @@ AppPage {
     }
 
     onVisibleChanged: {
-        if(loginPage.visible==true){
+        if(loginPage.visible===true){
             numberpad.txtPassword.clear()
         }
     }
@@ -86,6 +86,4 @@ AppPage {
             }
         }
     }
-
-
 }