Skip to content

Commit a48f93d

Browse files
authored
Merge branch 'main' into common_dep
2 parents 2d46bba + 79324e1 commit a48f93d

File tree

4 files changed

+5
-47
lines changed

4 files changed

+5
-47
lines changed

firebase-perf/src/main/java/com/google/firebase/perf/metrics/AppStartTrace.java

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import android.content.Context;
2323
import android.os.Build;
2424
import android.os.Bundle;
25-
import android.os.PowerManager;
2625
import android.os.Process;
2726
import android.view.View;
2827
import android.view.ViewTreeObserver;
@@ -564,42 +563,15 @@ public static boolean isAnyAppProcessInForeground(Context appContext) {
564563
}
565564
if (appProcess.processName.equals(appProcessName)
566565
|| appProcess.processName.startsWith(allowedAppProcessNamePrefix)) {
567-
boolean isAppInForeground = true;
568-
569-
// For the case when the app is in foreground and the device transitions to sleep mode,
570-
// the importance of the process is set to IMPORTANCE_TOP_SLEEPING. However, this
571-
// importance level was introduced in M. Pre M, the process importance is not changed to
572-
// IMPORTANCE_TOP_SLEEPING when the display turns off. So we need to rely also on the
573-
// state of the display to decide if any app process is really visible.
574-
if (Build.VERSION.SDK_INT < 23 /* M */) {
575-
isAppInForeground = isScreenOn(appContext);
576-
}
577-
578-
if (isAppInForeground) {
579-
return true;
580-
}
566+
// Returns true if the process with `IMPORTANCE_FOREGROUND` matches current process.
567+
return true;
581568
}
582569
}
583570
}
584571

585572
return false;
586573
}
587574

588-
/**
589-
* Returns whether the device screen is on.
590-
*
591-
* @param appContext The application's context.
592-
*/
593-
public static boolean isScreenOn(Context appContext) {
594-
PowerManager powerManager = (PowerManager) appContext.getSystemService(Context.POWER_SERVICE);
595-
if (powerManager == null) {
596-
return true;
597-
}
598-
return (Build.VERSION.SDK_INT >= 20 /* KITKAT_WATCH */)
599-
? powerManager.isInteractive()
600-
: powerManager.isScreenOn();
601-
}
602-
603575
/**
604576
* We use StartFromBackgroundRunnable to detect if app is started from background or foreground.
605577
* If app is started from background, we do not generate AppStart trace. This runnable is posted

firebase-perf/src/main/java/com/google/firebase/perf/network/InstrURLConnectionBase.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,7 @@ public void setFixedLengthStreamingMode(final int contentLength) {
411411
}
412412

413413
public void setFixedLengthStreamingMode(final long contentLength) {
414-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
415-
httpUrlConnection.setFixedLengthStreamingMode(contentLength);
416-
}
414+
httpUrlConnection.setFixedLengthStreamingMode(contentLength);
417415
}
418416

419417
public void setIfModifiedSince(final long ifmodifiedsince) {

firebase-perf/src/main/java/com/google/firebase/perf/util/FirstDrawDoneListener.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,6 @@ public void onDraw() {
8787
* placeholder.
8888
*/
8989
private static boolean isAliveAndAttached(View view) {
90-
return view.getViewTreeObserver().isAlive() && isAttachedToWindow(view);
91-
}
92-
93-
/** Backport {@link View#isAttachedToWindow()} which is API 19+ only. */
94-
private static boolean isAttachedToWindow(View view) {
95-
if (Build.VERSION.SDK_INT >= 19) {
96-
return view.isAttachedToWindow();
97-
}
98-
return view.getWindowToken() != null;
90+
return view.getViewTreeObserver().isAlive() && view.isAttachedToWindow();
9991
}
10092
}

firebase-perf/src/main/java/com/google/firebase/perf/util/Timer.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import static java.util.concurrent.TimeUnit.MILLISECONDS;
1818
import static java.util.concurrent.TimeUnit.NANOSECONDS;
1919

20-
import android.os.Build;
2120
import android.os.Parcel;
2221
import android.os.Parcelable;
2322
import android.os.SystemClock;
@@ -72,10 +71,7 @@ private static long wallClockMicros() {
7271
* @return wall-clock time in microseconds.
7372
*/
7473
private static long elapsedRealtimeMicros() {
75-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
76-
return NANOSECONDS.toMicros(SystemClock.elapsedRealtimeNanos());
77-
}
78-
return MILLISECONDS.toMicros(SystemClock.elapsedRealtime());
74+
return NANOSECONDS.toMicros(SystemClock.elapsedRealtimeNanos());
7975
}
8076

8177
// TODO: make all constructors private, use public static factory methods, per Effective Java

0 commit comments

Comments
 (0)