liyujie
2025-08-28 786ff4f4ca2374bdd9177f2e24b503d43e7a3b93
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
commit 4f461e76f27e4e57d8cec0fa408c9f335626b9cf
Author: zengshuchuan <zengshuchuan@allwinnertech.com>
Date:   Fri Dec 22 15:34:45 2017 +0800
 
    support start test apk
    
    1.add function of open dragonfire
    2.add permission to write external storage
    3.change signature to platform
    
    Change-Id: I32bbdedcbe2f09dbe1f6aaf868871432fcbdea3b
 
diff --git a/Android.mk b/Android.mk
index 5b92157..6433d21 100644
--- a/Android.mk
+++ b/Android.mk
@@ -33,6 +33,8 @@ LOCAL_SDK_VERSION := current
 LOCAL_PACKAGE_NAME := ExactCalculator
 LOCAL_OVERRIDES_PACKAGES := Calculator
 
+LOCAL_CERTIFICATE := platform
+
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_PROGUARD_FLAG_FILES := proguard.flags
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index a7675b1..72e1a9e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -18,6 +18,8 @@
 <manifest
     xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.android.calculator2">
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+    <uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE"/>
 
     <application
         android:allowBackup="false"
diff --git a/src/com/android/calculator2/Calculator.java b/src/com/android/calculator2/Calculator.java
index b3d79eb..080f493 100644
--- a/src/com/android/calculator2/Calculator.java
+++ b/src/com/android/calculator2/Calculator.java
@@ -868,6 +868,13 @@ public class Calculator extends Activity
                     evaluateInstantIfNecessary();
                 }
                 return;
+            case R.id.op_add:
+                //when sd card exist "custom_cases.xml", open test mode, check if Calculator's display TEST_MODE_KEY, then startup DragonFire application.
+                String str = mFormulaText.getText().toString();
+                if (TestModeManager.start(view.getContext(), str)) {
+                    onClear();
+                    break;
+                }
             default:
                 cancelIfEvaluating(false);
                 if (haveUnprocessed()) {
diff --git a/src/com/android/calculator2/TestModeManager.java b/src/com/android/calculator2/TestModeManager.java
new file mode 100755
index 0000000..ff7bc17
--- /dev/null
+++ b/src/com/android/calculator2/TestModeManager.java
@@ -0,0 +1,85 @@
+package com.android.calculator2;
+
+import java.io.File;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+public class TestModeManager {
+    private final static boolean debug = true;
+    private final static String TAG = "TestModeManager";
+    public final static String TEST_MODE_KEY = "33+";
+    public final static String TEST_MODE_CONFIG = "23+";
+    private final static String FLAG_INNER = "/system/etc/custom_cases.xml";
+    private final static String FLAG_SDCARD = "/mnt/sdcard/DragonFire/custom_cases.xml";
+    private final static String FLAG_AGING_SDCARD = "/mnt/sdcard/DragonFire/custom_cases_aging.xml";
+    private final static String FLAG_SDCARD_CONFIG = "/mnt/sdcard/DragonFire/";
+
+    public static boolean start(Context context, String inputKey) {
+        if (inputKey.equals(TEST_MODE_CONFIG)) {
+            return checkAndStartConfig(context);
+        } else if (inputKey.equals(TEST_MODE_KEY)) {
+            return checkAndStart(context);
+        }
+        return false;
+    }
+
+    private static boolean checkAndStart(Context context) {
+        if (debug) Log.d(TAG, "checkAndStart");
+        boolean b = false;
+        File file = findDragonFire("/storage", "DragonFire/custom_cases.xml");
+        File agingfile = findDragonFire("/storage", "DragonFire/custom_cases_aging.xml");
+        if (file != null || agingfile != null || new File(FLAG_SDCARD).exists() || new File(FLAG_AGING_SDCARD).exists() || new File(FLAG_INNER).exists()) {
+            if (debug) Log.d(TAG, "starting test");
+            Intent i = new Intent();
+            ComponentName component = new ComponentName(
+                    "com.softwinner.dragonfire",
+                    "com.softwinner.dragonfire.SplashScreen_test");
+
+            i.setComponent(component);
+            try {
+                if (debug) Log.d(TAG, "start dragonfire test");
+                context.startActivity(i);
+                b = true;
+            } catch (Exception e) {
+            }
+        }
+        return b;
+    }
+
+    private static boolean checkAndStartConfig(Context context) {
+        if (debug) Log.d(TAG, "checkAndStartConfig");
+        boolean b = false;
+        File file = findDragonFire("/storage", "DragonFire");
+        if (file != null || new File(FLAG_SDCARD_CONFIG).exists() || new File(FLAG_INNER).exists()) {
+            if (debug) Log.d(TAG, "starting test config");
+            Intent i = new Intent();
+            ComponentName component = new ComponentName(
+                    "com.softwinner.dragonfire",
+                    "com.softwinner.dragonfire.SplashScreen_configuration");
+            i.setComponent(component);
+            try {
+                context.startActivity(i);
+                b = true;
+            } catch (Exception e) {
+            }
+        }
+        return b;
+    }
+
+    private static File findDragonFire(String dir, String path) {
+        File file = new File(dir);
+        File list[] = file.listFiles();
+        for (File f : list) {
+            if (f.isDirectory()) {
+                File dfFile = new File(f, path);
+                if (dfFile.exists())
+                    return dfFile;
+            }
+        }
+        return null;
+    }
+}
+