Merge branch 'android12' into 'master'

Android 12 updates

See merge request AuroraOSS/AuroraStore!153
This commit is contained in:
Rahul Patel
2021-12-18 17:34:27 +00:00
8 changed files with 60 additions and 23 deletions

View File

@@ -23,16 +23,15 @@ apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs.kotlin"
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
compileSdkVersion 31
defaultConfig {
applicationId "com.aurora.store"
minSdkVersion 19
targetSdkVersion 30
targetSdkVersion 31
versionCode 38
versionName "4.0.7"
versionCode 39
versionName "4.1.0"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
@@ -82,8 +81,8 @@ buildscript {
fetch2 : "3.1.6",
fuel : "2.3.0",
glide : "4.11.0",
lifecycle : "2.3.1",
navigation: "2.3.4",
lifecycle : '2.4.0',
navigation: '2.3.5',
epoxy : "4.3.1",
libsu : "3.0.2"
]
@@ -108,12 +107,12 @@ dependencies {
implementation("org.apache.commons:commons-text:1.8")
//Google's Goodies
implementation("com.google.android.material:material:1.3.0")
implementation("com.google.android.material:material:1.4.0")
implementation("com.google.android:flexbox:2.0.1")
implementation("com.google.code.gson:gson:2.8.6")
//AndroidX
implementation("androidx.core:core-ktx:1.3.2")
implementation("androidx.core:core-ktx:1.7.0")
implementation("androidx.viewpager2:viewpager2:1.0.0")
implementation("androidx.vectordrawable:vectordrawable:1.1.0")
implementation("androidx.preference:preference-ktx:1.1.1")

View File

@@ -41,6 +41,7 @@
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" />
<uses-feature
android:name="android.software.leanback"
@@ -71,7 +72,8 @@
android:usesCleartextTraffic="true"
tools:targetApi="m">
<activity android:name=".view.ui.onboarding.OnboardingActivity">
<activity android:name=".view.ui.onboarding.OnboardingActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -88,7 +90,8 @@
android:name=".MainActivity"
android:launchMode="singleTask" />
<activity android:name=".view.ui.details.AppDetailsActivity">
<activity android:name=".view.ui.details.AppDetailsActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
@@ -120,7 +123,8 @@
</activity>
<activity android:name=".view.ui.details.DevProfileActivity">
<activity android:name=".view.ui.details.DevProfileActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
@@ -173,7 +177,8 @@
android:resource="@xml/paths" />
</provider>
<receiver android:name=".data.receiver.PackageManagerReceiver">
<receiver android:name=".data.receiver.PackageManagerReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_CHANGED" />

View File

@@ -96,11 +96,13 @@ fun <T> Context.open(className: Class<T>, newTask: Boolean = false) {
}
fun Context.restartApp() {
val flags = if (isMAndAbove()) PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
else PendingIntent.FLAG_CANCEL_CURRENT
val pendingIntent = PendingIntent.getActivity(
this,
1337,
Intent(this, MainActivity::class.java),
PendingIntent.FLAG_CANCEL_CURRENT
flags
)
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager

View File

@@ -52,6 +52,10 @@ fun isRAndAbove(): Boolean {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
}
fun isSAndAbove(): Boolean {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
}
fun isMIUI(): Boolean {
return getSystemProperty("ro.miui.ui.version.name").isNotEmpty()
}

View File

@@ -27,7 +27,9 @@ import android.net.Uri
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.core.content.FileProvider
import com.aurora.extensions.isMAndAbove
import com.aurora.extensions.isNAndAbove
import com.aurora.extensions.isSAndAbove
import com.aurora.store.BuildConfig
import com.aurora.store.util.Log
import org.apache.commons.io.IOUtils
@@ -63,6 +65,9 @@ class SessionInstaller(context: Context) : InstallerBase(context) {
if (isNAndAbove()) {
setOriginatingUid(android.os.Process.myUid())
}
if (isSAndAbove()) {
setRequireUserAction(SessionParams.USER_ACTION_NOT_REQUIRED)
}
}
val sessionId = packageInstaller.createSession(sessionParams)
val session = packageInstaller.openSession(sessionId)
@@ -87,11 +92,14 @@ class SessionInstaller(context: Context) : InstallerBase(context) {
}
val callBackIntent = Intent(context, InstallerService::class.java)
val flags = if (isSAndAbove())
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE else
PendingIntent.FLAG_UPDATE_CURRENT;
val pendingIntent = PendingIntent.getService(
context,
sessionId,
callBackIntent,
PendingIntent.FLAG_UPDATE_CURRENT
flags
)
Log.i("Starting install session for $packageName")

View File

@@ -32,6 +32,7 @@ import androidx.core.content.ContextCompat
import com.aurora.Constants
import com.aurora.extensions.getStyledAttributeColor
import com.aurora.extensions.isLAndAbove
import com.aurora.extensions.isMAndAbove
import com.aurora.gplayapi.data.models.App
import com.aurora.store.R
import com.aurora.store.data.downloader.DownloadManager
@@ -331,45 +332,63 @@ class NotificationService : Service() {
private fun getPauseIntent(groupId: Int): PendingIntent {
val intent = Intent(this, DownloadPauseReceiver::class.java)
intent.putExtra(Constants.FETCH_GROUP_ID, groupId)
return PendingIntent.getBroadcast(this, groupId, intent, PendingIntent.FLAG_UPDATE_CURRENT)
val flags = if (isMAndAbove())
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
else PendingIntent.FLAG_CANCEL_CURRENT
return PendingIntent.getBroadcast(this, groupId, intent, flags)
}
private fun getResumeIntent(groupId: Int): PendingIntent {
val intent = Intent(this, DownloadResumeReceiver::class.java)
intent.putExtra(Constants.FETCH_GROUP_ID, groupId)
return PendingIntent.getBroadcast(this, groupId, intent, PendingIntent.FLAG_UPDATE_CURRENT)
val flags = if (isMAndAbove())
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
else PendingIntent.FLAG_CANCEL_CURRENT
return PendingIntent.getBroadcast(this, groupId, intent, flags)
}
private fun getCancelIntent(groupId: Int): PendingIntent {
val intent = Intent(this, DownloadCancelReceiver::class.java)
intent.putExtra(Constants.FETCH_GROUP_ID, groupId)
return PendingIntent.getBroadcast(this, groupId, intent, PendingIntent.FLAG_UPDATE_CURRENT)
val flags = if (isMAndAbove())
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
else PendingIntent.FLAG_CANCEL_CURRENT
return PendingIntent.getBroadcast(this, groupId, intent, flags)
}
private fun getContentIntentForDetails(app: App?): PendingIntent {
val intent = Intent(this, AppDetailsActivity::class.java)
intent.putExtra(Constants.STRING_EXTRA, gson.toJson(app))
val flags = if (isMAndAbove())
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
else PendingIntent.FLAG_CANCEL_CURRENT
return PendingIntent.getActivity(
this,
packageName.hashCode(),
intent,
PendingIntent.FLAG_UPDATE_CURRENT
flags
)
}
private fun getContentIntentForDownloads(): PendingIntent {
val intent = Intent(this, DownloadActivity::class.java)
return PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
val flags = if (isMAndAbove())
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
else PendingIntent.FLAG_CANCEL_CURRENT
return PendingIntent.getActivity(this, 0, intent, flags)
}
private fun getInstallIntent(packageName: String, versionCode: String): PendingIntent {
val intent = Intent(this, InstallReceiver::class.java)
intent.putExtra(Constants.STRING_EXTRA, packageName)
val flags = if (isMAndAbove())
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
else PendingIntent.FLAG_CANCEL_CURRENT
return PendingIntent.getBroadcast(
this,
packageName.hashCode(),
intent,
PendingIntent.FLAG_UPDATE_CURRENT
flags
)
}

View File

@@ -32,7 +32,7 @@ buildscript {
ext.navigation= "2.3.4"
dependencies {
classpath ("com.android.tools.build:gradle:4.1.3")
classpath ('com.android.tools.build:gradle:7.0.3')
classpath ("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin")
classpath ("androidx.navigation:navigation-safe-args-gradle-plugin:$navigation")
}

View File

@@ -22,4 +22,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip