浏览代码

refactor: [1/n] Separate app into app and app-common

Going forward, app-common should end up containing ONLY unprivileged
code
Peter Cai 2 年之前
父节点
当前提交
6d9e4c579b
共有 46 个文件被更改,包括 177 次插入65 次删除
  1. 1 3
      .idea/compiler.xml
  2. 1 0
      .idea/gradle.xml
  3. 1 0
      app-common/.gitignore
  4. 47 0
      app-common/build.gradle
  5. 0 0
      app-common/consumer-rules.pro
  6. 21 0
      app-common/proguard-rules.pro
  7. 24 0
      app-common/src/androidTest/java/im/angry/openeuicc/common/ExampleInstrumentedTest.kt
  8. 22 0
      app-common/src/main/AndroidManifest.xml
  9. 0 0
      app-common/src/main/java/im/angry/openeuicc/OpenEuiccApplication.kt
  10. 0 0
      app-common/src/main/java/im/angry/openeuicc/core/EuiccChannel.kt
  11. 0 0
      app-common/src/main/java/im/angry/openeuicc/core/EuiccChannelManager.kt
  12. 0 0
      app-common/src/main/java/im/angry/openeuicc/core/OmapiApduInterface.kt
  13. 0 0
      app-common/src/main/java/im/angry/openeuicc/core/TelephonyManagerApduInterface.kt
  14. 0 0
      app-common/src/main/java/im/angry/openeuicc/ui/EuiccChannelFragmentUtils.kt
  15. 1 1
      app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt
  16. 1 1
      app-common/src/main/java/im/angry/openeuicc/ui/MainActivity.kt
  17. 1 1
      app-common/src/main/java/im/angry/openeuicc/ui/ProfileDeleteFragment.kt
  18. 1 1
      app-common/src/main/java/im/angry/openeuicc/ui/ProfileDownloadFragment.kt
  19. 1 1
      app-common/src/main/java/im/angry/openeuicc/ui/ProfileRenameFragment.kt
  20. 0 0
      app-common/src/main/java/im/angry/openeuicc/util/StringUtils.kt
  21. 0 0
      app-common/src/main/java/im/angry/openeuicc/util/TelephonyUtils.kt
  22. 0 0
      app-common/src/main/java/im/angry/openeuicc/util/UiUtils.kt
  23. 0 0
      app-common/src/main/res/drawable/ic_add.xml
  24. 0 0
      app-common/src/main/res/drawable/ic_check_black.xml
  25. 0 0
      app-common/src/main/res/drawable/ic_menu_black.xml
  26. 0 0
      app-common/src/main/res/drawable/ic_scan_black.xml
  27. 0 0
      app-common/src/main/res/layout/activity_main.xml
  28. 0 0
      app-common/src/main/res/layout/euicc_profile.xml
  29. 0 0
      app-common/src/main/res/layout/fragment_euicc.xml
  30. 0 0
      app-common/src/main/res/layout/fragment_profile_download.xml
  31. 0 0
      app-common/src/main/res/layout/fragment_profile_rename.xml
  32. 0 0
      app-common/src/main/res/layout/spinner_item.xml
  33. 0 0
      app-common/src/main/res/menu/activity_main.xml
  34. 0 0
      app-common/src/main/res/menu/fragment_profile_download.xml
  35. 0 0
      app-common/src/main/res/menu/fragment_profile_rename.xml
  36. 0 0
      app-common/src/main/res/menu/profile_options.xml
  37. 0 0
      app-common/src/main/res/raw/symantec_gsma_rspv2_root_ci1
  38. 0 0
      app-common/src/main/res/values/colors.xml
  39. 34 0
      app-common/src/main/res/values/strings.xml
  40. 0 0
      app-common/src/main/res/values/themes.xml
  41. 0 0
      app-common/src/main/res/xml/network_security_config.xml
  42. 17 0
      app-common/src/test/java/im/angry/openeuicc/common/ExampleUnitTest.kt
  43. 2 8
      app/build.gradle
  44. 1 17
      app/src/main/AndroidManifest.xml
  45. 0 32
      app/src/main/res/values/strings.xml
  46. 1 0
      settings.gradle

+ 1 - 3
.idea/compiler.xml

@@ -3,11 +3,9 @@
   <component name="CompilerConfiguration">
     <bytecodeTargetLevel target="1.7">
       <module name="OpenEUICC.app" target="17" />
+      <module name="OpenEUICC.app-common" target="17" />
       <module name="OpenEUICC.libs.hidden-apis-shim" target="17" />
       <module name="OpenEUICC.libs.lpac-jni" target="17" />
-      <module name="OpenEUICC.libs.lpad-sm-dp-plus-connector" target="17" />
-      <module name="OpenEUICC.libs.lpad-sm-dp-plus-connector.main" target="17" />
-      <module name="OpenEUICC.libs.lpad-sm-dp-plus-connector.test" target="17" />
     </bytecodeTargetLevel>
   </component>
 </project>

+ 1 - 0
.idea/gradle.xml

@@ -13,6 +13,7 @@
           <set>
             <option value="$PROJECT_DIR$" />
             <option value="$PROJECT_DIR$/app" />
+            <option value="$PROJECT_DIR$/app-common" />
             <option value="$PROJECT_DIR$/libs" />
             <option value="$PROJECT_DIR$/libs/hidden-apis-shim" />
             <option value="$PROJECT_DIR$/libs/hidden-apis-stub" />

+ 1 - 0
app-common/.gitignore

@@ -0,0 +1 @@
+/build

+ 47 - 0
app-common/build.gradle

@@ -0,0 +1,47 @@
+plugins {
+    id 'com.android.library'
+    id 'org.jetbrains.kotlin.android'
+}
+
+android {
+    namespace 'im.angry.openeuicc.common'
+    compileSdk 34
+
+    defaultConfig {
+        minSdk 30
+
+        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+        consumerProguardFiles "consumer-rules.pro"
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+    }
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+    kotlinOptions {
+        jvmTarget = '1.8'
+    }
+}
+
+dependencies {
+    compileOnly project(':libs:hidden-apis-stub')
+    implementation project(':libs:hidden-apis-shim')
+    implementation project(":libs:lpac-jni")
+    implementation 'androidx.core:core-ktx:1.12.0'
+    implementation 'androidx.appcompat:appcompat:1.6.1'
+    implementation 'com.google.android.material:material:1.10.0'
+    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
+    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
+    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
+    implementation "androidx.cardview:cardview:1.0.0"
+    implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
+    testImplementation 'junit:junit:4.13.2'
+    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
+    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
+}

+ 0 - 0
app-common/consumer-rules.pro


+ 21 - 0
app-common/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 24 - 0
app-common/src/androidTest/java/im/angry/openeuicc/common/ExampleInstrumentedTest.kt

@@ -0,0 +1,24 @@
+package im.angry.openeuicc.common
+
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.ext.junit.runners.AndroidJUnit4
+
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import org.junit.Assert.*
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+@RunWith(AndroidJUnit4::class)
+class ExampleInstrumentedTest {
+    @Test
+    fun useAppContext() {
+        // Context of the app under test.
+        val appContext = InstrumentationRegistry.getInstrumentation().targetContext
+        assertEquals("im.angry.openeuicc.common.test", appContext.packageName)
+    }
+}

+ 22 - 0
app-common/src/main/AndroidManifest.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:tools="http://schemas.android.com/tools"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    tools:ignore="ProtectedPermissions">
+    <uses-feature
+        android:name="android.hardware.telephony"
+        android:required="true" />
+
+    <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
+    <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
+    <uses-permission android:name="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.SECURE_ELEMENT_PRIVILEGED_OPERATION" />
+
+    <application
+        android:networkSecurityConfig="@xml/network_security_config">
+        <activity
+            android:name="com.journeyapps.barcodescanner.CaptureActivity"
+            android:screenOrientation="fullSensor"
+            tools:replace="screenOrientation" />
+    </application>
+</manifest>

+ 0 - 0
app/src/main/java/im/angry/openeuicc/OpenEuiccApplication.kt → app-common/src/main/java/im/angry/openeuicc/OpenEuiccApplication.kt


+ 0 - 0
app/src/main/java/im/angry/openeuicc/core/EuiccChannel.kt → app-common/src/main/java/im/angry/openeuicc/core/EuiccChannel.kt


+ 0 - 0
app/src/main/java/im/angry/openeuicc/core/EuiccChannelManager.kt → app-common/src/main/java/im/angry/openeuicc/core/EuiccChannelManager.kt


+ 0 - 0
app/src/main/java/im/angry/openeuicc/core/OmapiApduInterface.kt → app-common/src/main/java/im/angry/openeuicc/core/OmapiApduInterface.kt


+ 0 - 0
app/src/main/java/im/angry/openeuicc/core/TelephonyManagerApduInterface.kt → app-common/src/main/java/im/angry/openeuicc/core/TelephonyManagerApduInterface.kt


+ 0 - 0
app/src/main/java/im/angry/openeuicc/ui/EuiccChannelFragmentUtils.kt → app-common/src/main/java/im/angry/openeuicc/ui/EuiccChannelFragmentUtils.kt


+ 1 - 1
app/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt → app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt

@@ -19,7 +19,7 @@ import androidx.recyclerview.widget.RecyclerView
 import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
 import com.google.android.material.floatingactionbutton.FloatingActionButton
 import net.typeblog.lpac_jni.LocalProfileInfo
-import im.angry.openeuicc.R
+import im.angry.openeuicc.common.R
 import im.angry.openeuicc.util.*
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.launch

+ 1 - 1
app/src/main/java/im/angry/openeuicc/ui/MainActivity.kt → app-common/src/main/java/im/angry/openeuicc/ui/MainActivity.kt

@@ -12,7 +12,7 @@ import android.widget.Spinner
 import android.widget.Toast
 import androidx.appcompat.app.AppCompatActivity
 import androidx.lifecycle.lifecycleScope
-import im.angry.openeuicc.R
+import im.angry.openeuicc.common.R
 import im.angry.openeuicc.core.EuiccChannelManager
 import im.angry.openeuicc.util.*
 import kotlinx.coroutines.Dispatchers

+ 1 - 1
app/src/main/java/im/angry/openeuicc/ui/ProfileDeleteFragment.kt → app-common/src/main/java/im/angry/openeuicc/ui/ProfileDeleteFragment.kt

@@ -6,7 +6,7 @@ import android.util.Log
 import androidx.appcompat.app.AlertDialog
 import androidx.fragment.app.DialogFragment
 import androidx.lifecycle.lifecycleScope
-import im.angry.openeuicc.R
+import im.angry.openeuicc.common.R
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.launch
 import kotlinx.coroutines.withContext

+ 1 - 1
app/src/main/java/im/angry/openeuicc/ui/ProfileDownloadFragment.kt → app-common/src/main/java/im/angry/openeuicc/ui/ProfileDownloadFragment.kt

@@ -13,7 +13,7 @@ import androidx.lifecycle.lifecycleScope
 import com.google.android.material.textfield.TextInputLayout
 import com.journeyapps.barcodescanner.ScanContract
 import com.journeyapps.barcodescanner.ScanOptions
-import im.angry.openeuicc.R
+import im.angry.openeuicc.common.R
 import im.angry.openeuicc.util.setWidthPercent
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.launch

+ 1 - 1
app/src/main/java/im/angry/openeuicc/ui/ProfileRenameFragment.kt → app-common/src/main/java/im/angry/openeuicc/ui/ProfileRenameFragment.kt

@@ -13,7 +13,7 @@ import androidx.appcompat.widget.Toolbar
 import androidx.fragment.app.DialogFragment
 import androidx.lifecycle.lifecycleScope
 import com.google.android.material.textfield.TextInputLayout
-import im.angry.openeuicc.R
+import im.angry.openeuicc.common.R
 import im.angry.openeuicc.util.setWidthPercent
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.launch

+ 0 - 0
app/src/main/java/im/angry/openeuicc/util/StringUtils.kt → app-common/src/main/java/im/angry/openeuicc/util/StringUtils.kt


+ 0 - 0
app/src/main/java/im/angry/openeuicc/util/TelephonyUtils.kt → app-common/src/main/java/im/angry/openeuicc/util/TelephonyUtils.kt


+ 0 - 0
app/src/main/java/im/angry/openeuicc/util/UiUtils.kt → app-common/src/main/java/im/angry/openeuicc/util/UiUtils.kt


+ 0 - 0
app/src/main/res/drawable/ic_add.xml → app-common/src/main/res/drawable/ic_add.xml


+ 0 - 0
app/src/main/res/drawable/ic_check_black.xml → app-common/src/main/res/drawable/ic_check_black.xml


+ 0 - 0
app/src/main/res/drawable/ic_menu_black.xml → app-common/src/main/res/drawable/ic_menu_black.xml


+ 0 - 0
app/src/main/res/drawable/ic_scan_black.xml → app-common/src/main/res/drawable/ic_scan_black.xml


+ 0 - 0
app/src/main/res/layout/activity_main.xml → app-common/src/main/res/layout/activity_main.xml


+ 0 - 0
app/src/main/res/layout/euicc_profile.xml → app-common/src/main/res/layout/euicc_profile.xml


+ 0 - 0
app/src/main/res/layout/fragment_euicc.xml → app-common/src/main/res/layout/fragment_euicc.xml


+ 0 - 0
app/src/main/res/layout/fragment_profile_download.xml → app-common/src/main/res/layout/fragment_profile_download.xml


+ 0 - 0
app/src/main/res/layout/fragment_profile_rename.xml → app-common/src/main/res/layout/fragment_profile_rename.xml


+ 0 - 0
app/src/main/res/layout/spinner_item.xml → app-common/src/main/res/layout/spinner_item.xml


+ 0 - 0
app/src/main/res/menu/activity_main.xml → app-common/src/main/res/menu/activity_main.xml


+ 0 - 0
app/src/main/res/menu/fragment_profile_download.xml → app-common/src/main/res/menu/fragment_profile_download.xml


+ 0 - 0
app/src/main/res/menu/fragment_profile_rename.xml → app-common/src/main/res/menu/fragment_profile_rename.xml


+ 0 - 0
app/src/main/res/menu/profile_options.xml → app-common/src/main/res/menu/profile_options.xml


+ 0 - 0
app/src/main/res/raw/symantec_gsma_rspv2_root_ci1 → app-common/src/main/res/raw/symantec_gsma_rspv2_root_ci1


+ 0 - 0
app/src/main/res/values/colors.xml → app-common/src/main/res/values/colors.xml


+ 34 - 0
app-common/src/main/res/values/strings.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string name="no_euicc">No eUICC found on this device.\nOn some devices, you may need to enable dual SIM first in the menu of this app.</string>
+
+    <string name="dsds">Dual SIM</string>
+
+    <string name="enabled">Enabled</string>
+    <string name="disabled">Disabled</string>
+    <string name="provider">Provider:</string>
+    <string name="iccid">ICCID:</string>
+
+    <string name="enable">Enable</string>
+    <string name="disable">Disable</string>
+    <string name="delete">Delete</string>
+    <string name="rename">Rename</string>
+
+    <string name="toast_profile_enabled">eSIM profile switched. Please wait for a while when the card is restarting.</string>
+    <string name="toast_profile_enable_failed">Cannot switch to new eSIM profile.</string>
+    <string name="toast_profile_name_too_long">Nickname cannot be longer than 64 characters</string>
+    <string name="toast_dsds_switched">DSDS state switched. Please wait until the modem restarts.</string>
+
+    <string name="profile_download">New eSIM</string>
+    <string name="profile_download_server">Server (RSP / SM-DP+)</string>
+    <string name="profile_download_code">Activation Code</string>
+    <string name="profile_download_confirmation_code">Confirmation Code (Optional)</string>
+    <string name="profile_download_imei">IMEI (Optional)</string>
+    <string name="profile_download_scan">Scan QR Code</string>
+    <string name="profile_download_ok">Download</string>
+    <string name="profile_download_failed">Failed to download eSIM. Check your activation / QR code.</string>
+
+    <string name="profile_rename_new_name">New nickname</string>
+
+    <string name="profile_delete_confirm">Are you sure you want to delete the profile %s? This operation is irreversible.</string>
+</resources>

+ 0 - 0
app/src/main/res/values/themes.xml → app-common/src/main/res/values/themes.xml


+ 0 - 0
app/src/main/res/xml/network_security_config.xml → app-common/src/main/res/xml/network_security_config.xml


+ 17 - 0
app-common/src/test/java/im/angry/openeuicc/common/ExampleUnitTest.kt

@@ -0,0 +1,17 @@
+package im.angry.openeuicc.common
+
+import org.junit.Test
+
+import org.junit.Assert.*
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+class ExampleUnitTest {
+    @Test
+    fun addition_isCorrect() {
+        assertEquals(4, 2 + 2)
+    }
+}

+ 2 - 8
app/build.gradle

@@ -85,15 +85,9 @@ android {
 dependencies {
     compileOnly project(':libs:hidden-apis-stub')
     implementation project(':libs:hidden-apis-shim')
-    implementation project(":libs:lpac-jni")
-    implementation 'androidx.core:core-ktx:1.12.0'
+    implementation project(':libs:lpac-jni')
+    implementation project(":app-common")
     implementation 'androidx.appcompat:appcompat:1.6.1'
-    implementation 'com.google.android.material:material:1.10.0'
-    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
-    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
-    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
-    implementation "androidx.cardview:cardview:1.0.0"
-    implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
     testImplementation 'junit:junit:4.13.2'
     androidTestImplementation 'androidx.test.ext:junit:1.1.3'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

+ 1 - 17
app/src/main/AndroidManifest.xml

@@ -4,16 +4,6 @@
     tools:ignore="ProtectedPermissions"
     package="im.angry.openeuicc">
 
-    <uses-feature
-        android:name="android.hardware.telephony"
-        android:required="true" />
-
-    <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
-    <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
-    <uses-permission android:name="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS" />
-    <uses-permission android:name="android.permission.INTERNET" />
-    <uses-permission android:name="android.permission.SECURE_ELEMENT_PRIVILEGED_OPERATION" />
-
     <application
         android:name=".OpenEuiccApplication"
         android:allowBackup="true"
@@ -21,8 +11,7 @@
         android:label="@string/app_name"
         android:roundIcon="@mipmap/ic_launcher_round"
         android:supportsRtl="true"
-        android:theme="@style/Theme.OpenEUICC"
-        android:networkSecurityConfig="@xml/network_security_config">
+        android:theme="@style/Theme.OpenEUICC">
         <activity
             android:name=".ui.MainActivity"
             android:exported="true">
@@ -52,11 +41,6 @@
                 <category android:name="android.service.euicc.category.EUICC_UI" />
             </intent-filter>
         </activity>
-
-        <activity
-            android:name="com.journeyapps.barcodescanner.CaptureActivity"
-            android:screenOrientation="fullSensor"
-            tools:replace="screenOrientation" />
     </application>
 
 </manifest>

+ 0 - 32
app/src/main/res/values/strings.xml

@@ -1,35 +1,3 @@
 <resources>
     <string name="app_name">OpenEUICC</string>
-
-    <string name="no_euicc">No eUICC found on this device.\nOn some devices, you may need to enable dual SIM first in the menu of this app.</string>
-
-    <string name="dsds">Dual SIM</string>
-
-    <string name="enabled">Enabled</string>
-    <string name="disabled">Disabled</string>
-    <string name="provider">Provider:</string>
-    <string name="iccid">ICCID:</string>
-
-    <string name="enable">Enable</string>
-    <string name="disable">Disable</string>
-    <string name="delete">Delete</string>
-    <string name="rename">Rename</string>
-
-    <string name="toast_profile_enabled">eSIM profile switched. Please wait for a while when the card is restarting.</string>
-    <string name="toast_profile_enable_failed">Cannot switch to new eSIM profile.</string>
-    <string name="toast_profile_name_too_long">Nickname cannot be longer than 64 characters</string>
-    <string name="toast_dsds_switched">DSDS state switched. Please wait until the modem restarts.</string>
-
-    <string name="profile_download">New eSIM</string>
-    <string name="profile_download_server">Server (RSP / SM-DP+)</string>
-    <string name="profile_download_code">Activation Code</string>
-    <string name="profile_download_confirmation_code">Confirmation Code (Optional)</string>
-    <string name="profile_download_imei">IMEI (Optional)</string>
-    <string name="profile_download_scan">Scan QR Code</string>
-    <string name="profile_download_ok">Download</string>
-    <string name="profile_download_failed">Failed to download eSIM. Check your activation / QR code.</string>
-
-    <string name="profile_rename_new_name">New nickname</string>
-
-    <string name="profile_delete_confirm">Are you sure you want to delete the profile %s? This operation is irreversible.</string>
 </resources>

+ 1 - 0
settings.gradle

@@ -17,3 +17,4 @@ include ':app'
 include ':libs:hidden-apis-stub'
 include ':libs:hidden-apis-shim'
 include ':libs:lpac-jni'
+include ':app-common'