summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PermissionController/res/layout/car_switch_button_preference.xml68
-rw-r--r--PermissionController/res/layout/radio_button_preference_widget.xml2
-rw-r--r--PermissionController/res/layout/switch_button_preference_widget.xml30
-rw-r--r--PermissionController/res/values/dimens.xml2
-rw-r--r--PermissionController/src/com/android/permissioncontroller/permission/ui/auto/AutoAppPermissionFragment.java68
-rw-r--r--flags/flags.aconfig9
6 files changed, 174 insertions, 5 deletions
diff --git a/PermissionController/res/layout/car_switch_button_preference.xml b/PermissionController/res/layout/car_switch_button_preference.xml
new file mode 100644
index 000000000..a2c2dcd8f
--- /dev/null
+++ b/PermissionController/res/layout/car_switch_button_preference.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:minHeight="?android:attr/listPreferredItemHeightSmall">
+
+ <FrameLayout
+ android:id="@android:id/widget_frame"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:minWidth="?android:attr/listPreferredItemHeightSmall"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <TextView
+ android:id="@android:id/title"
+ style="@style/AppPermissionLocationAccuracyTitle"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:paddingBottom="@dimen/car_preference_row_vertical_margin"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingTop="@dimen/car_preference_row_vertical_margin"
+ android:singleLine="true"
+ android:text="@string/app_permission_location_accuracy"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ app:layout_constraintEnd_toStartOf="@android:id/widget_frame"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintWidth_default="spread" />
+
+ <TextView
+ android:id="@android:id/summary"
+ style="@style/AppPermissionLocationAccuracySubtitle"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:paddingBottom="@dimen/car_preference_row_vertical_margin"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:text="@string/app_permission_location_accuracy_subtitle"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ app:layout_constraintEnd_toStartOf="@android:id/widget_frame"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@android:id/title"
+ app:layout_constraintWidth_default="spread" />
+
+</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file
diff --git a/PermissionController/res/layout/radio_button_preference_widget.xml b/PermissionController/res/layout/radio_button_preference_widget.xml
index cd2a2ce42..9bff4e46e 100644
--- a/PermissionController/res/layout/radio_button_preference_widget.xml
+++ b/PermissionController/res/layout/radio_button_preference_widget.xml
@@ -19,7 +19,7 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
- android:minWidth="56dp"
+ android:minWidth="@dimen/toggle_preference_container_min_width"
android:layout_height="match_parent">
<RadioButton
diff --git a/PermissionController/res/layout/switch_button_preference_widget.xml b/PermissionController/res/layout/switch_button_preference_widget.xml
new file mode 100644
index 000000000..f5a2d595b
--- /dev/null
+++ b/PermissionController/res/layout/switch_button_preference_widget.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ ~ Copyright (C) 2018 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<FrameLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:minWidth="@dimen/toggle_preference_container_min_width"
+ android:layout_height="match_parent">
+
+ <Switch
+ android:id="@+id/location_accuracy_switch"
+ android:checked="false"
+ android:duplicateParentState="true"
+ style="@style/AppPermissionLocationAccuracySwitch" />
+</FrameLayout>
diff --git a/PermissionController/res/values/dimens.xml b/PermissionController/res/values/dimens.xml
index 53d5341fe..32a2d8334 100644
--- a/PermissionController/res/values/dimens.xml
+++ b/PermissionController/res/values/dimens.xml
@@ -70,6 +70,8 @@
<dimen name="location_accuracy_image_size">130dp</dimen>
+ <dimen name="toggle_preference_container_min_width">56dp</dimen>
+
<item name="permission_access_time_dialog_width_scalar" format="float" type="dimen">0.9</item>
<item name="permission_access_time_dialog_height_scalar" format="float" type="dimen">0.7</item>
diff --git a/PermissionController/src/com/android/permissioncontroller/permission/ui/auto/AutoAppPermissionFragment.java b/PermissionController/src/com/android/permissioncontroller/permission/ui/auto/AutoAppPermissionFragment.java
index 1f30572ad..b475ba36c 100644
--- a/PermissionController/src/com/android/permissioncontroller/permission/ui/auto/AutoAppPermissionFragment.java
+++ b/PermissionController/src/com/android/permissioncontroller/permission/ui/auto/AutoAppPermissionFragment.java
@@ -22,6 +22,8 @@ import static com.android.permissioncontroller.PermissionControllerStatsLog.APP_
import static com.android.permissioncontroller.PermissionControllerStatsLog.APP_PERMISSION_FRAGMENT_ACTION_REPORTED__BUTTON_PRESSED__ALLOW_ALWAYS;
import static com.android.permissioncontroller.PermissionControllerStatsLog.APP_PERMISSION_FRAGMENT_ACTION_REPORTED__BUTTON_PRESSED__ALLOW_FOREGROUND;
import static com.android.permissioncontroller.PermissionControllerStatsLog.APP_PERMISSION_FRAGMENT_ACTION_REPORTED__BUTTON_PRESSED__DENY;
+import static com.android.permissioncontroller.PermissionControllerStatsLog.APP_PERMISSION_FRAGMENT_ACTION_REPORTED__BUTTON_PRESSED__GRANT_FINE_LOCATION;
+import static com.android.permissioncontroller.PermissionControllerStatsLog.APP_PERMISSION_FRAGMENT_ACTION_REPORTED__BUTTON_PRESSED__REVOKE_FINE_LOCATION;
import static com.android.permissioncontroller.permission.ui.ManagePermissionsActivity.EXTRA_RESULT_PERMISSION_INTERACTED;
import static com.android.permissioncontroller.permission.ui.ManagePermissionsActivity.EXTRA_RESULT_PERMISSION_RESULT;
@@ -42,6 +44,7 @@ import android.text.BidiFormatter;
import android.util.Log;
import android.view.View;
import android.widget.RadioButton;
+import android.widget.Switch;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -95,6 +98,9 @@ public class AutoAppPermissionFragment extends AutoSettingsFrameFragment
private TwoStatePreference mForegroundOnlyPermissionPreference;
@NonNull
private TwoStatePreference mDenyPermissionPreference;
+
+ @NonNull
+ private TwoStatePreference mToggleFineLocationPreference;
@NonNull
private AutoTwoTargetPreference mDetailsPreference;
@@ -127,9 +133,9 @@ public class AutoAppPermissionFragment extends AutoSettingsFrameFragment
* Returns a new {@link AutoAppPermissionFragment}.
*
* @param packageName the package name for which the permission is being changed
- * @param permName the name of the permission being changed
- * @param groupName the name of the permission group being changed
- * @param userHandle the user for which the permission is being changed
+ * @param permName the name of the permission being changed
+ * @param groupName the name of the permission group being changed
+ * @param userHandle the user for which the permission is being changed
*/
@NonNull
public static AutoAppPermissionFragment newInstance(@NonNull String packageName,
@@ -157,6 +163,7 @@ public class AutoAppPermissionFragment extends AutoSettingsFrameFragment
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
mPackageName = getArguments().getString(Intent.EXTRA_PACKAGE_NAME);
mPermGroupName = getArguments().getString(Intent.EXTRA_PERMISSION_GROUP_NAME);
if (mPermGroupName == null) {
@@ -214,6 +221,29 @@ public class AutoAppPermissionFragment extends AutoSettingsFrameFragment
mDenyPermissionPreference.setTitle(R.string.app_permission_button_deny);
permissionSelector.addPreference(mDenyPermissionPreference);
+
+ Log.w(LOG_TAG, "enableCoarseFineLocationPromptForAaos flag set to: "
+ + Flags.enableCoarseFineLocationPromptForAaos());
+ if (Flags.enableCoarseFineLocationPromptForAaos()) {
+ mToggleFineLocationPreference = new SelectedSwitchPermissionPreference(
+ requireContext());
+ mToggleFineLocationPreference.setTitle(R.string.app_permission_location_accuracy);
+ mToggleFineLocationPreference.setSummary(
+ R.string.app_permission_location_accuracy_subtitle);
+ permissionSelector.addPreference(mToggleFineLocationPreference);
+
+ mToggleFineLocationPreference.setOnPreferenceClickListener(v -> {
+ if (mToggleFineLocationPreference.isChecked()) {
+ requestChange(ChangeRequest.GRANT_FINE_LOCATION,
+ APP_PERMISSION_FRAGMENT_ACTION_REPORTED__BUTTON_PRESSED__GRANT_FINE_LOCATION);
+ } else {
+ requestChange(ChangeRequest.REVOKE_FINE_LOCATION,
+ APP_PERMISSION_FRAGMENT_ACTION_REPORTED__BUTTON_PRESSED__REVOKE_FINE_LOCATION);
+ }
+ return true;
+ });
+ }
+
mAllowPermissionPreference.setOnPreferenceClickListener(v -> {
checkOnlyOneButtonOverride(AppPermissionViewModel.ButtonType.ALLOW);
setResult(GrantPermissionsViewHandler.GRANTED_ALWAYS);
@@ -294,6 +324,16 @@ public class AutoAppPermissionFragment extends AutoSettingsFrameFragment
}
}
}
+
+ if (Flags.enableCoarseFineLocationPromptForAaos()) {
+ mViewModel.getButtonStateLiveData().observe(this, buttonState -> {
+ AppPermissionViewModel.ButtonState locationAccuracyState = buttonState.get(
+ AppPermissionViewModel.ButtonType.LOCATION_ACCURACY);
+ mToggleFineLocationPreference.setVisible(locationAccuracyState.isShown());
+ mToggleFineLocationPreference.setChecked(locationAccuracyState.isChecked());
+ mToggleFineLocationPreference.setEnabled(locationAccuracyState.isEnabled());
+ });
+ }
}
@Override
@@ -552,6 +592,26 @@ public class AutoAppPermissionFragment extends AutoSettingsFrameFragment
}
}
+ private static class SelectedSwitchPermissionPreference extends TwoStatePreference {
+
+ SelectedSwitchPermissionPreference(Context context) {
+ super(context, null,
+ TypedArrayUtils.getAttr(context, androidx.preference.R.attr.preferenceStyle,
+ android.R.attr.preferenceStyle));
+ setPersistent(false);
+ setLayoutResource(R.layout.car_switch_button_preference);
+ setWidgetLayoutResource(R.layout.switch_button_preference_widget);
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+
+ Switch switchButton = (Switch) holder.findViewById(R.id.location_accuracy_switch);
+ switchButton.setChecked(isChecked());
+ }
+ }
+
/**
* A dialog warning the user that they are about to deny a permission that was granted by
* default.
@@ -564,7 +624,7 @@ public class AutoAppPermissionFragment extends AutoSettingsFrameFragment
+ ".arg.changeRequest";
private static final String BUTTON = ConfirmDialog.class.getName()
+ ".arg.button";
- private static int sCode = APP_PERMISSION_FRAGMENT_ACTION_REPORTED__BUTTON_PRESSED__ALLOW;
+ private static int sCode = APP_PERMISSION_FRAGMENT_ACTION_REPORTED__BUTTON_PRESSED__ALLOW;
@NonNull
@Override
diff --git a/flags/flags.aconfig b/flags/flags.aconfig
index a81de8144..cc7510b27 100644
--- a/flags/flags.aconfig
+++ b/flags/flags.aconfig
@@ -45,3 +45,12 @@ flag {
bug: "327489942"
is_fixed_read_only: true
}
+
+flag {
+ name: "enable_coarse_fine_location_prompt_for_aaos"
+ is_exported: true
+ namespace: "permissions"
+ description: "Feature flag to enable downgrading to coarse location on Automotive"
+ bug: "346369736"
+ is_fixed_read_only: true
+}