summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apex/jobscheduler/framework/java/com/android/server/usage/AppStandbyInternal.java20
-rw-r--r--apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java7
-rw-r--r--apex/jobscheduler/service/java/com/android/server/job/controllers/QuotaController.java9
-rw-r--r--apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java2
-rw-r--r--core/java/android/content/pm/VerificationParams.java211
-rw-r--r--core/proto/android/server/notificationhistory.proto18
-rw-r--r--core/tests/coretests/src/android/content/pm/VerificationParamsTest.java196
-rw-r--r--media/java/android/media/tv/tuner/Tuner.java51
-rw-r--r--media/jni/Android.bp24
-rw-r--r--media/jni/android_media_tv_Tuner.cpp135
-rw-r--r--media/jni/android_media_tv_Tuner.h43
-rw-r--r--services/core/java/android/app/usage/UsageStatsManagerInternal.java (renamed from core/java/android/app/usage/UsageStatsManagerInternal.java)31
-rw-r--r--services/core/java/com/android/server/AlarmManagerService.java8
-rw-r--r--services/core/java/com/android/server/AppStateTracker.java14
-rw-r--r--services/core/java/com/android/server/backup/SystemBackupAgent.java (renamed from core/java/com/android/server/backup/SystemBackupAgent.java)0
-rw-r--r--services/core/java/com/android/server/backup/UsageStatsBackupHelper.java (renamed from core/java/com/android/server/backup/UsageStatsBackupHelper.java)0
-rw-r--r--services/core/java/com/android/server/net/NetworkPolicyManagerService.java10
-rwxr-xr-xservices/core/java/com/android/server/notification/NotificationManagerService.java1
-rw-r--r--services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java13
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java3
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/AlarmManagerServiceTest.java13
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/AppStateTrackerTest.java11
-rw-r--r--services/usage/java/com/android/server/usage/UsageStatsService.java17
23 files changed, 345 insertions, 492 deletions
diff --git a/apex/jobscheduler/framework/java/com/android/server/usage/AppStandbyInternal.java b/apex/jobscheduler/framework/java/com/android/server/usage/AppStandbyInternal.java
index c036c772d7d0..041825c235d0 100644
--- a/apex/jobscheduler/framework/java/com/android/server/usage/AppStandbyInternal.java
+++ b/apex/jobscheduler/framework/java/com/android/server/usage/AppStandbyInternal.java
@@ -1,9 +1,9 @@
package com.android.server.usage;
+import android.annotation.UserIdInt;
import android.app.usage.AppStandbyInfo;
import android.app.usage.UsageEvents;
import android.app.usage.UsageStatsManager.StandbyBuckets;
-import android.app.usage.UsageStatsManagerInternal.AppIdleStateChangeListener;
import android.content.Context;
import android.os.Looper;
@@ -33,6 +33,24 @@ public interface AppStandbyInternal {
}
}
+ /**
+ * Listener interface for notifications that an app's idle state changed.
+ */
+ abstract static class AppIdleStateChangeListener {
+
+ /** Callback to inform listeners that the idle state has changed to a new bucket. */
+ public abstract void onAppIdleStateChanged(String packageName, @UserIdInt int userId,
+ boolean idle, int bucket, int reason);
+
+ /**
+ * Optional callback to inform the listener that the app has transitioned into
+ * an active state due to user interaction.
+ */
+ public void onUserInteractionStarted(String packageName, @UserIdInt int userId) {
+ // No-op by default
+ }
+ }
+
void onBootPhase(int phase);
void postCheckIdleStates(int userId);
diff --git a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
index c3ffad66d829..a1734d8d25d5 100644
--- a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
+++ b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
@@ -37,7 +37,6 @@ import android.app.job.JobSnapshot;
import android.app.job.JobWorkItem;
import android.app.usage.UsageStatsManager;
import android.app.usage.UsageStatsManagerInternal;
-import android.app.usage.UsageStatsManagerInternal.AppIdleStateChangeListener;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -103,6 +102,8 @@ import com.android.server.job.controllers.StorageController;
import com.android.server.job.controllers.TimeController;
import com.android.server.job.restrictions.JobRestriction;
import com.android.server.job.restrictions.ThermalStatusRestriction;
+import com.android.server.usage.AppStandbyInternal;
+import com.android.server.usage.AppStandbyInternal.AppIdleStateChangeListener;
import libcore.util.EmptyArray;
@@ -1295,7 +1296,9 @@ public class JobSchedulerService extends com.android.server.SystemService
// Set up the app standby bucketing tracker
mStandbyTracker = new StandbyTracker();
mUsageStats = LocalServices.getService(UsageStatsManagerInternal.class);
- mUsageStats.addAppIdleStateChangeListener(mStandbyTracker);
+
+ AppStandbyInternal appStandby = LocalServices.getService(AppStandbyInternal.class);
+ appStandby.addListener(mStandbyTracker);
// The job store needs to call back
publishLocalService(JobSchedulerInternal.class, new LocalService());
diff --git a/apex/jobscheduler/service/java/com/android/server/job/controllers/QuotaController.java b/apex/jobscheduler/service/java/com/android/server/job/controllers/QuotaController.java
index 14dce84e686a..cda524418664 100644
--- a/apex/jobscheduler/service/java/com/android/server/job/controllers/QuotaController.java
+++ b/apex/jobscheduler/service/java/com/android/server/job/controllers/QuotaController.java
@@ -35,8 +35,6 @@ import android.app.ActivityManagerInternal;
import android.app.AlarmManager;
import android.app.AppGlobals;
import android.app.IUidObserver;
-import android.app.usage.UsageStatsManagerInternal;
-import android.app.usage.UsageStatsManagerInternal.AppIdleStateChangeListener;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
@@ -70,6 +68,8 @@ import com.android.server.job.ConstantsProto;
import com.android.server.job.JobSchedulerService;
import com.android.server.job.JobServiceContext;
import com.android.server.job.StateControllerProto;
+import com.android.server.usage.AppStandbyInternal;
+import com.android.server.usage.AppStandbyInternal.AppIdleStateChangeListener;
import java.util.ArrayList;
import java.util.List;
@@ -574,9 +574,8 @@ public final class QuotaController extends StateController {
mContext.registerReceiverAsUser(mPackageAddedReceiver, UserHandle.ALL, filter, null, null);
// Set up the app standby bucketing tracker
- UsageStatsManagerInternal usageStats = LocalServices.getService(
- UsageStatsManagerInternal.class);
- usageStats.addAppIdleStateChangeListener(new StandbyTracker());
+ AppStandbyInternal appStandby = LocalServices.getService(AppStandbyInternal.class);
+ appStandby.addListener(new StandbyTracker());
try {
ActivityManager.getService().registerUidObserver(mUidObserver,
diff --git a/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java b/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java
index ecc045995521..bcd8be7b63e0 100644
--- a/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java
+++ b/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java
@@ -53,7 +53,6 @@ import android.app.AppGlobals;
import android.app.usage.AppStandbyInfo;
import android.app.usage.UsageEvents;
import android.app.usage.UsageStatsManager.StandbyBuckets;
-import android.app.usage.UsageStatsManagerInternal.AppIdleStateChangeListener;
import android.appwidget.AppWidgetManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
@@ -102,6 +101,7 @@ import com.android.internal.util.ConcurrentUtils;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.LocalServices;
import com.android.server.usage.AppIdleHistory.AppUsageHistory;
+import com.android.server.usage.AppStandbyInternal.AppIdleStateChangeListener;
import java.io.File;
import java.io.PrintWriter;
diff --git a/core/java/android/content/pm/VerificationParams.java b/core/java/android/content/pm/VerificationParams.java
deleted file mode 100644
index f07216796eb9..000000000000
--- a/core/java/android/content/pm/VerificationParams.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (C) 2012 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.content.pm;
-
-import android.net.Uri;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * Represents verification parameters used to verify packages to be installed.
- *
- * @deprecated callers should migrate to {@link PackageInstaller}.
- * @hide
- */
-@Deprecated
-public class VerificationParams implements Parcelable {
- /** A constant used to indicate that a uid value is not present. */
- public static final int NO_UID = -1;
-
- /** What we print out first when toString() is called. */
- private static final String TO_STRING_PREFIX = "VerificationParams{";
-
- /** The location of the supplementary verification file. */
- private final Uri mVerificationURI;
-
- /** URI referencing where the package was downloaded from. */
- private final Uri mOriginatingURI;
-
- /** HTTP referrer URI associated with the originatingURI. */
- private final Uri mReferrer;
-
- /** UID of the application that the install request originated from. */
- private final int mOriginatingUid;
-
- /** UID of application requesting the install */
- private int mInstallerUid;
-
- /**
- * Creates verification specifications for installing with application verification.
- *
- * @param verificationURI The location of the supplementary verification
- * file. This can be a 'file:' or a 'content:' URI. May be {@code null}.
- * @param originatingURI URI referencing where the package was downloaded
- * from. May be {@code null}.
- * @param referrer HTTP referrer URI associated with the originatingURI.
- * May be {@code null}.
- * @param originatingUid UID of the application that the install request originated
- * from, or NO_UID if not present
- */
- public VerificationParams(Uri verificationURI, Uri originatingURI, Uri referrer,
- int originatingUid) {
- mVerificationURI = verificationURI;
- mOriginatingURI = originatingURI;
- mReferrer = referrer;
- mOriginatingUid = originatingUid;
- mInstallerUid = NO_UID;
- }
-
- public Uri getVerificationURI() {
- return mVerificationURI;
- }
-
- public Uri getOriginatingURI() {
- return mOriginatingURI;
- }
-
- public Uri getReferrer() {
- return mReferrer;
- }
-
- /** return NO_UID if not available */
- public int getOriginatingUid() {
- return mOriginatingUid;
- }
-
- /** @return NO_UID when not set */
- public int getInstallerUid() {
- return mInstallerUid;
- }
-
- public void setInstallerUid(int uid) {
- mInstallerUid = uid;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- if (!(o instanceof VerificationParams)) {
- return false;
- }
-
- final VerificationParams other = (VerificationParams) o;
-
- if (mVerificationURI == null) {
- if (other.mVerificationURI != null) {
- return false;
- }
- } else if (!mVerificationURI.equals(other.mVerificationURI)) {
- return false;
- }
-
- if (mOriginatingURI == null) {
- if (other.mOriginatingURI != null) {
- return false;
- }
- } else if (!mOriginatingURI.equals(other.mOriginatingURI)) {
- return false;
- }
-
- if (mReferrer == null) {
- if (other.mReferrer != null) {
- return false;
- }
- } else if (!mReferrer.equals(other.mReferrer)) {
- return false;
- }
-
- if (mOriginatingUid != other.mOriginatingUid) {
- return false;
- }
-
- if (mInstallerUid != other.mInstallerUid) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int hash = 3;
-
- hash += 5 * (mVerificationURI == null ? 1 : mVerificationURI.hashCode());
- hash += 7 * (mOriginatingURI == null ? 1 : mOriginatingURI.hashCode());
- hash += 11 * (mReferrer == null ? 1 : mReferrer.hashCode());
- hash += 13 * mOriginatingUid;
- hash += 17 * mInstallerUid;
-
- return hash;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder(TO_STRING_PREFIX);
-
- sb.append("mVerificationURI=");
- sb.append(mVerificationURI.toString());
- sb.append(",mOriginatingURI=");
- sb.append(mOriginatingURI.toString());
- sb.append(",mReferrer=");
- sb.append(mReferrer.toString());
- sb.append(",mOriginatingUid=");
- sb.append(mOriginatingUid);
- sb.append(",mInstallerUid=");
- sb.append(mInstallerUid);
- sb.append('}');
-
- return sb.toString();
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeParcelable(mVerificationURI, 0);
- dest.writeParcelable(mOriginatingURI, 0);
- dest.writeParcelable(mReferrer, 0);
- dest.writeInt(mOriginatingUid);
- dest.writeInt(mInstallerUid);
- }
-
-
- private VerificationParams(Parcel source) {
- mVerificationURI = source.readParcelable(Uri.class.getClassLoader());
- mOriginatingURI = source.readParcelable(Uri.class.getClassLoader());
- mReferrer = source.readParcelable(Uri.class.getClassLoader());
- mOriginatingUid = source.readInt();
- mInstallerUid = source.readInt();
- }
-
- public static final @android.annotation.NonNull Parcelable.Creator<VerificationParams> CREATOR =
- new Parcelable.Creator<VerificationParams>() {
- public VerificationParams createFromParcel(Parcel source) {
- return new VerificationParams(source);
- }
-
- public VerificationParams[] newArray(int size) {
- return new VerificationParams[size];
- }
- };
-}
diff --git a/core/proto/android/server/notificationhistory.proto b/core/proto/android/server/notificationhistory.proto
index 148bd7e4b663..1e6ee3f1a3a8 100644
--- a/core/proto/android/server/notificationhistory.proto
+++ b/core/proto/android/server/notificationhistory.proto
@@ -46,7 +46,7 @@ message NotificationHistoryProto {
// The uid of the package that posted the notification
optional int32 uid = 7;
- // The user id of the package that posted the notification
+ // The user id that the notification was posted to
optional int32 user_id = 8;
// The time at which the notification was posted
optional int64 posted_time_ms = 9;
@@ -71,19 +71,19 @@ message NotificationHistoryProto {
optional ImageTypeEnum image_type = 1;
optional string image_bitmap_filename = 2;
optional int32 image_resource_id = 3;
- optional bytes image_data = 4;
- optional string image_uri = 5;
+ optional string image_resource_id_package = 4;
+ optional bytes image_data = 5;
+ optional int32 image_data_length = 6;
+ optional int32 image_data_offset = 7;
+ optional string image_uri = 8;
}
}
- // The time the last entry was written
- optional int64 end_time_ms = 1;
// Pool of strings to save space
- optional StringPool stringpool = 2;
+ optional StringPool string_pool = 1;
// Versioning fields
- optional int32 major_version = 3;
- optional int32 minor_version = 4;
+ optional int32 major_version = 2;
// List of historical notifications
- repeated Notification notification = 5;
+ repeated Notification notification = 3;
}
diff --git a/core/tests/coretests/src/android/content/pm/VerificationParamsTest.java b/core/tests/coretests/src/android/content/pm/VerificationParamsTest.java
deleted file mode 100644
index f6527da0ba1a..000000000000
--- a/core/tests/coretests/src/android/content/pm/VerificationParamsTest.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (C) 2012 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.content.pm;
-
-import android.net.Uri;
-import android.os.Parcel;
-import android.test.AndroidTestCase;
-
-import androidx.test.filters.LargeTest;
-
-/**
- * Tests the android.content.pm.VerificationParams class
- *
- * To test run:
- * ./development/testrunner/runtest.py frameworks-core -c android.content.pm.VerificationParamsTest
- */
-@LargeTest
-public class VerificationParamsTest extends AndroidTestCase {
-
- private final static String VERIFICATION_URI_STRING = "http://verification.uri/path";
- private final static String ORIGINATING_URI_STRING = "http://originating.uri/path";
- private final static String REFERRER_STRING = "http://referrer.uri/path";
- private final static int INSTALLER_UID = 42;
-
- private final static Uri VERIFICATION_URI = Uri.parse(VERIFICATION_URI_STRING);
- private final static Uri ORIGINATING_URI = Uri.parse(ORIGINATING_URI_STRING);
- private final static Uri REFERRER = Uri.parse(REFERRER_STRING);
-
- private final static int ORIGINATING_UID = 10042;
-
- public void testParcel() throws Exception {
- VerificationParams expected = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
- REFERRER, ORIGINATING_UID);
-
- Parcel parcel = Parcel.obtain();
- expected.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
-
- VerificationParams actual = VerificationParams.CREATOR.createFromParcel(parcel);
-
- assertEquals(VERIFICATION_URI, actual.getVerificationURI());
-
- assertEquals(ORIGINATING_URI, actual.getOriginatingURI());
-
- assertEquals(REFERRER, actual.getReferrer());
-
- assertEquals(ORIGINATING_UID, actual.getOriginatingUid());
- }
-
- public void testEquals_Success() throws Exception {
- VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
- REFERRER, ORIGINATING_UID);
-
- VerificationParams params2 = new VerificationParams(
- Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
- Uri.parse(REFERRER_STRING), ORIGINATING_UID);
-
- assertEquals(params1, params2);
- }
-
- public void testEquals_VerificationUri_Failure() throws Exception {
- VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
- REFERRER, ORIGINATING_UID);
-
- VerificationParams params2 = new VerificationParams(
- Uri.parse("http://a.different.uri/"), Uri.parse(ORIGINATING_URI_STRING),
- Uri.parse(REFERRER_STRING), ORIGINATING_UID);
-
- assertFalse(params1.equals(params2));
- }
-
- public void testEquals_OriginatingUri_Failure() throws Exception {
- VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
- REFERRER, ORIGINATING_UID);
-
- VerificationParams params2 = new VerificationParams(
- Uri.parse(VERIFICATION_URI_STRING), Uri.parse("http://a.different.uri/"),
- Uri.parse(REFERRER_STRING), ORIGINATING_UID);
-
- assertFalse(params1.equals(params2));
- }
-
- public void testEquals_Referrer_Failure() throws Exception {
- VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
- REFERRER, ORIGINATING_UID);
-
- VerificationParams params2 = new VerificationParams(
- Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
- Uri.parse("http://a.different.uri/"), ORIGINATING_UID);
-
- assertFalse(params1.equals(params2));
- }
-
- public void testEquals_Originating_Uid_Failure() throws Exception {
- VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
- REFERRER, ORIGINATING_UID);
-
- VerificationParams params2 = new VerificationParams(
- Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
- Uri.parse(REFERRER_STRING), 12345);
-
- assertFalse(params1.equals(params2));
- }
-
- public void testEquals_InstallerUid_Failure() throws Exception {
- VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
- REFERRER, ORIGINATING_UID);
-
- VerificationParams params2 = new VerificationParams(
- Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
- Uri.parse(REFERRER_STRING), ORIGINATING_UID);
- params2.setInstallerUid(INSTALLER_UID);
-
- assertFalse(params1.equals(params2));
- }
-
- public void testHashCode_Success() throws Exception {
- VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
- REFERRER, ORIGINATING_UID);
-
- VerificationParams params2 = new VerificationParams(
- Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
- Uri.parse(REFERRER_STRING), ORIGINATING_UID);
-
- assertEquals(params1.hashCode(), params2.hashCode());
- }
-
- public void testHashCode_VerificationUri_Failure() throws Exception {
- VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
- REFERRER, ORIGINATING_UID);
-
- VerificationParams params2 = new VerificationParams(null, Uri.parse(ORIGINATING_URI_STRING),
- Uri.parse(REFERRER_STRING), ORIGINATING_UID);
-
- assertFalse(params1.hashCode() == params2.hashCode());
- }
-
- public void testHashCode_OriginatingUri_Failure() throws Exception {
- VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
- REFERRER, ORIGINATING_UID);
-
- VerificationParams params2 = new VerificationParams(
- Uri.parse(VERIFICATION_URI_STRING), Uri.parse("http://a.different.uri/"),
- Uri.parse(REFERRER_STRING), ORIGINATING_UID);
-
- assertFalse(params1.hashCode() == params2.hashCode());
- }
-
- public void testHashCode_Referrer_Failure() throws Exception {
- VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
- REFERRER, ORIGINATING_UID);
-
- VerificationParams params2 = new VerificationParams(
- Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING), null,
- ORIGINATING_UID);
-
- assertFalse(params1.hashCode() == params2.hashCode());
- }
-
- public void testHashCode_Originating_Uid_Failure() throws Exception {
- VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
- REFERRER, ORIGINATING_UID);
-
- VerificationParams params2 = new VerificationParams(
- Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
- Uri.parse(REFERRER_STRING), 12345);
-
- assertFalse(params1.hashCode() == params2.hashCode());
- }
-
- public void testHashCode_InstallerUid_Failure() throws Exception {
- VerificationParams params1 = new VerificationParams(VERIFICATION_URI, ORIGINATING_URI,
- REFERRER, ORIGINATING_UID);
-
- VerificationParams params2 = new VerificationParams(
- Uri.parse(VERIFICATION_URI_STRING), Uri.parse(ORIGINATING_URI_STRING),
- Uri.parse(REFERRER_STRING), ORIGINATING_UID);
- params2.setInstallerUid(INSTALLER_UID);
-
- assertFalse(params1.hashCode() == params2.hashCode());
- }
-}
diff --git a/media/java/android/media/tv/tuner/Tuner.java b/media/java/android/media/tv/tuner/Tuner.java
new file mode 100644
index 000000000000..0228dc94fb25
--- /dev/null
+++ b/media/java/android/media/tv/tuner/Tuner.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner;
+
+/**
+ * Tuner is used to interact with tuner devices.
+ *
+ * @hide
+ */
+public final class Tuner implements AutoCloseable {
+ private static final String TAG = "MediaTvTuner";
+ private static final boolean DEBUG = false;
+
+ static {
+ System.loadLibrary("media_tv_tuner");
+ nativeInit();
+ }
+
+ public Tuner() {
+ nativeSetup();
+ }
+
+ private long mNativeContext; // used by native jMediaTuner
+
+ @Override
+ public void close() {}
+
+ /**
+ * Native Initialization.
+ */
+ private static native void nativeInit();
+
+ /**
+ * Native setup.
+ */
+ private native void nativeSetup();
+}
diff --git a/media/jni/Android.bp b/media/jni/Android.bp
index b4edabfb2e8b..a596d89bdcce 100644
--- a/media/jni/Android.bp
+++ b/media/jni/Android.bp
@@ -123,6 +123,30 @@ cc_library_shared {
],
}
+cc_library_shared {
+ name: "libmedia_tv_tuner",
+ srcs: [
+ "android_media_tv_Tuner.cpp",
+ ],
+
+ shared_libs: [
+ "android.hardware.tv.tuner@1.0",
+ "libandroid_runtime",
+ "liblog",
+ "libutils",
+ ],
+
+ export_include_dirs: ["."],
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-error=deprecated-declarations",
+ "-Wunused",
+ "-Wunreachable-code",
+ ],
+}
+
subdirs = [
"audioeffect",
"soundpool",
diff --git a/media/jni/android_media_tv_Tuner.cpp b/media/jni/android_media_tv_Tuner.cpp
new file mode 100644
index 000000000000..d499eee5a9da
--- /dev/null
+++ b/media/jni/android_media_tv_Tuner.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "TvTuner-JNI"
+#include <utils/Log.h>
+
+#include "android_media_tv_Tuner.h"
+#include "android_runtime/AndroidRuntime.h"
+
+#include <android/hardware/tv/tuner/1.0/ITuner.h>
+#include <media/stagefright/foundation/ADebug.h>
+
+#pragma GCC diagnostic ignored "-Wunused-function"
+
+using ::android::hardware::tv::tuner::V1_0::ITuner;
+
+struct fields_t {
+ jfieldID context;
+};
+
+static fields_t gFields;
+
+namespace android {
+
+sp<ITuner> JTuner::mTuner;
+
+JTuner::JTuner(JNIEnv *env, jobject thiz)
+ : mClass(NULL) {
+ jclass clazz = env->GetObjectClass(thiz);
+ CHECK(clazz != NULL);
+
+ mClass = (jclass)env->NewGlobalRef(clazz);
+ mObject = env->NewWeakGlobalRef(thiz);
+ if (mTuner == NULL) {
+ mTuner = getTunerService();
+ }
+}
+
+JTuner::~JTuner() {
+ JNIEnv *env = AndroidRuntime::getJNIEnv();
+
+ env->DeleteGlobalRef(mClass);
+ mTuner = NULL;
+ mClass = NULL;
+ mObject = NULL;
+}
+
+sp<ITuner> JTuner::getTunerService() {
+ if (mTuner == nullptr) {
+ mTuner = ITuner::getService();
+
+ if (mTuner == nullptr) {
+ ALOGW("Failed to get tuner service.");
+ }
+ }
+ return mTuner;
+}
+
+} // namespace android
+
+////////////////////////////////////////////////////////////////////////////////
+
+using namespace android;
+
+static sp<JTuner> setTuner(JNIEnv *env, jobject thiz, const sp<JTuner> &tuner) {
+ sp<JTuner> old = (JTuner *)env->GetLongField(thiz, gFields.context);
+
+ if (tuner != NULL) {
+ tuner->incStrong(thiz);
+ }
+ if (old != NULL) {
+ old->decStrong(thiz);
+ }
+ env->SetLongField(thiz, gFields.context, (jlong)tuner.get());
+
+ return old;
+}
+
+static sp<JTuner> getTuner(JNIEnv *env, jobject thiz) {
+ return (JTuner *)env->GetLongField(thiz, gFields.context);
+}
+
+static void android_media_tv_Tuner_native_init(JNIEnv *env) {
+ jclass clazz = env->FindClass("android/media/tv/tuner/Tuner");
+ CHECK(clazz != NULL);
+
+ gFields.context = env->GetFieldID(clazz, "mNativeContext", "J");
+ CHECK(gFields.context != NULL);
+}
+
+static void android_media_tv_Tuner_native_setup(JNIEnv *env, jobject thiz) {
+ sp<JTuner> tuner = new JTuner(env, thiz);
+ setTuner(env,thiz, tuner);
+}
+
+static const JNINativeMethod gMethods[] = {
+ { "nativeInit", "()V", (void *)android_media_tv_Tuner_native_init },
+ { "nativeSetup", "()V", (void *)android_media_tv_Tuner_native_setup },
+};
+
+static int register_android_media_tv_Tuner(JNIEnv *env) {
+ return AndroidRuntime::registerNativeMethods(
+ env, "android/media/tv/tuner/Tuner", gMethods, NELEM(gMethods));
+}
+
+jint JNI_OnLoad(JavaVM* vm, void* /* reserved */)
+{
+ JNIEnv* env = NULL;
+ jint result = -1;
+
+ if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
+ ALOGE("ERROR: GetEnv failed\n");
+ return result;
+ }
+ assert(env != NULL);
+
+ if (register_android_media_tv_Tuner(env) != JNI_OK) {
+ ALOGE("ERROR: Tuner native registration failed\n");
+ return result;
+ }
+ return JNI_VERSION_1_4;
+}
diff --git a/media/jni/android_media_tv_Tuner.h b/media/jni/android_media_tv_Tuner.h
new file mode 100644
index 000000000000..e7d5924a7dbe
--- /dev/null
+++ b/media/jni/android_media_tv_Tuner.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ANDROID_MEDIA_TV_TUNER_H_
+#define _ANDROID_MEDIA_TV_TUNER_H_
+
+#include <android/hardware/tv/tuner/1.0/ITuner.h>
+#include <utils/RefBase.h>
+
+#include "jni.h"
+
+using ::android::hardware::tv::tuner::V1_0::ITuner;
+
+namespace android {
+
+struct JTuner : public RefBase {
+ JTuner(JNIEnv *env, jobject thiz);
+ sp<ITuner> getTunerService();
+protected:
+ virtual ~JTuner();
+
+private:
+ jclass mClass;
+ jweak mObject;
+ static sp<ITuner> mTuner;
+};
+
+} // namespace android
+
+#endif // _ANDROID_MEDIA_TV_TUNER_H_
diff --git a/core/java/android/app/usage/UsageStatsManagerInternal.java b/services/core/java/android/app/usage/UsageStatsManagerInternal.java
index 024afe25f98e..6641b5be651d 100644
--- a/core/java/android/app/usage/UsageStatsManagerInternal.java
+++ b/services/core/java/android/app/usage/UsageStatsManagerInternal.java
@@ -23,6 +23,8 @@ import android.content.res.Configuration;
import android.os.UserHandle;
import android.os.UserManager;
+import com.android.server.usage.AppStandbyInternal.AppIdleStateChangeListener;
+
import java.util.List;
import java.util.Set;
@@ -153,35 +155,6 @@ public abstract class UsageStatsManagerInternal {
*/
public abstract int[] getIdleUidsForUser(@UserIdInt int userId);
- /**
- * Sets up a listener for changes to packages being accessed.
- * @param listener A listener within the system process.
- */
- public abstract void addAppIdleStateChangeListener(
- AppIdleStateChangeListener listener);
-
- /**
- * Removes a listener that was previously added for package usage state changes.
- * @param listener The listener within the system process to remove.
- */
- public abstract void removeAppIdleStateChangeListener(
- AppIdleStateChangeListener listener);
-
- public static abstract class AppIdleStateChangeListener {
-
- /** Callback to inform listeners that the idle state has changed to a new bucket. */
- public abstract void onAppIdleStateChanged(String packageName, @UserIdInt int userId,
- boolean idle, int bucket, int reason);
-
- /**
- * Optional callback to inform the listener that the app has transitioned into
- * an active state due to user interaction.
- */
- public void onUserInteractionStarted(String packageName, @UserIdInt int userId) {
- // No-op by default
- }
- }
-
/** Backup/Restore API */
public abstract byte[] getBackupPayload(@UserIdInt int userId, String key);
diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java
index b41e95fee15c..ff0044f6f1ad 100644
--- a/services/core/java/com/android/server/AlarmManagerService.java
+++ b/services/core/java/com/android/server/AlarmManagerService.java
@@ -99,6 +99,8 @@ import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.LocalLog;
import com.android.internal.util.StatLogger;
import com.android.server.AppStateTracker.Listener;
+import com.android.server.usage.AppStandbyInternal;
+import com.android.server.usage.AppStandbyInternal.AppIdleStateChangeListener;
import java.io.ByteArrayOutputStream;
import java.io.FileDescriptor;
@@ -1599,7 +1601,9 @@ class AlarmManagerService extends SystemService {
LocalServices.getService(DeviceIdleInternal.class);
mUsageStatsManagerInternal =
LocalServices.getService(UsageStatsManagerInternal.class);
- mUsageStatsManagerInternal.addAppIdleStateChangeListener(new AppStandbyTracker());
+ AppStandbyInternal appStandbyInternal =
+ LocalServices.getService(AppStandbyInternal.class);
+ appStandbyInternal.addListener(new AppStandbyTracker());
mAppStateTracker = LocalServices.getService(AppStateTracker.class);
mAppStateTracker.addListener(mForceAppStandbyListener);
@@ -4468,7 +4472,7 @@ class AlarmManagerService extends SystemService {
* Tracking of app assignments to standby buckets
*/
private final class AppStandbyTracker extends
- UsageStatsManagerInternal.AppIdleStateChangeListener {
+ AppIdleStateChangeListener {
@Override
public void onAppIdleStateChanged(final String packageName, final @UserIdInt int userId,
boolean idle, int bucket, int reason) {
diff --git a/services/core/java/com/android/server/AppStateTracker.java b/services/core/java/com/android/server/AppStateTracker.java
index da760b6f7ffd..5eff2c5c1d37 100644
--- a/services/core/java/com/android/server/AppStateTracker.java
+++ b/services/core/java/com/android/server/AppStateTracker.java
@@ -24,7 +24,6 @@ import android.app.IActivityManager;
import android.app.IUidObserver;
import android.app.usage.UsageStatsManager;
import android.app.usage.UsageStatsManagerInternal;
-import android.app.usage.UsageStatsManagerInternal.AppIdleStateChangeListener;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -58,6 +57,8 @@ import com.android.internal.util.Preconditions;
import com.android.internal.util.StatLogger;
import com.android.server.AppStateTrackerProto.ExemptedPackage;
import com.android.server.AppStateTrackerProto.RunAnyInBackgroundRestrictedPackages;
+import com.android.server.usage.AppStandbyInternal;
+import com.android.server.usage.AppStandbyInternal.AppIdleStateChangeListener;
import java.io.PrintWriter;
import java.util.Arrays;
@@ -89,7 +90,7 @@ public class AppStateTracker {
IAppOpsService mAppOpsService;
PowerManagerInternal mPowerManagerInternal;
StandbyTracker mStandbyTracker;
- UsageStatsManagerInternal mUsageStatsManagerInternal;
+ AppStandbyInternal mAppStandbyInternal;
private final MyHandler mHandler;
@@ -420,8 +421,7 @@ public class AppStateTracker {
mAppOpsManager = Preconditions.checkNotNull(injectAppOpsManager());
mAppOpsService = Preconditions.checkNotNull(injectIAppOpsService());
mPowerManagerInternal = Preconditions.checkNotNull(injectPowerManagerInternal());
- mUsageStatsManagerInternal = Preconditions.checkNotNull(
- injectUsageStatsManagerInternal());
+ mAppStandbyInternal = Preconditions.checkNotNull(injectAppStandbyInternal());
mFlagsObserver = new FeatureFlagsObserver();
mFlagsObserver.register();
@@ -429,7 +429,7 @@ public class AppStateTracker {
mForceAllAppStandbyForSmallBattery =
mFlagsObserver.isForcedAppStandbyForSmallBatteryEnabled();
mStandbyTracker = new StandbyTracker();
- mUsageStatsManagerInternal.addAppIdleStateChangeListener(mStandbyTracker);
+ mAppStandbyInternal.addListener(mStandbyTracker);
try {
mIActivityManager.registerUidObserver(new UidObserver(),
@@ -494,8 +494,8 @@ public class AppStateTracker {
}
@VisibleForTesting
- UsageStatsManagerInternal injectUsageStatsManagerInternal() {
- return LocalServices.getService(UsageStatsManagerInternal.class);
+ AppStandbyInternal injectAppStandbyInternal() {
+ return LocalServices.getService(AppStandbyInternal.class);
}
@VisibleForTesting
diff --git a/core/java/com/android/server/backup/SystemBackupAgent.java b/services/core/java/com/android/server/backup/SystemBackupAgent.java
index 35e8f56cf36d..35e8f56cf36d 100644
--- a/core/java/com/android/server/backup/SystemBackupAgent.java
+++ b/services/core/java/com/android/server/backup/SystemBackupAgent.java
diff --git a/core/java/com/android/server/backup/UsageStatsBackupHelper.java b/services/core/java/com/android/server/backup/UsageStatsBackupHelper.java
index d6a70d369cdc..d6a70d369cdc 100644
--- a/core/java/com/android/server/backup/UsageStatsBackupHelper.java
+++ b/services/core/java/com/android/server/backup/UsageStatsBackupHelper.java
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index 09be474a5598..3b14d50f3c07 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -229,6 +229,8 @@ import com.android.server.EventLogTags;
import com.android.server.LocalServices;
import com.android.server.ServiceThread;
import com.android.server.SystemConfig;
+import com.android.server.usage.AppStandbyInternal;
+import com.android.server.usage.AppStandbyInternal.AppIdleStateChangeListener;
import libcore.io.IoUtils;
@@ -396,6 +398,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
private NetworkStatsManagerInternal mNetworkStats;
private final INetworkManagementService mNetworkManager;
private UsageStatsManagerInternal mUsageStats;
+ private AppStandbyInternal mAppStandby;
private final Clock mClock;
private final UserManager mUserManager;
private final CarrierConfigManager mCarrierConfigManager;
@@ -734,6 +737,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
mUsageStats = LocalServices.getService(UsageStatsManagerInternal.class);
+ mAppStandby = LocalServices.getService(AppStandbyInternal.class);
mNetworkStats = LocalServices.getService(NetworkStatsManagerInternal.class);
synchronized (mUidRulesFirstLock) {
@@ -868,7 +872,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
mContext.getSystemService(ConnectivityManager.class).registerNetworkCallback(
new NetworkRequest.Builder().build(), mNetworkCallback);
- mUsageStats.addAppIdleStateChangeListener(new AppIdleStateChangeListener());
+ mAppStandby.addListener(new NetPolicyAppIdleStateChangeListener());
// Listen for subscriber changes
mContext.getSystemService(SubscriptionManager.class).addOnSubscriptionsChangedListener(
@@ -4375,9 +4379,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
return newUidRules;
}
- private class AppIdleStateChangeListener
- extends UsageStatsManagerInternal.AppIdleStateChangeListener {
-
+ private class NetPolicyAppIdleStateChangeListener extends AppIdleStateChangeListener {
@Override
public void onAppIdleStateChanged(String packageName, int userId, boolean idle, int bucket,
int reason) {
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index cd3343bbec7b..0fc1718ad673 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -7826,6 +7826,7 @@ public class NotificationManagerService extends SystemService {
R.array.config_allowedManagedServicesOnLowRamDevices)) {
if (whitelisted.equals(pkg)) {
canUseManagedServices = true;
+ break;
}
}
diff --git a/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java b/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java
index bc95481dcee9..11f09d0f1343 100644
--- a/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java
+++ b/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java
@@ -56,8 +56,6 @@ class ImeInsetsSourceProvider extends InsetsSourceProvider {
if (mIsImeLayoutDrawn && mShowImeRunner != null) {
// Show IME if InputMethodService requested to be shown and it's layout has finished.
mShowImeRunner.run();
- mIsImeLayoutDrawn = false;
- mShowImeRunner = null;
}
}
@@ -74,10 +72,19 @@ class ImeInsetsSourceProvider extends InsetsSourceProvider {
mDisplayContent.mInputMethodTarget.showInsets(
WindowInsets.Type.ime(), true /* fromIme */);
}
- mImeTargetFromIme = null;
+ abortShowImePostLayout();
};
}
+ /**
+ * Abort any pending request to show IME post layout.
+ */
+ void abortShowImePostLayout() {
+ mImeTargetFromIme = null;
+ mIsImeLayoutDrawn = false;
+ mShowImeRunner = null;
+ }
+
private boolean isImeTargetFromDisplayContentAndImeSame() {
// IMMS#mLastImeTargetWindow always considers focused window as
// IME target, however DisplayContent#computeImeTarget() can compute
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 63ce1b1c7ad7..caa2c0199e49 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -7331,6 +7331,9 @@ public class WindowManagerService extends IWindowManager.Stub
synchronized (mGlobalLock) {
final DisplayContent dc = mRoot.getDisplayContent(displayId);
if (dc != null && dc.mInputMethodTarget != null) {
+ // If there was a pending IME show(), reset it as IME has been
+ // requested to be hidden.
+ dc.getInsetsStateController().getImeSourceProvider().abortShowImePostLayout();
dc.mInputMethodTarget.hideInsets(WindowInsets.Type.ime(), true /* fromIme */);
}
}
diff --git a/services/tests/mockingservicestests/src/com/android/server/AlarmManagerServiceTest.java b/services/tests/mockingservicestests/src/com/android/server/AlarmManagerServiceTest.java
index 7b7b8e6c628a..9e7b80567263 100644
--- a/services/tests/mockingservicestests/src/com/android/server/AlarmManagerServiceTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/AlarmManagerServiceTest.java
@@ -85,6 +85,7 @@ import androidx.test.filters.FlakyTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.internal.annotations.GuardedBy;
+import com.android.server.usage.AppStandbyInternal;
import org.junit.After;
import org.junit.Before;
@@ -108,7 +109,7 @@ public class AlarmManagerServiceTest {
private long mAppStandbyWindow;
private AlarmManagerService mService;
- private UsageStatsManagerInternal.AppIdleStateChangeListener mAppStandbyListener;
+ private AppStandbyInternal.AppIdleStateChangeListener mAppStandbyListener;
private AlarmManagerService.ChargingReceiver mChargingReceiver;
@Mock
private ContentResolver mMockResolver;
@@ -119,6 +120,8 @@ public class AlarmManagerServiceTest {
@Mock
private UsageStatsManagerInternal mUsageStatsManagerInternal;
@Mock
+ private AppStandbyInternal mAppStandbyInternal;
+ @Mock
private AppStateTracker mAppStateTracker;
@Mock
private AlarmManagerService.ClockReceiver mClockReceiver;
@@ -257,6 +260,8 @@ public class AlarmManagerServiceTest {
doReturn(mAppStateTracker).when(() -> LocalServices.getService(AppStateTracker.class));
doReturn(null)
.when(() -> LocalServices.getService(DeviceIdleInternal.class));
+ doReturn(mAppStandbyInternal).when(
+ () -> LocalServices.getService(AppStandbyInternal.class));
doReturn(mUsageStatsManagerInternal).when(
() -> LocalServices.getService(UsageStatsManagerInternal.class));
when(mUsageStatsManagerInternal.getAppStandbyBucket(eq(TEST_CALLING_PACKAGE),
@@ -289,9 +294,9 @@ public class AlarmManagerServiceTest {
assertEquals(0, mService.mConstants.MIN_FUTURITY);
assertEquals(0, mService.mConstants.MIN_INTERVAL);
mAppStandbyWindow = mService.mConstants.APP_STANDBY_WINDOW;
- ArgumentCaptor<UsageStatsManagerInternal.AppIdleStateChangeListener> captor =
- ArgumentCaptor.forClass(UsageStatsManagerInternal.AppIdleStateChangeListener.class);
- verify(mUsageStatsManagerInternal).addAppIdleStateChangeListener(captor.capture());
+ ArgumentCaptor<AppStandbyInternal.AppIdleStateChangeListener> captor =
+ ArgumentCaptor.forClass(AppStandbyInternal.AppIdleStateChangeListener.class);
+ verify(mAppStandbyInternal).addListener(captor.capture());
mAppStandbyListener = captor.getValue();
ArgumentCaptor<AlarmManagerService.ChargingReceiver> chargingReceiverCaptor =
diff --git a/services/tests/mockingservicestests/src/com/android/server/AppStateTrackerTest.java b/services/tests/mockingservicestests/src/com/android/server/AppStateTrackerTest.java
index 80d11290fdd4..1f4656ae54a4 100644
--- a/services/tests/mockingservicestests/src/com/android/server/AppStateTrackerTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/AppStateTrackerTest.java
@@ -45,7 +45,6 @@ import android.app.IActivityManager;
import android.app.IUidObserver;
import android.app.usage.UsageStatsManager;
import android.app.usage.UsageStatsManagerInternal;
-import android.app.usage.UsageStatsManagerInternal.AppIdleStateChangeListener;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -70,6 +69,8 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.internal.app.IAppOpsCallback;
import com.android.internal.app.IAppOpsService;
import com.android.server.AppStateTracker.Listener;
+import com.android.server.usage.AppStandbyInternal;
+import com.android.server.usage.AppStandbyInternal.AppIdleStateChangeListener;
import org.junit.Before;
import org.junit.Test;
@@ -128,8 +129,8 @@ public class AppStateTrackerTest {
}
@Override
- UsageStatsManagerInternal injectUsageStatsManagerInternal() {
- return mMockUsageStatsManagerInternal;
+ AppStandbyInternal injectAppStandbyInternal() {
+ return mMockAppStandbyInternal;
}
@Override
@@ -175,7 +176,7 @@ public class AppStateTrackerTest {
private PowerManagerInternal mMockPowerManagerInternal;
@Mock
- private UsageStatsManagerInternal mMockUsageStatsManagerInternal;
+ private AppStandbyInternal mMockAppStandbyInternal;
private MockContentResolver mMockContentResolver;
@@ -271,7 +272,7 @@ public class AppStateTrackerTest {
verify(mMockContext).registerReceiver(
receiverCaptor.capture(), any(IntentFilter.class));
- verify(mMockUsageStatsManagerInternal).addAppIdleStateChangeListener(
+ verify(mMockAppStandbyInternal).addListener(
appIdleStateChangeListenerCaptor.capture());
mIUidObserver = uidObserverArgumentCaptor.getValue();
diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java
index 5d03e151e993..6a805683e23d 100644
--- a/services/usage/java/com/android/server/usage/UsageStatsService.java
+++ b/services/usage/java/com/android/server/usage/UsageStatsService.java
@@ -86,6 +86,7 @@ import com.android.internal.util.DumpUtils;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.LocalServices;
import com.android.server.SystemService;
+import com.android.server.usage.AppStandbyInternal.AppIdleStateChangeListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -180,8 +181,8 @@ public class UsageStatsService extends SystemService implements
}
}
- private UsageStatsManagerInternal.AppIdleStateChangeListener mStandbyChangeListener =
- new UsageStatsManagerInternal.AppIdleStateChangeListener() {
+ private AppIdleStateChangeListener mStandbyChangeListener =
+ new AppIdleStateChangeListener() {
@Override
public void onAppIdleStateChanged(String packageName, int userId, boolean idle,
int bucket, int reason) {
@@ -253,6 +254,7 @@ public class UsageStatsService extends SystemService implements
null, mHandler);
publishLocalService(UsageStatsManagerInternal.class, new LocalService());
+ publishLocalService(AppStandbyInternal.class, mAppStandby);
publishBinderService(Context.USAGE_STATS_SERVICE, new BinderService());
}
@@ -2029,17 +2031,6 @@ public class UsageStatsService extends SystemService implements
}
@Override
- public void addAppIdleStateChangeListener(AppIdleStateChangeListener listener) {
- mAppStandby.addListener(listener);
- }
-
- @Override
- public void removeAppIdleStateChangeListener(
- AppIdleStateChangeListener listener) {
- mAppStandby.removeListener(listener);
- }
-
- @Override
public byte[] getBackupPayload(int user, String key) {
synchronized (mLock) {
if (!mUserUnlockedStates.get(user)) {