Merge "Add comment to AndroidManifest" into sc-dev
diff --git a/res/xml/accessibility_button_settings.xml b/res/xml/accessibility_button_settings.xml
index 78d13ab..02b1c7d 100644
--- a/res/xml/accessibility_button_settings.xml
+++ b/res/xml/accessibility_button_settings.xml
@@ -61,6 +61,7 @@
<com.android.settings.accessibility.AccessibilityFooterPreference
android:key="accessibility_button_footer"
+ android:title="@string/accessibility_button_description"
android:persistent="false"
android:selectable="false"
settings:searchable="false"
diff --git a/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceController.java b/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceController.java
index 8b4a364..de90374 100644
--- a/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceController.java
+++ b/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceController.java
@@ -18,6 +18,8 @@
import android.content.Context;
+import androidx.preference.PreferenceScreen;
+
import com.android.settings.R;
/**
@@ -36,9 +38,16 @@
}
@Override
- public CharSequence getSummary() {
- return AccessibilityUtil.isGestureNavigateEnabled(mContext)
- ? mContext.getString(R.string.accessibility_button_gesture_description)
- : mContext.getString(R.string.accessibility_button_description);
+ public void displayPreference(PreferenceScreen screen) {
+ // Need to update footerPreference's data before super.displayPreference(), then it will use
+ // data to update related property of footerPreference.
+ if (AccessibilityUtil.isGestureNavigateEnabled(mContext)) {
+ final AccessibilityFooterPreference footerPreference =
+ screen.findPreference(getPreferenceKey());
+ footerPreference.setTitle(
+ mContext.getString(R.string.accessibility_button_gesture_description));
+ }
+
+ super.displayPreference(screen);
}
}
diff --git a/src/com/android/settings/wifi/WifiDialogActivity.java b/src/com/android/settings/wifi/WifiDialogActivity.java
index abe1205..4514b0d 100644
--- a/src/com/android/settings/wifi/WifiDialogActivity.java
+++ b/src/com/android/settings/wifi/WifiDialogActivity.java
@@ -33,6 +33,7 @@
import android.os.SimpleClock;
import android.os.SystemClock;
import android.text.TextUtils;
+import android.util.EventLog;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -356,6 +357,7 @@
final String callingPackage = getCallingPackage();
if (callingPackage == null) {
Log.d(TAG, "Failed to get the calling package, don't return the result.");
+ EventLog.writeEvent(0x534e4554, "185126813", -1 /* UID */, "no calling package");
return false;
}
@@ -372,6 +374,14 @@
}
Log.d(TAG, "The calling package does not have the necessary permissions for result.");
+ try {
+ EventLog.writeEvent(0x534e4554, "185126813",
+ getPackageManager().getPackageUid(callingPackage, 0 /* flags */),
+ "no permission");
+ } catch (PackageManager.NameNotFoundException e) {
+ EventLog.writeEvent(0x534e4554, "185126813", -1 /* UID */, "no permission");
+ Log.w(TAG, "Cannot find the UID, calling package: " + callingPackage, e);
+ }
return false;
}
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceControllerTest.java
index 33c5762..010b444 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceControllerTest.java
@@ -16,7 +16,6 @@
package com.android.settings.accessibility;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
import static com.google.common.truth.Truth.assertThat;
@@ -26,6 +25,7 @@
import android.content.Context;
import android.content.res.Resources;
+import androidx.preference.PreferenceScreen;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
@@ -34,6 +34,7 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
@@ -50,30 +51,29 @@
private final Context mContext = ApplicationProvider.getApplicationContext();
@Spy
private final Resources mResources = mContext.getResources();
+ @Mock
+ private PreferenceScreen mScreen;
private AccessibilityButtonFooterPreferenceController mController;
+ private AccessibilityFooterPreference mPreference;
@Before
public void setUp() {
- mController = new AccessibilityButtonFooterPreferenceController(mContext,
- "test_key");
+ mController = new AccessibilityButtonFooterPreferenceController(mContext, "test_key");
+ mPreference = new AccessibilityFooterPreference(mContext);
+ mPreference.setKey("test_key");
+
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
when(mContext.getResources()).thenReturn(mResources);
}
@Test
- public void getSummary_navigationGestureEnabled_shouldReturnButtonAndGestureSummary() {
+ public void displayPreference_navigationGestureEnabled_setCorrectTitle() {
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
- .thenReturn(NAV_BAR_MODE_GESTURAL);
+ .thenReturn(NAV_BAR_MODE_GESTURAL);
- assertThat(mController.getSummary()).isEqualTo(
+ mController.displayPreference(mScreen);
+
+ assertThat(mPreference.getTitle()).isEqualTo(
mContext.getText(R.string.accessibility_button_gesture_description));
}
-
- @Test
- public void getSummary_navigationGestureDisabled_shouldReturnButtonSummary() {
- when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
- .thenReturn(NAV_BAR_MODE_2BUTTON);
-
- assertThat(mController.getSummary()).isEqualTo(
- mContext.getText(R.string.accessibility_button_description));
- }
}