Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into 14-dev
  • Loading branch information
validcube committed Dec 19, 2023
2 parents 4b4daf1 + 0d64cd3 commit 48ddf68
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 28 deletions.
5 changes: 3 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Security Policy

## Supported Versions
Important note: Lawnchair v2 (Play Store version) is **unsupported**. Use the newer alphas instead. See [this FAQ page](https://lawnchair.app/faq#do-you-still-support-the-play-store-version) for additional information.
> [!NOTE]
> Lawnchair v2 (Play Store version) is **unsupported**. Use the newer alphas instead. See [this FAQ page](https://lawnchair.app/faq#do-you-still-support-the-play-store-version) for additional information.
The latest version of Lawnchair is the only supported version.
| Version | Supported |
Expand All @@ -17,6 +18,6 @@ The latest version of Lawnchair is the only supported version.
## Reporting Security issues
We appreciate your efforts to responsibly disclose your findings and will make every effort to acknowledge your contributions.

To report an issue, please contact a developer (can be found in the about page of the app) in Telegram or Discord and state your security vunerability starting with the words "SECURITY".
To report an issue, please contact a developer (can be found in the about page of the app) in Telegram or Discord and state your security vulnerability starting with the words "SECURITY".

We'll endeavour to respond quickly, and will keep you updated throughout the process.
16 changes: 13 additions & 3 deletions lawnchair/src/app/lawnchair/backup/ui/CreateBackupScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.app.Activity
import android.app.WallpaperManager
import android.content.Intent
import android.content.res.Configuration
import android.os.Build
import android.provider.DocumentsContract
import android.util.Log
import android.widget.Toast
Expand Down Expand Up @@ -39,6 +40,7 @@ import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavGraphBuilder
import app.lawnchair.backup.LawnchairBackup
import app.lawnchair.preferences.PreferenceManager
import app.lawnchair.ui.preferences.LocalNavController
import app.lawnchair.ui.preferences.components.DummyLauncherBox
import app.lawnchair.ui.preferences.components.WallpaperPreview
Expand All @@ -47,6 +49,8 @@ import app.lawnchair.ui.preferences.components.layout.PreferenceGroup
import app.lawnchair.ui.preferences.components.layout.PreferenceLayout
import app.lawnchair.ui.preferences.preferenceGraph
import app.lawnchair.util.BackHandler
import app.lawnchair.util.checkAndRequestFilesPermission
import app.lawnchair.util.filesAndStorageGranted
import app.lawnchair.util.hasFlag
import app.lawnchair.util.removeFlag
import com.android.launcher3.R
Expand All @@ -73,8 +77,14 @@ fun CreateBackupScreen(

val context = LocalContext.current
val hasLiveWallpaper = remember { WallpaperManager.getInstance(context).wallpaperInfo != null }
val permissionState = rememberPermissionState(Manifest.permission.READ_EXTERNAL_STORAGE)
val hasStoragePermission = permissionState.status.isGranted
val permissionState = rememberPermissionState(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
Manifest.permission.MANAGE_EXTERNAL_STORAGE
} else {
Manifest.permission.READ_EXTERNAL_STORAGE
},
)
val hasStoragePermission = permissionState.status.isGranted || filesAndStorageGranted(context)

val scope = rememberCoroutineScope()
var creatingBackup by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -155,7 +165,7 @@ fun CreateBackupScreen(
flags = contents,
setFlags = {
if (it.hasFlag(LawnchairBackup.INCLUDE_WALLPAPER) && !hasStoragePermission) {
permissionState.launchPermissionRequest()
checkAndRequestFilesPermission(context, PreferenceManager.getInstance(context))
} else {
viewModel.setBackupContents(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.app.WallpaperManager
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.os.Build
import android.util.Size
import androidx.compose.foundation.Image
import androidx.compose.runtime.Composable
Expand All @@ -15,6 +16,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.core.graphics.drawable.toBitmap
import app.lawnchair.preferences.PreferenceManager
import app.lawnchair.util.checkAndRequestFilesPermission
import app.lawnchair.util.filesAndStorageGranted
import app.lawnchair.util.scaleDownToDisplaySize
import com.google.accompanist.drawablepainter.rememberDrawablePainter
import com.google.accompanist.permissions.ExperimentalPermissionsApi
Expand Down Expand Up @@ -43,11 +47,17 @@ fun wallpaperDrawable(): Drawable? {
val context = LocalContext.current
val wallpaperManager = remember { WallpaperManager.getInstance(context) }
val wallpaperInfo = wallpaperManager.wallpaperInfo
val permissionState = rememberPermissionState(android.Manifest.permission.READ_EXTERNAL_STORAGE)
val permissionState = rememberPermissionState(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
android.Manifest.permission.MANAGE_EXTERNAL_STORAGE
} else {
android.Manifest.permission.READ_EXTERNAL_STORAGE
},
)
val wallpaperDrawable by produceState<Drawable?>(initialValue = null) {
value = when {
wallpaperInfo != null -> wallpaperInfo.loadThumbnail(context.packageManager)
permissionState.status.isGranted -> {
filesAndStorageGranted(context) -> {
withContext(Dispatchers.IO) {
wallpaperManager.drawable?.let {
val size = Size(it.intrinsicWidth, it.intrinsicHeight).scaleDownToDisplaySize(context)
Expand All @@ -62,7 +72,7 @@ fun wallpaperDrawable(): Drawable? {

if (!permissionState.status.isGranted) {
SideEffect {
permissionState.launchPermissionRequest()
checkAndRequestFilesPermission(context, PreferenceManager.getInstance(context))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ fun GeneralPreferences() {

PreferenceLayout(label = stringResource(id = R.string.general_label)) {
PreferenceGroup {
// SwitchPreference(
// adapter = prefs.allowRotation.getAdapter(),
// label = stringResource(id = R.string.home_screen_rotation_label),
// description = stringResource(id = R.string.home_screen_rotaton_description),
// )
SwitchPreference(
adapter = prefs.allowRotation.getAdapter(),
label = stringResource(id = R.string.home_screen_rotation_label),
description = stringResource(id = R.string.home_screen_rotaton_description),
)
val enableFontSelection = prefs2.enableFontSelection.asState().value
if (enableFontSelection) {
FontPreference(
Expand Down
4 changes: 2 additions & 2 deletions quickstep/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
<!-- Turn on work apps button -->
<color name="work_turn_on_stroke">?attr/colorAccentPrimary</color>
<color name="work_fab_bg_color">?attr/materialColorPrimaryFixedDim</color>
<color name="work_fab_icon_color">?attr/materialColorOnPrimaryFixed</color>
</resources>
<color name="work_fab_icon_color">@color/material_color_on_primary_fixed</color>
</resources>
4 changes: 2 additions & 2 deletions quickstep/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,5 @@
<!-- Turn on work apps button -->
<color name="work_turn_on_stroke">?attr/colorAccentPrimary</color>
<color name="work_fab_bg_color">?attr/materialColorPrimaryFixedDim</color>
<color name="work_fab_icon_color">?attr/materialColorOnPrimaryFixed</color>
</resources>
<color name="work_fab_icon_color">@color/material_color_on_primary_fixed</color>
</resources>
16 changes: 9 additions & 7 deletions src/com/android/launcher3/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,17 @@ public static void mapRectInSelfToDescendant(View descendant, View root, Rect re
public static void mapCoordInSelfToDescendant(View descendant, View root, float[] coord) {
sMatrix.reset();
View v = descendant;
while (v != root) {
if (v != null) {
while (v != root) {
sMatrix.postTranslate(-v.getScrollX(), -v.getScrollY());
sMatrix.postConcat(v.getMatrix());
sMatrix.postTranslate(v.getLeft(), v.getTop());
v = (View) v.getParent();
}
sMatrix.postTranslate(-v.getScrollX(), -v.getScrollY());
sMatrix.postConcat(v.getMatrix());
sMatrix.postTranslate(v.getLeft(), v.getTop());
v = (View) v.getParent();
sMatrix.invert(sInverseMatrix);
sInverseMatrix.mapPoints(coord);
}
sMatrix.postTranslate(-v.getScrollX(), -v.getScrollY());
sMatrix.invert(sInverseMatrix);
sInverseMatrix.mapPoints(coord);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/com/android/launcher3/allapps/WorkProfileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ private void updateCurrentState(@WorkProfileState int currentState) {
*/
public boolean attachWorkModeSwitch() {
if (!mAllApps.getAppsStore().hasModelFlag(
FLAG_HAS_SHORTCUT_PERMISSION | FLAG_QUIET_MODE_CHANGE_PERMISSION)
|| !Utilities.ATLEAST_Q) {
FLAG_HAS_SHORTCUT_PERMISSION | FLAG_QUIET_MODE_CHANGE_PERMISSION)) {
Log.e(TAG, "unable to attach work mode switch; Missing required permissions");
return false;
}
Expand Down
6 changes: 4 additions & 2 deletions src/com/android/launcher3/views/BaseDragLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,10 @@ public void mapCoordInSelfToDescendant(View descendant, float[] coord) {
public void mapCoordInSelfToDescendant(View descendant, int[] coord) {
mTmpXY[0] = coord[0];
mTmpXY[1] = coord[1];
Utilities.mapCoordInSelfToDescendant(descendant, this, mTmpXY);
Utilities.roundArray(mTmpXY, coord);
if (descendant != null) {
Utilities.mapCoordInSelfToDescendant(descendant, this, mTmpXY);
Utilities.roundArray(mTmpXY, coord);
}
}

public void getViewRectRelativeToSelf(View v, Rect r) {
Expand Down

0 comments on commit 48ddf68

Please sign in to comment.