wangyongj 2 лет назад
Родитель
Сommit
78bfaabe3b

BIN
app/release/emulator.apk


+ 0 - 20
app/release/output-metadata.json

@@ -1,20 +0,0 @@
-{
-  "version": 3,
-  "artifactType": {
-    "type": "APK",
-    "kind": "Directory"
-  },
-  "applicationId": "com.xugame.gameconsole",
-  "variantName": "release",
-  "elements": [
-    {
-      "type": "SINGLE",
-      "filters": [],
-      "attributes": [],
-      "versionCode": 1,
-      "versionName": "1.0",
-      "outputFile": "app-release.apk"
-    }
-  ],
-  "elementType": "File"
-}

+ 40 - 26
app/src/main/AndroidManifest.xml

@@ -3,14 +3,21 @@
     xmlns:tools="http://schemas.android.com/tools"
     package="com.xugame.gameconsole"
     android:installLocation="internalOnly"
-    android:versionCode="1597175257"
-    android:versionName="1.15.0"
     android:sharedUserId="android.uid.system"
-    >
+    android:versionCode="1597175257"
+    android:versionName="1.15.0">
+
     <uses-feature android:glEsVersion="0x00020000" />
-    <uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
-    <uses-feature android:name="android.software.leanback" android:required="false" />
-    <uses-feature android:name="android.hardware.gamepad" android:required="false"/>
+    <uses-feature
+        android:name="android.hardware.touchscreen"
+        android:required="false" />
+    <uses-feature
+        android:name="android.software.leanback"
+        android:required="false" />
+    <uses-feature
+        android:name="android.hardware.gamepad"
+        android:required="false" />
+
     <uses-permission android:name="android.permission.VIBRATE" />
 
     <uses-permission android:name="android.permission.INTERNET" />
@@ -33,45 +40,53 @@
     <!--    <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>-->
 
 
-
     <uses-permission android:name="android.permission.RECORD_AUDIO" />
 
 
     <application
-        android:allowBackup="true"
         android:allowAudioPlaybackCapture="true"
+        android:allowBackup="true"
+        android:extractNativeLibs="true"
+        android:hasCode="true"
         android:icon="@mipmap/ic_launcher"
+        android:isGame="true"
         android:label="@string/app_name"
+        android:requestLegacyExternalStorage="true"
         android:roundIcon="@mipmap/ic_launcher"
         android:supportsRtl="true"
-        android:isGame="true"
-        android:hasCode="true"
-        android:extractNativeLibs="true"
-        android:requestLegacyExternalStorage="true"
         android:theme="@style/Theme.GameConsole"
-        tools:ignore="UnusedAttribute"
-        >
+        tools:ignore="UnusedAttribute">
         <activity
             android:name=".TextCopyFileActivity"
-            android:launchMode="singleTop"
             android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale"
+            android:exported="true"
 
-            android:exported="true">
+            android:launchMode="singleTop">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
+                <data
+                    android:host="com.xugame.gameconsole.TextCopyFileActivity"
+                    android:scheme="com.xugame.gameconsole.TextCopyFileActivity"
+                    tools:ignore="AppLinkUrlError" />
             </intent-filter>
         </activity>
-        <activity android:name=".MainActivity"
-            android:exported="true"
+        <activity
+            android:name=".MainActivity"
             android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale"
-            ></activity>
+            android:exported="true">
+            <intent-filter>
+                <data
+                    android:host="com.xugame.gameconsole.MainActivity"
+                    android:scheme="com.xugame.gameconsole.MainActivity"
+                    tools:ignore="AppLinkUrlError" />
+            </intent-filter>
+        </activity>
         <activity
             android:name=".emulator.RetroArchEmulatorActivity"
             android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale"
 
-            android:launchMode="standard"
-            >
+            android:launchMode="standard">
             <meta-data
                 android:name="android.app.lib_name"
                 android:value="retroarch-activity" />
@@ -80,8 +95,7 @@
                 android:value="ANativeActivity_onCreate" />
         </activity>
 
-        <activity android:name=".Test2Activity"
-            >
+        <activity android:name=".Test2Activity">
             <meta-data
                 android:name="android.app.lib_name"
                 android:value="retroarch-activity" />
@@ -90,14 +104,14 @@
                 android:value="ANativeActivity_onCreate" />
 
         </activity>
-        <activity android:name="com.xugame.Test3Activity"
-            ></activity>
+        <activity android:name="com.xugame.Test3Activity"></activity>
+
         <provider
             android:name="com.retroarch.browser.provider.RetroDocumentsProvider"
             android:authorities="${applicationId}.documents"
-            android:grantUriPermissions="true"
             android:enabled="@bool/document_provider_enabled"
             android:exported="true"
+            android:grantUriPermissions="true"
             android:permission="android.permission.MANAGE_DOCUMENTS">
             <intent-filter>
                 <action android:name="android.content.action.DOCUMENTS_PROVIDER" />

+ 1 - 1
app/src/main/java/com/xugame/gameconsole/MainActivity.java

@@ -269,7 +269,7 @@ public class MainActivity extends PreferenceActivity implements View.OnClickList
         // Bind audio stream to hardware controls.
         setVolumeControlStream(AudioManager.STREAM_MUSIC);
 
-        UserPreferences.updateConfigFile(this);
+        UserPreferences.updateConfigFile(this,baseUsbPath+File.separator+"/system");
 
         checkRuntimePermissions();
     }

+ 11 - 7
app/src/main/java/com/xugame/gameconsole/emulator/RetroArchEmulatorActivity.java

@@ -114,13 +114,17 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
 
     @Override
     public void showLocalExitDialog() {
-        runOnUiThread(new Runnable() {
-            @Override
-            public void run() {
-                showDialog();
-            }
-        });
-
+//        runOnUiThread(new Runnable() {
+//            @Override
+//            public void run() {
+//                showDialog();
+//            }
+//        });
+        Intent intent=new Intent();//调出主菜单UI
+        ComponentName componentName=new ComponentName("com.xugame.gameconsoleMenu",
+                "com.xugame.gameconsole.dialog.localgamesetting.LocalGameSettingDialog");
+        intent.setComponent(componentName);
+        startActivityForResult(intent,200);
         DebugUtil.i(TAG,"showLocalExitDialog");
     }
 

+ 32 - 63
app/src/main/java/com/xugame/gameconsole/preferences/UserPreferences.java

@@ -21,19 +21,16 @@ public class UserPreferences {
     private static final String TAG = "UserPreferences";
 
     // Disallow explicit instantiation.
-    private UserPreferences()
-    {
+    private UserPreferences() {
     }
 
     /**
      * Retrieves the path to the default location of the libretro config.
      *
      * @param ctx the current {@link Context}
-     *
      * @return the path to the default location of the libretro config.
      */
-    public static String getDefaultConfigPath(Context ctx)
-    {
+    public static String getDefaultConfigPath(Context ctx) {
         // Internal/External storage dirs.
         final String internal = ctx.getFilesDir().getAbsolutePath();
         String external = null;
@@ -58,30 +55,23 @@ public class UserPreferences {
 
         String append_path;
         // If we aren't using the global config.
-        if (!globalConfigEnabled && !libretro_path.equals(coreDir))
-        {
+        if (!globalConfigEnabled && !libretro_path.equals(coreDir)) {
             String sanitized_name = sanitizeLibretroPath(libretro_path);
             append_path = File.separator + sanitized_name + ".cfg";
-        }
-        else // Using global config.
+        } else // Using global config.
         {
             append_path = File.separator + "retroarch.cfg";
         }
 
-        if (external != null)
-        {
+        if (external != null) {
             String confPath = external + append_path;
             if (new File(confPath).exists())
                 return confPath;
-        }
-        else if (internal != null)
-        {
+        } else if (internal != null) {
             String confPath = internal + append_path;
             if (new File(confPath).exists())
                 return confPath;
-        }
-        else
-        {
+        } else {
             String confPath = "/mnt/extsd" + append_path;
             if (new File(confPath).exists())
                 return confPath;
@@ -101,9 +91,7 @@ public class UserPreferences {
 
         try {
             new File(new_path).createNewFile();
-        }
-        catch (IOException e)
-        {
+        } catch (IOException e) {
             Log.e(TAG, "Failed to create config file to: " + new_path);
         }
         return new_path;
@@ -115,8 +103,7 @@ public class UserPreferences {
      *
      * @param ctx the current {@link Context}.
      */
-    public static void updateConfigFile(Context ctx)
-    {
+    public static void updateConfigFile(Context ctx, String systemDir) {
         String path = getDefaultConfigPath(ctx);
         ConfigFile config = new ConfigFile(path);
 
@@ -133,6 +120,8 @@ public class UserPreferences {
         config.setString("input_overlay_enable", "false");
         config.setBoolean("log_verbosity", true);
         config.setBoolean("fps_show", true);
+        config.setString("system_directory", systemDir);//20230829添加system路径设置
+        DebugUtil.i(TAG,"write system dir:"+systemDir);
         config.setInt("input_player1_analog_dpad_mode", 1);
 
         config.setInt("frontend_log_level", 1);
@@ -143,66 +132,56 @@ public class UserPreferences {
             config.setInt("audio_out_rate", samplingRate);
         }
 
-        try
-        {
-            int version							= ctx.getPackageManager().
+        try {
+            int version = ctx.getPackageManager().
                     getPackageInfo(ctx.getPackageName(), 0).versionCode;
-            final String dst_path			= dataDir;
-            final String dst_path_subdir	= "assets";
+            final String dst_path = dataDir;
+            final String dst_path_subdir = "assets";
 
             Log.i(TAG, "dst dir is: " + dst_path);
             Log.i(TAG, "dst subdir is: " + dst_path_subdir);
 
             config.setString("bundle_assets_src_path", ctx.getApplicationInfo().sourceDir);
-            DebugUtil.i(TAG,"source="+ctx.getApplicationInfo().sourceDir);
-            DebugUtil.i(TAG,"versionCode="+version);
+            DebugUtil.i(TAG, "source=" + ctx.getApplicationInfo().sourceDir);
+            DebugUtil.i(TAG, "versionCode=" + version);
             config.setString("bundle_assets_dst_path", dst_path);
             config.setString("bundle_assets_dst_path_subdir", dst_path_subdir);
             config.setInt("bundle_assets_extract_version_current", version);
-        }
-        catch (PackageManager.NameNotFoundException ignored)
-        {
+        } catch (PackageManager.NameNotFoundException ignored) {
         }
 
         // Refactor this entire mess and make this usable for per-core config
-        if (Build.VERSION.SDK_INT >= 17 && prefs.getBoolean("audio_latency_auto", true))
-        {
+        if (Build.VERSION.SDK_INT >= 17 && prefs.getBoolean("audio_latency_auto", true)) {
             int bufferSize = getLowLatencyBufferSize(ctx);
             if (bufferSize != -1) {
                 config.setInt("audio_block_frames", bufferSize);
             }
         }
 
-        try
-        {
+        try {
             config.write(path);
-        }
-        catch (IOException e)
-        {
+        } catch (IOException e) {
             Log.e(TAG, "Failed to save config file to: " + path);
         }
     }
 
-    private static void readbackString(ConfigFile cfg, SharedPreferences.Editor edit, String key)
-    {
+    private static void readbackString(ConfigFile cfg, SharedPreferences.Editor edit, String key) {
         if (cfg.keyExists(key))
             edit.putString(key, cfg.getString(key));
         else
             edit.remove(key);
     }
 
-    private static void readbackBool(ConfigFile cfg, SharedPreferences.Editor edit, String key)
-    {
+    private static void readbackBool(ConfigFile cfg, SharedPreferences.Editor edit, String key) {
         if (cfg.keyExists(key))
             edit.putBoolean(key, cfg.getBoolean(key));
         else
             edit.remove(key);
     }
 
-    private static void readbackDouble(ConfigFile cfg, SharedPreferences.Editor edit, String key)
-    {
+    private static void readbackDouble(ConfigFile cfg, SharedPreferences.Editor edit, String key) {
         if (cfg.keyExists(key))
-            edit.putFloat(key, (float)cfg.getDouble(key));
+            edit.putFloat(key, (float) cfg.getDouble(key));
         else
             edit.remove(key);
     }
@@ -231,11 +210,9 @@ public class UserPreferences {
      * Sanitizes a libretro core path.
      *
      * @param path The path to the libretro core.
-     *
      * @return the sanitized libretro path.
      */
-    private static String sanitizeLibretroPath(String path)
-    {
+    private static String sanitizeLibretroPath(String path) {
         String sanitized_name = path.substring(
                 path.lastIndexOf('/') + 1,
                 path.lastIndexOf('.'));
@@ -249,11 +226,9 @@ public class UserPreferences {
      * Gets a {@link SharedPreferences} instance containing current settings.
      *
      * @param ctx the current {@link Context}.
-     *
      * @return A SharedPreference instance containing current settings.
      */
-    public static SharedPreferences getPreferences(Context ctx)
-    {
+    public static SharedPreferences getPreferences(Context ctx) {
         return PreferenceManager.getDefaultSharedPreferences(ctx);
     }
 
@@ -261,16 +236,14 @@ public class UserPreferences {
      * Gets the optimal sampling rate for low-latency audio playback.
      *
      * @param ctx the current {@link Context}.
-     *
      * @return the optimal sampling rate for low-latency audio playback in Hz.
      */
     @TargetApi(17)
-    private static int getLowLatencyOptimalSamplingRate(Context ctx)
-    {
+    private static int getLowLatencyOptimalSamplingRate(Context ctx) {
         AudioManager manager = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
         String value = manager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
 
-        if(value == null || value.isEmpty()) {
+        if (value == null || value.isEmpty()) {
             return -1;
         }
 
@@ -281,16 +254,14 @@ public class UserPreferences {
      * Gets the optimal buffer size for low-latency audio playback.
      *
      * @param ctx the current {@link Context}.
-     *
      * @return the optimal output buffer size in decimal PCM frames.
      */
     @TargetApi(17)
-    private static int getLowLatencyBufferSize(Context ctx)
-    {
+    private static int getLowLatencyBufferSize(Context ctx) {
         AudioManager manager = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
         String value = manager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
 
-        if(value == null || value.isEmpty()) {
+        if (value == null || value.isEmpty()) {
             return -1;
         }
 
@@ -309,11 +280,9 @@ public class UserPreferences {
      * as returned by the hardware.
      *
      * @param ctx The current {@link Context}.
-     *
      * @return the optimal audio sampling rate in Hz.
      */
-    private static int getOptimalSamplingRate(Context ctx)
-    {
+    private static int getOptimalSamplingRate(Context ctx) {
         int ret;
         if (Build.VERSION.SDK_INT >= 17)
             ret = getLowLatencyOptimalSamplingRate(ctx);