Merge "WM: Fix flaky DragDropControllerTests tests"
diff --git a/config/preloaded-classes b/config/preloaded-classes
index 0014793..63c583f 100644
--- a/config/preloaded-classes
+++ b/config/preloaded-classes
@@ -6236,9 +6236,9 @@
org.json.JSONStringer
org.json.JSONStringer$Scope
org.json.JSONTokener
-org.kxml2.io.KXmlParser
-org.kxml2.io.KXmlParser$ValueContext
-org.kxml2.io.KXmlSerializer
+com.android.org.kxml2.io.KXmlParser
+com.android.org.kxml2.io.KXmlParser$ValueContext
+com.android.org.kxml2.io.KXmlSerializer
org.w3c.dom.CharacterData
org.w3c.dom.DOMImplementation
org.w3c.dom.Document
diff --git a/core/java/android/app/job/JobSnapshot.java b/core/java/android/app/job/JobSnapshot.java
index d6cc70d..ceeaab7 100644
--- a/core/java/android/app/job/JobSnapshot.java
+++ b/core/java/android/app/job/JobSnapshot.java
@@ -50,6 +50,14 @@
}
/**
+ * Returning JobInfo bound to this snapshot
+ * @return JobInfo of this snapshot
+ */
+ public JobInfo getJobInfo() {
+ return mJob;
+ }
+
+ /**
* Is this job actually runnable at this moment?
*/
public boolean isRunnable() {
@@ -77,7 +85,7 @@
*/
public boolean isRequireDeviceIdleSatisfied() {
return !mJob.isRequireDeviceIdle()
- || satisfied(JobInfo.CONSTRAINT_FLAG_BATTERY_NOT_LOW);
+ || satisfied(JobInfo.CONSTRAINT_FLAG_DEVICE_IDLE);
}
public boolean isRequireStorageNotLowSatisfied() {
diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java
index e606964..6ddcbe0 100644
--- a/core/java/android/os/Debug.java
+++ b/core/java/android/os/Debug.java
@@ -1752,13 +1752,13 @@
public static native long getPss();
/**
- * Retrieves the PSS memory used by the process as given by the
- * smaps. Optionally supply a long array of 2 entries to also
- * receive the Uss and SwapPss of the process, and another array to also
- * retrieve the separate memtrack size.
+ * Retrieves the PSS memory used by the process as given by the smaps. Optionally supply a long
+ * array of up to 3 entries to also receive (up to 3 values in order): the Uss and SwapPss and
+ * Rss (only filled in as of {@link android.os.Build.VERSION_CODES#P}) of the process, and
+ * another array to also retrieve the separate memtrack size.
* @hide
*/
- public static native long getPss(int pid, long[] outUssSwapPss, long[] outMemtrack);
+ public static native long getPss(int pid, long[] outUssSwapPssRss, long[] outMemtrack);
/** @hide */
public static final int MEMINFO_TOTAL = 0;
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl
index 13e4e38..7ceeb52 100644
--- a/core/java/android/os/IPowerManager.aidl
+++ b/core/java/android/os/IPowerManager.aidl
@@ -56,6 +56,7 @@
void shutdown(boolean confirm, String reason, boolean wait);
void crash(String message);
int getLastShutdownReason();
+ int getLastSleepReason();
void setStayOnSetting(int val);
void boostScreenBrightness(long time);
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 463a6aa..89a5def 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -397,6 +397,23 @@
public static final int GO_TO_SLEEP_REASON_ACCESSIBILITY = 7;
/**
+ * @hide
+ */
+ public static String sleepReasonToString(int sleepReason) {
+ switch (sleepReason) {
+ case GO_TO_SLEEP_REASON_APPLICATION: return "application";
+ case GO_TO_SLEEP_REASON_DEVICE_ADMIN: return "device_admin";
+ case GO_TO_SLEEP_REASON_TIMEOUT: return "timeout";
+ case GO_TO_SLEEP_REASON_LID_SWITCH: return "lid_switch";
+ case GO_TO_SLEEP_REASON_POWER_BUTTON: return "power_button";
+ case GO_TO_SLEEP_REASON_HDMI: return "hdmi";
+ case GO_TO_SLEEP_REASON_SLEEP_BUTTON: return "sleep_button";
+ case GO_TO_SLEEP_REASON_ACCESSIBILITY: return "accessibility";
+ default: return Integer.toString(sleepReason);
+ }
+ }
+
+ /**
* Go to sleep flag: Skip dozing state and directly go to full sleep.
* @hide
*/
@@ -1310,6 +1327,22 @@
}
/**
+ * Returns the reason the device last went to sleep (i.e. the last value of
+ * the second argument of {@link #goToSleep(long, int, int) goToSleep}).
+ *
+ * @return One of the {@code GO_TO_SLEEP_REASON_*} constants.
+ *
+ * @hide
+ */
+ public int getLastSleepReason() {
+ try {
+ return mService.getLastSleepReason();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Intent that is broadcast when the state of {@link #isPowerSaveMode()} changes.
* This broadcast is only sent to registered receivers.
*/
diff --git a/core/java/android/service/autofill/UserData.java b/core/java/android/service/autofill/UserData.java
index 55aecdd..fccb85b 100644
--- a/core/java/android/service/autofill/UserData.java
+++ b/core/java/android/service/autofill/UserData.java
@@ -145,6 +145,9 @@
// Non-persistent array used to limit the number of unique ids.
private final ArraySet<String> mUniqueCategoryIds;
+ // Non-persistent array used to ignore duplaicated value/category pairs.
+ private final ArraySet<String> mUniqueValueCategoryPairs;
+
/**
* Creates a new builder for the user data used for <a href="#FieldClassification">field
@@ -185,6 +188,7 @@
final int maxUserDataSize = getMaxUserDataSize();
mCategoryIds = new ArrayList<>(maxUserDataSize);
mValues = new ArrayList<>(maxUserDataSize);
+ mUniqueValueCategoryPairs = new ArraySet<>(maxUserDataSize);
mUniqueCategoryIds = new ArraySet<>(getMaxCategoryCount());
addMapping(value, categoryId);
@@ -222,7 +226,8 @@
* @throws IllegalStateException if:
* <ul>
* <li>{@link #build()} already called</li>
- * <li>the {@code value} has already been added</li>
+ * <li>the {@code value} has already been added (<b>Note: </b> this restriction was
+ * lifted on Android {@link android.os.Build.VERSION_CODES#Q} and later)</li>
* <li>the number of unique {@code categoryId} values added so far is more than
* {@link UserData#getMaxCategoryCount()}</li>
* <li>the number of {@code values} added so far is is more than
@@ -248,12 +253,8 @@
// New category - check size
Preconditions.checkState(mUniqueCategoryIds.size() < getMaxCategoryCount(),
"already added " + mUniqueCategoryIds.size() + " unique category ids");
-
}
- Preconditions.checkState(!mValues.contains(value),
- // Don't include value on message because it could contain PII
- "already has entry with same value");
Preconditions.checkState(mValues.size() < getMaxUserDataSize(),
"already added " + mValues.size() + " elements");
addMapping(value, categoryId);
@@ -262,9 +263,16 @@
}
private void addMapping(@NonNull String value, @NonNull String categoryId) {
+ final String pair = value + ":" + categoryId;
+ if (mUniqueValueCategoryPairs.contains(pair)) {
+ // Don't include value on message because it could contain PII
+ Log.w(TAG, "Ignoring entry with same value / category");
+ return;
+ }
mCategoryIds.add(categoryId);
mValues.add(value);
mUniqueCategoryIds.add(categoryId);
+ mUniqueValueCategoryPairs.add(pair);
}
private String checkNotEmpty(@NonNull String name, @Nullable String value) {
diff --git a/core/java/android/service/notification/INotificationListener.aidl b/core/java/android/service/notification/INotificationListener.aidl
index 2dff716..d8bd002 100644
--- a/core/java/android/service/notification/INotificationListener.aidl
+++ b/core/java/android/service/notification/INotificationListener.aidl
@@ -18,6 +18,7 @@
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
+import android.content.pm.ParceledListSlice;
import android.os.UserHandle;
import android.service.notification.NotificationStats;
import android.service.notification.IStatusBarNotificationHolder;
@@ -45,4 +46,5 @@
// assistants only
void onNotificationEnqueuedWithChannel(in IStatusBarNotificationHolder notificationHolder, in NotificationChannel channel);
void onNotificationSnoozedUntilContext(in IStatusBarNotificationHolder notificationHolder, String snoozeCriterionId);
+ void onNotificationsSeen(in List<String> keys);
}
diff --git a/core/java/android/service/notification/NotificationAssistantService.java b/core/java/android/service/notification/NotificationAssistantService.java
index 3853fc5..3b820ca 100644
--- a/core/java/android/service/notification/NotificationAssistantService.java
+++ b/core/java/android/service/notification/NotificationAssistantService.java
@@ -149,6 +149,14 @@
}
/**
+ * Implement this to know when a user has seen notifications, as triggered by
+ * {@link #setNotificationsShown(String[])}.
+ */
+ public void onNotificationsSeen(List<String> keys) {
+
+ }
+
+ /**
* Updates a notification. N.B. this won’t cause
* an existing notification to alert, but might allow a future update to
* this notification to alert.
@@ -236,11 +244,20 @@
mHandler.obtainMessage(MyHandler.MSG_ON_NOTIFICATION_SNOOZED,
args).sendToTarget();
}
+
+ @Override
+ public void onNotificationsSeen(List<String> keys) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = keys;
+ mHandler.obtainMessage(MyHandler.MSG_ON_NOTIFICATIONS_SEEN,
+ args).sendToTarget();
+ }
}
private final class MyHandler extends Handler {
public static final int MSG_ON_NOTIFICATION_ENQUEUED = 1;
public static final int MSG_ON_NOTIFICATION_SNOOZED = 2;
+ public static final int MSG_ON_NOTIFICATIONS_SEEN = 3;
public MyHandler(Looper looper) {
super(looper, null, false);
@@ -275,6 +292,13 @@
onNotificationSnoozedUntilContext(sbn, snoozeCriterionId);
break;
}
+ case MSG_ON_NOTIFICATIONS_SEEN: {
+ SomeArgs args = (SomeArgs) msg.obj;
+ List<String> keys = (List<String>) args.arg1;
+ args.recycle();
+ onNotificationsSeen(keys);
+ break;
+ }
}
}
}
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java
index 98da569..1b588f4 100644
--- a/core/java/android/service/notification/NotificationListenerService.java
+++ b/core/java/android/service/notification/NotificationListenerService.java
@@ -1332,6 +1332,12 @@
}
@Override
+ public void onNotificationsSeen(List<String> keys)
+ throws RemoteException {
+ // no-op in the listener
+ }
+
+ @Override
public void onNotificationSnoozedUntilContext(
IStatusBarNotificationHolder notificationHolder, String snoozeCriterionId)
throws RemoteException {
diff --git a/core/java/com/android/internal/os/HandlerCaller.java b/core/java/com/android/internal/os/HandlerCaller.java
index ae7c5f2..709cf43 100644
--- a/core/java/com/android/internal/os/HandlerCaller.java
+++ b/core/java/com/android/internal/os/HandlerCaller.java
@@ -21,6 +21,12 @@
import android.os.Looper;
import android.os.Message;
+/**
+ * @deprecated Use {@link com.android.internal.util.function.pooled.PooledLambda#obtainMessage}
+ * to achieve the same effect of storing multiple values in a message with the added typesafety
+ * and code continuity benefits.
+ */
+@Deprecated
public class HandlerCaller {
final Looper mMainLooper;
final Handler mH;
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 4989406..8f176e8 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -359,6 +359,7 @@
<protected-broadcast android:name="android.net.wifi.action.PASSPOINT_ICON" />
<protected-broadcast android:name="android.net.wifi.action.PASSPOINT_OSU_PROVIDERS_LIST" />
<protected-broadcast android:name="android.net.wifi.action.PASSPOINT_SUBSCRIPTION_REMEDIATION" />
+ <protected-broadcast android:name="android.net.wifi.action.PASSPOINT_LAUNCH_OSU_VIEW" />
<protected-broadcast android:name="android.net.wifi.supplicant.CONNECTION_CHANGE" />
<protected-broadcast android:name="android.net.wifi.supplicant.STATE_CHANGE" />
<protected-broadcast android:name="android.net.wifi.p2p.STATE_CHANGED" />
diff --git a/core/res/res/values-watch/config.xml b/core/res/res/values-watch/config.xml
index 8e82479..a96a96d 100644
--- a/core/res/res/values-watch/config.xml
+++ b/core/res/res/values-watch/config.xml
@@ -64,9 +64,8 @@
Set to true for watch devices. -->
<bool name="config_focusScrollContainersInTouchMode">true</bool>
- <!-- Enable generic multi-window in order to support Activity in virtual display. -->
- <bool name="config_supportsMultiWindow">true</bool>
- <bool name="config_supportsMultiDisplay">true</bool>
+ <bool name="config_supportsMultiWindow">false</bool>
+ <bool name="config_supportsMultiDisplay">false</bool>
<bool name="config_supportsSplitScreenMultiWindow">false</bool>
<!-- Default Gravity setting for the system Toast view. Equivalent to: Gravity.CENTER -->
diff --git a/graphics/java/android/graphics/fonts/SystemFonts.java b/graphics/java/android/graphics/fonts/SystemFonts.java
index dae48f8..26b4ec5 100644
--- a/graphics/java/android/graphics/fonts/SystemFonts.java
+++ b/graphics/java/android/graphics/fonts/SystemFonts.java
@@ -24,6 +24,7 @@
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.util.ArrayUtils;
import org.xmlpull.v1.XmlPullParserException;
@@ -251,7 +252,7 @@
return fontConfig.getAliases();
} catch (IOException | XmlPullParserException e) {
Log.e(TAG, "Failed initialize system fallbacks.", e);
- return null;
+ return ArrayUtils.emptyArray(FontConfig.Alias.class);
}
}
diff --git a/libs/hwui/renderthread/VulkanManager.cpp b/libs/hwui/renderthread/VulkanManager.cpp
index a19edae..1517f57 100644
--- a/libs/hwui/renderthread/VulkanManager.cpp
+++ b/libs/hwui/renderthread/VulkanManager.cpp
@@ -25,6 +25,8 @@
#include <GrBackendSurface.h>
#include <GrContext.h>
#include <GrTypes.h>
+#include <GrTypes.h>
+#include <vk/GrVkExtensions.h>
#include <vk/GrVkTypes.h>
namespace android {
@@ -62,7 +64,7 @@
mInstance = VK_NULL_HANDLE;
}
-bool VulkanManager::setupDevice(VkPhysicalDeviceFeatures& deviceFeatures) {
+bool VulkanManager::setupDevice(GrVkExtensions& grExtensions, VkPhysicalDeviceFeatures2& features) {
VkResult err;
constexpr VkApplicationInfo app_info = {
@@ -128,7 +130,7 @@
GET_INST_PROC(DestroyInstance);
GET_INST_PROC(EnumeratePhysicalDevices);
GET_INST_PROC(GetPhysicalDeviceQueueFamilyProperties);
- GET_INST_PROC(GetPhysicalDeviceFeatures);
+ GET_INST_PROC(GetPhysicalDeviceFeatures2);
GET_INST_PROC(CreateDevice);
GET_INST_PROC(EnumerateDeviceExtensionProperties);
GET_INST_PROC(CreateAndroidSurfaceKHR);
@@ -217,11 +219,38 @@
}
}
- // query to get the physical device properties
- mGetPhysicalDeviceFeatures(mPhysicalDevice, &deviceFeatures);
+ auto getProc = [] (const char* proc_name, VkInstance instance, VkDevice device) {
+ if (device != VK_NULL_HANDLE) {
+ return vkGetDeviceProcAddr(device, proc_name);
+ }
+ return vkGetInstanceProcAddr(instance, proc_name);
+ };
+ grExtensions.init(getProc, mInstance, mPhysicalDevice, instanceExtensions.size(),
+ instanceExtensions.data(), deviceExtensions.size(), deviceExtensions.data());
+
+ memset(&features, 0, sizeof(VkPhysicalDeviceFeatures2));
+ features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
+ features.pNext = nullptr;
+
+ // Setup all extension feature structs we may want to use.
+ void** tailPNext = &features.pNext;
+
+ if (grExtensions.hasExtension(VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME, 2)) {
+ VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT* blend;
+ blend = (VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT*) malloc(
+ sizeof(VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT));
+ LOG_ALWAYS_FATAL_IF(!blend);
+ blend->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT;
+ blend->pNext = nullptr;
+ *tailPNext = blend;
+ tailPNext = &blend->pNext;
+ }
+
+ // query to get the physical device features
+ mGetPhysicalDeviceFeatures2(mPhysicalDevice, &features);
// this looks like it would slow things down,
// and we can't depend on it on all platforms
- deviceFeatures.robustBufferAccess = VK_FALSE;
+ features.features.robustBufferAccess = VK_FALSE;
float queuePriorities[1] = { 0.0 };
@@ -247,7 +276,7 @@
const VkDeviceCreateInfo deviceInfo = {
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType
- nullptr, // pNext
+ &features, // pNext
0, // VkDeviceCreateFlags
queueInfoCount, // queueCreateInfoCount
queueInfo, // pQueueCreateInfos
@@ -255,7 +284,7 @@
nullptr, // ppEnabledLayerNames
(uint32_t) deviceExtensions.size(), // extensionCount
deviceExtensions.data(), // ppEnabledExtensionNames
- &deviceFeatures // ppEnabledFeatures
+ nullptr, // ppEnabledFeatures
};
err = mCreateDevice(mPhysicalDevice, &deviceInfo, nullptr, &mDevice);
@@ -294,33 +323,39 @@
return true;
}
+static void free_features_extensions_structs(const VkPhysicalDeviceFeatures2& features) {
+ // All Vulkan structs that could be part of the features chain will start with the
+ // structure type followed by the pNext pointer. We cast to the CommonVulkanHeader
+ // so we can get access to the pNext for the next struct.
+ struct CommonVulkanHeader {
+ VkStructureType sType;
+ void* pNext;
+ };
+
+ void* pNext = features.pNext;
+ while (pNext) {
+ void* current = pNext;
+ pNext = static_cast<CommonVulkanHeader*>(current)->pNext;
+ free(current);
+ }
+}
+
void VulkanManager::initialize() {
if (mDevice != VK_NULL_HANDLE) {
return;
}
- std::vector<const char*> instanceExtensions;
- std::vector<const char*> deviceExtensions;
- VkPhysicalDeviceFeatures deviceFeatures;
- LOG_ALWAYS_FATAL_IF(!this->setupDevice(deviceFeatures));
+ GET_PROC(EnumerateInstanceVersion);
+ uint32_t instanceVersion = 0;
+ LOG_ALWAYS_FATAL_IF(mEnumerateInstanceVersion(&instanceVersion));
+ LOG_ALWAYS_FATAL_IF(instanceVersion < VK_MAKE_VERSION(1, 1, 0));
+
+ GrVkExtensions extensions;
+ VkPhysicalDeviceFeatures2 features;
+ LOG_ALWAYS_FATAL_IF(!this->setupDevice(extensions, features));
mGetDeviceQueue(mDevice, mGraphicsQueueIndex, 0, &mGraphicsQueue);
- uint32_t extensionFlags = kKHR_surface_GrVkExtensionFlag |
- kKHR_android_surface_GrVkExtensionFlag |
- kKHR_swapchain_GrVkExtensionFlag;
-
- uint32_t featureFlags = 0;
- if (deviceFeatures.geometryShader) {
- featureFlags |= kGeometryShader_GrVkFeatureFlag;
- }
- if (deviceFeatures.dualSrcBlend) {
- featureFlags |= kDualSrcBlend_GrVkFeatureFlag;
- }
- if (deviceFeatures.sampleRateShading) {
- featureFlags |= kSampleRateShading_GrVkFeatureFlag;
- }
-
auto getProc = [] (const char* proc_name, VkInstance instance, VkDevice device) {
if (device != VK_NULL_HANDLE) {
return vkGetDeviceProcAddr(device, proc_name);
@@ -334,11 +369,10 @@
backendContext.fDevice = mDevice;
backendContext.fQueue = mGraphicsQueue;
backendContext.fGraphicsQueueIndex = mGraphicsQueueIndex;
- backendContext.fMinAPIVersion = VK_MAKE_VERSION(1, 0, 0);
- backendContext.fExtensions = extensionFlags;
- backendContext.fFeatures = featureFlags;
+ backendContext.fInstanceVersion = instanceVersion;
+ backendContext.fVkExtensions = &extensions;
+ backendContext.fDeviceFeatures2 = &features;
backendContext.fGetProc = std::move(getProc);
- backendContext.fOwnsInstanceAndDevice = false;
// create the command pool for the command buffers
if (VK_NULL_HANDLE == mCommandPool) {
@@ -361,6 +395,9 @@
sk_sp<GrContext> grContext(GrContext::MakeVulkan(backendContext, options));
LOG_ALWAYS_FATAL_IF(!grContext.get());
mRenderThread.setGrContext(grContext);
+
+ free_features_extensions_structs(features);
+
DeviceInfo::initialize(mRenderThread.getGrContext()->maxRenderTargetSize());
if (Properties::enablePartialUpdates && Properties::useBufferAge) {
diff --git a/libs/hwui/renderthread/VulkanManager.h b/libs/hwui/renderthread/VulkanManager.h
index 69641d5..5524c39 100644
--- a/libs/hwui/renderthread/VulkanManager.h
+++ b/libs/hwui/renderthread/VulkanManager.h
@@ -25,6 +25,8 @@
#include <SkSurface.h>
#include <vk/GrVkBackendContext.h>
+class GrVkExtensions;
+
namespace android {
namespace uirenderer {
namespace renderthread {
@@ -116,7 +118,7 @@
// Sets up the VkInstance and VkDevice objects. Also fills out the passed in
// VkPhysicalDeviceFeatures struct.
- bool setupDevice(VkPhysicalDeviceFeatures& deviceFeatures);
+ bool setupDevice(GrVkExtensions&, VkPhysicalDeviceFeatures2&);
void destroyBuffers(VulkanSurface* surface);
@@ -156,13 +158,14 @@
VkPtr<PFN_vkCreateSharedSwapchainsKHR> mCreateSharedSwapchainsKHR;
// Instance Functions
+ VkPtr<PFN_vkEnumerateInstanceVersion> mEnumerateInstanceVersion;
VkPtr<PFN_vkEnumerateInstanceExtensionProperties> mEnumerateInstanceExtensionProperties;
VkPtr<PFN_vkCreateInstance> mCreateInstance;
VkPtr<PFN_vkDestroyInstance> mDestroyInstance;
VkPtr<PFN_vkEnumeratePhysicalDevices> mEnumeratePhysicalDevices;
VkPtr<PFN_vkGetPhysicalDeviceQueueFamilyProperties> mGetPhysicalDeviceQueueFamilyProperties;
- VkPtr<PFN_vkGetPhysicalDeviceFeatures> mGetPhysicalDeviceFeatures;
+ VkPtr<PFN_vkGetPhysicalDeviceFeatures2> mGetPhysicalDeviceFeatures2;
VkPtr<PFN_vkCreateDevice> mCreateDevice;
VkPtr<PFN_vkEnumerateDeviceExtensionProperties> mEnumerateDeviceExtensionProperties;
diff --git a/media/java/android/media/audiofx/DefaultEffect.java b/media/java/android/media/audiofx/DefaultEffect.java
index a919868..ce087ad 100644
--- a/media/java/android/media/audiofx/DefaultEffect.java
+++ b/media/java/android/media/audiofx/DefaultEffect.java
@@ -24,6 +24,7 @@
* <p>Applications should not use the DefaultEffect class directly but one of its derived classes
* to control specific types of defaults:
* <ul>
+ * <li> {@link android.media.audiofx.SourceDefaultEffect}</li>
* <li> {@link android.media.audiofx.StreamDefaultEffect}</li>
* </ul>
* <p>Creating a DefaultEffect object will register the corresponding effect engine as a default
diff --git a/media/java/android/media/audiofx/SourceDefaultEffect.java b/media/java/android/media/audiofx/SourceDefaultEffect.java
new file mode 100644
index 0000000..d7a292e
--- /dev/null
+++ b/media/java/android/media/audiofx/SourceDefaultEffect.java
@@ -0,0 +1,118 @@
+/*
+ * 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.
+ */
+
+package android.media.audiofx;
+
+import android.annotation.RequiresPermission;
+import android.app.ActivityThread;
+import android.util.Log;
+import java.util.UUID;
+
+/**
+ * SourceDefaultEffect is a default effect that attaches automatically to all AudioRecord and
+ * MediaRecorder instances of a given source type.
+ * <p>see {@link android.media.audiofx.DefaultEffect} class for more details on default effects.
+ * @hide
+ */
+
+public class SourceDefaultEffect extends DefaultEffect {
+ static {
+ System.loadLibrary("audioeffect_jni");
+ }
+
+ private final static String TAG = "SourceDefaultEffect-JAVA";
+
+ /**
+ * Class constructor.
+ *
+ * @param type type of effect engine to be default. This parameter is ignored if uuid is set,
+ * and can be set to {@link android.media.audiofx.AudioEffect#EFFECT_TYPE_NULL}
+ * in that case.
+ * @param uuid unique identifier of a particular effect implementation to be default. This
+ * parameter can be set to
+ * {@link android.media.audiofx.AudioEffect#EFFECT_TYPE_NULL}, in which case only
+ * the type will be used to select the effect.
+ * @param priority the priority level requested by the application for controlling the effect
+ * engine. As the same engine can be shared by several applications, this parameter
+ * indicates how much the requesting application needs control of effect parameters.
+ * The normal priority is 0, above normal is a positive number, below normal a
+ * negative number.
+ * @param source a MediaRecorder.AudioSource.* constant from
+ * {@link android.media.MediaRecorder.AudioSource} indicating
+ * what sources the given effect should attach to by default. Note that similar
+ * sources may share defaults.
+ *
+ * @throws java.lang.IllegalArgumentException
+ * @throws java.lang.UnsupportedOperationException
+ * @throws java.lang.RuntimeException
+ */
+ @RequiresPermission(value = android.Manifest.permission.MODIFY_DEFAULT_AUDIO_EFFECTS,
+ conditional = true) // Android Things uses an alternate permission.
+ public SourceDefaultEffect(UUID type, UUID uuid, int priority, int source) {
+ int[] id = new int[1];
+ int initResult = native_setup(type.toString(),
+ uuid.toString(),
+ priority,
+ source,
+ ActivityThread.currentOpPackageName(),
+ id);
+ if (initResult != AudioEffect.SUCCESS) {
+ Log.e(TAG, "Error code " + initResult + " when initializing SourceDefaultEffect");
+ switch (initResult) {
+ case AudioEffect.ERROR_BAD_VALUE:
+ throw (new IllegalArgumentException(
+ "Source, type uuid, or implementation uuid not supported."));
+ case AudioEffect.ERROR_INVALID_OPERATION:
+ throw (new UnsupportedOperationException(
+ "Effect library not loaded"));
+ default:
+ throw (new RuntimeException(
+ "Cannot initialize effect engine for type: " + type
+ + " Error: " + initResult));
+ }
+ }
+
+ mId = id[0];
+ }
+
+
+ /**
+ * Releases the native SourceDefaultEffect resources. It is a good practice to
+ * release the default effect when done with use as control can be returned to
+ * other applications or the native resources released.
+ */
+ public void release() {
+ native_release(mId);
+ }
+
+ @Override
+ protected void finalize() {
+ release();
+ }
+
+ // ---------------------------------------------------------
+ // Native methods called from the Java side
+ // --------------------
+
+ private native final int native_setup(String type,
+ String uuid,
+ int priority,
+ int source,
+ String opPackageName,
+ int[] id);
+
+ private native final void native_release(int id);
+}
diff --git a/media/jni/audioeffect/Android.bp b/media/jni/audioeffect/Android.bp
index 0063c11..09c546a 100644
--- a/media/jni/audioeffect/Android.bp
+++ b/media/jni/audioeffect/Android.bp
@@ -3,6 +3,7 @@
srcs: [
"android_media_AudioEffect.cpp",
+ "android_media_SourceDefaultEffect.cpp",
"android_media_StreamDefaultEffect.cpp",
"android_media_Visualizer.cpp",
],
diff --git a/media/jni/audioeffect/android_media_AudioEffect.cpp b/media/jni/audioeffect/android_media_AudioEffect.cpp
index d3ba9f2..8c9025b 100644
--- a/media/jni/audioeffect/android_media_AudioEffect.cpp
+++ b/media/jni/audioeffect/android_media_AudioEffect.cpp
@@ -907,6 +907,7 @@
// ----------------------------------------------------------------------------
+extern int register_android_media_SourceDefaultEffect(JNIEnv *env);
extern int register_android_media_StreamDefaultEffect(JNIEnv *env);
extern int register_android_media_visualizer(JNIEnv *env);
@@ -932,6 +933,11 @@
goto bail;
}
+ if (register_android_media_SourceDefaultEffect(env) < 0) {
+ ALOGE("ERROR: SourceDefaultEffect native registration failed\n");
+ goto bail;
+ }
+
if (register_android_media_StreamDefaultEffect(env) < 0) {
ALOGE("ERROR: StreamDefaultEffect native registration failed\n");
goto bail;
diff --git a/media/jni/audioeffect/android_media_SourceDefaultEffect.cpp b/media/jni/audioeffect/android_media_SourceDefaultEffect.cpp
new file mode 100644
index 0000000..d244bcb7
--- /dev/null
+++ b/media/jni/audioeffect/android_media_SourceDefaultEffect.cpp
@@ -0,0 +1,142 @@
+/*
+ * 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.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "SourceDefaultEffect-JNI"
+
+#include <utils/Errors.h>
+#include <utils/Log.h>
+#include <jni.h>
+#include <nativehelper/JNIHelp.h>
+#include <android_runtime/AndroidRuntime.h>
+#include "media/AudioEffect.h"
+
+#include <nativehelper/ScopedUtfChars.h>
+
+#include "android_media_AudioEffect.h"
+
+using namespace android;
+
+static const char* const kClassPathName = "android/media/audiofx/SourceDefaultEffect";
+
+static jint android_media_SourceDefaultEffect_native_setup(JNIEnv *env,
+ jobject /*thiz*/,
+ jstring type,
+ jstring uuid,
+ jint priority,
+ jint source,
+ jstring opPackageName,
+ jintArray jId)
+{
+ ALOGV("android_media_SourceDefaultEffect_native_setup");
+ status_t lStatus = NO_ERROR;
+ jint* nId = NULL;
+ const char *typeStr = NULL;
+ const char *uuidStr = NULL;
+
+ ScopedUtfChars opPackageNameStr(env, opPackageName);
+
+ if (type != NULL) {
+ typeStr = env->GetStringUTFChars(type, NULL);
+ if (typeStr == NULL) { // Out of memory
+ lStatus = NO_MEMORY;
+ jniThrowException(env, "java/lang/RuntimeException", "Out of memory");
+ goto setup_exit;
+ }
+ }
+
+ if (uuid != NULL) {
+ uuidStr = env->GetStringUTFChars(uuid, NULL);
+ if (uuidStr == NULL) { // Out of memory
+ lStatus = NO_MEMORY;
+ jniThrowException(env, "java/lang/RuntimeException", "Out of memory");
+ goto setup_exit;
+ }
+ }
+
+ if (typeStr == NULL && uuidStr == NULL) {
+ lStatus = BAD_VALUE;
+ goto setup_exit;
+ }
+
+ nId = reinterpret_cast<jint *>(env->GetPrimitiveArrayCritical(jId, NULL));
+ if (nId == NULL) {
+ ALOGE("setup: Error retrieving id pointer");
+ lStatus = BAD_VALUE;
+ goto setup_exit;
+ }
+
+ // create the native SourceDefaultEffect.
+ audio_unique_id_t id;
+ lStatus = AudioEffect::addSourceDefaultEffect(typeStr,
+ String16(opPackageNameStr.c_str()),
+ uuidStr,
+ priority,
+ static_cast<audio_source_t>(source),
+ &id);
+ if (lStatus != NO_ERROR) {
+ ALOGE("setup: Error adding SourceDefaultEffect");
+ goto setup_exit;
+ }
+
+ nId[0] = static_cast<jint>(id);
+
+setup_exit:
+ // Final cleanup and return.
+
+ if (nId != NULL) {
+ env->ReleasePrimitiveArrayCritical(jId, nId, 0);
+ nId = NULL;
+ }
+
+ if (uuidStr != NULL) {
+ env->ReleaseStringUTFChars(uuid, uuidStr);
+ uuidStr = NULL;
+ }
+
+ if (typeStr != NULL) {
+ env->ReleaseStringUTFChars(type, typeStr);
+ typeStr = NULL;
+ }
+
+ return AudioEffectJni::translateNativeErrorToJava(lStatus);
+}
+
+static void android_media_SourceDefaultEffect_native_release(JNIEnv */*env*/,
+ jobject /*thiz*/,
+ jint id) {
+ status_t lStatus = AudioEffect::removeSourceDefaultEffect(id);
+ if (lStatus != NO_ERROR) {
+ ALOGW("Error releasing SourceDefaultEffect: %d", lStatus);
+ }
+}
+
+// ----------------------------------------------------------------------------
+
+// Dalvik VM type signatures
+static const JNINativeMethod gMethods[] = {
+ {"native_setup", "(Ljava/lang/String;Ljava/lang/String;IILjava/lang/String;[I)I",
+ (void *)android_media_SourceDefaultEffect_native_setup},
+ {"native_release", "(I)V", (void *)android_media_SourceDefaultEffect_native_release},
+};
+
+
+// ----------------------------------------------------------------------------
+
+int register_android_media_SourceDefaultEffect(JNIEnv *env)
+{
+ return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods));
+}
diff --git a/packages/ExtServices/src/android/ext/services/notification/AgingHelper.java b/packages/ExtServices/src/android/ext/services/notification/AgingHelper.java
new file mode 100644
index 0000000..5782ea1
--- /dev/null
+++ b/packages/ExtServices/src/android/ext/services/notification/AgingHelper.java
@@ -0,0 +1,172 @@
+/**
+ * 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.
+ */
+package android.ext.services.notification;
+
+import static android.app.NotificationManager.IMPORTANCE_MIN;
+
+import android.app.AlarmManager;
+import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.ext.services.notification.NotificationCategorizer.Category;
+import android.net.Uri;
+import android.util.ArraySet;
+import android.util.Slog;
+
+import java.util.Set;
+
+public class AgingHelper {
+ private final static String TAG = "AgingHelper";
+ private final boolean DEBUG = false;
+
+ private static final String AGING_ACTION = AgingHelper.class.getSimpleName() + ".EVALUATE";
+ private static final int REQUEST_CODE_AGING = 1;
+ private static final String AGING_SCHEME = "aging";
+ private static final String EXTRA_KEY = "key";
+ private static final String EXTRA_CATEGORY = "category";
+
+ private static final int HOUR_MS = 1000 * 60 * 60;
+ private static final int TWO_HOURS_MS = 2 * HOUR_MS;
+
+ private Context mContext;
+ private NotificationCategorizer mNotificationCategorizer;
+ private AlarmManager mAm;
+ private Callback mCallback;
+
+ // The set of keys we've scheduled alarms for
+ private Set<String> mAging = new ArraySet<>();
+
+ public AgingHelper(Context context, NotificationCategorizer categorizer, Callback callback) {
+ mNotificationCategorizer = categorizer;
+ mContext = context;
+ mAm = mContext.getSystemService(AlarmManager.class);
+ mCallback = callback;
+
+ IntentFilter filter = new IntentFilter(AGING_ACTION);
+ filter.addDataScheme(AGING_SCHEME);
+ mContext.registerReceiver(mBroadcastReceiver, filter);
+ }
+
+ // NAS lifecycle methods
+
+ public void onNotificationSeen(NotificationEntry entry) {
+ // user has strong opinions about this notification. we can't down rank it, so don't bother.
+ if (entry.getChannel().isImportanceLocked()) {
+ return;
+ }
+
+ @Category int category = mNotificationCategorizer.getCategory(entry);
+
+ // already very low
+ if (category == NotificationCategorizer.CATEGORY_MIN) {
+ return;
+ }
+
+ if (entry.hasSeen()) {
+ if (category == NotificationCategorizer.CATEGORY_ONGOING
+ || category > NotificationCategorizer.CATEGORY_REMINDER) {
+ scheduleAging(entry.getSbn().getKey(), category, TWO_HOURS_MS);
+ } else {
+ scheduleAging(entry.getSbn().getKey(), category, HOUR_MS);
+ }
+
+ mAging.add(entry.getSbn().getKey());
+ }
+ }
+
+ public void onNotificationPosted(NotificationEntry entry) {
+ cancelAging(entry.getSbn().getKey());
+ }
+
+ public void onNotificationRemoved(String key) {
+ cancelAging(key);
+ }
+
+ public void onDestroy() {
+ mContext.unregisterReceiver(mBroadcastReceiver);
+ }
+
+ // Aging
+
+ private void scheduleAging(String key, @Category int category, long duration) {
+ if (mAging.contains(key)) {
+ // already scheduled. Don't reset aging just because the user saw the noti again.
+ return;
+ }
+ final PendingIntent pi = createPendingIntent(key, category);
+ long time = System.currentTimeMillis() + duration;
+ if (DEBUG) Slog.d(TAG, "Scheduling evaluate for " + key + " in ms: " + duration);
+ mAm.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, time, pi);
+ }
+
+ private void cancelAging(String key) {
+ final PendingIntent pi = createPendingIntent(key);
+ mAm.cancel(pi);
+ mAging.remove(key);
+ }
+
+ private Intent createBaseIntent(String key) {
+ return new Intent(AGING_ACTION)
+ .setData(new Uri.Builder().scheme(AGING_SCHEME).appendPath(key).build());
+ }
+
+ private Intent createAgingIntent(String key, @Category int category) {
+ Intent intent = createBaseIntent(key);
+ intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
+ .putExtra(EXTRA_CATEGORY, category)
+ .putExtra(EXTRA_KEY, key);
+ return intent;
+ }
+
+ private PendingIntent createPendingIntent(String key, @Category int category) {
+ return PendingIntent.getBroadcast(mContext,
+ REQUEST_CODE_AGING,
+ createAgingIntent(key, category),
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ }
+
+ private PendingIntent createPendingIntent(String key) {
+ return PendingIntent.getBroadcast(mContext,
+ REQUEST_CODE_AGING,
+ createBaseIntent(key),
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ }
+
+ private void demote(String key, @Category int category) {
+ int newImportance = IMPORTANCE_MIN;
+ // TODO: Change "aged" importance based on category
+ mCallback.sendAdjustment(key, newImportance);
+ }
+
+ protected interface Callback {
+ void sendAdjustment(String key, int newImportance);
+ }
+
+ private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (DEBUG) {
+ Slog.d(TAG, "Reposting notification");
+ }
+ if (AGING_ACTION.equals(intent.getAction())) {
+ demote(intent.getStringExtra(EXTRA_KEY), intent.getIntExtra(EXTRA_CATEGORY,
+ NotificationCategorizer.CATEGORY_EVERYTHING_ELSE));
+ }
+ }
+ };
+}
diff --git a/packages/ExtServices/src/android/ext/services/notification/Assistant.java b/packages/ExtServices/src/android/ext/services/notification/Assistant.java
index a8ecec3..f0f31fb 100644
--- a/packages/ExtServices/src/android/ext/services/notification/Assistant.java
+++ b/packages/ExtServices/src/android/ext/services/notification/Assistant.java
@@ -18,23 +18,28 @@
import static android.app.NotificationManager.IMPORTANCE_LOW;
import static android.app.NotificationManager.IMPORTANCE_MIN;
+import static android.service.notification.Adjustment.KEY_IMPORTANCE;
import static android.service.notification.NotificationListenerService.Ranking
.USER_SENTIMENT_NEGATIVE;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityThread;
+import android.app.AlarmManager;
import android.app.INotificationManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.pm.IPackageManager;
import android.database.ContentObserver;
+import android.ext.services.notification.AgingHelper.Callback;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
+import android.os.UserHandle;
import android.os.storage.StorageManager;
import android.provider.Settings;
import android.service.notification.Adjustment;
@@ -64,6 +69,7 @@
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
/**
@@ -89,15 +95,17 @@
private int mStreakLimit;
private SmartActionsHelper mSmartActionsHelper;
private NotificationCategorizer mNotificationCategorizer;
+ private AgingHelper mAgingHelper;
// key : impressions tracker
// TODO: prune deleted channels and apps
- final ArrayMap<String, ChannelImpressions> mkeyToImpressions = new ArrayMap<>();
- // SBN key : channel id
- ArrayMap<String, String> mLiveNotifications = new ArrayMap<>();
+ private final ArrayMap<String, ChannelImpressions> mkeyToImpressions = new ArrayMap<>();
+ // SBN key : entry
+ protected ArrayMap<String, NotificationEntry> mLiveNotifications = new ArrayMap<>();
private Ranking mFakeRanking = null;
private AtomicFile mFile = null;
+ private IPackageManager mPackageManager;
protected SettingsObserver mSettingsObserver;
public Assistant() {
@@ -108,9 +116,13 @@
super.onCreate();
// Contexts are correctly hooked up by the creation step, which is required for the observer
// to be hooked up/initialized.
+ mPackageManager = ActivityThread.getPackageManager();
mSettingsObserver = new SettingsObserver(mHandler);
mSmartActionsHelper = new SmartActionsHelper();
mNotificationCategorizer = new NotificationCategorizer();
+ mAgingHelper = new AgingHelper(getContext(),
+ mNotificationCategorizer,
+ new AgingCallback());
}
private void loadFile() {
@@ -157,7 +169,7 @@
}
}
- private void saveFile() throws IOException {
+ private void saveFile() {
AsyncTask.execute(() -> {
final FileOutputStream stream;
try {
@@ -200,6 +212,9 @@
public Adjustment onNotificationEnqueued(StatusBarNotification sbn,
NotificationChannel channel) {
if (DEBUG) Log.i(TAG, "ENQUEUED " + sbn.getKey() + " on " + channel.getId());
+ if (!isForCurrentUser(sbn)) {
+ return null;
+ }
NotificationEntry entry = new NotificationEntry(
ActivityThread.getPackageManager(), sbn, channel);
ArrayList<Notification.Action> actions =
@@ -222,7 +237,7 @@
signals.putCharSequenceArrayList(Adjustment.KEY_SMART_REPLIES, smartReplies);
}
if (mNotificationCategorizer.shouldSilence(entry)) {
- signals.putInt(Adjustment.KEY_IMPORTANCE, IMPORTANCE_LOW);
+ signals.putInt(KEY_IMPORTANCE, IMPORTANCE_LOW);
}
return new Adjustment(
@@ -237,8 +252,13 @@
public void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) {
if (DEBUG) Log.i(TAG, "POSTED " + sbn.getKey());
try {
+ if (!isForCurrentUser(sbn)) {
+ return;
+ }
Ranking ranking = getRanking(sbn.getKey(), rankingMap);
if (ranking != null && ranking.getChannel() != null) {
+ NotificationEntry entry = new NotificationEntry(mPackageManager,
+ sbn, ranking.getChannel());
String key = getKey(
sbn.getPackageName(), sbn.getUserId(), ranking.getChannel().getId());
ChannelImpressions ci = mkeyToImpressions.getOrDefault(key,
@@ -248,7 +268,8 @@
sbn.getPackageName(), sbn.getKey(), sbn.getUserId()));
}
mkeyToImpressions.put(key, ci);
- mLiveNotifications.put(sbn.getKey(), ranking.getChannel().getId());
+ mLiveNotifications.put(sbn.getKey(), entry);
+ mAgingHelper.onNotificationPosted(entry);
}
} catch (Throwable e) {
Log.e(TAG, "Error occurred processing post", e);
@@ -259,8 +280,11 @@
public void onNotificationRemoved(StatusBarNotification sbn, RankingMap rankingMap,
NotificationStats stats, int reason) {
try {
+ if (!isForCurrentUser(sbn)) {
+ return;
+ }
boolean updatedImpressions = false;
- String channelId = mLiveNotifications.remove(sbn.getKey());
+ String channelId = mLiveNotifications.remove(sbn.getKey()).getChannel().getId();
String key = getKey(sbn.getPackageName(), sbn.getUserId(), channelId);
synchronized (mkeyToImpressions) {
ChannelImpressions ci = mkeyToImpressions.getOrDefault(key,
@@ -302,6 +326,22 @@
}
@Override
+ public void onNotificationsSeen(List<String> keys) {
+ if (keys == null) {
+ return;
+ }
+
+ for (String key : keys) {
+ NotificationEntry entry = mLiveNotifications.get(key);
+
+ if (entry != null) {
+ entry.setSeen();
+ mAgingHelper.onNotificationSeen(entry);
+ }
+ }
+ }
+
+ @Override
public void onListenerConnected() {
if (DEBUG) Log.i(TAG, "CONNECTED");
try {
@@ -318,6 +358,17 @@
}
}
+ @Override
+ public void onListenerDisconnected() {
+ if (mAgingHelper != null) {
+ mAgingHelper.onDestroy();
+ }
+ }
+
+ private boolean isForCurrentUser(StatusBarNotification sbn) {
+ return sbn != null && sbn.getUserId() == UserHandle.myUserId();
+ }
+
protected String getKey(String pkg, int userId, String channelId) {
return pkg + "|" + userId + "|" + channelId;
}
@@ -361,6 +412,11 @@
}
@VisibleForTesting
+ public void setPackageManager(IPackageManager pm) {
+ mPackageManager = pm;
+ }
+
+ @VisibleForTesting
public ChannelImpressions getImpressions(String key) {
synchronized (mkeyToImpressions) {
return mkeyToImpressions.get(key);
@@ -380,6 +436,20 @@
return impressions;
}
+ protected final class AgingCallback implements Callback {
+ @Override
+ public void sendAdjustment(String key, int newImportance) {
+ NotificationEntry entry = mLiveNotifications.get(key);
+ if (entry != null) {
+ Bundle bundle = new Bundle();
+ bundle.putInt(KEY_IMPORTANCE, newImportance);
+ Adjustment adjustment = new Adjustment(entry.getSbn().getPackageName(), key, bundle,
+ "aging", entry.getSbn().getUserId());
+ adjustNotification(adjustment);
+ }
+ }
+ }
+
/**
* Observer for updates on blocking helper threshold values.
*/
diff --git a/packages/ExtServices/src/android/ext/services/notification/NotificationEntry.java b/packages/ExtServices/src/android/ext/services/notification/NotificationEntry.java
index cdc0990..8fee822 100644
--- a/packages/ExtServices/src/android/ext/services/notification/NotificationEntry.java
+++ b/packages/ExtServices/src/android/ext/services/notification/NotificationEntry.java
@@ -50,6 +50,7 @@
private AudioAttributes mAttributes;
private NotificationChannel mChannel;
private int mImportance;
+ private boolean mSeen;
public NotificationEntry(IPackageManager packageManager, StatusBarNotification sbn,
NotificationChannel channel) {
@@ -198,6 +199,14 @@
return false;
}
+ public void setSeen() {
+ mSeen = true;
+ }
+
+ public boolean hasSeen() {
+ return mSeen;
+ }
+
public StatusBarNotification getSbn() {
return mSbn;
}
diff --git a/packages/ExtServices/tests/src/android/ext/services/notification/AgingHelperTest.java b/packages/ExtServices/tests/src/android/ext/services/notification/AgingHelperTest.java
new file mode 100644
index 0000000..b023b36
--- /dev/null
+++ b/packages/ExtServices/tests/src/android/ext/services/notification/AgingHelperTest.java
@@ -0,0 +1,153 @@
+/**
+ * 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.
+ */
+
+package android.ext.services.notification;
+
+import static android.app.NotificationManager.IMPORTANCE_HIGH;
+import static android.app.NotificationManager.IMPORTANCE_MIN;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.AlarmManager;
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.PendingIntent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
+import android.os.Build;
+import android.os.Process;
+import android.os.UserHandle;
+import android.service.notification.StatusBarNotification;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import android.testing.TestableContext;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+@RunWith(AndroidJUnit4.class)
+public class AgingHelperTest {
+ private String mPkg = "pkg";
+ private int mUid = 2018;
+
+ @Rule
+ public final TestableContext mContext =
+ new TestableContext(InstrumentationRegistry.getTargetContext(), null);
+
+ @Mock
+ private NotificationCategorizer mCategorizer;
+ @Mock
+ private AlarmManager mAlarmManager;
+ @Mock
+ private IPackageManager mPackageManager;
+ @Mock
+ private AgingHelper.Callback mCallback;
+
+ private AgingHelper mAgingHelper;
+
+ private StatusBarNotification generateSbn(String channelId) {
+ Notification n = new Notification.Builder(mContext, channelId)
+ .setContentTitle("foo")
+ .build();
+
+ return new StatusBarNotification(mPkg, mPkg, 0, "tag", mUid, mUid, n,
+ UserHandle.SYSTEM, null, 0);
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ mPkg = mContext.getPackageName();
+ mUid = Process.myUid();
+
+ ApplicationInfo info = mock(ApplicationInfo.class);
+ when(mPackageManager.getApplicationInfo(anyString(), anyInt(), anyInt()))
+ .thenReturn(info);
+ info.targetSdkVersion = Build.VERSION_CODES.P;
+
+ mContext.addMockSystemService(AlarmManager.class, mAlarmManager);
+
+ mAgingHelper = new AgingHelper(mContext, mCategorizer, mCallback);
+ }
+
+ @Test
+ public void testNoSnoozingOnPost() {
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
+ StatusBarNotification sbn = generateSbn(channel.getId());
+ NotificationEntry entry = new NotificationEntry(mPackageManager, sbn, channel);
+
+
+ mAgingHelper.onNotificationPosted(entry);
+ verify(mAlarmManager, never()).setExactAndAllowWhileIdle(anyInt(), anyLong(), any());
+ }
+
+ @Test
+ public void testPostResetsSnooze() {
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
+ StatusBarNotification sbn = generateSbn(channel.getId());
+ NotificationEntry entry = new NotificationEntry(mPackageManager, sbn, channel);
+
+
+ mAgingHelper.onNotificationPosted(entry);
+ verify(mAlarmManager, times(1)).cancel(any(PendingIntent.class));
+ }
+
+ @Test
+ public void testSnoozingOnSeen() {
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
+ StatusBarNotification sbn = generateSbn(channel.getId());
+ NotificationEntry entry = new NotificationEntry(mPackageManager, sbn, channel);
+ entry.setSeen();
+ when(mCategorizer.getCategory(entry)).thenReturn(NotificationCategorizer.CATEGORY_PEOPLE);
+
+ mAgingHelper.onNotificationSeen(entry);
+ verify(mAlarmManager, times(1)).setExactAndAllowWhileIdle(anyInt(), anyLong(), any());
+ }
+
+ @Test
+ public void testNoSnoozingOnSeenUserLocked() {
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
+ channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
+ StatusBarNotification sbn = generateSbn(channel.getId());
+ NotificationEntry entry = new NotificationEntry(mPackageManager, sbn, channel);
+ when(mCategorizer.getCategory(entry)).thenReturn(NotificationCategorizer.CATEGORY_PEOPLE);
+
+ mAgingHelper.onNotificationSeen(entry);
+ verify(mAlarmManager, never()).setExactAndAllowWhileIdle(anyInt(), anyLong(), any());
+ }
+
+ @Test
+ public void testNoSnoozingOnSeenAlreadyLow() {
+ NotificationEntry entry = mock(NotificationEntry.class);
+ when(entry.getChannel()).thenReturn(new NotificationChannel("", "", IMPORTANCE_HIGH));
+ when(entry.getImportance()).thenReturn(IMPORTANCE_MIN);
+
+ mAgingHelper.onNotificationSeen(entry);
+ verify(mAlarmManager, never()).setExactAndAllowWhileIdle(anyInt(), anyLong(), any());
+ }
+}
diff --git a/packages/ExtServices/tests/src/android/ext/services/notification/AssistantTest.java b/packages/ExtServices/tests/src/android/ext/services/notification/AssistantTest.java
index bb68bc2..2820232 100644
--- a/packages/ExtServices/tests/src/android/ext/services/notification/AssistantTest.java
+++ b/packages/ExtServices/tests/src/android/ext/services/notification/AssistantTest.java
@@ -21,6 +21,8 @@
import static android.app.NotificationManager.IMPORTANCE_MIN;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
@@ -33,6 +35,9 @@
import android.app.NotificationChannel;
import android.content.ContentResolver;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
+import android.os.Build;
import android.os.UserHandle;
import android.provider.Settings;
import android.service.notification.Adjustment;
@@ -80,6 +85,8 @@
@Mock INotificationManager mNoMan;
@Mock AtomicFile mFile;
+ @Mock
+ IPackageManager mPackageManager;
Assistant mAssistant;
Application mApplication;
@@ -113,6 +120,11 @@
mAssistant = getService();
mAssistant.setNoMan(mNoMan);
mAssistant.setFile(mFile);
+ mAssistant.setPackageManager(mPackageManager);
+ ApplicationInfo info = mock(ApplicationInfo.class);
+ when(mPackageManager.getApplicationInfo(anyString(), anyInt(), anyInt()))
+ .thenReturn(info);
+ info.targetSdkVersion = Build.VERSION_CODES.P;
when(mFile.startWrite()).thenReturn(mock(FileOutputStream.class));
}
@@ -439,4 +451,19 @@
// With the new threshold, the blocking helper should be triggered.
assertEquals(true, ci.shouldTriggerBlock());
}
+
+ @Test
+ public void testTrimLiveNotifications() {
+ StatusBarNotification sbn = generateSbn(PKG1, UID1, P1C1, "no", null);
+ mAssistant.setFakeRanking(generateRanking(sbn, P1C1));
+
+ mAssistant.onNotificationPosted(sbn, mock(RankingMap.class));
+
+ assertTrue(mAssistant.mLiveNotifications.containsKey(sbn.getKey()));
+
+ mAssistant.onNotificationRemoved(
+ sbn, mock(RankingMap.class), new NotificationStats(), 0);
+
+ assertFalse(mAssistant.mLiveNotifications.containsKey(sbn.getKey()));
+ }
}
diff --git a/packages/PackageInstaller/AndroidManifest.xml b/packages/PackageInstaller/AndroidManifest.xml
index 513c862..2be9311 100644
--- a/packages/PackageInstaller/AndroidManifest.xml
+++ b/packages/PackageInstaller/AndroidManifest.xml
@@ -19,7 +19,7 @@
android:label="@string/app_name"
android:icon="@drawable/ic_app_icon"
android:allowBackup="false"
- android:theme="@style/DialogWhenLarge"
+ android:theme="@style/Theme.AlertDialogActivity"
android:supportsRtl="true"
android:defaultToDeviceProtectedStorage="true"
android:directBootAware="true">
@@ -32,6 +32,7 @@
</receiver>
<activity android:name=".InstallStart"
+ android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:exported="true"
android:excludeFromRecents="true">
<intent-filter android:priority="1">
@@ -59,13 +60,14 @@
android:exported="false" />
<activity android:name=".DeleteStagedFileOnResult"
+ android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:exported="false" />
<activity android:name=".PackageInstallerActivity"
android:exported="false" />
<activity android:name=".InstallInstalling"
- android:theme="@style/DialogWhenLargeNoAnimation"
+ android:theme="@style/Theme.AlertDialogActivity.NoAnimation"
android:exported="false" />
<receiver android:name=".InstallEventReceiver"
@@ -77,18 +79,17 @@
</receiver>
<activity android:name=".InstallSuccess"
- android:theme="@style/DialogWhenLargeNoAnimation"
+ android:theme="@style/Theme.AlertDialogActivity.NoAnimation"
android:exported="false" />
<activity android:name=".InstallFailed"
- android:theme="@style/DialogWhenLargeNoAnimation"
+ android:theme="@style/Theme.AlertDialogActivity.NoAnimation"
android:exported="false" />
<activity android:name=".UninstallerActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:excludeFromRecents="true"
- android:noHistory="true"
- android:theme="@style/AlertDialogActivity">
+ android:noHistory="true">
<intent-filter android:priority="1">
<action android:name="android.intent.action.DELETE" />
<action android:name="android.intent.action.UNINSTALL_PACKAGE" />
@@ -107,7 +108,6 @@
<activity android:name=".UninstallUninstalling"
android:excludeFromRecents="true"
- android:theme="@style/AlertDialogActivity"
android:exported="false" />
<receiver android:name=".UninstallFinish"
diff --git a/packages/PackageInstaller/res/layout/install_confirm.xml b/packages/PackageInstaller/res/layout/install_confirm.xml
deleted file mode 100644
index 6be46fc..0000000
--- a/packages/PackageInstaller/res/layout/install_confirm.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2016 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:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <LinearLayout android:id="@+id/app_snippet"
- android:background="?android:attr/colorPrimary"
- android:layout_width="match_parent"
- android:layout_height="?android:attr/actionBarSize"
- android:orientation="horizontal"
- android:elevation="@dimen/headerElevation"
- android:gravity="center_vertical">
-
- <ImageView android:id="@+id/app_icon"
- android:layout_marginStart="16dp"
- android:layout_width="24dp"
- android:layout_height="24dp"
- android:scaleType="fitCenter"
- android:src="@drawable/ic_file_download" />
-
- <TextView android:id="@+id/app_name"
- android:layout_marginStart="32dp"
- android:layout_marginEnd="16dp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/titleTextStyle"
- android:singleLine="true"
- android:text="@string/app_name_unknown"
- android:ellipsize="end" />
-
- </LinearLayout>
-
- <ScrollView android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:padding="16dip">
-
- <TextView android:id="@+id/install_confirm_question"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- </ScrollView>
-
- <LinearLayout style="?android:attr/buttonBarStyle"
- android:background="?android:attr/colorBackground"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:padding="8dp"
- android:measureWithLargestChild="true">
-
- <!-- spacer to push buttons to the right -->
- <View android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1" />
-
- <Button android:id="@+id/cancel_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/cancel"
- android:maxLines="2"
- style="?android:attr/buttonBarButtonStyle" />
-
- <Button android:id="@+id/ok_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/install"
- android:maxLines="2"
- style="?android:attr/buttonBarButtonStyle" />
-
- </LinearLayout>
-
-</LinearLayout>
diff --git a/packages/PackageInstaller/res/layout/install_content_view.xml b/packages/PackageInstaller/res/layout/install_content_view.xml
new file mode 100644
index 0000000..5e94a29
--- /dev/null
+++ b/packages/PackageInstaller/res/layout/install_content_view.xml
@@ -0,0 +1,144 @@
+<?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="match_parent"
+ android:layout_height="wrap_content"
+ android:theme="?android:attr/alertDialogTheme"
+ android:paddingTop="8dp"
+ android:paddingLeft="?android:attr/dialogPreferredPadding"
+ android:paddingRight="?android:attr/dialogPreferredPadding">
+
+ <LinearLayout
+ android:id="@+id/staging"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:visibility="invisible">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@android:style/TextAppearance.Material.Subhead"
+ android:text="@string/message_staging" />
+
+ <ProgressBar
+ android:id="@+id/progress_indeterminate"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="8dp"
+ style="?android:attr/progressBarStyleHorizontal"
+ android:indeterminate="true" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/installing"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:visibility="invisible">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@android:style/TextAppearance.Material.Subhead"
+ android:text="@string/installing" />
+
+ <ProgressBar
+ android:id="@+id/progress"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="8dp"
+ style="?android:attr/progressBarStyleHorizontal" />
+
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/install_confirm_question"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@android:style/TextAppearance.Material.Subhead"
+ android:text="@string/install_confirm_question"
+ android:visibility="invisible" />
+
+ <TextView
+ android:id="@+id/install_confirm_question_update"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@android:style/TextAppearance.Material.Subhead"
+ android:text="@string/install_confirm_question_update"
+ android:visibility="invisible" />
+
+ <TextView
+ android:id="@+id/install_confirm_question_update_system"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@android:style/TextAppearance.Material.Subhead"
+ android:text="@string/install_confirm_question_update_system"
+ android:visibility="invisible" />
+
+ <TextView
+ android:id="@+id/install_success"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@android:style/TextAppearance.Material.Subhead"
+ android:text="@string/install_done"
+ android:visibility="invisible" />
+
+ <TextView
+ android:id="@+id/install_failed"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@android:style/TextAppearance.Material.Subhead"
+ android:text="@string/install_failed"
+ android:visibility="invisible" />
+
+ <TextView
+ android:id="@+id/install_failed_blocked"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@android:style/TextAppearance.Material.Subhead"
+ android:text="@string/install_failed_blocked"
+ android:visibility="invisible" />
+
+ <TextView
+ android:id="@+id/install_failed_conflict"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@android:style/TextAppearance.Material.Subhead"
+ android:text="@string/install_failed_conflict"
+ android:visibility="invisible" />
+
+ <TextView
+ android:id="@+id/install_failed_incompatible"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@android:style/TextAppearance.Material.Subhead"
+ android:text="@string/install_failed_incompatible"
+ android:visibility="invisible" />
+
+ <TextView
+ android:id="@+id/install_failed_invalid_apk"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@android:style/TextAppearance.Material.Subhead"
+ android:text="@string/install_failed_invalid_apk"
+ android:visibility="invisible" />
+
+</FrameLayout>
diff --git a/packages/PackageInstaller/res/layout/install_failed.xml b/packages/PackageInstaller/res/layout/install_failed.xml
deleted file mode 100644
index d000ee9..0000000
--- a/packages/PackageInstaller/res/layout/install_failed.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2016 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:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <LinearLayout android:id="@+id/app_snippet"
- android:background="?android:attr/colorPrimary"
- android:layout_width="match_parent"
- android:layout_height="?android:attr/actionBarSize"
- android:orientation="horizontal"
- android:elevation="@dimen/headerElevation"
- android:gravity="center_vertical">
-
- <ImageView android:id="@+id/app_icon"
- android:layout_marginStart="16dp"
- android:layout_width="24dp"
- android:layout_height="24dp"
- android:scaleType="fitCenter" />
-
- <TextView android:id="@+id/app_name"
- android:layout_marginStart="32dp"
- android:layout_marginEnd="16dp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/titleTextStyle"
- android:singleLine="true"
- android:ellipsize="end" />
-
- </LinearLayout>
-
- <LinearLayout android:id="@+id/simple_status_view"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:gravity="center"
- android:orientation="vertical"
- android:paddingLeft="16dip"
- android:paddingRight="16dip">
-
- <ImageView android:id="@+id/center_icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="12dp"
- android:src="@drawable/ic_report_problem_92"
- android:tint="@color/bigIconColor"
- android:contentDescription="@null" />
-
- <TextView android:id="@+id/simple_status"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- </LinearLayout>
-
- <LinearLayout android:id="@+id/buttons_panel"
- style="?android:attr/buttonBarStyle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:measureWithLargestChild="true"
- android:padding="8dip">
-
- <!-- spacer to push button to the right -->
- <View android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1" />
-
- <Button android:id="@+id/done_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/done"
- android:maxLines="2"
- style="?android:attr/buttonBarButtonStyle" />
-
- </LinearLayout>
-
-</LinearLayout>
-
-
diff --git a/packages/PackageInstaller/res/layout/install_installing.xml b/packages/PackageInstaller/res/layout/install_installing.xml
deleted file mode 100644
index a043a01..0000000
--- a/packages/PackageInstaller/res/layout/install_installing.xml
+++ /dev/null
@@ -1,108 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2016 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:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <LinearLayout android:id="@+id/app_snippet"
- android:background="?android:attr/colorPrimary"
- android:layout_width="match_parent"
- android:layout_height="?android:attr/actionBarSize"
- android:orientation="horizontal"
- android:elevation="@dimen/headerElevation"
- android:gravity="center_vertical">
-
- <ImageView
- android:id="@+id/app_icon"
- android:layout_width="24dp"
- android:layout_height="24dp"
- android:layout_marginStart="16dp"
- android:scaleType="fitCenter" />
-
- <TextView
- android:id="@+id/app_name"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="32dp"
- android:layout_marginEnd="16dp"
- android:ellipsize="end"
- android:singleLine="true"
- android:textAppearance="?android:attr/titleTextStyle" />
-
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:gravity="center"
- android:orientation="vertical"
- android:paddingLeft="16dip"
- android:paddingRight="16dip">
-
- <ImageView
- android:layout_width="92dp"
- android:layout_height="92dp"
- android:layout_marginBottom="12dp"
- android:contentDescription="@null"
- android:tint="@color/bigIconColor"
- android:src="@drawable/ic_file_download" />
-
- <ProgressBar
- android:id="@+id/progress_bar"
- style="?android:attr/progressBarStyleHorizontal"
- android:layout_width="250dp"
- android:layout_height="wrap_content"
- android:indeterminate="false" />
-
- <TextView
- android:id="@+id/center_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_horizontal"
- android:text="@string/installing"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- </LinearLayout>
-
- <LinearLayout
- android:id="@+id/buttons_panel"
- style="?android:attr/buttonBarStyle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:measureWithLargestChild="true"
- android:orientation="horizontal"
- android:padding="8dip">
-
- <View
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1" />
-
- <Button
- android:id="@+id/cancel_button"
- style="?android:attr/buttonBarButtonStyle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:maxLines="2"
- android:text="@string/cancel" />
-
- </LinearLayout>
-
-</LinearLayout>
diff --git a/packages/PackageInstaller/res/layout/install_staging.xml b/packages/PackageInstaller/res/layout/install_staging.xml
deleted file mode 100644
index e3022e7..0000000
--- a/packages/PackageInstaller/res/layout/install_staging.xml
+++ /dev/null
@@ -1,113 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2016 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.
- -->
-
-<!--
- Defines the layout of the splash screen that displays the security
- settings required for an application and requests the confirmation of the
- user before it is installed.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <!-- title bar -->
- <LinearLayout android:id="@+id/app_snippet"
- android:layout_width="match_parent"
- android:layout_height="?android:attr/actionBarSize"
- android:background="?android:attr/colorPrimary"
- android:elevation="@dimen/headerElevation"
- android:gravity="center_vertical"
- android:orientation="horizontal">
-
- <ImageView android:layout_width="24dp"
- android:layout_height="24dp"
- android:layout_marginLeft="16dp"
- android:scaleType="fitCenter"
- android:src="@drawable/ic_file_download"
- android:tint="?android:attr/colorAccent" />
-
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="32dp"
- android:layout_marginRight="16dp"
- android:ellipsize="end"
- android:singleLine="true"
- android:text="@string/app_name_unknown"
- android:textAppearance="?android:attr/titleTextStyle" />
-
- </LinearLayout>
-
- <!-- content -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:gravity="center"
- android:orientation="vertical"
- android:paddingLeft="16dip"
- android:paddingRight="16dip">
-
- <ImageView
- android:layout_width="92dp"
- android:layout_height="92dp"
- android:scaleType="fitCenter"
- android:layout_marginBottom="12dp"
- android:contentDescription="@null"
- android:tint="@color/bigIconColor"
- android:src="@drawable/ic_file_download" />
-
- <ProgressBar
- style="?android:attr/progressBarStyleHorizontal"
- android:layout_width="250dp"
- android:layout_height="wrap_content"
- android:indeterminate="true" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_horizontal"
- android:text="@string/message_staging"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- </LinearLayout>
-
- <!-- Bottom buttons -->
- <LinearLayout style="?android:attr/buttonBarStyle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:padding="8dp">
-
- <!-- spacer to push button to the right -->
- <View android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1" />
-
- <Button android:id="@+id/cancel_button"
- style="?android:attr/buttonBarButtonStyle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:maxLines="2"
- android:text="@string/cancel" />
-
- </LinearLayout>
-
-</LinearLayout>
-
-
diff --git a/packages/PackageInstaller/res/layout/install_success.xml b/packages/PackageInstaller/res/layout/install_success.xml
deleted file mode 100644
index fee6bed..0000000
--- a/packages/PackageInstaller/res/layout/install_success.xml
+++ /dev/null
@@ -1,101 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2016 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:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <LinearLayout android:id="@+id/app_snippet"
- android:background="?android:attr/colorPrimary"
- android:layout_width="match_parent"
- android:layout_height="?android:attr/actionBarSize"
- android:orientation="horizontal"
- android:elevation="@dimen/headerElevation"
- android:gravity="center_vertical">
-
- <ImageView android:id="@+id/app_icon"
- android:layout_marginStart="16dp"
- android:layout_width="24dp"
- android:layout_height="24dp"
- android:scaleType="fitCenter" />
-
- <TextView android:id="@+id/app_name"
- android:layout_marginStart="32dp"
- android:layout_marginEnd="16dp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/titleTextStyle"
- android:singleLine="true"
- android:ellipsize="end" />
-
- </LinearLayout>
-
- <LinearLayout android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:gravity="center"
- android:orientation="vertical"
- android:paddingLeft="16dip"
- android:paddingRight="16dip">
-
- <ImageView android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="12dp"
- android:src="@drawable/ic_done_92"
- android:tint="@color/bigIconColor"
- android:contentDescription="@null" />
-
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_horizontal"
- android:text="@string/install_done"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- </LinearLayout>
-
- <LinearLayout style="?android:attr/buttonBarStyle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:measureWithLargestChild="true"
- android:padding="8dip">
-
- <!-- spacer to push buttons to the right -->
- <View android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="1" />
-
- <Button android:id="@+id/done_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/done"
- android:maxLines="2"
- style="?android:attr/buttonBarButtonStyle" />
-
- <Button android:id="@+id/launch_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/launch"
- android:maxLines="2"
- style="?android:attr/buttonBarButtonStyle" />
-
- </LinearLayout>
-
-</LinearLayout>
-
-
diff --git a/packages/PackageInstaller/res/values-night/themes.xml b/packages/PackageInstaller/res/values-night/themes.xml
new file mode 100644
index 0000000..483b0cf
--- /dev/null
+++ b/packages/PackageInstaller/res/values-night/themes.xml
@@ -0,0 +1,23 @@
+<?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.
+ -->
+
+<resources>
+
+ <style name="Theme.AlertDialogActivity"
+ parent="@android:style/Theme.DeviceDefault.Dialog.Alert" />
+
+</resources>
diff --git a/packages/PackageInstaller/res/values/strings.xml b/packages/PackageInstaller/res/values/strings.xml
index 6c7160f..ba81278 100644
--- a/packages/PackageInstaller/res/values/strings.xml
+++ b/packages/PackageInstaller/res/values/strings.xml
@@ -36,11 +36,11 @@
<!-- Message for updating an existing app [CHAR LIMIT=NONE] -->
<string name="install_confirm_question_update">Do you want to install an update
to this existing application? Your existing data will not
- be lost. The updated application will get access to:</string>
+ be lost.</string>
<!-- Message for updating an existing system app [CHAR LIMIT=NONE] -->
<string name="install_confirm_question_update_system">Do you want to install an update
to this built-in application? Your existing data will not
- be lost. The updated application will get access to:</string>
+ be lost.</string>
<!-- [CHAR LIMIT=100] -->
<string name="install_failed">App not installed.</string>
<!-- Reason displayed when installation fails because the package was blocked
diff --git a/packages/PackageInstaller/res/values/styles.xml b/packages/PackageInstaller/res/values/styles.xml
deleted file mode 100755
index f79f98f..0000000
--- a/packages/PackageInstaller/res/values/styles.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<resources>
-
- <style name="MediumText"
- parent="@android:style/TextAppearance.Medium">
- <item name="android:textColor">?android:attr/textColorPrimary</item>
- </style>
-
- <style name="SmallText"
- parent="@android:style/TextAppearance.Small">
- <item name="android:textColor">?android:attr/textColorPrimary</item>
- </style>
-
- <style name="TitleText">
- <item name="android:fontFamily">sans-serif-medium</item>
- <item name="android:textSize">20dp</item>
- <item name="android:textColor">?android:attr/textColorPrimary</item>
- </style>
-
- <style name="ActionBar" parent="@android:style/Widget.Material.ActionBar.Solid">
- <item name="android:contentInsetStart">72dp</item>
- </style>
-
-</resources>
diff --git a/packages/PackageInstaller/res/values/themes.xml b/packages/PackageInstaller/res/values/themes.xml
index 6df6246..6c8e4c5 100644
--- a/packages/PackageInstaller/res/values/themes.xml
+++ b/packages/PackageInstaller/res/values/themes.xml
@@ -17,25 +17,11 @@
<resources>
- <style name="DialogWhenLarge"
- parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
- <item name="android:textAppearanceMedium">@style/MediumText</item>
- <item name="android:textAppearanceSmall">@style/SmallText</item>
- <item name="android:titleTextStyle">@style/TitleText</item>
- </style>
-
- <style name="DialogWhenLargeNoAnimation" parent="DialogWhenLarge">
+ <style name="Theme.AlertDialogActivity.NoAnimation">
<item name="android:windowAnimationStyle">@null</item>
</style>
- <style name="AlertDialogActivity"
- parent="@android:style/Theme.DeviceDefault.Light.Panel">
- <item name="android:backgroundDimEnabled">true</item>
- </style>
-
- <style name="Header.Settings"
- parent="@android:style/Theme.DeviceDefault.Settings">
- </style>
-
+ <style name="Theme.AlertDialogActivity"
+ parent="@android:style/Theme.DeviceDefault.Light.Dialog.Alert" />
</resources>
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/InstallFailed.java b/packages/PackageInstaller/src/com/android/packageinstaller/InstallFailed.java
index 5ba2d32..54105bb 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/InstallFailed.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/InstallFailed.java
@@ -30,41 +30,49 @@
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
-import android.widget.TextView;
+import android.view.View;
+
+import com.android.internal.app.AlertActivity;
import java.io.File;
/**
* Installation failed: Return status code to the caller or display failure UI to user
*/
-public class InstallFailed extends Activity {
+public class InstallFailed extends AlertActivity {
private static final String LOG_TAG = InstallFailed.class.getSimpleName();
/** Label of the app that failed to install */
private CharSequence mLabel;
/**
- * Convert an package installer status code into the user friendly label.
+ * Unhide the appropriate label for the statusCode.
*
* @param statusCode The status code from the package installer.
- *
- * @return The user friendly label for the status code
*/
- private int getExplanationFromErrorCode(int statusCode) {
+ private void setExplanationFromErrorCode(int statusCode) {
Log.d(LOG_TAG, "Installation status code: " + statusCode);
+ View viewToEnable;
switch (statusCode) {
case PackageInstaller.STATUS_FAILURE_BLOCKED:
- return R.string.install_failed_blocked;
+ viewToEnable = requireViewById(R.id.install_failed_blocked);
+ break;
case PackageInstaller.STATUS_FAILURE_CONFLICT:
- return R.string.install_failed_conflict;
+ viewToEnable = requireViewById(R.id.install_failed_conflict);
+ break;
case PackageInstaller.STATUS_FAILURE_INCOMPATIBLE:
- return R.string.install_failed_incompatible;
+ viewToEnable = requireViewById(R.id.install_failed_incompatible);
+ break;
case PackageInstaller.STATUS_FAILURE_INVALID:
- return R.string.install_failed_invalid_apk;
+ viewToEnable = requireViewById(R.id.install_failed_invalid_apk);
+ break;
default:
- return R.string.install_failed;
+ viewToEnable = requireViewById(R.id.install_failed);
+ break;
}
+
+ viewToEnable.setVisibility(View.VISIBLE);
}
@Override
@@ -89,8 +97,6 @@
.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO);
Uri packageURI = intent.getData();
- setContentView(R.layout.install_failed);
-
// Set header icon and title
PackageUtil.AppSnippet as;
PackageManager pm = getPackageManager();
@@ -106,7 +112,12 @@
// Store label for dialog
mLabel = as.label;
- PackageUtil.initSnippetForNewApp(this, as, R.id.app_snippet);
+ mAlert.setIcon(as.icon);
+ mAlert.setTitle(as.label);
+ mAlert.setView(R.layout.install_content_view);
+ mAlert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.done),
+ (ignored, ignored2) -> finish(), null);
+ setupAlert();
// Show out of space dialog if needed
if (statusCode == PackageInstaller.STATUS_FAILURE_STORAGE) {
@@ -114,11 +125,7 @@
}
// Get status messages
- ((TextView) findViewById(R.id.simple_status)).setText(
- getExplanationFromErrorCode(statusCode));
-
- // Set up "done" button
- findViewById(R.id.done_button).setOnClickListener(view -> finish());
+ setExplanationFromErrorCode(statusCode);
}
}
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/InstallInstalling.java b/packages/PackageInstaller/src/com/android/packageinstaller/InstallInstalling.java
index c2dd740..deb6163 100755
--- a/packages/PackageInstaller/src/com/android/packageinstaller/InstallInstalling.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/InstallInstalling.java
@@ -19,8 +19,8 @@
import static android.content.pm.PackageInstaller.SessionParams.UID_UNKNOWN;
import android.annotation.Nullable;
-import android.app.Activity;
import android.app.PendingIntent;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInstaller;
@@ -30,9 +30,11 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
+import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
+import com.android.internal.app.AlertActivity;
import com.android.internal.content.PackageHelper;
import java.io.File;
@@ -47,7 +49,7 @@
* <p>This has two phases: First send the data to the package manager, then wait until the package
* manager processed the result.</p>
*/
-public class InstallInstalling extends Activity {
+public class InstallInstalling extends AlertActivity {
private static final String LOG_TAG = InstallInstalling.class.getSimpleName();
private static final String SESSION_ID = "com.android.packageinstaller.SESSION_ID";
@@ -78,11 +80,31 @@
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.install_installing);
-
ApplicationInfo appInfo = getIntent()
.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO);
mPackageURI = getIntent().getData();
+ final File sourceFile = new File(mPackageURI.getPath());
+ PackageUtil.AppSnippet as = PackageUtil.getAppSnippet(this, appInfo, sourceFile);
+
+ mAlert.setIcon(as.icon);
+ mAlert.setTitle(as.label);
+ mAlert.setView(R.layout.install_content_view);
+ mAlert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel),
+ (ignored, ignored2) -> {
+ if (mInstallingTask != null) {
+ mInstallingTask.cancel(true);
+ }
+
+ if (mSessionId > 0) {
+ getPackageManager().getPackageInstaller().abandonSession(mSessionId);
+ mSessionId = 0;
+ }
+
+ setResult(RESULT_CANCELED);
+ finish();
+ }, null);
+ setupAlert();
+ requireViewById(R.id.installing).setVisibility(View.VISIBLE);
if ("package".equals(mPackageURI.getScheme())) {
try {
@@ -92,10 +114,6 @@
launchFailure(PackageManager.INSTALL_FAILED_INTERNAL_ERROR, null);
}
} else {
- final File sourceFile = new File(mPackageURI.getPath());
- PackageUtil.initSnippetForNewApp(this, PackageUtil.getAppSnippet(this, appInfo,
- sourceFile), R.id.app_snippet);
-
if (savedInstanceState != null) {
mSessionId = savedInstanceState.getInt(SESSION_ID);
mInstallId = savedInstanceState.getInt(INSTALL_ID);
@@ -153,21 +171,7 @@
}
}
- mCancelButton = (Button) findViewById(R.id.cancel_button);
-
- mCancelButton.setOnClickListener(view -> {
- if (mInstallingTask != null) {
- mInstallingTask.cancel(true);
- }
-
- if (mSessionId > 0) {
- getPackageManager().getPackageInstaller().abandonSession(mSessionId);
- mSessionId = 0;
- }
-
- setResult(RESULT_CANCELED);
- finish();
- });
+ mCancelButton = mAlert.getButton(DialogInterface.BUTTON_NEGATIVE);
mSessionCallback = new InstallSessionCallback();
}
@@ -307,7 +311,7 @@
@Override
public void onProgressChanged(int sessionId, float progress) {
if (sessionId == mSessionId) {
- ProgressBar progressBar = (ProgressBar)findViewById(R.id.progress_bar);
+ ProgressBar progressBar = requireViewById(R.id.progress);
progressBar.setMax(Integer.MAX_VALUE);
progressBar.setProgress((int) (Integer.MAX_VALUE * progress));
}
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/InstallStaging.java b/packages/PackageInstaller/src/com/android/packageinstaller/InstallStaging.java
index 1bc9dbd..98438cd 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/InstallStaging.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/InstallStaging.java
@@ -29,6 +29,9 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
+import android.view.View;
+
+import com.android.internal.app.AlertActivity;
import java.io.File;
import java.io.FileOutputStream;
@@ -40,7 +43,7 @@
* If a package gets installed from an content URI this step loads the package and turns it into
* and installation from a file. Then it re-starts the installation as usual.
*/
-public class InstallStaging extends Activity {
+public class InstallStaging extends AlertActivity {
private static final String LOG_TAG = InstallStaging.class.getSimpleName();
private static final String STAGED_FILE = "STAGED_FILE";
@@ -55,7 +58,19 @@
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.install_staging);
+ mAlert.setIcon(R.drawable.ic_file_download);
+ mAlert.setTitle(getString(R.string.app_name_unknown));
+ mAlert.setView(R.layout.install_content_view);
+ mAlert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel),
+ (ignored, ignored2) -> {
+ if (mStagingTask != null) {
+ mStagingTask.cancel(true);
+ }
+ setResult(RESULT_CANCELED);
+ finish();
+ }, null);
+ setupAlert();
+ requireViewById(R.id.staging).setVisibility(View.VISIBLE);
if (savedInstanceState != null) {
mStagedFile = new File(savedInstanceState.getString(STAGED_FILE));
@@ -64,14 +79,6 @@
mStagedFile = null;
}
}
-
- findViewById(R.id.cancel_button).setOnClickListener(view -> {
- if (mStagingTask != null) {
- mStagingTask.cancel(true);
- }
- setResult(RESULT_CANCELED);
- finish();
- });
}
@Override
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/InstallSuccess.java b/packages/PackageInstaller/src/com/android/packageinstaller/InstallSuccess.java
index 94f6b31..705d3f4 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/InstallSuccess.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/InstallSuccess.java
@@ -19,6 +19,7 @@
import android.annotation.Nullable;
import android.app.Activity;
import android.content.ActivityNotFoundException;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -26,15 +27,18 @@
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
+import android.view.View;
import android.widget.Button;
+import com.android.internal.app.AlertActivity;
+
import java.io.File;
import java.util.List;
/**
* Finish installation: Return status code to the caller or display "success" UI to user
*/
-public class InstallSuccess extends Activity {
+public class InstallSuccess extends AlertActivity {
private static final String LOG_TAG = InstallSuccess.class.getSimpleName();
@Override
@@ -53,8 +57,6 @@
intent.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO);
Uri packageURI = intent.getData();
- setContentView(R.layout.install_success);
-
// Set header icon and title
PackageUtil.AppSnippet as;
PackageManager pm = getPackageManager();
@@ -67,16 +69,20 @@
as = PackageUtil.getAppSnippet(this, appInfo, sourceFile);
}
- PackageUtil.initSnippetForNewApp(this, as, R.id.app_snippet);
-
- // Set up "done" button
- findViewById(R.id.done_button).setOnClickListener(view -> {
- if (appInfo.packageName != null) {
- Log.i(LOG_TAG, "Finished installing " + appInfo.packageName);
- }
- finish();
- });
-
+ mAlert.setIcon(as.icon);
+ mAlert.setTitle(as.label);
+ mAlert.setView(R.layout.install_content_view);
+ mAlert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.launch), null,
+ null);
+ mAlert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.done),
+ (ignored, ignored2) -> {
+ if (appInfo.packageName != null) {
+ Log.i(LOG_TAG, "Finished installing " + appInfo.packageName);
+ }
+ finish();
+ }, null);
+ setupAlert();
+ requireViewById(R.id.install_success).setVisibility(View.VISIBLE);
// Enable or disable "launch" button
Intent launchIntent = getPackageManager().getLaunchIntentForPackage(
appInfo.packageName);
@@ -89,7 +95,7 @@
}
}
- Button launchButton = (Button)findViewById(R.id.launch_button);
+ Button launchButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
if (enabled) {
launchButton.setOnClickListener(view -> {
try {
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/OverlayTouchActivity.java b/packages/PackageInstaller/src/com/android/packageinstaller/OverlayTouchActivity.java
deleted file mode 100644
index 1fdbd97..0000000
--- a/packages/PackageInstaller/src/com/android/packageinstaller/OverlayTouchActivity.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.
- */
-package com.android.packageinstaller;
-
-import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-class OverlayTouchActivity extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- getWindow().addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
- super.onCreate(savedInstanceState);
- }
-}
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java b/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java
index 97bafe7..580308a 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java
@@ -16,6 +16,8 @@
*/
package com.android.packageinstaller;
+import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+
import android.Manifest;
import android.annotation.NonNull;
import android.annotation.StringRes;
@@ -45,9 +47,9 @@
import android.provider.Settings;
import android.util.Log;
import android.view.View;
-import android.view.View.OnClickListener;
import android.widget.Button;
-import android.widget.TextView;
+
+import com.android.internal.app.AlertActivity;
import java.io.File;
@@ -61,7 +63,7 @@
* Based on the user response the package is then installed by launching InstallAppConfirm
* sub activity. All state transitions are handled in this activity
*/
-public class PackageInstallerActivity extends OverlayTouchActivity implements OnClickListener {
+public class PackageInstallerActivity extends AlertActivity {
private static final String TAG = "PackageInstaller";
private static final int REQUEST_TRUST_EXTERNAL_SOURCE = 1;
@@ -95,7 +97,6 @@
// Buttons to indicate user acceptance
private Button mOk;
- private Button mCancel;
private PackageUtil.AppSnippet mAppSnippet;
@@ -119,18 +120,18 @@
private boolean mEnableOk = false;
private void startInstallConfirm() {
- int msg;
+ View viewToEnable;
if (mAppInfo != null) {
- msg = (mAppInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0
- ? R.string.install_confirm_question_update_system
- : R.string.install_confirm_question_update;
+ viewToEnable = (mAppInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0
+ ? requireViewById(R.id.install_confirm_question_update_system)
+ : requireViewById(R.id.install_confirm_question_update);
} else {
// This is a new application with no permissions.
- msg = R.string.install_confirm_question;
+ viewToEnable = requireViewById(R.id.install_confirm_question);
}
- ((TextView) findViewById(R.id.install_confirm_question)).setText(msg);
+ viewToEnable.setVisibility(View.VISIBLE);
mEnableOk = true;
mOk.setEnabled(true);
@@ -280,6 +281,8 @@
@Override
protected void onCreate(Bundle icicle) {
+ getWindow().addPrivateFlags(PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
+
super.onCreate(null);
if (icicle != null) {
@@ -344,7 +347,7 @@
// load dummy layout with OK button disabled until we override this layout in
// startInstallConfirm
- bindUi(R.layout.install_confirm);
+ bindUi();
checkIfAllowedAndInitiateInstall();
}
@@ -374,17 +377,34 @@
outState.putBoolean(ALLOW_UNKNOWN_SOURCES_KEY, mAllowUnknownSources);
}
- private void bindUi(int layout) {
- setContentView(layout);
+ private void bindUi() {
+ mAlert.setIcon(mAppSnippet.icon);
+ mAlert.setTitle(mAppSnippet.label);
+ mAlert.setView(R.layout.install_content_view);
+ mAlert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.install),
+ (ignored, ignored2) -> {
+ if (mOk.isEnabled()) {
+ if (mSessionId != -1) {
+ mInstaller.setPermissionsResult(mSessionId, true);
+ finish();
+ } else {
+ startInstall();
+ }
+ }
+ }, null);
+ mAlert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel),
+ (ignored, ignored2) -> {
+ // Cancel and finish
+ setResult(RESULT_CANCELED);
+ if (mSessionId != -1) {
+ mInstaller.setPermissionsResult(mSessionId, false);
+ }
+ finish();
+ }, null);
+ setupAlert();
- mOk = (Button) findViewById(R.id.ok_button);
- mCancel = (Button)findViewById(R.id.cancel_button);
- mOk.setOnClickListener(this);
- mCancel.setOnClickListener(this);
-
+ mOk = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
mOk.setEnabled(false);
-
- PackageUtil.initSnippetForNewApp(this, mAppSnippet, R.id.app_snippet);
}
/**
@@ -525,26 +545,6 @@
super.onBackPressed();
}
- public void onClick(View v) {
- if (v == mOk) {
- if (mOk.isEnabled()) {
- if (mSessionId != -1) {
- mInstaller.setPermissionsResult(mSessionId, true);
- finish();
- } else {
- startInstall();
- }
- }
- } else if (v == mCancel) {
- // Cancel and finish
- setResult(RESULT_CANCELED);
- if (mSessionId != -1) {
- mInstaller.setPermissionsResult(mSessionId, false);
- }
- finish();
- }
- }
-
private void startInstall() {
// Start subactivity to actually install the application
Intent newIntent = new Intent();
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/PackageUtil.java b/packages/PackageInstaller/src/com/android/packageinstaller/PackageUtil.java
index ba4bf8a..0e89f56 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/PackageUtil.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/PackageUtil.java
@@ -108,26 +108,6 @@
icon);
}
- /**
- * Utility method to display application snippet of a new package.
- * The content view should have been set on context before invoking this method.
- * appSnippet view should include R.id.app_icon and R.id.app_name
- * defined on it.
- *
- * @param pContext context of package that can load the resources
- * @param as The resources to be loaded
- * @param snippetId view id of app snippet view
- */
- @NonNull public static View initSnippetForNewApp(@NonNull Activity pContext,
- @NonNull AppSnippet as, int snippetId) {
- View appSnippet = pContext.findViewById(snippetId);
- if (as.icon != null) {
- ((ImageView) appSnippet.findViewById(R.id.app_icon)).setImageDrawable(as.icon);
- }
- ((TextView)appSnippet.findViewById(R.id.app_name)).setText(as.label);
- return appSnippet;
- }
-
static public class AppSnippet {
@NonNull public CharSequence label;
@Nullable public Drawable icon;
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
index 5ecbe80..c511589 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
@@ -1189,7 +1189,7 @@
/**
* @return {@code true} if {@code cachedBluetoothDevice} is a2dp device
*/
- public boolean isA2dpDevice() {
+ public boolean isConnectedA2dpDevice() {
A2dpProfile a2dpProfile = mProfileManager.getA2dpProfile();
return a2dpProfile != null && a2dpProfile.getConnectionStatus(mDevice) ==
BluetoothProfile.STATE_CONNECTED;
@@ -1198,7 +1198,7 @@
/**
* @return {@code true} if {@code cachedBluetoothDevice} is HFP device
*/
- public boolean isHfpDevice() {
+ public boolean isConnectedHfpDevice() {
HeadsetProfile headsetProfile = mProfileManager.getHeadsetProfile();
return headsetProfile != null && headsetProfile.getConnectionStatus(mDevice) ==
BluetoothProfile.STATE_CONNECTED;
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java
index 2d34f23..7baded8 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java
@@ -50,7 +50,6 @@
private final static String DEVICE_ADDRESS_3 = "AA:BB:CC:DD:EE:33";
private final static String DEVICE_SUMMARY_1 = "summary 1";
private final static String DEVICE_SUMMARY_2 = "summary 2";
- private final static String DEVICE_SUMMARY_3 = "summary 3";
private final static long HISYNCID1 = 10;
private final static long HISYNCID2 = 11;
private final BluetoothClass DEVICE_CLASS_1 =
@@ -82,11 +81,6 @@
private CachedBluetoothDevice mCachedDevice3;
private CachedBluetoothDeviceManager mCachedDeviceManager;
private Context mContext;
- private String[] mActiveDeviceStringsArray;
- private String mActiveDeviceStringNone;
- private String mActiveDeviceStringAll;
- private String mActiveDeviceStringMedia;
- private String mActiveDeviceStringPhone;
@Before
public void setUp() {
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java
index 034574f..5e417c3 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java
@@ -538,7 +538,7 @@
when(mA2dpProfile.getConnectionStatus(mDevice)).
thenReturn(BluetoothProfile.STATE_CONNECTED);
- assertThat(mCachedDevice.isA2dpDevice()).isTrue();
+ assertThat(mCachedDevice.isConnectedA2dpDevice()).isTrue();
}
@Test
@@ -547,7 +547,7 @@
when(mA2dpProfile.getConnectionStatus(mDevice)).
thenReturn(BluetoothProfile.STATE_DISCONNECTING);
- assertThat(mCachedDevice.isA2dpDevice()).isFalse();
+ assertThat(mCachedDevice.isConnectedA2dpDevice()).isFalse();
}
@Test
@@ -556,7 +556,7 @@
when(mHfpProfile.getConnectionStatus(mDevice)).
thenReturn(BluetoothProfile.STATE_CONNECTED);
- assertThat(mCachedDevice.isHfpDevice()).isTrue();
+ assertThat(mCachedDevice.isConnectedHfpDevice()).isTrue();
}
@Test
@@ -565,7 +565,7 @@
when(mHfpProfile.getConnectionStatus(mDevice)).
thenReturn(BluetoothProfile.STATE_DISCONNECTING);
- assertThat(mCachedDevice.isHfpDevice()).isFalse();
+ assertThat(mCachedDevice.isConnectedHfpDevice()).isFalse();
}
@Test
@@ -590,14 +590,14 @@
public void isConnectedHfpDevice_profileIsNull_returnFalse() {
when(mProfileManager.getHeadsetProfile()).thenReturn(null);
- assertThat(mCachedDevice.isHfpDevice()).isFalse();
+ assertThat(mCachedDevice.isConnectedHfpDevice()).isFalse();
}
@Test
public void isConnectedA2dpDevice_profileIsNull_returnFalse() {
when(mProfileManager.getA2dpProfile()).thenReturn(null);
- assertThat(mCachedDevice.isA2dpDevice()).isFalse();
+ assertThat(mCachedDevice.isConnectedA2dpDevice()).isFalse();
}
@Test
diff --git a/packages/SystemUI/res/layout/notification_snooze.xml b/packages/SystemUI/res/layout/notification_snooze.xml
index fae759a..ffe2eee 100644
--- a/packages/SystemUI/res/layout/notification_snooze.xml
+++ b/packages/SystemUI/res/layout/notification_snooze.xml
@@ -22,7 +22,7 @@
android:orientation="vertical"
android:clickable="true"
android:background="@color/notification_guts_bg_color"
- android:theme="@*android:style/Theme.DeviceDefault.Light">
+ android:theme="@style/Theme.SystemUI">
<RelativeLayout
android:id="@+id/notification_snooze"
@@ -36,7 +36,7 @@
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:paddingStart="@*android:dimen/notification_content_margin_start"
- android:textColor="@color/notification_primary_text_color"
+ android:textColor="?android:attr/textColorPrimary"
android:paddingEnd="4dp"/>
<ImageView
diff --git a/packages/SystemUI/res/layout/notification_snooze_option.xml b/packages/SystemUI/res/layout/notification_snooze_option.xml
index aaf45f3..f203839 100644
--- a/packages/SystemUI/res/layout/notification_snooze_option.xml
+++ b/packages/SystemUI/res/layout/notification_snooze_option.xml
@@ -22,4 +22,4 @@
android:layout_marginEnd="@*android:dimen/notification_content_margin_end"
android:gravity="center_vertical"
android:textSize="14sp"
- android:textColor="#DD000000"/>
\ No newline at end of file
+ android:textColor="?android:attr/textColorSecondary"/>
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
index 0ab71382..1393f8f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
@@ -678,9 +678,15 @@
entry.row.getNotificationChildren();
for (int i = 0; i < notificationChildren.size(); i++) {
ExpandableNotificationRow row = notificationChildren.get(i);
- if ((row.getStatusBarNotification().getNotification().flags
- & Notification.FLAG_FOREGROUND_SERVICE) != 0) {
- // the child is a foreground service notification which we can't remove!
+ NotificationData.Entry childEntry = row.getEntry();
+ boolean isForeground = (row.getStatusBarNotification().getNotification().flags
+ & Notification.FLAG_FOREGROUND_SERVICE) != 0;
+ boolean keepForReply = FORCE_REMOTE_INPUT_HISTORY
+ && (shouldKeepForRemoteInput(childEntry)
+ || shouldKeepForSmartReply(childEntry));
+ if (isForeground || keepForReply) {
+ // the child is a foreground service notification which we can't remove or it's
+ // a child we're keeping around for reply!
continue;
}
row.setKeepInParent(true);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java
index 767b07f..e96e176 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationLogger.java
@@ -62,6 +62,8 @@
protected IStatusBarService mBarService;
private long mLastVisibilityReportUptimeMs;
private NotificationListContainer mListContainer;
+ private Object mDozingLock = new Object();
+ private boolean mDozing;
protected final OnChildLocationsChangedListener mNotificationLocationsChangedListener =
new OnChildLocationsChangedListener() {
@@ -174,6 +176,12 @@
mNotificationLocationsChangedListener.onChildLocationsChanged();
}
+ public void setDozing(boolean dozing) {
+ synchronized (mDozingLock) {
+ mDozing = dozing;
+ }
+ }
+
private void logNotificationVisibilityChanges(
Collection<NotificationVisibility> newlyVisible,
Collection<NotificationVisibility> noLongerVisible) {
@@ -190,19 +198,25 @@
// Ignore.
}
- final int N = newlyVisible.size();
+ final int N = newlyVisibleAr.length;
if (N > 0) {
String[] newlyVisibleKeyAr = new String[N];
for (int i = 0; i < N; i++) {
newlyVisibleKeyAr[i] = newlyVisibleAr[i].key;
}
- // TODO: Call NotificationEntryManager to do this, once it exists.
- // TODO: Consider not catching all runtime exceptions here.
- try {
- mNotificationListener.setNotificationsShown(newlyVisibleKeyAr);
- } catch (RuntimeException e) {
- Log.d(TAG, "failed setNotificationsShown: ", e);
+ synchronized (mDozingLock) {
+ // setNotificationsShown should only be called if we are confident that
+ // the user has seen the notification, aka not when ambient display is on
+ if (!mDozing) {
+ // TODO: Call NotificationEntryManager to do this, once it exists.
+ // TODO: Consider not catching all runtime exceptions here.
+ try {
+ mNotificationListener.setNotificationsShown(newlyVisibleKeyAr);
+ } catch (RuntimeException e) {
+ Log.d(TAG, "failed setNotificationsShown: ", e);
+ }
+ }
}
}
recycleAllVisibilityObjects(newlyVisibleAr);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
index f3e100d..40c8fde 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
@@ -181,6 +181,9 @@
public void onQuickStepStarted() {
// Use navbar dragging as a signal to hide the rotate button
setRotateSuggestionButtonState(false);
+
+ // Hide the notifications panel when quick step starts
+ mStatusBar.collapsePanel(true /* animate */);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java
index ed1ae10..8c02e1f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java
@@ -75,7 +75,6 @@
private int mTouchDownY;
private boolean mDownOnRecents;
private VelocityTracker mVelocityTracker;
- private boolean mNotificationsVisibleOnDown;
private boolean mDockWindowEnabled;
private boolean mDockWindowTouchSlopExceeded;
@@ -108,9 +107,6 @@
}
public boolean onInterceptTouchEvent(MotionEvent event) {
- if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
- mNotificationsVisibleOnDown = !mStatusBar.isPresenterFullyCollapsed();
- }
if (!canHandleGestures()) {
return false;
}
@@ -275,7 +271,7 @@
}
private boolean canHandleGestures() {
- return !mStatusBar.isKeyguardShowing() && !mNotificationsVisibleOnDown;
+ return !mStatusBar.isKeyguardShowing();
}
private int calculateDragMode() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 3837fbc..3e41cd2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -791,8 +791,19 @@
showSwipeUpUI ? mQuickStepAccessibilityDelegate : null);
}
+ public boolean isNotificationsFullyCollapsed() {
+ return mPanelView.isFullyCollapsed();
+ }
+
+ /**
+ * Updates the {@link WindowManager.LayoutParams.FLAG_SLIPPERY} state dependent on if swipe up
+ * is enabled, or the notifications is fully opened without being in an animated state. If
+ * slippery is enabled, touch events will leave the nav bar window and enter into the fullscreen
+ * app/home window, if not nav bar will receive a cancelled touch event once gesture leaves bar.
+ */
public void updateSlippery() {
- setSlippery(!isQuickStepSwipeUpEnabled() || mPanelView.isFullyExpanded());
+ setSlippery(!isQuickStepSwipeUpEnabled() ||
+ (mPanelView.isFullyExpanded() && !mPanelView.isCollapsing()));
}
private void setSlippery(boolean slippery) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java
index 6cc88bb..a13bebd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java
@@ -45,9 +45,6 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManagerGlobal;
-import android.view.animation.DecelerateInterpolator;
-import android.view.animation.Interpolator;
-import androidx.annotation.DimenRes;
import com.android.systemui.Dependency;
import com.android.systemui.OverviewProxyService;
import com.android.systemui.R;
@@ -72,6 +69,7 @@
private boolean mQuickScrubActive;
private boolean mAllowGestureDetection;
private boolean mQuickStepStarted;
+ private boolean mNotificationsVisibleOnDown;
private int mTouchDownX;
private int mTouchDownY;
private boolean mDragPositive;
@@ -190,7 +188,7 @@
mNavigationBarView.getDownHitTarget() == HIT_TARGET_DEAD_ZONE;
if (mOverviewEventSender.getProxy() == null || (!mNavigationBarView.isQuickScrubEnabled()
&& !mNavigationBarView.isQuickStepSwipeUpEnabled())) {
- return false;
+ return deadZoneConsumed;
}
mNavigationBarView.requestUnbufferedDispatch(event);
@@ -221,6 +219,7 @@
mNavigationBarView.transformMatrixToLocal(mTransformLocalMatrix);
mQuickStepStarted = false;
mAllowGestureDetection = true;
+ mNotificationsVisibleOnDown = !mNavigationBarView.isNotificationsFullyCollapsed();
break;
}
case MotionEvent.ACTION_MOVE: {
@@ -257,7 +256,8 @@
// Decide to start quickstep if dragging away from the navigation bar, otherwise in
// the parallel direction, decide to start quickscrub. Only one may run.
if (!mQuickScrubActive && exceededSwipeUpTouchSlop) {
- if (mNavigationBarView.isQuickStepSwipeUpEnabled()) {
+ if (mNavigationBarView.isQuickStepSwipeUpEnabled()
+ && !mNotificationsVisibleOnDown) {
startQuickStep(event);
}
break;
@@ -303,15 +303,28 @@
break;
}
- // Proxy motion events to launcher if not handled by quick scrub
- // Proxy motion events up/cancel that would be sent after long press on any nav button
- if (!mQuickScrubActive && !mIsInScreenPinning && (mAllowGestureDetection
- || action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP)) {
+ if (shouldProxyEvents(action)) {
proxyMotionEvents(event);
}
return mQuickScrubActive || mQuickStepStarted || deadZoneConsumed;
}
+ private boolean shouldProxyEvents(int action) {
+ if (!mQuickScrubActive && !mIsInScreenPinning) {
+ // Allow down, cancel and up events, move and other events are passed if notifications
+ // are not showing and disabled gestures (such as long press) are not executed
+ switch (action) {
+ case MotionEvent.ACTION_DOWN:
+ case MotionEvent.ACTION_CANCEL:
+ case MotionEvent.ACTION_UP:
+ return true;
+ default:
+ return !mNotificationsVisibleOnDown && mAllowGestureDetection;
+ }
+ }
+ return false;
+ }
+
@Override
public void onDraw(Canvas canvas) {
if (!mNavigationBarView.isQuickScrubEnabled()) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index cd0255b..3701eaf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -3924,6 +3924,7 @@
mDozeScrimController.setDozing(mDozing);
mKeyguardIndicationController.setDozing(mDozing);
mNotificationPanel.setDozing(mDozing, animate);
+ mNotificationLogger.setDozing(mDozing);
updateQsExpansionEnabled();
Trace.endSection();
}
diff --git a/packages/SystemUI/tests/src/com/android/AAAPlusPlusVerifySysuiRequiredTestPropertiesTest.java b/packages/SystemUI/tests/src/com/android/AAAPlusPlusVerifySysuiRequiredTestPropertiesTest.java
index 6792bc0..7f83ed6 100644
--- a/packages/SystemUI/tests/src/com/android/AAAPlusPlusVerifySysuiRequiredTestPropertiesTest.java
+++ b/packages/SystemUI/tests/src/com/android/AAAPlusPlusVerifySysuiRequiredTestPropertiesTest.java
@@ -19,6 +19,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
+import android.content.pm.PackageManager;
import android.support.test.filters.LargeTest;
import android.support.test.filters.MediumTest;
import android.support.test.filters.SmallTest;
@@ -115,6 +116,13 @@
filter.add(new ExternalClassNameFilter());
filter.add(s -> s.startsWith("com.android.systemui")
|| s.startsWith("com.android.keyguard"));
+
+
+ if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
+ // If it's not automotive target, exclude automotive classes from the test.
+ excludeAutomotiveClasses(filter);
+ }
+
try {
return scanner.getClassPathEntries(filter);
} catch (IOException e) {
@@ -123,6 +131,13 @@
return Collections.emptyList();
}
+ private void excludeAutomotiveClasses(ChainedClassNameFilter filter) {
+ // Modifies the passed in filter.
+ filter.add(s -> !s.startsWith("com.android.systemui.statusbar.car."));
+ filter.add(s -> !s.startsWith("com.android.systemui.qs.car."));
+ filter.add(s -> !s.startsWith("com.android.systemui.car."));
+ }
+
private String getClsStr() {
return TextUtils.join(",", Arrays.asList(BASE_CLS_WHITELIST)
.stream().map(cls -> cls.getSimpleName()).toArray());
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CastControllerImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CastControllerImplTest.java
new file mode 100644
index 0000000..1b22f09
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CastControllerImplTest.java
@@ -0,0 +1,77 @@
+package com.android.systemui.statusbar.policy;
+
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.media.MediaRouter;
+import android.media.projection.MediaProjectionInfo;
+import android.media.projection.MediaProjectionManager;
+import android.support.test.filters.SmallTest;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
+
+import com.android.systemui.SysuiTestCase;
+import com.android.systemui.statusbar.policy.CastController.Callback;
+
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.junit.Test;
+
+@SmallTest
+@RunWith(AndroidTestingRunner.class)
+@TestableLooper.RunWithLooper
+public class CastControllerImplTest extends SysuiTestCase {
+
+ @Mock
+ MediaRouter mMediaRouter;
+ @Mock
+ MediaProjectionManager mMediaProjectionManager;
+ @Mock
+ MediaProjectionInfo mProjection;
+
+ private CastControllerImpl mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext.addMockSystemService(MediaRouter.class, mMediaRouter);
+ mContext.addMockSystemService(MediaProjectionManager.class, mMediaProjectionManager);
+ when(mMediaProjectionManager.getActiveProjectionInfo()).thenReturn(mProjection);
+
+ mController = new CastControllerImpl(mContext);
+ }
+
+ @Test
+ public void testAddCallback(){
+ Callback mockCallback = mock(Callback.class);
+
+ mController.addCallback(mockCallback);
+ verify(mockCallback,times(1)).onCastDevicesChanged();
+ }
+
+ @Test
+ public void testRemoveCallback(){
+ Callback mockCallback = mock(Callback.class);
+
+ mController.addCallback(mockCallback);
+ verify(mockCallback, times(1)).onCastDevicesChanged();
+
+ mController.removeCallback(mockCallback);
+ verify(mockCallback, times(1)).onCastDevicesChanged();
+ }
+
+ @Test
+ public void testRemoveCallbackFromEmptyList(){
+ Callback mockCallback = mock(Callback.class);
+
+ mController.removeCallback(mockCallback);
+ verify(mockCallback, never()).onCastDevicesChanged();
+ }
+}
diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java
index f81541e..a07939e 100644
--- a/services/core/java/com/android/server/BluetoothManagerService.java
+++ b/services/core/java/com/android/server/BluetoothManagerService.java
@@ -1171,6 +1171,26 @@
}
private boolean bindService() {
+ int state = BluetoothAdapter.STATE_OFF;
+ try {
+ mBluetoothLock.readLock().lock();
+ if (mBluetooth != null) {
+ state = mBluetooth.getState();
+ }
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Unable to call getState", e);
+ return false;
+ } finally {
+ mBluetoothLock.readLock().unlock();
+ }
+
+ if (!mEnable || state != BluetoothAdapter.STATE_ON) {
+ if (DBG) {
+ Slog.d(TAG, "Unable to bindService while Bluetooth is disabled");
+ }
+ return false;
+ }
+
if (mIntent != null && mService == null && doBind(mIntent, this, 0,
UserHandle.CURRENT_OR_SELF)) {
Message msg = mHandler.obtainMessage(MESSAGE_BIND_PROFILE_SERVICE);
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index ad9fa40..566ce4f 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -36,6 +36,7 @@
import android.telephony.CellLocation;
import android.telephony.DisconnectCause;
import android.telephony.LocationAccessPolicy;
+import android.telephony.PhoneCapability;
import android.telephony.PhoneStateListener;
import android.telephony.PhysicalChannelConfig;
import android.telephony.PreciseCallState;
@@ -47,7 +48,6 @@
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.VoLteServiceState;
-import android.text.TextUtils;
import android.util.LocalLog;
import com.android.internal.app.IBatteryStats;
@@ -200,6 +200,8 @@
private boolean mCarrierNetworkChangeState = false;
+ private PhoneCapability mPhoneCapability = null;
+
private final LocalLog mLocalLog = new LocalLog(100);
private PreciseDataConnectionState mPreciseDataConnectionState =
@@ -658,6 +660,13 @@
remove(r.binder);
}
}
+ if ((events & PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE) != 0) {
+ try {
+ r.callback.onPhoneCapabilityChanged(mPhoneCapability);
+ } catch (RemoteException ex) {
+ remove(r.binder);
+ }
+ }
}
}
} else {
@@ -1453,6 +1462,33 @@
}
}
+ public void notifyPhoneCapabilityChanged(PhoneCapability capability) {
+ if (!checkNotifyPermission("notifyPhoneCapabilityChanged()")) {
+ return;
+ }
+
+ if (VDBG) {
+ log("notifyPhoneCapabilityChanged: capability=" + capability);
+ }
+
+ synchronized (mRecords) {
+ mPhoneCapability = capability;
+
+ for (Record r : mRecords) {
+ if (r.matchPhoneStateListenerEvent(
+ PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE)) {
+ try {
+ r.callback.onPhoneCapabilityChanged(capability);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
+ }
+ }
+ }
+ handleRemoveListLocked();
+ }
+ }
+
+
@Override
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ");
@@ -1488,6 +1524,7 @@
pw.println("mForegroundCallState=" + mForegroundCallState);
pw.println("mBackgroundCallState=" + mBackgroundCallState);
pw.println("mVoLteServiceState=" + mVoLteServiceState);
+ pw.println("mPhoneCapability=" + mPhoneCapability);
pw.decreaseIndent();
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index f074319..dd3e2d4 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -72,7 +72,6 @@
import static android.service.notification.NotificationListenerService.REASON_USER_STOPPED;
import static android.service.notification.NotificationListenerService.TRIM_FULL;
import static android.service.notification.NotificationListenerService.TRIM_LIGHT;
-import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
import static com.android.server.utils.PriorityDump.PRIORITY_ARG;
@@ -2694,24 +2693,30 @@
try {
synchronized (mNotificationLock) {
final ManagedServiceInfo info = mListeners.checkServiceTokenLocked(token);
- if (keys != null) {
- final int N = keys.length;
- for (int i = 0; i < N; i++) {
- NotificationRecord r = mNotificationsByKey.get(keys[i]);
- if (r == null) continue;
- final int userId = r.sbn.getUserId();
- if (userId != info.userid && userId != UserHandle.USER_ALL &&
- !mUserProfiles.isCurrentProfile(userId)) {
- throw new SecurityException("Disallowed call from listener: "
- + info.service);
- }
- if (!r.isSeen()) {
- if (DBG) Slog.d(TAG, "Marking notification as seen " + keys[i]);
- reportSeen(r);
- r.setSeen();
- maybeRecordInterruptionLocked(r);
- }
+ if (keys == null) {
+ return;
+ }
+ ArrayList<NotificationRecord> seen = new ArrayList<>();
+ final int n = keys.length;
+ for (int i = 0; i < n; i++) {
+ NotificationRecord r = mNotificationsByKey.get(keys[i]);
+ if (r == null) continue;
+ final int userId = r.sbn.getUserId();
+ if (userId != info.userid && userId != UserHandle.USER_ALL
+ && !mUserProfiles.isCurrentProfile(userId)) {
+ throw new SecurityException("Disallowed call from listener: "
+ + info.service);
}
+ seen.add(r);
+ if (!r.isSeen()) {
+ if (DBG) Slog.d(TAG, "Marking notification as seen " + keys[i]);
+ reportSeen(r);
+ r.setSeen();
+ maybeRecordInterruptionLocked(r);
+ }
+ }
+ if (!seen.isEmpty()) {
+ mAssistants.onNotificationsSeenLocked(seen);
}
}
} finally {
@@ -6556,6 +6561,35 @@
rebindServices(true);
}
+ protected void onNotificationsSeenLocked(ArrayList<NotificationRecord> records) {
+ // There should be only one, but it's a list, so while we enforce
+ // singularity elsewhere, we keep it general here, to avoid surprises.
+ for (final ManagedServiceInfo info : NotificationAssistants.this.getServices()) {
+ ArrayList<String> keys = new ArrayList<>(records.size());
+ for (NotificationRecord r : records) {
+ boolean sbnVisible = isVisibleToListener(r.sbn, info)
+ && info.isSameUser(r.getUserId());
+ if (sbnVisible) {
+ keys.add(r.getKey());
+ }
+ }
+
+ if (!keys.isEmpty()) {
+ mHandler.post(() -> notifySeen(info, keys));
+ }
+ }
+ }
+
+ private void notifySeen(final ManagedServiceInfo info,
+ final ArrayList<String> keys) {
+ final INotificationListener assistant = (INotificationListener) info.service;
+ try {
+ assistant.onNotificationsSeen(keys);
+ } catch (RemoteException ex) {
+ Log.e(TAG, "unable to notify assistant (seen): " + assistant, ex);
+ }
+ }
+
public void onNotificationEnqueued(final NotificationRecord r) {
final StatusBarNotification sbn = r.sbn;
TrimCache trimCache = new TrimCache(sbn);
diff --git a/services/core/java/com/android/server/pm/permission/BasePermission.java b/services/core/java/com/android/server/pm/permission/BasePermission.java
index 1d002ef..8202580 100644
--- a/services/core/java/com/android/server/pm/permission/BasePermission.java
+++ b/services/core/java/com/android/server/pm/permission/BasePermission.java
@@ -39,6 +39,7 @@
import com.android.server.pm.DumpState;
import com.android.server.pm.PackageManagerService;
+import com.android.server.pm.PackageSetting;
import com.android.server.pm.PackageSettingBase;
import org.xmlpull.v1.XmlPullParser;
@@ -374,8 +375,10 @@
}
public void enforceDeclaredUsedAndRuntimeOrDevelopment(PackageParser.Package pkg) {
+ final PackageSetting pkgSetting = (PackageSetting) pkg.mExtras;
+ final PermissionsState permsState = pkgSetting.getPermissionsState();
int index = pkg.requestedPermissions.indexOf(name);
- if (index == -1) {
+ if (!permsState.hasRequestedPermission(name) && index == -1) {
throw new SecurityException("Package " + pkg.packageName
+ " has not requested permission " + name);
}
diff --git a/services/core/java/com/android/server/pm/permission/PermissionsState.java b/services/core/java/com/android/server/pm/permission/PermissionsState.java
index 11df380..5e66bfc3 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionsState.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionsState.java
@@ -20,9 +20,9 @@
import android.os.UserHandle;
import android.util.ArrayMap;
import android.util.ArraySet;
-
import android.util.SparseArray;
import android.util.SparseBooleanArray;
+
import com.android.internal.util.ArrayUtils;
import java.util.ArrayList;
@@ -291,6 +291,13 @@
}
/**
+ * Returns whether the state has any known request for the given permission name,
+ * whether or not it has been granted.
+ */
+ public boolean hasRequestedPermission(String name) {
+ return mPermissions != null && (mPermissions.get(name) != null);
+ }
+ /**
* Gets all permissions for a given device user id regardless if they
* are install time or runtime permissions.
*
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 13800b6..91d4717 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -288,6 +288,9 @@
private long mLastWakeTime;
private long mLastSleepTime;
+ // Last reason the device went to sleep.
+ private int mLastSleepReason;
+
// Timestamp of the last call to user activity.
private long mLastUserActivityTime;
private long mLastUserActivityTimeNoChangeLights;
@@ -1433,6 +1436,7 @@
}
mLastSleepTime = eventTime;
+ mLastSleepReason = reason;
mSandmanSummoned = true;
setWakefulnessLocked(WAKEFULNESS_DOZING, reason);
@@ -3266,6 +3270,7 @@
pw.println(" mDeviceIdleTempWhitelist=" + Arrays.toString(mDeviceIdleTempWhitelist));
pw.println(" mLastWakeTime=" + TimeUtils.formatUptime(mLastWakeTime));
pw.println(" mLastSleepTime=" + TimeUtils.formatUptime(mLastSleepTime));
+ pw.println(" mLastSleepReason=" + PowerManager.sleepReasonToString(mLastSleepReason));
pw.println(" mLastUserActivityTime=" + TimeUtils.formatUptime(mLastUserActivityTime));
pw.println(" mLastUserActivityTimeNoChangeLights="
+ TimeUtils.formatUptime(mLastUserActivityTimeNoChangeLights));
@@ -4404,6 +4409,19 @@
}
}
+ @Override // Binder call
+ public int getLastSleepReason() {
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.DEVICE_POWER, null);
+
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ return getLastSleepReasonInternal();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
/**
* Reboots the device.
*
@@ -4619,6 +4637,12 @@
}
}
+ private int getLastSleepReasonInternal() {
+ synchronized (mLock) {
+ return mLastSleepReason;
+ }
+ }
+
private final class LocalService extends PowerManagerInternal {
@Override
public void setScreenBrightnessOverrideFromWindowManager(int screenBrightness) {
diff --git a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
index 519881e..f418ad4 100644
--- a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
+++ b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
@@ -80,6 +80,7 @@
private int mDisabled2 = 0;
private final Object mLock = new Object();
+ private final DeathRecipient mDeathRecipient = new DeathRecipient();
// encompasses lights-out mode and other flags defined on View
private int mSystemUiVisibility = 0;
private int mFullscreenStackSysUiVisibility;
@@ -93,6 +94,23 @@
private IBinder mImeToken = null;
private int mCurrentUserId;
+ private class DeathRecipient implements IBinder.DeathRecipient {
+ public void binderDied() {
+ mBar.asBinder().unlinkToDeath(this,0);
+ mBar = null;
+ notifyBarAttachChanged();
+ }
+
+ public void linkToDeath() {
+ try {
+ mBar.asBinder().linkToDeath(mDeathRecipient,0);
+ } catch (RemoteException e) {
+ Slog.e(TAG,"Unable to register Death Recipient for status bar", e);
+ }
+ }
+
+ }
+
private class DisableRecord implements IBinder.DeathRecipient {
int userId;
String pkg;
@@ -859,16 +877,7 @@
Slog.i(TAG, "registerStatusBar bar=" + bar);
mBar = bar;
- try {
- mBar.asBinder().linkToDeath(new DeathRecipient() {
- @Override
- public void binderDied() {
- mBar = null;
- notifyBarAttachChanged();
- }
- }, 0);
- } catch (RemoteException e) {
- }
+ mDeathRecipient.linkToDeath();
notifyBarAttachChanged();
synchronized (mIcons) {
for (String slot : mIcons.keySet()) {
diff --git a/telephony/java/android/telephony/ModemInfo.java b/telephony/java/android/telephony/ModemInfo.java
new file mode 100644
index 0000000..564effe
--- /dev/null
+++ b/telephony/java/android/telephony/ModemInfo.java
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+
+package android.telephony;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Objects;
+
+/**
+ * Information of a single logical modem indicating
+ * its id, supported rats and whether it supports voice or data, etc.
+ * @hide
+ */
+public class ModemInfo implements Parcelable {
+ public final int modemId;
+ public final int rat; /* bitset */
+ public final boolean isVoiceSupported;
+ public final boolean isDataSupported;
+
+ public ModemInfo(int modemId, int rat, boolean isVoiceSupported, boolean isDataSupported) {
+ this.modemId = modemId;
+ this.rat = rat;
+ this.isVoiceSupported = isVoiceSupported;
+ this.isDataSupported = isDataSupported;
+ }
+
+ public ModemInfo(Parcel in) {
+ modemId = in.readInt();
+ rat = in.readInt();
+ isVoiceSupported = in.readBoolean();
+ isDataSupported = in.readBoolean();
+ }
+
+ @Override
+ public String toString() {
+ return "modemId=" + modemId + " rat=" + rat + " isVoiceSupported:" + isVoiceSupported
+ + " isDataSupported:" + isDataSupported;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(modemId, rat, isVoiceSupported, isDataSupported);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null || !(o instanceof ModemInfo) || hashCode() != o.hashCode()) {
+ return false;
+ }
+
+ if (this == o) {
+ return true;
+ }
+
+ ModemInfo s = (ModemInfo) o;
+
+ return (modemId == s.modemId
+ && rat == s.rat
+ && isVoiceSupported == s.isVoiceSupported
+ && isDataSupported == s.isDataSupported);
+ }
+
+ /**
+ * {@link Parcelable#describeContents}
+ */
+ public @ContentsFlags int describeContents() {
+ return 0;
+ }
+
+ /**
+ * {@link Parcelable#writeToParcel}
+ */
+ public void writeToParcel(Parcel dest, @WriteFlags int flags) {
+ dest.writeInt(modemId);
+ dest.writeInt(rat);
+ dest.writeBoolean(isVoiceSupported);
+ dest.writeBoolean(isDataSupported);
+ }
+
+ public static final Parcelable.Creator<ModemInfo> CREATOR = new Parcelable.Creator() {
+ public ModemInfo createFromParcel(Parcel in) {
+ return new ModemInfo(in);
+ }
+
+ public ModemInfo[] newArray(int size) {
+ return new ModemInfo[size];
+ }
+ };
+}
diff --git a/telephony/java/android/telephony/PhoneCapability.aidl b/telephony/java/android/telephony/PhoneCapability.aidl
new file mode 100644
index 0000000..5de8d4a
--- /dev/null
+++ b/telephony/java/android/telephony/PhoneCapability.aidl
@@ -0,0 +1,20 @@
+/*
+**
+** Copyright 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.
+*/
+
+package android.telephony;
+
+parcelable PhoneCapability;
\ No newline at end of file
diff --git a/telephony/java/android/telephony/PhoneCapability.java b/telephony/java/android/telephony/PhoneCapability.java
new file mode 100644
index 0000000..2ebfa53
--- /dev/null
+++ b/telephony/java/android/telephony/PhoneCapability.java
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+
+package android.telephony;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Define capability of a modem group. That is, the capabilities
+ * are shared between those modems defined by list of modem IDs.
+ * @hide
+ */
+public class PhoneCapability implements Parcelable {
+ public final int maxActiveVoiceCalls;
+ public final int maxActiveData;
+ public final int max5G;
+ public final List<ModemInfo> logicalModemList;
+
+ public PhoneCapability(int maxActiveVoiceCalls, int maxActiveData, int max5G,
+ List<ModemInfo> logicalModemList) {
+ this.maxActiveVoiceCalls = maxActiveVoiceCalls;
+ this.maxActiveData = maxActiveData;
+ this.max5G = max5G;
+ // Make sure it's not null.
+ this.logicalModemList = logicalModemList == null ? new ArrayList<>() : logicalModemList;
+ }
+
+ @Override
+ public String toString() {
+ return "maxActiveVoiceCalls=" + maxActiveVoiceCalls + " maxActiveData=" + maxActiveData
+ + " max5G=" + max5G + "logicalModemList:"
+ + Arrays.toString(logicalModemList.toArray());
+ }
+
+ private PhoneCapability(Parcel in) {
+ maxActiveVoiceCalls = in.readInt();
+ maxActiveData = in.readInt();
+ max5G = in.readInt();
+ logicalModemList = new ArrayList<>();
+ in.readList(logicalModemList, ModemInfo.class.getClassLoader());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(maxActiveVoiceCalls, maxActiveData, max5G, logicalModemList);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null || !(o instanceof PhoneCapability) || hashCode() != o.hashCode()) {
+ return false;
+ }
+
+ if (this == o) {
+ return true;
+ }
+
+ PhoneCapability s = (PhoneCapability) o;
+
+ return (maxActiveVoiceCalls == s.maxActiveVoiceCalls
+ && maxActiveData == s.maxActiveData
+ && max5G == s.max5G
+ && logicalModemList.equals(s.logicalModemList));
+ }
+
+ /**
+ * {@link Parcelable#describeContents}
+ */
+ public @Parcelable.ContentsFlags int describeContents() {
+ return 0;
+ }
+
+ /**
+ * {@link Parcelable#writeToParcel}
+ */
+ public void writeToParcel(Parcel dest, @Parcelable.WriteFlags int flags) {
+ dest.writeInt(maxActiveVoiceCalls);
+ dest.writeInt(maxActiveData);
+ dest.writeInt(max5G);
+ dest.writeList(logicalModemList);
+ }
+
+ public static final Parcelable.Creator<PhoneCapability> CREATOR = new Parcelable.Creator() {
+ public PhoneCapability createFromParcel(Parcel in) {
+ return new PhoneCapability(in);
+ }
+
+ public PhoneCapability[] newArray(int size) {
+ return new PhoneCapability[size];
+ }
+ };
+}
diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java
index 7f7ce8e..bd6a59d 100644
--- a/telephony/java/android/telephony/PhoneStateListener.java
+++ b/telephony/java/android/telephony/PhoneStateListener.java
@@ -22,12 +22,11 @@
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
-import android.telecom.TelecomManager;
import com.android.internal.telephony.IPhoneStateListener;
-import java.util.List;
import java.lang.ref.WeakReference;
+import java.util.List;
/**
* A listener class for monitoring changes in specific telephony states
@@ -273,6 +272,14 @@
*/
public static final int LISTEN_PHYSICAL_CHANNEL_CONFIGURATION = 0x00100000;
+ /**
+ * Listen for changes to the phone capability.
+ *
+ * @see #onPhoneCapabilityChanged
+ * @hide
+ */
+ public static final int LISTEN_PHONE_CAPABILITY_CHANGE = 0x00200000;
+
/*
* Subscription used to listen to the phone state changes
* @hide
@@ -395,6 +402,10 @@
PhoneStateListener.this.onPhysicalChannelConfigurationChanged(
(List<PhysicalChannelConfig>)msg.obj);
break;
+ case LISTEN_PHONE_CAPABILITY_CHANGE:
+ PhoneStateListener.this.onPhoneCapabilityChanged(
+ (PhoneCapability) msg.obj);
+ break;
}
}
};
@@ -625,6 +636,16 @@
}
/**
+ * Callback invoked when phone capability changes. Requires
+ * the READ_PRIVILEGED_PHONE_STATE permission.
+ * @param capability the new phone capability
+ * @hide
+ */
+ public void onPhoneCapabilityChanged(PhoneCapability capability) {
+ // default implementation empty
+ }
+
+ /**
* Callback invoked when telephony has received notice from a carrier
* app that a network action that could result in connectivity loss
* has been requested by an app using
@@ -751,6 +772,10 @@
public void onPhysicalChannelConfigurationChanged(List<PhysicalChannelConfig> configs) {
send(LISTEN_PHYSICAL_CHANNEL_CONFIGURATION, 0, 0, configs);
}
+
+ public void onPhoneCapabilityChanged(PhoneCapability capability) {
+ send(LISTEN_PHONE_CAPABILITY_CHANGE, 0, 0, capability);
+ }
}
@UnsupportedAppUsage
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 3a8dba8..81d0d68 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -8075,4 +8075,23 @@
}
return UNKNOWN_CARRIER_ID_LIST_VERSION;
}
+
+
+ /**
+ * How many modems can have simultaneous data connections.
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
+ public int getNumberOfModemsWithSimultaneousDataConnections() {
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ return telephony.getNumberOfModemsWithSimultaneousDataConnections(
+ getSubId(), mContext.getOpPackageName());
+ }
+ } catch (RemoteException ex) {
+ // This could happen if binder process crashes.
+ }
+ return 0;
+ }
}
diff --git a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl
index 0d315e5..1ebb697 100644
--- a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl
+++ b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl
@@ -21,6 +21,7 @@
import android.telephony.SignalStrength;
import android.telephony.CellInfo;
import android.telephony.DataConnectionRealTimeInfo;
+import android.telephony.PhoneCapability;
import android.telephony.PhysicalChannelConfig;
import android.telephony.PreciseCallState;
import android.telephony.PreciseDataConnectionState;
@@ -50,5 +51,6 @@
void onOemHookRawEvent(in byte[] rawData);
void onCarrierNetworkChange(in boolean active);
void onUserMobileDataStateChanged(in boolean enabled);
+ void onPhoneCapabilityChanged(in PhoneCapability capability);
}
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index f9c3940..c59a739 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -1531,4 +1531,10 @@
* @hide
*/
void refreshUiccProfile(int subId);
+
+ /**
+ * How many modems can have simultaneous data connections.
+ * @hide
+ */
+ int getNumberOfModemsWithSimultaneousDataConnections(int subId, String callingPackage);
}
diff --git a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl
index 0127db9..e0e1a7b 100644
--- a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl
@@ -21,6 +21,7 @@
import android.net.NetworkCapabilities;
import android.os.Bundle;
import android.telephony.CellInfo;
+import android.telephony.PhoneCapability;
import android.telephony.PhysicalChannelConfig;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
@@ -74,4 +75,5 @@
void notifySubscriptionInfoChanged();
void notifyCarrierNetworkChange(in boolean active);
void notifyUserMobileDataStateChangedForPhoneId(in int phoneId, in int subId, in boolean state);
+ void notifyPhoneCapabilityChanged(in PhoneCapability capability);
}
diff --git a/tools/aapt2/format/Container.cpp b/tools/aapt2/format/Container.cpp
index 739555c..d4b4571 100644
--- a/tools/aapt2/format/Container.cpp
+++ b/tools/aapt2/format/Container.cpp
@@ -270,7 +270,8 @@
}
if (magic != kContainerFormatMagic) {
- error_ = "magic value doesn't match AAPT";
+ error_ =
+ StringPrintf("magic value is 0x%08x but AAPT expects 0x%08x", magic, kContainerFormatMagic);
return;
}
diff --git a/tools/aapt2/format/binary/TableFlattener.cpp b/tools/aapt2/format/binary/TableFlattener.cpp
index 6fd4c8d..8641a7c 100644
--- a/tools/aapt2/format/binary/TableFlattener.cpp
+++ b/tools/aapt2/format/binary/TableFlattener.cpp
@@ -133,11 +133,10 @@
}
void Visit(Array* array) override {
- for (auto& item : array->elements) {
- ResTable_map* out_entry = buffer_->NextBlock<ResTable_map>();
- FlattenValue(item.get(), out_entry);
- out_entry->value.size = util::HostToDevice16(sizeof(out_entry->value));
- entry_count_++;
+ const size_t count = array->elements.size();
+ for (size_t i = 0; i < count; i++) {
+ Reference key(android::ResTable_map::ATTR_MIN + i);
+ FlattenEntry(&key, array->elements[i].get());
}
}
diff --git a/tools/aapt2/format/binary/TableFlattener_test.cpp b/tools/aapt2/format/binary/TableFlattener_test.cpp
index bab7010..af19b98 100644
--- a/tools/aapt2/format/binary/TableFlattener_test.cpp
+++ b/tools/aapt2/format/binary/TableFlattener_test.cpp
@@ -17,7 +17,9 @@
#include "format/binary/TableFlattener.h"
#include "android-base/stringprintf.h"
+#include "androidfw/TypeWrappers.h"
+#include "ResChunkPullParser.h"
#include "ResourceUtils.h"
#include "SdkConstants.h"
#include "format/binary/BinaryResourceParser.h"
@@ -236,6 +238,62 @@
EXPECT_EQ(attr.max_int, actual_attr->max_int);
}
+TEST_F(TableFlattenerTest, FlattenArray) {
+ auto array = util::make_unique<Array>();
+ array->elements.push_back(util::make_unique<BinaryPrimitive>(uint8_t(Res_value::TYPE_INT_DEC),
+ 1u));
+ array->elements.push_back(util::make_unique<BinaryPrimitive>(uint8_t(Res_value::TYPE_INT_DEC),
+ 2u));
+ std::unique_ptr<ResourceTable> table =
+ test::ResourceTableBuilder()
+ .SetPackageId("android", 0x01)
+ .AddValue("android:array/foo", ResourceId(0x01010000), std::move(array))
+ .Build();
+
+ std::string result;
+ ASSERT_TRUE(Flatten(context_.get(), {}, table.get(), &result));
+
+ // Parse the flattened resource table
+ ResChunkPullParser parser(result.data(), result.size());
+ ASSERT_TRUE(parser.IsGoodEvent(parser.Next()));
+ ASSERT_EQ(util::DeviceToHost16(parser.chunk()->type), RES_TABLE_TYPE);
+
+ // Retrieve the package of the entry
+ ResChunkPullParser table_parser(GetChunkData(parser.chunk()), GetChunkDataLen(parser.chunk()));
+ const ResChunk_header* package_chunk = nullptr;
+ while (table_parser.IsGoodEvent(table_parser.Next())) {
+ if (util::DeviceToHost16(table_parser.chunk()->type) == RES_TABLE_PACKAGE_TYPE) {
+ package_chunk = table_parser.chunk();
+ break;
+ }
+ }
+
+ // Retrieve the type that proceeds the array entry
+ ASSERT_NE(package_chunk, nullptr);
+ ResChunkPullParser package_parser(GetChunkData(table_parser.chunk()),
+ GetChunkDataLen(table_parser.chunk()));
+ const ResChunk_header* type_chunk = nullptr;
+ while (package_parser.IsGoodEvent(package_parser.Next())) {
+ if (util::DeviceToHost16(package_parser.chunk()->type) == RES_TABLE_TYPE_TYPE) {
+ type_chunk = package_parser.chunk();
+ break;
+ }
+ }
+
+ // Retrieve the array entry
+ ASSERT_NE(type_chunk, nullptr);
+ TypeVariant typeVariant((const ResTable_type*) type_chunk);
+ auto entry = (const ResTable_map_entry*)*typeVariant.beginEntries();
+ ASSERT_EQ(util::DeviceToHost16(entry->count), 2u);
+
+ // Check that the value and name of the array entries are correct
+ auto values = (const ResTable_map*)(((const uint8_t *)entry) + entry->size);
+ ASSERT_EQ(values->value.data, 1u);
+ ASSERT_EQ(values->name.ident, android::ResTable_map::ATTR_MIN);
+ ASSERT_EQ((values+1)->value.data, 2u);
+ ASSERT_EQ((values+1)->name.ident, android::ResTable_map::ATTR_MIN + 1);
+}
+
static std::unique_ptr<ResourceTable> BuildTableWithSparseEntries(
IAaptContext* context, const ConfigDescription& sparse_config, float load) {
std::unique_ptr<ResourceTable> table =
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index 5631919..12f50c8 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -126,7 +126,7 @@
void acquireMulticastLock(IBinder binder, String tag);
- void releaseMulticastLock();
+ void releaseMulticastLock(String tag);
void updateInterfaceIpState(String ifaceName, int mode);
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index f7de370..b56a758 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -318,6 +318,31 @@
"android.net.wifi.extra.SUBSCRIPTION_REMEDIATION_METHOD";
/**
+ * Activity Action: lunch OSU (Online Sign Up) view.
+ * Included extras:
+ *
+ * {@link #EXTRA_OSU_NETWORK}: {@link Network} instance associated with OSU AP.
+ * {@link #EXTRA_URL}: String representation of a server URL used for OSU process.
+ *
+ * <p>Note: The broadcast is only delivered to registered receivers - no manifest registered
+ * components will be launched.
+ *
+ * @hide
+ */
+ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+ public static final String ACTION_PASSPOINT_LAUNCH_OSU_VIEW =
+ "android.net.wifi.action.PASSPOINT_LAUNCH_OSU_VIEW";
+
+ /**
+ * The lookup key for a {@link android.net.Network} associated with OSU server.
+ *
+ * Retrieve with {@link android.content.Intent#getParcelableExtra(String)}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_OSU_NETWORK = "android.net.wifi.extra.OSU_NETWORK";
+
+ /**
* Broadcast intent action indicating that Wi-Fi has been enabled, disabled,
* enabling, disabling, or unknown. One extra provides this state as an int.
* Another extra provides the previous state, if available.
@@ -3409,7 +3434,7 @@
mService.acquireMulticastLock(mBinder, mTag);
synchronized (WifiManager.this) {
if (mActiveLockCount >= MAX_ACTIVE_LOCKS) {
- mService.releaseMulticastLock();
+ mService.releaseMulticastLock(mTag);
throw new UnsupportedOperationException(
"Exceeded maximum number of wifi locks");
}
@@ -3451,7 +3476,7 @@
synchronized (mBinder) {
if (mRefCounted ? (--mRefCount == 0) : (mHeld)) {
try {
- mService.releaseMulticastLock();
+ mService.releaseMulticastLock(mTag);
synchronized (WifiManager.this) {
mActiveLockCount--;
}
diff --git a/wifi/java/android/net/wifi/hotspot2/ProvisioningCallback.java b/wifi/java/android/net/wifi/hotspot2/ProvisioningCallback.java
index 66297fc..ef9c59f 100644
--- a/wifi/java/android/net/wifi/hotspot2/ProvisioningCallback.java
+++ b/wifi/java/android/net/wifi/hotspot2/ProvisioningCallback.java
@@ -85,6 +85,17 @@
public static final int OSU_FAILURE_SOAP_MESSAGE_EXCHANGE = 11;
/**
+ * The reason code for provisioning failure when a redirect server fails to start.
+ */
+ public static final int OSU_FAILURE_START_REDIRECT_SERVER = 12;
+
+ /**
+ * The reason code for provisioning failure when there is no OSU activity to listen to
+ * {@link WifiManager#ACTION_PASSPOINT_LAUNCH_OSU_VIEW} intent.
+ */
+ public static final int OSU_FAILURE_NO_OSU_ACTIVITY_FOUND = 13;
+
+ /**
* The status code for provisioning flow to indicate connecting to OSU AP
*/
public static final int OSU_STATUS_AP_CONNECTING = 1;
@@ -115,6 +126,16 @@
public static final int OSU_STATUS_INIT_SOAP_EXCHANGE = 6;
/**
+ * The status code for provisioning flow to indicate waiting for a HTTP redirect response.
+ */
+ public static final int OSU_STATUS_WAITING_FOR_REDIRECT_RESPONSE = 7;
+
+ /**
+ * The status code for provisioning flow to indicate a HTTP redirect response is received.
+ */
+ public static final int OSU_STATUS_REDIRECT_RESPONSE_RECEIVED = 8;
+
+ /**
* Provisioning status for OSU failure
*
* @param status indicates error condition