Merge "Create settings for window magnification (2/n)"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6ee6a87..a4803a9 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3244,6 +3244,24 @@
android:value="com.android.settings.gestures.GlobalActionsPanelSettings" />
</activity>
+ <activity
+ android:name="Settings$GestureNavigationSettingsActivity"
+ android:label="@string/gesture_settings_activity_title"
+ android:enabled="true">
+ <intent-filter android:priority="32">
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.android.settings.SHORTCUT" />
+ </intent-filter>
+ <intent-filter android:priority="1">
+ <action android:name="com.android.settings.GESTURE_NAVIGATION_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.gestures.GestureNavigationSettingsFragment" />
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
+ </activity>
+
<!-- This is the longest AndroidManifest.xml ever. -->
</application>
</manifest>
diff --git a/res/layout/back_gesture_indicator_container.xml b/res/layout/back_gesture_indicator_container.xml
new file mode 100644
index 0000000..17b9126
--- /dev/null
+++ b/res/layout/back_gesture_indicator_container.xml
@@ -0,0 +1,41 @@
+<?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
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <ImageView
+ android:layout_width="@dimen/back_gesture_indicator_width"
+ android:layout_height="match_parent"
+ android:id="@+id/indicator_left">
+ </ImageView>
+
+ <Space
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_weight="1" />
+
+ <ImageView
+ android:layout_width="@dimen/back_gesture_indicator_width"
+ android:layout_height="match_parent"
+ android:id="@+id/indicator_right">
+ </ImageView>
+
+</LinearLayout>
+
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 5d03216..e4a6b27 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -482,6 +482,11 @@
<item>1xRTT</item>
<item>IS95B</item>
<item>IS95A</item>
+ <item>GSM</item>
+ <item>TD_SCDMA</item>
+ <item>IWLAN</item>
+ <item>LTE_CA</item>
+ <item>NR</item>
</string-array>
<string-array translatable="false" name="bearer_values">
@@ -517,6 +522,16 @@
<item>5</item>
<!-- Do not translate. -->
<item>4</item>
+ <!-- Do not translate. -->
+ <item>16</item>
+ <!-- Do not translate. -->
+ <item>17</item>
+ <!-- Do not translate. -->
+ <item>18</item>
+ <!-- Do not translate. -->
+ <item>19</item>
+ <!-- Do not translate. -->
+ <item>20</item>
</string-array>
<!-- MVNO Info used in APN editor -->
diff --git a/res/values/colors.xml b/res/values/colors.xml
index a1cb8fc..3fd77e8 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -146,4 +146,6 @@
<color name="dialog_background">@*android:color/background_device_default_light</color>
<color name="face_intro_outline">#ffdadce0</color>
+
+ <color name="back_gesture_indicator">#4182ef</color>
</resources>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 41c059c..aca64fb 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -216,8 +216,8 @@
<dimen name="fingerprint_finish_max_size">288dp</dimen>
<!-- Face -->
- <dimen name="face_preview_translate_y">0dp</dimen>
- <dimen name="face_preview_translate_x">0dp</dimen>
+ <item name="face_preview_translate_y" format="float" type="dimen">0</item>
+ <item name="face_preview_translate_x" format="float" type="dimen">0</item>
<item name="face_preview_scale" format="float" type="dimen">1.0</item>
<!-- Confirm device credentials -->
@@ -403,6 +403,8 @@
<!-- System navigation settings illustration height -->
<dimen name="system_navigation_illustration_height">320dp</dimen>
+ <dimen name="back_gesture_indicator_width">60dp</dimen>
+
<!-- Header title size of advanced bluetooth device -->
<dimen name="advanced_bluetooth_header_title_text_size">16sp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d0704ed..86708a4 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -10272,6 +10272,9 @@
<!-- Title for the screen to show all the gesture navigation settings [CHAR LIMIT=80] -->
<string name="gesture_settings_activity_title">Gesture Settings</string>
+ <!-- Keywords for the gesture navigation settings. [CHAR LIMIT=NONE] -->
+ <string name="keywords_gesture_navigation_settings">gesture navigation, back sensitivity, back gesture</string>
+
<!-- Preference and settings suggestion title text for ambient display double tap (phone) [CHAR LIMIT=60]-->
<string name="ambient_display_title" product="default">Double-tap to check phone</string>
<!-- Preference and settings suggestion title text for ambient display double tap (tablet) [CHAR LIMIT=60]-->
diff --git a/res/xml/gesture_navigation_settings.xml b/res/xml/gesture_navigation_settings.xml
new file mode 100644
index 0000000..2751f88
--- /dev/null
+++ b/res/xml/gesture_navigation_settings.xml
@@ -0,0 +1,51 @@
+<?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
+ -->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:key="gesture_navigation_settings_page"
+ android:title="@string/gesture_settings_activity_title"
+ settings:keywords="@string/keywords_gesture_navigation_settings">
+
+ <PreferenceCategory
+ android:key="back_sensitivity_category"
+ android:persistent="false"
+ android:title="@string/back_sensitivity_dialog_title">
+
+ <com.android.settings.gestures.GestureNavigationSeekBarPreference
+ android:key="gesture_left_back_sensitivity"
+ android:title="@string/left_edge"
+ android:max="3"
+ android:selectable="true"/>
+
+ <com.android.settings.gestures.GestureNavigationSeekBarPreference
+ android:key="gesture_right_back_sensitivity"
+ android:title="@string/right_edge"
+ android:max="3"
+ android:selectable="true"/>
+ </PreferenceCategory>
+
+ <com.android.settingslib.widget.FooterPreference
+ android:key="gesture_navigation_settings_footer"
+ android:title="@string/back_sensitivity_dialog_message"
+ android:selectable="false"
+ settings:searchable="false"
+ settings:allowDividerAbove="true"/>
+</PreferenceScreen>
+
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 46992ef..50caf32 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -131,6 +131,7 @@
public static class PhotosStorageActivity extends SettingsActivity {
/* empty */
}
+ public static class GestureNavigationSettingsActivity extends SettingsActivity { /* empty */ }
public static class ApnSettingsActivity extends SettingsActivity { /* empty */ }
public static class WifiCallingSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/accounts/AccountDashboardFragment.java b/src/com/android/settings/accounts/AccountDashboardFragment.java
index 53b5ea3..7b50b46 100644
--- a/src/com/android/settings/accounts/AccountDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDashboardFragment.java
@@ -17,8 +17,13 @@
import static android.provider.Settings.EXTRA_AUTHORITIES;
+import android.accounts.Account;
+import android.accounts.AccountManager;
import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.content.pm.UserInfo;
+import android.os.UserHandle;
+import android.os.UserManager;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
@@ -97,7 +102,26 @@
@Override
public List<SearchIndexableRaw> getDynamicRawDataToIndex(Context context,
boolean enabled) {
- return null;
+ final List<SearchIndexableRaw> indexRaws = new ArrayList<>();
+ final UserManager userManager = (UserManager) context.getSystemService(
+ Context.USER_SERVICE);
+ final List<UserInfo> profiles = userManager.getProfiles(UserHandle.myUserId());
+ for (final UserInfo userInfo : profiles) {
+ if (userInfo.isManagedProfile()) {
+ return indexRaws;
+ }
+ }
+
+ final AccountManager accountManager = AccountManager.get(context);
+ final Account[] accounts = accountManager.getAccounts();
+ for (Account account : accounts) {
+ final SearchIndexableRaw raw = new SearchIndexableRaw(context);
+ raw.key = AccountTypePreference.buildKey(account);
+ raw.title = account.name;
+ indexRaws.add(raw);
+ }
+
+ return indexRaws;
}
};
}
diff --git a/src/com/android/settings/applications/appops/AppOpsState.java b/src/com/android/settings/applications/appops/AppOpsState.java
index fed77ae..cbffe47 100644
--- a/src/com/android/settings/applications/appops/AppOpsState.java
+++ b/src/com/android/settings/applications/appops/AppOpsState.java
@@ -28,7 +28,6 @@
import android.os.Parcelable;
import android.text.format.DateUtils;
import android.util.Log;
-import android.util.Pair;
import android.util.SparseArray;
import com.android.settings.R;
@@ -619,7 +618,7 @@
}
AppOpsManager.OpEntry opEntry = new AppOpsManager.OpEntry(
- permOps.get(k), AppOpsManager.MODE_ALLOWED, new Pair[0]);
+ permOps.get(k), AppOpsManager.MODE_ALLOWED, Collections.emptyMap());
dummyOps.add(opEntry);
addOp(entries, pkgOps, appEntry, opEntry, packageName == null,
packageName == null ? 0 : opToOrder[opEntry.getOp()]);
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollPreviewFragment.java b/src/com/android/settings/biometrics/face/FaceEnrollPreviewFragment.java
index 8806712..853ca7c 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollPreviewFragment.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollPreviewFragment.java
@@ -18,6 +18,7 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.graphics.Matrix;
import android.graphics.SurfaceTexture;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
@@ -316,14 +317,19 @@
scaleX = scaleX / smaller;
scaleY = scaleY / smaller;
- // Apply the transformation/scale
- mTextureView.setTranslationX(getResources().getDimension(R.dimen.face_preview_translate_x));
- mTextureView.setTranslationY(getResources().getDimension(R.dimen.face_preview_translate_y));
-
+ final TypedValue tx = new TypedValue();
+ final TypedValue ty = new TypedValue();
final TypedValue scale = new TypedValue();
+ getResources().getValue(R.dimen.face_preview_translate_x, tx, true /* resolveRefs */);
+ getResources().getValue(R.dimen.face_preview_translate_y, ty, true /* resolveRefs */);
getResources().getValue(R.dimen.face_preview_scale, scale, true /* resolveRefs */);
- mTextureView.setScaleX(scaleX * scale.getFloat());
- mTextureView.setScaleY(scaleY * scale.getFloat());
+
+ // Apply the transformation/scale
+ final Matrix transform = new Matrix();
+ mTextureView.getTransform(transform);
+ transform.setScale(scaleX * scale.getFloat(), scaleY * scale.getFloat());
+ transform.postTranslate(tx.getFloat(), ty.getFloat());
+ mTextureView.setTransform(transform);
}
private void closeCamera() {
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 01b1598..1e97bdb 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -87,6 +87,7 @@
import com.android.settings.gestures.DoubleTapPowerSettings;
import com.android.settings.gestures.DoubleTapScreenSettings;
import com.android.settings.gestures.DoubleTwistGestureSettings;
+import com.android.settings.gestures.GestureNavigationSettingsFragment;
import com.android.settings.gestures.GlobalActionsPanelSettings;
import com.android.settings.gestures.PickupGestureSettings;
import com.android.settings.gestures.SwipeToNotificationSettings;
@@ -289,7 +290,8 @@
MobileNetworkListFragment.class.getName(),
GlobalActionsPanelSettings.class.getName(),
DarkModeSettingsFragment.class.getName(),
- BugReportHandlerPicker.class.getName()
+ BugReportHandlerPicker.class.getName(),
+ GestureNavigationSettingsFragment.class.getName()
};
public static final String[] SETTINGS_FOR_RESTRICTED = {
diff --git a/src/com/android/settings/gestures/BackGestureIndicatorDrawable.java b/src/com/android/settings/gestures/BackGestureIndicatorDrawable.java
new file mode 100644
index 0000000..2d09e6b
--- /dev/null
+++ b/src/com/android/settings/gestures/BackGestureIndicatorDrawable.java
@@ -0,0 +1,161 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.gestures;
+
+import android.animation.TimeAnimator;
+import android.annotation.IntRange;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.ColorFilter;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.settings.R;
+
+/** A drawable to animate the inset back gesture in both edges of the screen */
+public class BackGestureIndicatorDrawable extends Drawable {
+
+ private static final String TAG = "BackGestureIndicatorDrawable";
+
+ private static final int MSG_SET_INDICATOR_WIDTH = 1;
+ private static final int MSG_HIDE_INDICATOR = 3;
+
+ private static final long ANIMATION_DURATION_MS = 200L;
+ private static final long HIDE_DELAY_MS = 700L;
+
+ private static final int ALPHA_MAX = 64;
+
+ private Context mContext;
+
+ private Paint mPaint = new Paint();
+ private boolean mReversed;
+
+ private float mFinalWidth;
+ private float mCurrentWidth;
+ private float mWidthChangePerMs;
+
+ private TimeAnimator mTimeAnimator = new TimeAnimator();
+
+ private final Handler mHandler = new Handler(Looper.getMainLooper()) {
+ @Override
+ public void handleMessage(Message msg) {
+ switch(msg.what) {
+ case MSG_SET_INDICATOR_WIDTH:
+ mTimeAnimator.end();
+ mFinalWidth = msg.arg1;
+ mWidthChangePerMs = Math.abs(mCurrentWidth - mFinalWidth)
+ / ANIMATION_DURATION_MS;
+ mTimeAnimator.start();
+ break;
+ case MSG_HIDE_INDICATOR:
+ mCurrentWidth = mFinalWidth;
+ removeMessages(MSG_SET_INDICATOR_WIDTH);
+ sendMessageDelayed(obtainMessage(MSG_SET_INDICATOR_WIDTH, 0, 0), HIDE_DELAY_MS);
+ invalidateSelf();
+ break;
+ default:
+ break;
+ }
+ }
+ };
+
+ /**
+ * Creates an indicator drawable that responds to back gesture inset size change
+ * @param reversed If false, indicator will expand right. If true, indicator will expand left
+ */
+ public BackGestureIndicatorDrawable(Context context, boolean reversed) {
+ mContext = context;
+ mReversed = reversed;
+
+ // Restart the timer whenever a change is detected, so we can shrink/fade the indicators
+ mTimeAnimator.setTimeListener((TimeAnimator animation, long totalTime, long deltaTime) -> {
+ updateCurrentWidth(totalTime, deltaTime);
+ invalidateSelf();
+ });
+ }
+
+ private void updateCurrentWidth(long totalTime, long deltaTime) {
+ synchronized (mTimeAnimator) {
+ float step = deltaTime * mWidthChangePerMs;
+ if (totalTime >= ANIMATION_DURATION_MS
+ || step >= Math.abs(mFinalWidth - mCurrentWidth)) {
+ mCurrentWidth = mFinalWidth;
+ mTimeAnimator.end();
+ } else {
+ float direction = mCurrentWidth < mFinalWidth ? 1 : -1;
+ mCurrentWidth += direction * step;
+ }
+ }
+ }
+
+ @Override
+ public void draw(@NonNull Canvas canvas) {
+
+ mPaint.setAntiAlias(true);
+ mPaint.setColor(mContext.getResources().getColor(R.color.back_gesture_indicator));
+ mPaint.setAlpha(ALPHA_MAX);
+
+ final int top = 0;
+ final int bottom = canvas.getHeight();
+ final int width = (int) mCurrentWidth;
+
+ Rect rect = new Rect(0, top, width, bottom);
+ if (mReversed) {
+ rect.offset(canvas.getWidth() - width, 0);
+ }
+
+ canvas.drawRect(rect, mPaint);
+ }
+
+ @Override
+ public void setAlpha(@IntRange(from = 0, to = 255) int alpha) {
+
+ }
+
+ @Override
+ public void setColorFilter(@Nullable ColorFilter colorFilter) {
+
+ }
+
+ @Override
+ public int getOpacity() {
+ return 0;
+ }
+
+ /**
+ * Sets the visible width of the indicator in pixels.
+ */
+ public void setWidth(int width) {
+ if (width == 0) {
+ mHandler.sendEmptyMessage(MSG_HIDE_INDICATOR);
+ } else {
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_SET_INDICATOR_WIDTH, width, 0));
+ }
+ }
+
+ @VisibleForTesting
+ public int getWidth() {
+ return (int) mFinalWidth;
+ }
+}
diff --git a/src/com/android/settings/gestures/BackGestureIndicatorView.java b/src/com/android/settings/gestures/BackGestureIndicatorView.java
new file mode 100644
index 0000000..2bb8435
--- /dev/null
+++ b/src/com/android/settings/gestures/BackGestureIndicatorView.java
@@ -0,0 +1,100 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.gestures;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.PixelFormat;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+
+import com.android.settings.R;
+
+/**
+ * A linear layout containing the left and right location indicators.
+ */
+public class BackGestureIndicatorView extends LinearLayout {
+ private ViewGroup mLayout;
+ private ImageView mLeftIndicator;
+ private ImageView mRightIndicator;
+ private BackGestureIndicatorDrawable mLeftDrawable;
+ private BackGestureIndicatorDrawable mRightDrawable;
+
+ public BackGestureIndicatorView(Context context) {
+ super(context);
+
+ LayoutInflater factory = LayoutInflater.from(context);
+ mLayout = (ViewGroup) factory.inflate(R.layout.back_gesture_indicator_container,
+ this, false);
+
+ if (mLayout == null) {
+ return;
+ }
+
+ addView(mLayout);
+
+ mLeftDrawable = new BackGestureIndicatorDrawable(context, false);
+ mRightDrawable = new BackGestureIndicatorDrawable(context, true);
+
+ mLeftIndicator = mLayout.findViewById(R.id.indicator_left);
+ mRightIndicator = mLayout.findViewById(R.id.indicator_right);
+
+ mLeftIndicator.setImageDrawable(mLeftDrawable);
+ mRightIndicator.setImageDrawable(mRightDrawable);
+
+ TypedArray a = context.obtainStyledAttributes(new int[] {
+ android.R.attr.windowLightNavigationBar,
+ android.R.attr.windowLightStatusBar});
+ if (a.getBoolean(0, false)) {
+ setSystemUiVisibility(
+ getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
+ }
+ if (a.getBoolean(1, false)) {
+ setSystemUiVisibility(
+ getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+ }
+ a.recycle();
+ }
+
+ public void setIndicatorWidth(int width, boolean leftIndicator) {
+ BackGestureIndicatorDrawable indicator = leftIndicator ? mLeftDrawable : mRightDrawable;
+ indicator.setWidth(width);
+ }
+
+ public WindowManager.LayoutParams getLayoutParams(
+ WindowManager.LayoutParams parentWindowAttributes) {
+ int copiedFlags = (parentWindowAttributes.flags
+ & WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+ final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ WindowManager.LayoutParams.TYPE_APPLICATION,
+ WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
+ | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
+ | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+ | copiedFlags,
+ PixelFormat.TRANSLUCENT);
+
+ lp.setTitle("BackGestureIndicatorView");
+ lp.token = getContext().getActivityToken();
+ return lp;
+ }
+}
diff --git a/src/com/android/settings/gestures/GestureNavigationSettingsFragment.java b/src/com/android/settings/gestures/GestureNavigationSettingsFragment.java
new file mode 100644
index 0000000..c209c81
--- /dev/null
+++ b/src/com/android/settings/gestures/GestureNavigationSettingsFragment.java
@@ -0,0 +1,148 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.gestures;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.view.WindowManager;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.search.SearchIndexable;
+
+/**
+ * A fragment to include all the settings related to Gesture Navigation mode.
+ */
+@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
+public class GestureNavigationSettingsFragment extends DashboardFragment {
+
+ public static final String TAG = "GestureNavigationSettingsFragment";
+
+ public static final String GESTURE_NAVIGATION_SETTINGS =
+ "com.android.settings.GESTURE_NAVIGATION_SETTINGS";
+
+ private static final String LEFT_EDGE_SEEKBAR_KEY = "gesture_left_back_sensitivity";
+ private static final String RIGHT_EDGE_SEEKBAR_KEY = "gesture_right_back_sensitivity";
+
+ private WindowManager mWindowManager;
+ private BackGestureIndicatorView mIndicatorView;
+
+ private static final float[] BACK_GESTURE_INSET_SCALES = {0.75f, 1.0f, 1.33f, 1.66f};
+
+ private float mDefaultBackGestureInset;
+
+ public GestureNavigationSettingsFragment() {
+ super();
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mIndicatorView = new BackGestureIndicatorView(getActivity());
+ mWindowManager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
+
+ mDefaultBackGestureInset = getActivity().getResources().getDimensionPixelSize(
+ com.android.internal.R.dimen.config_backGestureInset);
+ }
+
+ @Override
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+ super.onCreatePreferences(savedInstanceState, rootKey);
+
+ initSeekBarPreference(LEFT_EDGE_SEEKBAR_KEY);
+ initSeekBarPreference(RIGHT_EDGE_SEEKBAR_KEY);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ mWindowManager.addView(mIndicatorView, mIndicatorView.getLayoutParams(
+ getActivity().getWindow().getAttributes()));
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+
+ mWindowManager.removeView(mIndicatorView);
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.gesture_navigation_settings;
+ }
+
+ @Override
+ public int getHelpResource() {
+ // TODO(b/146001201): Replace with gesture navigation help page when ready.
+ return R.string.help_uri_default;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.SETTINGS_GESTURE_NAV_BACK_SENSITIVITY_DLG;
+ }
+
+ private void initSeekBarPreference(final String key) {
+ final GestureNavigationSeekBarPreference pref = getPreferenceScreen().findPreference(key);
+ pref.setContinuousUpdates(true);
+
+ final String settingsKey = key == LEFT_EDGE_SEEKBAR_KEY
+ ? Settings.Secure.BACK_GESTURE_INSET_SCALE_LEFT
+ : Settings.Secure.BACK_GESTURE_INSET_SCALE_RIGHT;
+ final float initScale = Settings.Secure.getFloat(
+ getContext().getContentResolver(), settingsKey, 1.0f);
+
+ // Find the closest value to initScale
+ float minDistance = Float.MAX_VALUE;
+ int minDistanceIndex = -1;
+ for (int i = 0; i < BACK_GESTURE_INSET_SCALES.length; i++) {
+ float d = Math.abs(BACK_GESTURE_INSET_SCALES[i] - initScale);
+ if (d < minDistance) {
+ minDistance = d;
+ minDistanceIndex = i;
+ }
+ }
+ pref.setProgress(minDistanceIndex);
+
+ pref.setOnPreferenceChangeListener((p, v) -> {
+ final int width = (int) (mDefaultBackGestureInset * BACK_GESTURE_INSET_SCALES[(int) v]);
+ mIndicatorView.setIndicatorWidth(width, key == LEFT_EDGE_SEEKBAR_KEY);
+ return true;
+ });
+
+ pref.setOnPreferenceChangeStopListener((p, v) -> {
+ mIndicatorView.setIndicatorWidth(0, key == LEFT_EDGE_SEEKBAR_KEY);
+ final float scale = BACK_GESTURE_INSET_SCALES[(int) v];
+ Settings.Secure.putFloat(getContext().getContentResolver(), settingsKey, scale);
+ return true;
+ });
+ }
+
+ public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider(R.xml.gesture_navigation_settings);
+}
diff --git a/src/com/android/settings/network/AirplaneModePreferenceController.java b/src/com/android/settings/network/AirplaneModePreferenceController.java
index 3c79be3..f5fff1c 100644
--- a/src/com/android/settings/network/AirplaneModePreferenceController.java
+++ b/src/com/android/settings/network/AirplaneModePreferenceController.java
@@ -23,13 +23,13 @@
import android.content.pm.PackageManager;
import android.net.Uri;
import android.provider.SettingsSlicesContract;
+import android.telephony.TelephonyManager;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
-import com.android.internal.telephony.TelephonyIntents;
import com.android.settings.AirplaneModeEnabler;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
@@ -77,7 +77,7 @@
// In ECM mode launch ECM app dialog
if (mFragment != null) {
mFragment.startActivityForResult(
- new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null),
+ new Intent(TelephonyManager.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null),
REQUEST_CODE_EXIT_ECM);
}
return true;
diff --git a/src/com/android/settings/network/MobileDataContentObserver.java b/src/com/android/settings/network/MobileDataContentObserver.java
index b8a1c8c..15e726f 100644
--- a/src/com/android/settings/network/MobileDataContentObserver.java
+++ b/src/com/android/settings/network/MobileDataContentObserver.java
@@ -33,9 +33,13 @@
super(handler);
}
- public static Uri getObservableUri(int subId) {
+ /**
+ * Return a URI of mobile data(ON vs OFF)
+ */
+ public static Uri getObservableUri(Context context, int subId) {
Uri uri = Settings.Global.getUriFor(Settings.Global.MOBILE_DATA);
- if (TelephonyManager.getDefault().getSimCount() != 1) {
+ TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class);
+ if (telephonyManager.getSimCount() != 1) {
uri = Settings.Global.getUriFor(Settings.Global.MOBILE_DATA + subId);
}
return uri;
@@ -54,7 +58,7 @@
}
public void register(Context context, int subId) {
- final Uri uri = getObservableUri(subId);
+ final Uri uri = getObservableUri(context, subId);
context.getContentResolver().registerContentObserver(uri, false, this);
}
diff --git a/src/com/android/settings/network/telephony/MobileDataSlice.java b/src/com/android/settings/network/telephony/MobileDataSlice.java
index 152028c..c70ae1a 100644
--- a/src/com/android/settings/network/telephony/MobileDataSlice.java
+++ b/src/com/android/settings/network/telephony/MobileDataSlice.java
@@ -252,7 +252,7 @@
}
public void register(Context context, int subId) {
- final Uri uri = MobileDataContentObserver.getObservableUri(subId);
+ final Uri uri = MobileDataContentObserver.getObservableUri(context, subId);
context.getContentResolver().registerContentObserver(uri, false, this);
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index 2c3cd3a..90d8d4e 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -34,7 +34,6 @@
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
-import com.android.internal.telephony.TelephonyIntents;
import com.android.settings.R;
import com.android.settings.dashboard.RestrictedDashboardFragment;
import com.android.settings.datausage.BillingCyclePreferenceController;
@@ -98,7 +97,7 @@
|| TextUtils.equals(key, BUTTON_CDMA_SUBSCRIPTION_KEY)) {
if (mTelephonyManager.getEmergencyCallbackMode()) {
startActivityForResult(
- new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null),
+ new Intent(TelephonyManager.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null),
REQUEST_CODE_EXIT_ECM);
mClickedPrefKey = key;
}
diff --git a/src/com/android/settings/password/BiometricFragment.java b/src/com/android/settings/password/BiometricFragment.java
index 9898719..fe0740b 100644
--- a/src/com/android/settings/password/BiometricFragment.java
+++ b/src/com/android/settings/password/BiometricFragment.java
@@ -16,8 +16,6 @@
package com.android.settings.password;
-import android.app.Activity;
-import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
import android.content.DialogInterface;
import android.hardware.biometrics.BiometricConstants;
@@ -26,16 +24,10 @@
import android.hardware.biometrics.BiometricPrompt.AuthenticationResult;
import android.os.Bundle;
import android.os.CancellationSignal;
-import android.os.Handler;
-import android.os.Looper;
-import android.util.Log;
import androidx.annotation.NonNull;
-import com.android.internal.widget.LockPatternUtils;
-import com.android.settings.R;
import com.android.settings.core.InstrumentedFragment;
-import com.android.settings.overlay.FeatureFactory;
import java.util.concurrent.Executor;
@@ -139,7 +131,9 @@
.setSubtitle(mBundle.getString(BiometricPrompt.KEY_SUBTITLE))
.setDescription(mBundle.getString(BiometricPrompt.KEY_DESCRIPTION))
.setConfirmationRequired(
- mBundle.getBoolean(BiometricPrompt.KEY_REQUIRE_CONFIRMATION, true));
+ mBundle.getBoolean(BiometricPrompt.KEY_REQUIRE_CONFIRMATION, true))
+ .setDisallowBiometricsIfPolicyExists(mBundle.getBoolean(
+ BiometricPrompt.EXTRA_DISALLOW_BIOMETRICS_IF_POLICY_EXISTS, false));
mBiometricPrompt = builder.build();
mCancellationSignal = new CancellationSignal();
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index bf8c571..912b600 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -25,7 +25,6 @@
import android.app.trust.TrustManager;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.PackageManager;
import android.hardware.biometrics.BiometricConstants;
import android.hardware.biometrics.BiometricManager;
import android.hardware.biometrics.BiometricPrompt;
@@ -54,10 +53,11 @@
public static final String TAG = ConfirmDeviceCredentialActivity.class.getSimpleName();
/**
- * If the intent is sent from {@link com.android.systemui.keyguard.WorkLockActivity} then
- * check for device policy management flags.
+ * If the intent is sent from {@link com.android.systemui.keyguard.WorkLockActivityController}
+ * then check for device policy management flags.
*/
- public static final String EXTRA_FROM_WORK_LOCK_ACTIVITY = "from_work_lock_activity";
+ public static final String EXTRA_FROM_WORK_LOCK_ACTIVITY_CONTROLLER =
+ "from_work_lock_activity_controller";
// The normal flow that apps go through
private static final int CREDENTIAL_NORMAL = 1;
@@ -98,7 +98,7 @@
private ChooseLockSettingsHelper mChooseLockSettingsHelper;
private Handler mHandler = new Handler(Looper.getMainLooper());
private Context mContext;
- private boolean mFromWorkLockActivity;
+ private boolean mCheckDevicePolicyManager;
private String mTitle;
private String mDetails;
@@ -159,7 +159,8 @@
Intent intent = getIntent();
mContext = this;
- mFromWorkLockActivity = intent.getBooleanExtra(EXTRA_FROM_WORK_LOCK_ACTIVITY, false);
+ mCheckDevicePolicyManager = intent
+ .getBooleanExtra(BiometricPrompt.EXTRA_DISALLOW_BIOMETRICS_IF_POLICY_EXISTS, false);
mTitle = intent.getStringExtra(KeyguardManager.EXTRA_TITLE);
mDetails = intent.getStringExtra(KeyguardManager.EXTRA_DESCRIPTION);
String alternateButton = intent.getStringExtra(
@@ -189,6 +190,8 @@
mDetails = bpBundle.getString(BiometricPrompt.KEY_SUBTITLE);
bpBundle.putString(BiometricPrompt.KEY_TITLE, mTitle);
bpBundle.putString(BiometricPrompt.KEY_DESCRIPTION, mDetails);
+ bpBundle.putBoolean(BiometricPrompt.EXTRA_DISALLOW_BIOMETRICS_IF_POLICY_EXISTS,
+ mCheckDevicePolicyManager);
boolean launchedBiometric = false;
boolean launchedCDC = false;
@@ -201,7 +204,7 @@
} else if (isManagedProfile && isInternalActivity()
&& !lockPatternUtils.isSeparateProfileChallengeEnabled(mUserId)) {
mCredentialMode = CREDENTIAL_MANAGED;
- if (mFromWorkLockActivity && isBiometricAllowed(effectiveUserId, mUserId)) {
+ if (isBiometricAllowed(effectiveUserId, mUserId)) {
showBiometricPrompt(bpBundle);
launchedBiometric = true;
} else {
@@ -267,42 +270,9 @@
|| !mUserManager.isUserUnlocked(mUserId);
}
- /**
- * TODO: Pass a list of disabled features to an internal BiometricPrompt API, so we can
- * potentially show different modalities on multi-auth devices.
- *
- * @param effectiveUserId
- * @return false if their exists one biometric on the device which is not disabled by the
- * policy manager.
- */
- private boolean isBiometricDisabledByAdmin(int effectiveUserId) {
- final int disabledFeatures =
- mDevicePolicyManager.getKeyguardDisabledFeatures(null, effectiveUserId);
-
- final PackageManager pm = mContext.getPackageManager();
- if (pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)
- && (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT) == 0) {
- Log.d(TAG,"Fingerprint enabled & allowed by device policy manager");
- return false;
- }
- if (pm.hasSystemFeature(PackageManager.FEATURE_IRIS)
- && (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_IRIS) == 0) {
- Log.d(TAG,"Iris enabled & allowed by device policy manager");
- return false;
- }
- if (pm.hasSystemFeature(PackageManager.FEATURE_FACE)
- && (disabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_FACE) == 0) {
- Log.d(TAG,"Face enabled & allowed by device policy manager");
- return false;
- }
-
- return true;
- }
-
private boolean isBiometricAllowed(int effectiveUserId, int realUserId) {
- return !isStrongAuthRequired(effectiveUserId)
- && !isBiometricDisabledByAdmin(effectiveUserId)
- && !mLockPatternUtils.hasPendingEscrowToken(realUserId);
+ return !isStrongAuthRequired(effectiveUserId) && !mLockPatternUtils
+ .hasPendingEscrowToken(realUserId);
}
private void showBiometricPrompt(Bundle bundle) {
@@ -346,7 +316,7 @@
.launchConfirmationActivityWithExternalAndChallenge(
0 /* request code */, null /* title */, mTitle, mDetails,
true /* isExternal */, 0L /* challenge */, mUserId);
- } else if (mCredentialMode == CREDENTIAL_NORMAL){
+ } else if (mCredentialMode == CREDENTIAL_NORMAL) {
launched = mChooseLockSettingsHelper.launchConfirmationActivity(
0 /* request code */, null /* title */,
mTitle, mDetails, false /* returnCredentials */, true /* isExternal */,
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java
index 0060875..fe57090 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java
@@ -17,26 +17,55 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.content.Context;
+import android.content.pm.UserInfo;
+import android.os.UserManager;
import android.provider.SearchIndexableResource;
import com.android.settingslib.drawer.CategoryKey;
+import com.android.settingslib.search.SearchIndexableRaw;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import java.util.ArrayList;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
public class AccountDashboardFragmentTest {
+ private static final int PROFILE_ID = 10;
+ private static final String PROFILE_NAME = "User";
+ private static final String ACCOUNT_TYPE = "com.android.settings";
+ private static final String ACCOUNT_NAME = "test account";
+
+ @Mock
+ private UserManager mUserManager;
+ @Mock
+ private AccountManager mAccountManager;
+
+ private Context mContext;
private AccountDashboardFragment mFragment;
@Before
public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
mFragment = new AccountDashboardFragment();
+
+ doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
}
@Test
@@ -45,7 +74,7 @@
}
@Test
- public void testSearchIndexProvider_shouldIndexResource() {
+ public void searchIndexProvider_shouldIndexResource() {
final List<SearchIndexableResource> indexRes =
AccountDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
.getXmlResourcesToIndex(RuntimeEnvironment.application, true /* enabled */);
@@ -53,4 +82,36 @@
assertThat(indexRes).isNotNull();
assertThat(indexRes.get(0).xmlResId).isEqualTo(mFragment.getPreferenceScreenResId());
}
+
+ @Test
+ public void searchIndexProvider_hasManagedProfile_shouldNotIndex() {
+ final List<UserInfo> infos = new ArrayList<>();
+ infos.add(new UserInfo(PROFILE_ID, PROFILE_NAME, UserInfo.FLAG_MANAGED_PROFILE));
+ doReturn(infos).when(mUserManager).getProfiles(anyInt());
+
+ final List<SearchIndexableRaw> indexRaws =
+ AccountDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
+ .getDynamicRawDataToIndex(mContext, true /* enabled */);
+
+ assertThat(indexRaws).isEmpty();
+ }
+
+ @Test
+ public void searchIndexProvider_hasAccounts_shouldIndex() {
+ final List<UserInfo> infos = new ArrayList<>();
+ infos.add(new UserInfo(PROFILE_ID, PROFILE_NAME, UserInfo.FLAG_PRIMARY));
+ doReturn(infos).when(mUserManager).getProfiles(anyInt());
+
+ final Account[] accounts = {
+ new Account(ACCOUNT_NAME, ACCOUNT_TYPE)
+ };
+ when(AccountManager.get(mContext)).thenReturn(mAccountManager);
+ doReturn(accounts).when(mAccountManager).getAccounts();
+
+ final List<SearchIndexableRaw> indexRaws =
+ AccountDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
+ .getDynamicRawDataToIndex(mContext, true /* enabled */);
+
+ assertThat(indexRaws).isNotEmpty();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java
index 3be4347..0a8f7d6 100644
--- a/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/MockLocationAppPreferenceControllerTest.java
@@ -146,6 +146,6 @@
}
private AppOpsManager.OpEntry createOpEntry(int opMode) {
- return new OpEntry(0, opMode, new Pair[0]);
+ return new OpEntry(0, opMode, Collections.emptyMap());
}
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
index 1febbe4..598ef6e 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
@@ -54,6 +54,7 @@
import org.robolectric.RobolectricTestRunner;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
@@ -84,10 +85,12 @@
MockitoAnnotations.initMocks(this);
final List<AppOpsManager.OpEntry> allowOps = new ArrayList<>();
allowOps.add(new AppOpsManager.OpEntry(
- AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, AppOpsManager.MODE_ALLOWED, new Pair[0]));
+ AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, AppOpsManager.MODE_ALLOWED,
+ Collections.emptyMap()));
final List<AppOpsManager.OpEntry> restrictedOps = new ArrayList<>();
restrictedOps.add(new AppOpsManager.OpEntry(
- AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, AppOpsManager.MODE_IGNORED, new Pair[0]));
+ AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, AppOpsManager.MODE_IGNORED,
+ Collections.emptyMap()));
mAllowedPackageOps = new AppOpsManager.PackageOps(
ALLOWED_PACKAGE_NAME, ALLOWED_UID, allowOps);
mRestrictedPackageOps = new AppOpsManager.PackageOps(
diff --git a/tests/robotests/src/com/android/settings/gestures/BackGestureIndicatorViewTest.java b/tests/robotests/src/com/android/settings/gestures/BackGestureIndicatorViewTest.java
new file mode 100644
index 0000000..8d43aaa
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/gestures/BackGestureIndicatorViewTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+
+package com.android.settings.gestures;
+
+import static org.junit.Assert.assertEquals;
+
+import android.content.Context;
+import android.widget.ImageView;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class BackGestureIndicatorViewTest {
+
+ private Context mContext;
+
+ private BackGestureIndicatorDrawable mLeftDrawable;
+ private BackGestureIndicatorDrawable mRightDrawable;
+
+ private BackGestureIndicatorView mView;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mContext = RuntimeEnvironment.application;
+ mView = new BackGestureIndicatorView(mContext);
+
+ mLeftDrawable = (BackGestureIndicatorDrawable) ((ImageView) mView.findViewById(
+ R.id.indicator_left)).getDrawable();
+ mRightDrawable = (BackGestureIndicatorDrawable) ((ImageView) mView.findViewById(
+ R.id.indicator_right)).getDrawable();
+ }
+
+ @Test
+ public void testSetIndicatoreWidth() {
+ mView.setIndicatorWidth(25, true);
+ mView.setIndicatorWidth(52, false);
+
+ assertEquals(25, mLeftDrawable.getWidth());
+ assertEquals(52, mRightDrawable.getWidth());
+ }
+}