diff options
23 files changed, 214 insertions, 120 deletions
diff --git a/cmds/statsd/Android.mk b/cmds/statsd/Android.mk index e2e1a7f80266..56f9512f66c7 100644 --- a/cmds/statsd/Android.mk +++ b/cmds/statsd/Android.mk @@ -44,6 +44,7 @@ LOCAL_SRC_FILES := \ ../../core/java/android/os/IStatsManager.aidl \ src/StatsService.cpp \ src/AnomalyMonitor.cpp \ + src/StatsPuller.cpp \ src/LogEntryPrinter.cpp \ src/LogReader.cpp \ src/main.cpp \ diff --git a/cmds/statsd/src/StatsPuller.cpp b/cmds/statsd/src/StatsPuller.cpp new file mode 100644 index 000000000000..94e8361b6425 --- /dev/null +++ b/cmds/statsd/src/StatsPuller.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2017 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 "StatsPuller" +#define DEBUG true + +#include "StatsPuller.h" +#include "StatsService.h" +#include <android/os/IStatsCompanionService.h> +#include <cutils/log.h> + +using namespace android; + +namespace android { +namespace os { +namespace statsd { + +String16 StatsPuller::pull(int pullCode) { + if (DEBUG) ALOGD("Initiating pulling %d", pullCode); + + switch (pullCode) { + // All stats_companion_service cases go here with fallthroughs + case PULL_CODE_KERNEL_WAKELOCKS: { + // TODO: Consider caching the statsCompanion service + sp <IStatsCompanionService> + statsCompanion = StatsService::getStatsCompanionService(); + String16 returned_value(""); + Status status = statsCompanion->pullData(pullCode, &returned_value); + if (DEBUG) ALOGD("Finished pulling the data"); + if (!status.isOk()) { + ALOGW("error pulling data of type %d", pullCode); + } + return returned_value; + } + + // case OTHER_TYPES: etc. + + default: { + ALOGE("invalid pull code %d", pullCode); + return String16(""); + } + } +} + +} // namespace statsd +} // namespace os +} // namespace android diff --git a/cmds/statsd/src/StatsPuller.h b/cmds/statsd/src/StatsPuller.h new file mode 100644 index 000000000000..05343b541972 --- /dev/null +++ b/cmds/statsd/src/StatsPuller.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2017 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 STATSD_STATSPULLER_H +#define STATSD_STATSPULLER_H + +#include <utils/String16.h> + +namespace android { +namespace os { +namespace statsd { + +class StatsPuller { +public: + // Enums of pulled data types (pullCodes) + // These values must be kept in sync with com/android/server/stats/StatsCompanionService.java. + // TODO: pull the constant from stats_events.proto instead + const static int PULL_CODE_KERNEL_WAKELOCKS = 20; + + StatsPuller(); + ~StatsPuller(); + + static String16 pull(int pullCode); +}; + +} // namespace statsd +} // namespace os +} // namespace android + +#endif //STATSD_STATSPULLER_H diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp index a28f0850ccea..ae7d66bf0da9 100644 --- a/cmds/statsd/src/StatsService.cpp +++ b/cmds/statsd/src/StatsService.cpp @@ -177,6 +177,9 @@ Status StatsService::informPollAlarmFired() { if (DEBUG) ALOGD("StatsService::informPollAlarmFired succeeded"); // TODO: determine what services to poll and poll (or ask StatsCompanionService to poll) them. + String16 output = StatsPuller::pull(StatsPuller::PULL_CODE_KERNEL_WAKELOCKS); + // TODO: do something useful with the output instead of writing a string to screen. + ALOGD("%s", String8(output).string()); return Status::ok(); } diff --git a/cmds/statsd/src/StatsService.h b/cmds/statsd/src/StatsService.h index eb6aa49b0be1..a16b115baf8e 100644 --- a/cmds/statsd/src/StatsService.h +++ b/cmds/statsd/src/StatsService.h @@ -19,6 +19,7 @@ #include "AnomalyMonitor.h" #include "StatsLogProcessor.h" +#include "StatsPuller.h" #include <android/os/BnStatsManager.h> #include <android/os/IStatsCompanionService.h> @@ -66,19 +67,21 @@ public: /** Inform statsCompanion that statsd is ready. */ virtual void sayHiToStatsCompanion(); -private: - sp<StatsLogProcessor> m_processor; // Reference to the processor for updating configs. + // TODO: Move this to a more logical file/class + // TODO: Should be private. Temporarily public for testing purposes only. + const sp<AnomalyMonitor> mAnomalyMonitor; - const sp<AnomalyMonitor> mAnomalyMonitor; // TODO: Move this to a more logical file/class + /** Fetches and returns the StatsCompanionService. */ + static sp<IStatsCompanionService> getStatsCompanionService(); + + private: + sp<StatsLogProcessor> m_processor; // Reference to the processor for updating configs. status_t doPrintStatsLog(FILE* out, const Vector<String8>& args); void printCmdHelp(FILE* out); status_t doLoadConfig(FILE* in); - - /** Fetches the StatsCompanionService. */ - sp<IStatsCompanionService> getStatsCompanionService(); }; // --- StatsdDeathRecipient --- diff --git a/core/java/android/os/IStatsCompanionService.aidl b/core/java/android/os/IStatsCompanionService.aidl index a83d31390775..d8f9567fddcb 100644 --- a/core/java/android/os/IStatsCompanionService.aidl +++ b/core/java/android/os/IStatsCompanionService.aidl @@ -20,11 +20,11 @@ package android.os; * Binder interface to communicate with the Java-based statistics service helper. * {@hide} */ -oneway interface IStatsCompanionService { +interface IStatsCompanionService { /** * Tell statscompanion that stastd is up and running. */ - void statsdReady(); + oneway void statsdReady(); /** * Register an alarm for anomaly detection to fire at the given timestamp (ms since epoch). @@ -32,10 +32,10 @@ oneway interface IStatsCompanionService { * Uses AlarmManager.set API, so if the timestamp is in the past, alarm fires immediately, and * alarm is inexact. */ - void setAnomalyAlarm(long timestampMs); + oneway void setAnomalyAlarm(long timestampMs); /** Cancel any anomaly detection alarm. */ - void cancelAnomalyAlarm(); + oneway void cancelAnomalyAlarm(); /** * Register a repeating alarm for polling to fire at the given timestamp and every @@ -44,8 +44,11 @@ oneway interface IStatsCompanionService { * Uses AlarmManager.setRepeating API, so if the timestamp is in past, alarm fires immediately, * and alarm is inexact. */ - void setPollingAlarms(long timestampMs, long intervalMs); + oneway void setPollingAlarms(long timestampMs, long intervalMs); /** Cancel any repeating polling alarm. */ - void cancelPollingAlarms(); + oneway void cancelPollingAlarms(); + + /** Pull the specified data. Results will be sent to statsd when complete. */ + String pullData(int pullCode); } diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index eb639bd98d49..e3a55cb617db 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -1585,8 +1585,8 @@ public class ChooserActivity extends ResolverActivity { } catch (RemoteException e) { Log.e(TAG, "Querying ChooserTargetService " + name + " failed.", e); mChooserActivity.unbindService(this); - destroy(); mChooserActivity.mServiceConnections.remove(this); + destroy(); } } } @@ -1602,7 +1602,6 @@ public class ChooserActivity extends ResolverActivity { } mChooserActivity.unbindService(this); - destroy(); mChooserActivity.mServiceConnections.remove(this); if (mChooserActivity.mServiceConnections.isEmpty()) { mChooserActivity.mChooserHandler.removeMessages( @@ -1610,6 +1609,7 @@ public class ChooserActivity extends ResolverActivity { mChooserActivity.sendVoiceChoicesIfNeeded(); } mConnectedComponent = null; + destroy(); } } diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/Android.mk b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/Android.mk index 278419315779..c5e112b2e999 100644 --- a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/Android.mk +++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/Android.mk @@ -33,29 +33,17 @@ mainDexList:= \ $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME),$(LOCAL_IS_HOST_MODULE),common)/maindex.list LOCAL_DX_FLAGS := --multi-dex --main-dex-list=$(mainDexList) --minimal-main-dex -LOCAL_JACK_FLAGS := -D jack.dex.output.policy=minimal-multidex -D jack.preprocessor=true\ - -D jack.preprocessor.file=$(LOCAL_PATH)/test.jpp -D jack.dex.output.multidex.legacy=true - -################################# -include $(BUILD_SYSTEM)/configure_local_jack.mk -################################# - -ifdef LOCAL_JACK_ENABLED -LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/test.jpp -endif LOCAL_MIN_SDK_VERSION := 8 include $(BUILD_PACKAGE) -ifndef LOCAL_JACK_ENABLED $(mainDexList): $(full_classes_proguard_jar) | $(MAINDEXCLASSES) $(hide) mkdir -p $(dir $@) $(MAINDEXCLASSES) $< 1>$@ echo "com/android/multidexlegacytestapp/Test.class" >> $@ $(built_dex_intermediate): $(mainDexList) -endif ## The application with a full main dex include $(CLEAR_VARS) @@ -76,26 +64,14 @@ mainDexList2:= \ $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME),$(LOCAL_IS_HOST_MODULE),common)/maindex.list LOCAL_DX_FLAGS := --multi-dex --main-dex-list=$(mainDexList2) -LOCAL_JACK_FLAGS := -D jack.dex.output.policy=multidex -D jack.preprocessor=true\ - -D jack.preprocessor.file=$(LOCAL_PATH)/test.jpp -D jack.dex.output.multidex.legacy=true - -################################# -include $(BUILD_SYSTEM)/configure_local_jack.mk -################################# - -ifdef LOCAL_JACK_ENABLED -LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/test.jpp -endif LOCAL_MIN_SDK_VERSION := 8 include $(BUILD_PACKAGE) -ifndef LOCAL_JACK_ENABLED $(mainDexList2): $(full_classes_proguard_jar) | $(MAINDEXCLASSES) $(hide) mkdir -p $(dir $@) $(MAINDEXCLASSES) $< 1>$@ echo "com/android/multidexlegacytestapp/Test.class" >> $@ $(built_dex_intermediate): $(mainDexList2) -endif
\ No newline at end of file diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/test.jpp b/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/test.jpp deleted file mode 100644 index a1f56565c749..000000000000 --- a/core/tests/hosttests/test-apps/MultiDexLegacyTestApp/test.jpp +++ /dev/null @@ -1,3 +0,0 @@ -test: - @@com.android.jack.annotations.ForceInMainDex - class com.android.multidexlegacytestapp.Test diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v1/Android.mk b/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v1/Android.mk index 1c7d80790120..da48df93a1d8 100644 --- a/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v1/Android.mk +++ b/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v1/Android.mk @@ -32,24 +32,12 @@ mainDexList:= \ $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME),$(LOCAL_IS_HOST_MODULE),common)/maindex.list LOCAL_DX_FLAGS := --multi-dex --main-dex-list=$(mainDexList) --minimal-main-dex -LOCAL_JACK_FLAGS := -D jack.dex.output.policy=minimal-multidex -D jack.preprocessor=true\ - -D jack.preprocessor.file=$(LOCAL_PATH)/test.jpp -D jack.dex.output.multidex.legacy=true - -################################# -include $(BUILD_SYSTEM)/configure_local_jack.mk -################################# - -ifdef LOCAL_JACK_ENABLED -LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/test.jpp -endif include $(BUILD_PACKAGE) -ifndef LOCAL_JACK_ENABLED $(mainDexList): $(full_classes_proguard_jar) | $(MAINDEXCLASSES) $(hide) mkdir -p $(dir $@) $(MAINDEXCLASSES) $< 1>$@ echo "com/android/framework/multidexlegacyversionedtestapp/MultiDexUpdateTest.class" >> $@ $(built_dex_intermediate): $(mainDexList) -endif
\ No newline at end of file diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v1/test.jpp b/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v1/test.jpp deleted file mode 100644 index 6d384e31351b..000000000000 --- a/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v1/test.jpp +++ /dev/null @@ -1,3 +0,0 @@ -test: - @@com.android.jack.annotations.ForceInMainDex - class com.android.framework.multidexlegacyversionedtestapp.MultiDexUpdateTest diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v2/Android.mk b/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v2/Android.mk index b77cf31edc62..02b3f537758e 100644 --- a/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v2/Android.mk +++ b/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v2/Android.mk @@ -32,24 +32,12 @@ mainDexList:= \ $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME),$(LOCAL_IS_HOST_MODULE),common)/maindex.list LOCAL_DX_FLAGS := --multi-dex --main-dex-list=$(mainDexList) --minimal-main-dex -LOCAL_JACK_FLAGS := -D jack.dex.output.policy=minimal-multidex -D jack.preprocessor=true\ - -D jack.preprocessor.file=$(LOCAL_PATH)/test.jpp -D jack.dex.output.multidex.legacy=true - -################################# -include $(BUILD_SYSTEM)/configure_local_jack.mk -################################# - -ifdef LOCAL_JACK_ENABLED -LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/test.jpp -endif include $(BUILD_PACKAGE) -ifndef LOCAL_JACK_ENABLED $(mainDexList): $(full_classes_proguard_jar) | $(MAINDEXCLASSES) $(hide) mkdir -p $(dir $@) $(MAINDEXCLASSES) $< 1>$@ echo "com/android/framework/multidexlegacyversionedtestapp/MultiDexUpdateTest.class" >> $@ $(built_dex_intermediate): $(mainDexList) -endif diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v2/test.jpp b/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v2/test.jpp deleted file mode 100644 index 6d384e31351b..000000000000 --- a/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v2/test.jpp +++ /dev/null @@ -1,3 +0,0 @@ -test: - @@com.android.jack.annotations.ForceInMainDex - class com.android.framework.multidexlegacyversionedtestapp.MultiDexUpdateTest diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v3/Android.mk b/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v3/Android.mk index 3631626f6b31..480868460d6a 100644 --- a/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v3/Android.mk +++ b/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v3/Android.mk @@ -32,25 +32,13 @@ mainDexList:= \ LOCAL_DEX_PREOPT := false LOCAL_DX_FLAGS := --multi-dex --main-dex-list=$(mainDexList) --minimal-main-dex -LOCAL_JACK_FLAGS := -D jack.dex.output.policy=minimal-multidex -D jack.preprocessor=true\ - -D jack.preprocessor.file=$(LOCAL_PATH)/test.jpp -D jack.dex.output.multidex.legacy=true - -################################# -include $(BUILD_SYSTEM)/configure_local_jack.mk -################################# - -ifdef LOCAL_JACK_ENABLED -LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/test.jpp -endif include $(BUILD_PACKAGE) -ifndef LOCAL_JACK_ENABLED $(mainDexList): $(full_classes_proguard_jar) | $(MAINDEXCLASSES) $(hide) mkdir -p $(dir $@) $(MAINDEXCLASSES) $< 1>$@ echo "com/android/framework/multidexlegacyversionedtestapp/MultiDexUpdateTest.class" >> $@ $(built_dex_intermediate): $(mainDexList) -endif diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v3/test.jpp b/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v3/test.jpp deleted file mode 100644 index 6d384e31351b..000000000000 --- a/core/tests/hosttests/test-apps/MultiDexLegacyVersionedTestApp_v3/test.jpp +++ /dev/null @@ -1,3 +0,0 @@ -test: - @@com.android.jack.annotations.ForceInMainDex - class com.android.framework.multidexlegacyversionedtestapp.MultiDexUpdateTest diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml index b758e7f5bc87..eab42dac5a27 100644 --- a/packages/Shell/AndroidManifest.xml +++ b/packages/Shell/AndroidManifest.xml @@ -96,6 +96,9 @@ <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" /> <uses-permission android:name="android.permission.CREATE_USERS" /> <uses-permission android:name="android.permission.MANAGE_DEVICE_ADMINS" /> + <uses-permission android:name="android.permission.ACCESS_LOWPAN_STATE"/> + <uses-permission android:name="android.permission.CHANGE_LOWPAN_STATE"/> + <uses-permission android:name="android.permission.READ_LOWPAN_CREDENTIAL"/> <uses-permission android:name="android.permission.BLUETOOTH_STACK" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.RETRIEVE_WINDOW_TOKEN" /> diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto index 787d36397dfe..401705d43810 100644 --- a/proto/src/metrics_constants.proto +++ b/proto/src/metrics_constants.proto @@ -3851,7 +3851,7 @@ message MetricsEvent { // Tag of a field for the length of the filter text FIELD_AUTOFILL_FILTERTEXT_LEN = 911; - // An autofill authentification succeeded + // An autofill authentication succeeded // Package: Package of app that was autofilled AUTOFILL_AUTHENTICATED = 912; @@ -4462,19 +4462,19 @@ message MetricsEvent { // OS: O MR FIELD_AUTOFILL_PREVIOUS_LENGTH = 1125; - // An autofill dataset authentification succeeded + // An autofill dataset authentication succeeded // Package: Package of app that was autofilled // OS: O MR // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request AUTOFILL_DATASET_AUTHENTICATED = 1126; - // An autofill service provided an invalid dataset authentification + // An autofill service provided an invalid dataset authentication // Package: Package of app that was autofilled // OS: O MR // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request AUTOFILL_INVALID_DATASET_AUTHENTICATION = 1127; - // An autofill service provided an invalid authentification extra + // An autofill service provided an invalid authentication extra // Package: Package of app that was autofilled // OS: O MR // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java index 2f31fc34a135..f4dbb5a9b0b2 100644 --- a/services/backup/java/com/android/server/backup/BackupManagerService.java +++ b/services/backup/java/com/android/server/backup/BackupManagerService.java @@ -1987,7 +1987,7 @@ public class BackupManagerService implements BackupManagerServiceInterface { if (uri == null) { return; } - String pkgName = uri.getSchemeSpecificPart(); + final String pkgName = uri.getSchemeSpecificPart(); if (pkgName != null) { pkgList = new String[] { pkgName }; } @@ -1995,7 +1995,7 @@ public class BackupManagerService implements BackupManagerServiceInterface { // At package-changed we only care about looking at new transport states if (changed) { - String[] components = + final String[] components = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST); if (MORE_DEBUG) { @@ -2005,7 +2005,8 @@ public class BackupManagerService implements BackupManagerServiceInterface { } } - mTransportManager.onPackageChanged(pkgName, components); + mBackupHandler.post( + () -> mTransportManager.onPackageChanged(pkgName, components)); return; // nothing more to do in the PACKAGE_CHANGED case } @@ -2037,7 +2038,7 @@ public class BackupManagerService implements BackupManagerServiceInterface { } // If they're full-backup candidates, add them there instead final long now = System.currentTimeMillis(); - for (String packageName : pkgList) { + for (final String packageName : pkgList) { try { PackageInfo app = mPackageManager.getPackageInfo(packageName, 0); if (appGetsFullBackup(app) @@ -2054,7 +2055,8 @@ public class BackupManagerService implements BackupManagerServiceInterface { writeFullBackupScheduleAsync(); } - mTransportManager.onPackageAdded(packageName); + mBackupHandler.post( + () -> mTransportManager.onPackageAdded(packageName)); } catch (NameNotFoundException e) { // doesn't really exist; ignore it @@ -2078,8 +2080,9 @@ public class BackupManagerService implements BackupManagerServiceInterface { removePackageParticipantsLocked(pkgList, uid); } } - for (String pkgName : pkgList) { - mTransportManager.onPackageRemoved(pkgName); + for (final String pkgName : pkgList) { + mBackupHandler.post( + () -> mTransportManager.onPackageRemoved(pkgName)); } } } diff --git a/services/backup/java/com/android/server/backup/RefactoredBackupManagerService.java b/services/backup/java/com/android/server/backup/RefactoredBackupManagerService.java index 8b4cc7f6d22b..14a008e0852f 100644 --- a/services/backup/java/com/android/server/backup/RefactoredBackupManagerService.java +++ b/services/backup/java/com/android/server/backup/RefactoredBackupManagerService.java @@ -1188,7 +1188,7 @@ public class RefactoredBackupManagerService implements BackupManagerServiceInter if (uri == null) { return; } - String pkgName = uri.getSchemeSpecificPart(); + final String pkgName = uri.getSchemeSpecificPart(); if (pkgName != null) { pkgList = new String[]{pkgName}; } @@ -1196,7 +1196,7 @@ public class RefactoredBackupManagerService implements BackupManagerServiceInter // At package-changed we only care about looking at new transport states if (changed) { - String[] components = + final String[] components = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST); if (MORE_DEBUG) { @@ -1206,7 +1206,8 @@ public class RefactoredBackupManagerService implements BackupManagerServiceInter } } - mTransportManager.onPackageChanged(pkgName, components); + mBackupHandler.post( + () -> mTransportManager.onPackageChanged(pkgName, components)); return; // nothing more to do in the PACKAGE_CHANGED case } @@ -1238,7 +1239,7 @@ public class RefactoredBackupManagerService implements BackupManagerServiceInter } // If they're full-backup candidates, add them there instead final long now = System.currentTimeMillis(); - for (String packageName : pkgList) { + for (final String packageName : pkgList) { try { PackageInfo app = mPackageManager.getPackageInfo(packageName, 0); if (AppBackupUtils.appGetsFullBackup(app) @@ -1256,7 +1257,8 @@ public class RefactoredBackupManagerService implements BackupManagerServiceInter writeFullBackupScheduleAsync(); } - mTransportManager.onPackageAdded(packageName); + mBackupHandler.post( + () -> mTransportManager.onPackageAdded(packageName)); } catch (NameNotFoundException e) { // doesn't really exist; ignore it @@ -1280,8 +1282,9 @@ public class RefactoredBackupManagerService implements BackupManagerServiceInter removePackageParticipantsLocked(pkgList, uid); } } - for (String pkgName : pkgList) { - mTransportManager.onPackageRemoved(pkgName); + for (final String pkgName : pkgList) { + mBackupHandler.post( + () -> mTransportManager.onPackageRemoved(pkgName)); } } } diff --git a/services/backup/java/com/android/server/backup/TransportManager.java b/services/backup/java/com/android/server/backup/TransportManager.java index 9aae38416bd1..7a0173f669af 100644 --- a/services/backup/java/com/android/server/backup/TransportManager.java +++ b/services/backup/java/com/android/server/backup/TransportManager.java @@ -341,9 +341,9 @@ public class TransportManager { private class TransportConnection implements ServiceConnection { // Hold mTransportsLock to access these fields so as to provide a consistent view of them. - private IBackupTransport mBinder; + private volatile IBackupTransport mBinder; private final List<TransportReadyCallback> mListeners = new ArrayList<>(); - private String mTransportName; + private volatile String mTransportName; private final ComponentName mTransportComponent; @@ -426,25 +426,24 @@ public class TransportManager { + rebindTimeout + "ms"); } + // Intentionally not synchronized -- the variable is volatile and changes to its value + // are inside synchronized blocks, providing a memory sync barrier; and this method + // does not touch any other state protected by that lock. private IBackupTransport getBinder() { - synchronized (mTransportLock) { - return mBinder; - } + return mBinder; } + // Intentionally not synchronized; same as getBinder() private String getName() { - synchronized (mTransportLock) { - return mTransportName; - } + return mTransportName; } + // Intentionally not synchronized; same as getBinder() private void bindIfUnbound() { - synchronized (mTransportLock) { - if (mBinder == null) { - Slog.d(TAG, - "Rebinding to transport " + mTransportComponent.flattenToShortString()); - bindToTransport(mTransportComponent, this); - } + if (mBinder == null) { + Slog.d(TAG, + "Rebinding to transport " + mTransportComponent.flattenToShortString()); + bindToTransport(mTransportComponent, this); } } diff --git a/services/core/java/com/android/server/stats/StatsCompanionService.java b/services/core/java/com/android/server/stats/StatsCompanionService.java index 1a62662a754b..05fd248ed312 100644 --- a/services/core/java/com/android/server/stats/StatsCompanionService.java +++ b/services/core/java/com/android/server/stats/StatsCompanionService.java @@ -30,8 +30,12 @@ import android.os.ServiceManager; import android.util.Slog; import com.android.internal.annotations.GuardedBy; +import com.android.internal.os.KernelWakelockReader; +import com.android.internal.os.KernelWakelockStats; import com.android.server.SystemService; +import java.util.Map; + /** * Helper service for statsd (the native stats management service in cmds/statsd/). * Used for registering and receiving alarms on behalf of statsd. @@ -157,7 +161,44 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { } } - @Override + // These values must be kept in sync with cmd/statsd/StatsPuller.h. + // TODO: pull the constant from stats_events.proto instead + private static final int PULL_CODE_KERNEL_WAKELOCKS = 20; + + private final KernelWakelockReader mKernelWakelockReader = new KernelWakelockReader(); + private final KernelWakelockStats mTmpWakelockStats = new KernelWakelockStats(); + + @Override // Binder call + public String pullData(int pullCode) { + enforceCallingPermission(); + if (DEBUG) Slog.d(TAG, "Fetching " + pullCode); + + StringBuilder s = new StringBuilder(); // TODO: use and return a Parcel instead of a string + switch (pullCode) { + case PULL_CODE_KERNEL_WAKELOCKS: + final KernelWakelockStats wakelockStats = + mKernelWakelockReader.readKernelWakelockStats(mTmpWakelockStats); + + for (Map.Entry<String, KernelWakelockStats.Entry> ent : wakelockStats.entrySet()) { + String name = ent.getKey(); + KernelWakelockStats.Entry kws = ent.getValue(); + s.append("Wakelock ") + .append(name) + .append(", time=") + .append(kws.mTotalTime) + .append(", count=") + .append(kws.mCount) + .append('\n'); + } + break; + default: + Slog.w(TAG, "No such pollable data as " + pullCode); + return null; + } + return s.toString(); + } + + @Override // Binder call public void statsdReady() { enforceCallingPermission(); if (DEBUG) Slog.d(TAG, "learned that statsdReady"); diff --git a/services/core/java/com/android/server/vr/Vr2dDisplay.java b/services/core/java/com/android/server/vr/Vr2dDisplay.java index 8f50a39a5424..5721415c55f5 100644 --- a/services/core/java/com/android/server/vr/Vr2dDisplay.java +++ b/services/core/java/com/android/server/vr/Vr2dDisplay.java @@ -294,6 +294,8 @@ class Vr2dDisplay { int flags = DisplayManager.VIRTUAL_DISPLAY_FLAG_SUPPORTS_TOUCH; flags |= DisplayManager.VIRTUAL_DISPLAY_FLAG_ROTATES_WITH_CONTENT; + flags |= DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC; + flags |= DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY; mVirtualDisplay = mDisplayManager.createVirtualDisplay(null /* projection */, DISPLAY_NAME, mVirtualDisplayWidth, mVirtualDisplayHeight, mVirtualDisplayDpi, null /* surface */, flags, null /* callback */, null /* handler */, diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java index 4308ff977398..652788377005 100644 --- a/services/core/java/com/android/server/wm/TaskStack.java +++ b/services/core/java/com/android/server/wm/TaskStack.java @@ -923,7 +923,9 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye void resetAnimationBackgroundAnimator() { mAnimationBackgroundAnimator = null; - mAnimationBackgroundSurface.hide(); + if (mAnimationBackgroundSurface != null) { + mAnimationBackgroundSurface.hide(); + } } void setAnimationBackground(WindowStateAnimator winAnimator, int color) { |