Merge "Catch SercurityException while reading device properties" into tm-qpr-dev am: 2b3b871984
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22099104 Change-Id: I3f141f5587e7ea66bb5c7c65336153fd76e3a267 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
|
||||
package com.android.internal.jank;
|
||||
|
||||
import static android.Manifest.permission.READ_DEVICE_CONFIG;
|
||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||
import static android.provider.DeviceConfig.NAMESPACE_INTERACTION_JANK_MONITOR;
|
||||
|
||||
import static com.android.internal.jank.FrameTracker.REASON_CANCEL_NORMAL;
|
||||
import static com.android.internal.jank.FrameTracker.REASON_CANCEL_TIMEOUT;
|
||||
import static com.android.internal.jank.FrameTracker.REASON_END_NORMAL;
|
||||
@@ -94,6 +98,7 @@ import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.UiThread;
|
||||
import android.annotation.WorkerThread;
|
||||
import android.app.ActivityThread;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
@@ -436,18 +441,37 @@ public class InteractionJankMonitor {
|
||||
mWorker = worker;
|
||||
mWorker.start();
|
||||
mSamplingInterval = DEFAULT_SAMPLING_INTERVAL;
|
||||
|
||||
// Post initialization to the background in case we're running on the main
|
||||
// thread.
|
||||
mWorker.getThreadHandler().post(
|
||||
() -> mPropertiesChangedListener.onPropertiesChanged(
|
||||
DeviceConfig.getProperties(
|
||||
DeviceConfig.NAMESPACE_INTERACTION_JANK_MONITOR)));
|
||||
DeviceConfig.addOnPropertiesChangedListener(
|
||||
DeviceConfig.NAMESPACE_INTERACTION_JANK_MONITOR,
|
||||
new HandlerExecutor(mWorker.getThreadHandler()),
|
||||
mPropertiesChangedListener);
|
||||
mEnabled = DEFAULT_ENABLED;
|
||||
|
||||
final Context context = ActivityThread.currentApplication();
|
||||
if (context.checkCallingOrSelfPermission(READ_DEVICE_CONFIG) != PERMISSION_GRANTED) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Initialized the InteractionJankMonitor."
|
||||
+ " (No READ_DEVICE_CONFIG permission to change configs)"
|
||||
+ " enabled=" + mEnabled + ", interval=" + mSamplingInterval
|
||||
+ ", missedFrameThreshold=" + mTraceThresholdMissedFrames
|
||||
+ ", frameTimeThreshold=" + mTraceThresholdFrameTimeMillis
|
||||
+ ", package=" + context.getPackageName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Post initialization to the background in case we're running on the main thread.
|
||||
mWorker.getThreadHandler().post(
|
||||
() -> {
|
||||
try {
|
||||
mPropertiesChangedListener.onPropertiesChanged(
|
||||
DeviceConfig.getProperties(NAMESPACE_INTERACTION_JANK_MONITOR));
|
||||
DeviceConfig.addOnPropertiesChangedListener(
|
||||
NAMESPACE_INTERACTION_JANK_MONITOR,
|
||||
new HandlerExecutor(mWorker.getThreadHandler()),
|
||||
mPropertiesChangedListener);
|
||||
} catch (SecurityException ex) {
|
||||
Log.d(TAG, "Can't get properties: READ_DEVICE_CONFIG granted="
|
||||
+ context.checkCallingOrSelfPermission(READ_DEVICE_CONFIG)
|
||||
+ ", package=" + context.getPackageName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user