Skip to content

Commit

Permalink
feat(#15): adapt to Android 14.0 (#16)
Browse files Browse the repository at this point in the history
* feat: update SettingsLib parts from android-14.0.0_r31

* All SettingsLib's parts are now shipped using a separate namespace in
  order to use resource processor.
* Enabled newly added 'use_resource_processor' clause in Android.bp to
  use Bazel's resource processor instead of aapt2 to generate R.class
  files. As per sources, this will be enabled by default in the future.
  The android.nonTransitiveRClass is the equivalent setting in AGP which
  is enabled by default since AGP 8, so we removed it.
  All in all, this speeds up compilation and reduces app size.

* chore: align Gradle dependencies with android-14.0.0_r31

* feat(SubscriptionsDao): switch to `@Upsert` added in Room v2.5.0-alpha03

* Also, convert the DAO back to interface while we're at it.

See https://developer.android.com/jetpack/androidx/releases/room#2.5.0-alpha03

* feat(telephony): switch to BundleCompat.getParcelable() impl

* Support was added in AndroidX Core v1.10.0

* fix(QsAppLauncherTileService): startActivityAndCollapse: Starting activity from TileService using an Intent is not allowed.

* --------- beginning of crash
    E  AndroidRuntime FATAL EXCEPTION: main
    E  AndroidRuntime Process: com.github.iusmac.sevensim, PID: 10791
    E  AndroidRuntime java.lang.UnsupportedOperationException: startActivityAndCollapse: Starting activity from TileService using an Intent is not allowed.
    E  AndroidRuntime    at android.service.quicksettings.TileService.startActivityAndCollapse(TileService.java:355)
    E  AndroidRuntime    at com.github.iusmac.sevensim.launcher.QsAppLauncherTileService.onClick(QsAppLauncherTileService.java:30)
    E  AndroidRuntime    at android.service.quicksettings.TileService$H.handleMessage(TileService.java:494)
    E  AndroidRuntime    at android.os.Handler.dispatchMessage(Handler.java:107)
    E  AndroidRuntime    at android.os.Looper.loopOnce(Looper.java:232)
    E  AndroidRuntime    at android.os.Looper.loop(Looper.java:317)
    E  AndroidRuntime    at android.app.ActivityThread.main(ActivityThread.java:8498)
    E  AndroidRuntime    at java.lang.reflect.Method.invoke(Native Method)
    E  AndroidRuntime    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    E  AndroidRuntime    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)

* Also
    > Task :compileDebugJavaWithJavac
    Note:
    src/com/github/iusmac/sevensim/launcher/QsAppLauncherTileService.java uses or overrides a deprecated API.

* fix(NotificationManager): handle a potential SecurityException

/home/runner/work/7SIM/7SIM/src/com/github/iusmac/sevensim/NotificationManager.java:87: Error: Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with checkPermission) or explicitly handle a potential SecurityException [MissingPermission]

       mNotificationManagerCompat.notify(BACKGROUND_RESTRICTED_NOTIFICATION_ID, notification);
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* chore(AndroidManifest): specify foreground service type for FGS to meed the U requirement

* fix(ApplicationInfo): un-deprecate PackageManager APIs that use int flags

See https://android.googlesource.com/platform/frameworks/base/+/15aa824757dc80d8e10775d77dbf2535be51cad8.

* chore: update README.md

Signed-off-by: iusmac <[email protected]>

* fix: the resource @string/not_set is marked as private in androidx.preference:preference:1.2.0-alpha01

../../src/com/github/iusmac/sevensim/ui/components/TimePickerPreference.java:226: The resource @string/not_set is marked as private in androidx.preference:preference:1.2.0-alpha01
        public @nullable CharSequence provideSummary(final @nonnull TimePickerPreference preference) {
            final CharSequence time = preference.getTime();
            return time != null ? time :
                preference.getContext().getString(androidx.preference.R.string.not_set);
        }
    }
}

Signed-off-by: iusmac <[email protected]>

---------

Signed-off-by: iusmac <[email protected]>
  • Loading branch information
iusmac authored May 1, 2024
1 parent 29b8274 commit e15dda0
Show file tree
Hide file tree
Showing 71 changed files with 356 additions and 227 deletions.
4 changes: 3 additions & 1 deletion Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android_app {
system_ext_specific: true,

min_sdk_version: "29",
target_sdk_version: "33",
target_sdk_version: "34",

static_libs: [
"SettingsLibBannerMessagePreference",
Expand All @@ -34,6 +34,8 @@ android_app {
"androidx.room_room-compiler-plugin",
],

use_resource_processor: true,

optimize: {
optimize: true,
proguard_flags_files: ["proguard.flags"],
Expand Down
3 changes: 3 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" android:maxSdkVersion="32"/>
<uses-permission android:name="android.permission.USE_EXACT_ALARM"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SYSTEM_EXEMPTED"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

Expand Down Expand Up @@ -132,6 +133,7 @@
<service
android:name=".ForegroundService"
android:exported="false"
android:foregroundServiceType="systemExempted"
android:directBootAware="true">
</service>

Expand All @@ -143,6 +145,7 @@
<service
android:name=".PhoneCallEndObserverService"
android:exported="false"
android:foregroundServiceType="systemExempted"
android:directBootAware="true">
</service>
</application>
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,20 @@ If you're a ROM maintainer and wish to integrate this app into your ROM, follow
1. Choose one of the following methods to add the app to the Android sources:
- As a remote project via [Local Manifests](https://gerrit.googlesource.com/git-repo/+/master/docs/manifest-format.md#Local-Manifests):
```xml
<remote name="iusmac" fetch="https://github.com/iusmac" revision="13.0-dev" />
<remote name="iusmac" fetch="https://github.com/iusmac" revision="14.0-dev" />
<project path="packages/apps/7SIM" name="7SIM" remote="iusmac" />
```
- As an in-tree package within the device tree directory:
```sh
git clone --depth=1 -b 13.0-dev https://github.com/iusmac/7SIM.git
git clone --depth=1 -b 14.0-dev https://github.com/iusmac/7SIM.git
```
- Or better — as Git [Submodule/Subtree](https://training.github.com/downloads/submodule-vs-subtree-cheat-sheet/):
```sh
git submodule add --depth=1 -b 13.0-dev https://github.com/iusmac/7SIM.git
git submodule add --depth=1 -b 14.0-dev https://github.com/iusmac/7SIM.git
```
OR
```sh
git subtree add --prefix=7SIM https://github.com/iusmac/7SIM.git 13.0-dev --squash
git subtree add --prefix=7SIM https://github.com/iusmac/7SIM.git 14.0-dev --squash
```
2. Add app module to a product makefile (e.g., `device.mk`):
```
Expand Down Expand Up @@ -270,7 +270,7 @@ If you're a ROM maintainer and wish to integrate this app into your ROM, follow
### Using Gradle Build Tool
**Requirements:**
- Android 13 SDK or newer with access to hidden APIs and internal resources
- Android 14 SDK or newer with access to hidden APIs and internal resources
> [!TIP]
> If you don't have one already, you can use our own `android.jar` that you can find at
> [`prebuilts/jars/`](./prebuilts/jars/). Replace it with the stock one in the Android SDK directory.
Expand All @@ -280,7 +280,7 @@ If you're a ROM maintainer and wish to integrate this app into your ROM, follow
As mentioned above, the 7SIM app is an extension of the built-in Settings app. In order to have the
same UI, and also write less code, it relies on some parts of the
[SettingsLib](https://android.googlesource.com/platform/frameworks/base.git/+/refs/tags/android-13.0.0_r75/packages/SettingsLib/)
[SettingsLib](https://android.googlesource.com/platform/frameworks/base.git/+/refs/tags/android-14.0.0_r31/packages/SettingsLib/)
package that you can download automatically using this script:
```sh
./SettingsLib/fetch.sh
Expand All @@ -303,7 +303,7 @@ To enable debug logging on releases with R8, see [Debug Opt-in Logging](#debug-o

### Using Soong Build System
**Requirements:**
- Android 13 and later source code base
- Android 14 and later source code base
> [!NOTE]
> The app stability is not guaranteed when building against the upstream source code base.
Expand Down
18 changes: 16 additions & 2 deletions SettingsLib/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
/*
/fwb
!/.gitignore
!/fetch.sh
!/build.gradle
!/BannerMessagePreference/
/BannerMessagePreference/*
!/BannerMessagePreference/build.gradle
!/CollapsingToolbarBaseActivity/
/CollapsingToolbarBaseActivity/*
!/CollapsingToolbarBaseActivity/build.gradle
!/MainSwitchPreference/
/MainSwitchPreference/*
!/MainSwitchPreference/build.gradle
!/SettingsTheme/
/SettingsTheme/*
!/SettingsTheme/build.gradle
!/TwoTargetPreference/
/TwoTargetPreference/*
!/TwoTargetPreference/build.gradle
!/Utils/
/Utils/*
!/Utils/build.gradle
41 changes: 41 additions & 0 deletions SettingsLib/BannerMessagePreference/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
plugins {
id 'com.android.library'
}

def SettingsLibBannerMessagePreference = '../fwb/packages/SettingsLib/BannerMessagePreference'

android {
namespace 'com.android.settingslib.widget.preference.banner'

defaultConfig {
minSdk 28
targetSdk 34
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

lint {
checkReleaseBuilds false
abortOnError false
}

sourceSets {
main {
res.srcDirs = ["${SettingsLibBannerMessagePreference}/res"]
java.srcDirs = ["${SettingsLibBannerMessagePreference}/src"]
}
}
}

dependencies {
implementation libs.preference
implementation project(':SettingsLib:SettingsTheme')
implementation project(':SettingsLib:Utils')
}
45 changes: 45 additions & 0 deletions SettingsLib/CollapsingToolbarBaseActivity/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
plugins {
id 'com.android.library'
}

def SettingsLibCollapsingToolbarBaseActivity = '../fwb/packages/SettingsLib/CollapsingToolbarBaseActivity'

android {
namespace 'com.android.settingslib.collapsingtoolbar'

defaultConfig {
minSdk 29
targetSdk 34
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

lint {
checkReleaseBuilds false
abortOnError false
}

sourceSets {
main {
res.srcDirs = ["${SettingsLibCollapsingToolbarBaseActivity}/res"]
java.srcDirs = ["${SettingsLibCollapsingToolbarBaseActivity}/src"]
}
}
}

dependencies {
implementation libs.annotation
implementation libs.appcompat
implementation libs.coordinatorlayout
implementation libs.material
implementation libs.preference
implementation project(':SettingsLib:SettingsTheme')
implementation project(':SettingsLib:Utils')
}
40 changes: 40 additions & 0 deletions SettingsLib/MainSwitchPreference/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
plugins {
id 'com.android.library'
}

def SettingsLibMainSwitchPreference = '../fwb/packages/SettingsLib/MainSwitchPreference'

android {
namespace 'com.android.settingslib.widget.mainswitch'

defaultConfig {
minSdk 28
targetSdk 34
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

lint {
checkReleaseBuilds false
abortOnError false
}

sourceSets {
main {
res.srcDirs = ["${SettingsLibMainSwitchPreference}/res"]
java.srcDirs = ["${SettingsLibMainSwitchPreference}/src"]
}
}
}

dependencies {
implementation libs.preference
implementation project(':SettingsLib:SettingsTheme')
}
38 changes: 38 additions & 0 deletions SettingsLib/SettingsTheme/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
plugins {
id 'com.android.library'
}

def SettingsLibSettingsTheme = '../fwb/packages/SettingsLib/SettingsTheme'

android {
namespace 'com.android.settingslib.widget.theme'

defaultConfig {
minSdk 21
targetSdk 34
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

lint {
checkReleaseBuilds false
abortOnError false
}

sourceSets {
main {
res.srcDirs = ["${SettingsLibSettingsTheme}/res"]
}
}
}

dependencies {
implementation libs.preference
}
41 changes: 41 additions & 0 deletions SettingsLib/TwoTargetPreference/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
plugins {
id 'com.android.library'
}

def SettingsLibTwoTargetPreference = '../fwb/packages/SettingsLib/TwoTargetPreference'

android {
namespace 'com.android.settingslib.widget.preference.twotarget'

defaultConfig {
minSdk 21
targetSdk 34
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

lint {
checkReleaseBuilds false
abortOnError false
}

sourceSets {
main {
res.srcDirs = ["${SettingsLibTwoTargetPreference}/res"]
java.srcDirs = ["${SettingsLibTwoTargetPreference}/src"]
}
}
}

dependencies {
implementation libs.annotation
implementation libs.preference
implementation project(':SettingsLib:SettingsTheme')
}
5 changes: 2 additions & 3 deletions SettingsLib/Utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ android {

defaultConfig {
minSdk 21
targetSdk 33
targetSdk 34
versionCode 1
versionName "1.0"
}

buildTypes {
release {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
Expand All @@ -35,7 +34,7 @@ android {
}
}

addCompileOnlyJar('android-33.jar')
addCompileOnlyJar('android-34.jar')

dependencies {
implementation libs.annotation
Expand Down
Loading

0 comments on commit e15dda0

Please sign in to comment.