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

Commit 5812c578 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5322077 from 5a50cb42 to pi-qpr3-release

Change-Id: I4475a2045dc9df43da24f96bb9502a024c82fc8e
parents b5f3f030 5a50cb42
Loading
Loading
Loading
Loading
+24 −10
Original line number Diff line number Diff line
@@ -64,6 +64,9 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

//TODO: use java.lang.ref.Cleaner once Android supports Java 9
import sun.misc.Cleaner;

/**
 * Default implementation of the {@link TextClassifier} interface.
 *
@@ -92,6 +95,8 @@ public final class TextClassifierImpl implements TextClassifier {
    private ModelFile mModel;
    @GuardedBy("mLock") // Do not access outside this lock.
    private TextClassifierImplNative mNative;
    @GuardedBy("mLock")
    private Cleaner mNativeCleaner;

    private final Object mLoggerLock = new Object();
    @GuardedBy("mLoggerLock") // Do not access outside this lock.
@@ -304,12 +309,12 @@ public final class TextClassifierImpl implements TextClassifier {
            if (bestModel == null) {
                throw new FileNotFoundException("No model for " + localeList.toLanguageTags());
            }
            if (mNative == null || !Objects.equals(mModel, bestModel)) {
            if (mNative == null || mNative.isClosed() || !Objects.equals(mModel, bestModel)) {
                Log.d(DEFAULT_LOG_TAG, "Loading " + bestModel);
                destroyNativeIfExistsLocked();
                final ParcelFileDescriptor fd = ParcelFileDescriptor.open(
                        new File(bestModel.getPath()), ParcelFileDescriptor.MODE_READ_ONLY);
                mNative = new TextClassifierImplNative(fd.getFd());
                mNativeCleaner = Cleaner.create(this, new NativeCloser(mNative));
                closeAndLogError(fd);
                mModel = bestModel;
            }
@@ -324,14 +329,6 @@ public final class TextClassifierImpl implements TextClassifier {
        }
    }

    @GuardedBy("mLock") // Do not call outside this lock.
    private void destroyNativeIfExistsLocked() {
        if (mNative != null) {
            mNative.close();
            mNative = null;
        }
    }

    private static String concatenateLocales(@Nullable LocaleList locales) {
        return (locales == null) ? "" : locales.toLanguageTags();
    }
@@ -822,4 +819,21 @@ public final class TextClassifierImpl implements TextClassifier {
                    parsedTime.hashCode());
        }
    }

    /**
     * Code to close a TextClassifierImplNative. Must not reference the TextClassifierImpl.
     */
    private static final class NativeCloser implements Runnable {

        private final TextClassifierImplNative mNative;

        NativeCloser(TextClassifierImplNative nativeImpl) {
            mNative = Preconditions.checkNotNull(nativeImpl);
        }

        @Override
        public void run() {
            mNative.close();
        }
    }
}
+15 −2
Original line number Diff line number Diff line
@@ -28,7 +28,8 @@ final class TextClassifierImplNative {
        System.loadLibrary("textclassifier");
    }

    private final long mModelPtr;
    private final Object mCloseLock = new Object();
    private long mModelPtr;

    /**
     * Creates a new instance of TextClassifierImplNative, using the provided model image, given as
@@ -102,7 +103,19 @@ final class TextClassifierImplNative {

    /** Frees up the allocated memory. */
    public void close() {
        synchronized (mCloseLock) {
            if (!isClosed()) {
                nativeClose(mModelPtr);
                mModelPtr = 0;
            }
        }
    }

    /**
     * Returns true if this object is closed, returns false otherwise.
     */
    public boolean isClosed() {
        return mModelPtr == 0L;
    }

    /** Returns a comma separated list of locales supported by the model as BCP 47 tags. */
+62 −28
Original line number Diff line number Diff line
@@ -1436,26 +1436,6 @@
    <integer-array name="config_autoBrightnessKeyboardBacklightValues">
    </integer-array>

    <!-- Array of hysteresis constraint values for brightening, represented as tenths of a
         percent. The length of this array is assumed to be one greater than
         config_dynamicHysteresisLuxLevels. The brightening threshold is calculated as
         lux * (1.0f + CONSTRAINT_VALUE). When the current lux is higher than this threshold,
         the screen brightness is recalculated. See the config_dynamicHysteresisLuxLevels
         description for how the constraint value is chosen. -->
    <integer-array name="config_dynamicHysteresisBrightLevels">
        <item>100</item>
    </integer-array>

    <!-- Array of hysteresis constraint values for darkening, represented as tenths of a
         percent. The length of this array is assumed to be one greater than
         config_dynamicHysteresisLuxLevels. The darkening threshold is calculated as
         lux * (1.0f - CONSTRAINT_VALUE). When the current lux is lower than this threshold,
         the screen brightness is recalculated. See the config_dynamicHysteresisLuxLevels
         description for how the constraint value is chosen. -->
    <integer-array name="config_dynamicHysteresisDarkLevels">
        <item>200</item>
    </integer-array>

    <!-- An array describing the screen's backlight values corresponding to the brightness
         values in the config_screenBrightnessNits array.

@@ -1473,19 +1453,73 @@
    <array name="config_screenBrightnessNits">
    </array>


    <!-- Array of ambient lux threshold values. This is used for determining hysteresis constraint
         values by calculating the index to use for lookup and then setting the constraint value
         to the corresponding value of the array. The new brightening hysteresis constraint value
         is the n-th element of config_dynamicHysteresisBrightLevels, and the new darkening
         hysteresis constraint value is the n-th element of config_dynamicHysteresisDarkLevels.
         is the n-th element of config_ambientBrighteningThresholds, and the new darkening
         hysteresis constraint value is the n-th element of config_ambientDarkeningThresholds.

         The (zero-based) index is calculated as follows: (MAX is the largest index of the array)
         condition                       calculated index
         value < level[0]                0
         level[n] <= value < level[n+1]  n+1
         level[MAX] <= value             MAX+1 -->
    <integer-array name="config_ambientThresholdLevels">
    </integer-array>

    <!-- Array of hysteresis constraint values for brightening, represented as tenths of a
         percent. The length of this array is assumed to be one greater than
         config_ambientThresholdLevels. The brightening threshold is calculated as
         lux * (1.0f + CONSTRAINT_VALUE). When the current lux is higher than this threshold,
         the screen brightness is recalculated. See the config_ambientThresholdLevels
         description for how the constraint value is chosen. -->
    <integer-array name="config_ambientBrighteningThresholds">
        <item>100</item>
    </integer-array>

    <!-- Array of hysteresis constraint values for darkening, represented as tenths of a
         percent. The length of this array is assumed to be one greater than
         config_ambientThresholdLevels. The darkening threshold is calculated as
         lux * (1.0f - CONSTRAINT_VALUE). When the current lux is lower than this threshold,
         the screen brightness is recalculated. See the config_ambientThresholdLevels
         description for how the constraint value is chosen. -->
    <integer-array name="config_ambientDarkeningThresholds">
        <item>200</item>
    </integer-array>

    <!-- Array of screen brightness threshold values. This is used for determining hysteresis
         constraint values by calculating the index to use for lookup and then setting the
         constraint value to the corresponding value of the array. The new brightening hysteresis
         constraint value is the n-th element of config_screenBrighteningThresholds, and the new
         darkening hysteresis constraint value is the n-th element of
         config_screenDarkeningThresholds.

         The (zero-based) index is calculated as follows: (MAX is the largest index of the array)
         condition                       calculated index
         value < lux[0]                 0
         lux[n] <= value < lux[n+1]     n+1
         lux[MAX] <= value              MAX+1 -->
    <integer-array name="config_dynamicHysteresisLuxLevels">
         value < level[0]                0
         level[n] <= value < level[n+1]  n+1
         level[MAX] <= value             MAX+1 -->
    <integer-array name="config_screenThresholdLevels">
    </integer-array>

    <!-- Array of hysteresis constraint values for brightening, represented as tenths of a
         percent. The length of this array is assumed to be one greater than
         config_screenThresholdLevels. The brightening threshold is calculated as
         screenBrightness * (1.0f + CONSTRAINT_VALUE). When the new screen brightness is higher
         than this threshold, it is applied. See the config_screenThresholdLevels description for
         how the constraint value is chosen. -->
    <integer-array name="config_screenBrighteningThresholds">
        <item>100</item>
    </integer-array>

    <!-- Array of hysteresis constraint values for darkening, represented as tenths of a
         percent. The length of this array is assumed to be one greater than
         config_screenThresholdLevels. The darkening threshold is calculated as
         screenBrightness * (1.0f - CONSTRAINT_VALUE). When the new screen brightness is lower than
         this threshold, it is applied. See the config_screenThresholdLevels description for how
         the constraint value is chosen. -->
    <integer-array name="config_screenDarkeningThresholds">
        <item>200</item>
    </integer-array>

    <!-- Amount of time it takes for the light sensor to warm up in milliseconds.
+6 −3
Original line number Diff line number Diff line
@@ -1823,9 +1823,12 @@
  <java-symbol type="array" name="config_autoBrightnessKeyboardBacklightValues" />
  <java-symbol type="array" name="config_autoBrightnessLcdBacklightValues" />
  <java-symbol type="array" name="config_autoBrightnessLevels" />
  <java-symbol type="array" name="config_dynamicHysteresisBrightLevels" />
  <java-symbol type="array" name="config_dynamicHysteresisDarkLevels" />
  <java-symbol type="array" name="config_dynamicHysteresisLuxLevels" />
  <java-symbol type="array" name="config_ambientThresholdLevels" />
  <java-symbol type="array" name="config_ambientBrighteningThresholds" />
  <java-symbol type="array" name="config_ambientDarkeningThresholds" />
  <java-symbol type="array" name="config_screenThresholdLevels" />
  <java-symbol type="array" name="config_screenBrighteningThresholds" />
  <java-symbol type="array" name="config_screenDarkeningThresholds" />
  <java-symbol type="array" name="config_minimumBrightnessCurveLux" />
  <java-symbol type="array" name="config_minimumBrightnessCurveNits" />
  <java-symbol type="array" name="config_protectedNetworks" />
+1 −1
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@
    <string name="data_usage_uninstalled_apps" msgid="614263770923231598">"আঁতৰোৱা এপ্‌সমূহ"</string>
    <string name="data_usage_uninstalled_apps_users" msgid="7986294489899813194">"আঁতৰোৱা এপ্‌ আৰু ব্যৱহাৰকাৰীসমূহ"</string>
    <string name="tether_settings_title_usb" msgid="6688416425801386511">"ইউএছবি টেডাৰিং"</string>
    <string name="tether_settings_title_wifi" msgid="3277144155960302049">"প\'ৰ্টেবল হ\'টস্প\'ট"</string>
    <string name="tether_settings_title_wifi" msgid="3277144155960302049">"প\'ৰ্টেবল হটস্পট"</string>
    <string name="tether_settings_title_bluetooth" msgid="355855408317564420">"ব্লুটুথ টেডাৰিং"</string>
    <string name="tether_settings_title_usb_bluetooth" msgid="5355828977109785001">"টেডাৰ কৰি থকা হৈছে"</string>
    <string name="tether_settings_title_all" msgid="8356136101061143841">"টেডাৰিং আৰু প\'ৰ্টেবল হটস্পট"</string>
Loading