Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3429d2a authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Add log to measure startup performance"

parents 37bddc2f 49627cc3
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.contacts;

import com.android.contacts.model.AccountTypeManager;
import com.android.contacts.test.InjectedServices;
import com.android.contacts.util.Constants;
import com.google.common.annotations.VisibleForTesting;

import android.app.Application;
@@ -27,9 +28,9 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.os.StrictMode;
import android.preference.PreferenceManager;
import android.util.Log;

public final class ContactsApplication extends Application {

    private static InjectedServices sInjectedServices;
    private AccountTypeManager mAccountTypeManager;
    private ContactPhotoManager mContactPhotoManager;
@@ -100,6 +101,10 @@ public final class ContactsApplication extends Application {
    public void onCreate() {
        super.onCreate();

        if (Log.isLoggable(Constants.PERFORMANCE_TAG, Log.DEBUG)) {
            Log.d(Constants.PERFORMANCE_TAG, "ContactsApplication.onCreate start");
        }

        // Priming caches to placate the StrictMode police
        Context context = getApplicationContext();
        PreferenceManager.getDefaultSharedPreferences(context);
@@ -108,5 +113,9 @@ public final class ContactsApplication extends Application {

        StrictMode.setThreadPolicy(
                new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());

        if (Log.isLoggable(Constants.PERFORMANCE_TAG, Log.DEBUG)) {
            Log.d(Constants.PERFORMANCE_TAG, "ContactsApplication.onCreate finish");
        }
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import com.android.contacts.preference.ContactsPreferenceActivity;
import com.android.contacts.preference.DisplayOptionsPreferenceFragment;
import com.android.contacts.util.AccountSelectionUtil;
import com.android.contacts.util.AccountsListAdapter;
import com.android.contacts.util.Constants;
import com.android.contacts.util.DialogManager;
import com.android.contacts.util.PhoneCapabilityTester;

@@ -233,6 +234,9 @@ public class PeopleActivity extends ContactsActivity

    @Override
    protected void onCreate(Bundle savedState) {
        if (Log.isLoggable(Constants.PERFORMANCE_TAG, Log.DEBUG)) {
            Log.d(Constants.PERFORMANCE_TAG, "PeopleActivity.onCreate start");
        }
        super.onCreate(savedState);

        if (!processIntent(false)) {
@@ -242,6 +246,9 @@ public class PeopleActivity extends ContactsActivity

        mIsRecreatedInstance = (savedState != null);
        createViewsAndFragments(savedState);
        if (Log.isLoggable(Constants.PERFORMANCE_TAG, Log.DEBUG)) {
            Log.d(Constants.PERFORMANCE_TAG, "PeopleActivity.onCreate finish");
        }
    }

    @Override
+7 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.contacts.model;

import com.android.contacts.util.Constants;
import com.android.i18n.phonenumbers.PhoneNumberUtil;
import com.android.internal.util.Objects;
import com.google.android.collect.Lists;
@@ -271,6 +272,9 @@ class AccountTypeManagerImpl extends AccountTypeManager
     * called on a background thread.
     */
    protected void loadAccountsInBackground() {
        if (Log.isLoggable(Constants.PERFORMANCE_TAG, Log.DEBUG)) {
            Log.d(Constants.PERFORMANCE_TAG, "AccountTypeManager.loadAccountsInBackground start");
        }
        long startTime = SystemClock.currentThreadTimeMillis();

        // Account types, keyed off the account type and data set concatenation.
@@ -419,6 +423,9 @@ class AccountTypeManagerImpl extends AccountTypeManager
            mInitializationLatch.countDown();
            mInitializationLatch = null;
        }
        if (Log.isLoggable(Constants.PERFORMANCE_TAG, Log.DEBUG)) {
            Log.d(Constants.PERFORMANCE_TAG, "AccountTypeManager.loadAccountsInBackground finish");
        }
    }

    // Bookkeeping method for tracking the known account types in the given maps.
+4 −0
Original line number Diff line number Diff line
@@ -24,4 +24,8 @@ public class Constants {
    public static final String SCHEME_MAILTO = "mailto";
    public static final String SCHEME_IMTO = "imto";
    public static final String SCHEME_SIP = "sip";

    // Log tag for performance measurement.
    // To enable: adb shell setprop log.tag.ContactsPerf VERBOSE
    public static final String PERFORMANCE_TAG = "ContactsPerf";
}