Search in sources :

Example 86 with Time

use of android.text.format.Time in project android_frameworks_base by ResurrectionRemix.

the class Shared method formatTime.

public static String formatTime(Context context, long when) {
    // TODO: DateUtils should make this easier
    Time then = new Time();
    then.set(when);
    Time now = new Time();
    now.setToNow();
    int flags = DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL;
    if (then.year != now.year) {
        flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE;
    } else if (then.yearDay != now.yearDay) {
        flags |= DateUtils.FORMAT_SHOW_DATE;
    } else {
        flags |= DateUtils.FORMAT_SHOW_TIME;
    }
    return DateUtils.formatDateTime(context, when, flags);
}
Also used : Time(android.text.format.Time)

Example 87 with Time

use of android.text.format.Time in project android_frameworks_base by ResurrectionRemix.

the class TelephonyRegistry method logServiceStateChanged.

private void logServiceStateChanged(String s, int subId, int phoneId, ServiceState state) {
    if (logSSC == null || logSSC.length == 0) {
        return;
    }
    if (logSSC[next] == null) {
        logSSC[next] = new LogSSC();
    }
    Time t = new Time();
    t.setToNow();
    logSSC[next].set(t, s, subId, phoneId, state);
    if (++next >= logSSC.length) {
        next = 0;
    }
}
Also used : Time(android.text.format.Time)

Example 88 with Time

use of android.text.format.Time in project android_frameworks_base by ResurrectionRemix.

the class NetworkPolicyManagerService method ensureActiveMobilePolicyNL.

private void ensureActiveMobilePolicyNL(String subscriberId) {
    // Poke around to see if we already have a policy
    final NetworkIdentity probeIdent = new NetworkIdentity(TYPE_MOBILE, TelephonyManager.NETWORK_TYPE_UNKNOWN, subscriberId, null, false, true);
    for (int i = mNetworkPolicy.size() - 1; i >= 0; i--) {
        final NetworkTemplate template = mNetworkPolicy.keyAt(i);
        if (template.matches(probeIdent)) {
            if (LOGD) {
                Slog.d(TAG, "Found template " + template + " which matches subscriber " + NetworkIdentity.scrubSubscriberId(subscriberId));
            }
            return;
        }
    }
    Slog.i(TAG, "No policy for subscriber " + NetworkIdentity.scrubSubscriberId(subscriberId) + "; generating default policy");
    // Build default mobile policy, and assume usage cycle starts today
    final int dataWarningConfig = mContext.getResources().getInteger(com.android.internal.R.integer.config_networkPolicyDefaultWarning);
    final long warningBytes;
    if (dataWarningConfig == WARNING_DISABLED) {
        warningBytes = WARNING_DISABLED;
    } else {
        warningBytes = dataWarningConfig * MB_IN_BYTES;
    }
    final Time time = new Time();
    time.setToNow();
    final int cycleDay = time.monthDay;
    final String cycleTimezone = time.timezone;
    final NetworkTemplate template = buildTemplateMobileAll(subscriberId);
    final NetworkPolicy policy = new NetworkPolicy(template, cycleDay, cycleTimezone, warningBytes, LIMIT_DISABLED, SNOOZE_NEVER, SNOOZE_NEVER, true, true);
    addNetworkPolicyNL(policy);
}
Also used : NetworkTemplate(android.net.NetworkTemplate) NetworkIdentity(android.net.NetworkIdentity) NetworkPolicy(android.net.NetworkPolicy) Time(android.text.format.Time) TrustedTime(android.util.TrustedTime) NtpTrustedTime(android.util.NtpTrustedTime) NetworkPolicyManager.uidRulesToString(android.net.NetworkPolicyManager.uidRulesToString)

Example 89 with Time

use of android.text.format.Time in project android_frameworks_base by ResurrectionRemix.

the class ShortcutService method formatTime.

static String formatTime(long time) {
    Time tobj = new Time();
    tobj.set(time);
    return tobj.format("%Y-%m-%d %H:%M:%S");
}
Also used : Time(android.text.format.Time)

Example 90 with Time

use of android.text.format.Time in project android_frameworks_base by ResurrectionRemix.

the class DataUsageController method addMonth.

private static Time addMonth(Time t, int months) {
    final Time rt = new Time(t);
    rt.set(t.monthDay, t.month + months, t.year);
    rt.normalize(false);
    return rt;
}
Also used : Time(android.text.format.Time)

Aggregations

Time (android.text.format.Time)395 SmallTest (android.test.suitebuilder.annotation.SmallTest)97 Test (org.junit.Test)25 ArrayList (java.util.ArrayList)23 Date (java.util.Date)21 NetworkPolicy (android.net.NetworkPolicy)16 TrustedTime (android.util.TrustedTime)16 TextView (android.widget.TextView)15 Bundle (android.os.Bundle)13 TimeFormatException (android.util.TimeFormatException)13 Suppress (android.test.suitebuilder.annotation.Suppress)12 View (android.view.View)12 Paint (android.graphics.Paint)11 IOException (java.io.IOException)11 Matcher (java.util.regex.Matcher)9 IntentFilter (android.content.IntentFilter)7 File (java.io.File)7 DateFormat (java.text.DateFormat)7 SimpleDateFormat (java.text.SimpleDateFormat)7 ContentValues (android.content.ContentValues)6