summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaiyiz <kaiyiz@codeaurora.org>2014-03-27 12:09:52 +0800
committeremancebo <emancebo@cyngn.com>2014-09-04 10:40:20 -0700
commita1f2e8ec818fc6f06b974bcce8bdfc85e1635cc9 (patch)
treeeb38e3441a3fd4416cfa1d9f8685d27ed8eff332
parentb46f99cd31ecd5de4f5ff1e66709ffd0e769dbba (diff)
downloadandroid_packages_apps_Gallery2-a1f2e8ec818fc6f06b974bcce8bdfc85e1635cc9.tar.gz
android_packages_apps_Gallery2-a1f2e8ec818fc6f06b974bcce8bdfc85e1635cc9.tar.bz2
android_packages_apps_Gallery2-a1f2e8ec818fc6f06b974bcce8bdfc85e1635cc9.zip
Gallery: add an activity to set system properties for streaming
App forgets add an activity to set system properties for streaming. add an activity to set system properties for streaming. CRs-Fixed: 635639 Change-Id: Idba31bd7a7489a01b5cc061fffb4ebcc7af3f813
-rw-r--r--AndroidManifest.xml7
-rwxr-xr-xsrc/org/codeaurora/gallery3d/video/SettingsActivity.java35
-rwxr-xr-xsrc/org/codeaurora/gallery3d/video/StreamingSettingsEnablerActivity.java92
3 files changed, 130 insertions, 4 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8957042cd..03e7a0877 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -420,5 +420,12 @@
android:label="@string/movie_view_label"
android:configChanges="orientation|keyboardHidden|screenSize|mnc|mcc">
</activity>
+ <activity android:name="org.codeaurora.gallery3d.video.StreamingSettingsEnablerActivity"
+ android:theme="@android:style/Theme.Translucent.NoTitleBar">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
</application>
</manifest>
diff --git a/src/org/codeaurora/gallery3d/video/SettingsActivity.java b/src/org/codeaurora/gallery3d/video/SettingsActivity.java
index 1490f234c..d58dd3c3b 100755
--- a/src/org/codeaurora/gallery3d/video/SettingsActivity.java
+++ b/src/org/codeaurora/gallery3d/video/SettingsActivity.java
@@ -1,3 +1,32 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package org.codeaurora.gallery3d.video;
import android.app.ActionBar;
@@ -204,7 +233,6 @@ public class SettingsActivity extends PreferenceActivity {
Integer.toString(DEFAULT_RTP_MINPORT));
final String rtpMaxPortStr = mPref.getString(PREFERENCE_RTP_MAXPORT,
Integer.toString(DEFAULT_RTP_MAXPORT));
- final String CLASS_NAME = "com.android.settings.StreamingSettingsEnablerActivity";
final int rtpMinPort;
final int rtpMaxPort;
try {
@@ -215,7 +243,7 @@ public class SettingsActivity extends PreferenceActivity {
return;
}
Intent intent = new Intent();
- intent.setClassName(PACKAGE_NAME, CLASS_NAME);
+ intent.setClass(this,StreamingSettingsEnablerActivity.class);
intent.putExtra(PREFERENCE_RTP_MINPORT, rtpMinPort);
intent.putExtra(PREFERENCE_RTP_MAXPORT, rtpMaxPort);
startActivity(intent);
@@ -224,7 +252,6 @@ public class SettingsActivity extends PreferenceActivity {
private void enableBufferSetting() {
final String bufferSizeStr = mPref.getString(PREFERENCE_BUFFER_SIZE,
Integer.toString(DEFAULT_CACHE_MAX_SIZE));
- final String CLASS_NAME = "com.android.settings.StreamingSettingsEnablerActivity";
final int cacheMaxSize;
try {
cacheMaxSize = Integer.valueOf(bufferSizeStr);
@@ -233,7 +260,7 @@ public class SettingsActivity extends PreferenceActivity {
return;
}
Intent intent = new Intent();
- intent.setClassName(PACKAGE_NAME, CLASS_NAME);
+ intent.setClass(this,StreamingSettingsEnablerActivity.class);
intent.putExtra(PREFERENCE_CACHE_MIN_SIZE, DEFAULT_CACHE_MIN_SIZE);
intent.putExtra(PREFERENCE_CACHE_MAX_SIZE, cacheMaxSize);
intent.putExtra(PREFERENCE_KEEP_ALIVE_INTERVAL_SECOND, DEFAULT_KEEP_ALIVE_INTERVAL_SECOND);
diff --git a/src/org/codeaurora/gallery3d/video/StreamingSettingsEnablerActivity.java b/src/org/codeaurora/gallery3d/video/StreamingSettingsEnablerActivity.java
new file mode 100755
index 000000000..34de5d4a0
--- /dev/null
+++ b/src/org/codeaurora/gallery3d/video/StreamingSettingsEnablerActivity.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.codeaurora.gallery3d.video;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.SystemProperties;
+import android.util.Log;
+
+public class StreamingSettingsEnablerActivity extends Activity {
+
+ private static final String LOG_TAG = "StreamingSettingsEnablerActivity";
+
+ private static final String PREFERENCE_RTP_MINPORT = "rtp_min_port";
+ private static final String PREFERENCE_RTP_MAXPORT = "rtp_max_port";
+ private static final String PREFERENCE_KEEP_ALIVE_INTERVAL_SECOND =
+ "keep_alive_interval_second";
+ private static final String PREFERENCE_CACHE_MIN_SIZE = "cache_min_size";
+ private static final String PREFERENCE_CACHE_MAX_SIZE = "cache_max_size";
+
+ private static final int DEFAULT_RTP_MINPORT = 15550;
+ private static final int DEFAULT_RTP_MAXPORT = 65535;
+ private static final int DEFAULT_CACHE_MIN_SIZE = 4 * 1024 * 1024;
+ private static final int DEFAULT_CACHE_MAX_SIZE = 20 * 1024 * 1024;
+ private static final int DEFAULT_KEEP_ALIVE_INTERVAL_SECOND = 15;
+ private static final String RTP_PORTS_PROPERTY_NAME = "persist.env.media.rtp-ports";
+ private static final String CACHE_PROPERTY_NAME = "persist.env.media.cache-params";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ final Intent intent = getIntent();
+ final int rtpMinPort = intent.getIntExtra(PREFERENCE_RTP_MINPORT, DEFAULT_RTP_MINPORT);
+ final int rtpMaxPort = intent.getIntExtra(PREFERENCE_RTP_MAXPORT, DEFAULT_RTP_MAXPORT);
+ enableRtpPortSetting(rtpMinPort, rtpMaxPort);
+
+ final int cacheMinSize =
+ intent.getIntExtra(PREFERENCE_CACHE_MIN_SIZE, DEFAULT_CACHE_MIN_SIZE);
+ final int cacheMaxSize =
+ intent.getIntExtra(PREFERENCE_CACHE_MAX_SIZE, DEFAULT_CACHE_MAX_SIZE);
+ final int keepAliveIntervalSec =
+ intent.getIntExtra(PREFERENCE_KEEP_ALIVE_INTERVAL_SECOND,
+ DEFAULT_KEEP_ALIVE_INTERVAL_SECOND);
+ enableCacheSetting(cacheMinSize, cacheMaxSize, keepAliveIntervalSec);
+ finish();
+ }
+
+
+ private void enableRtpPortSetting(final int rtpMinPort, final int rtpMaxPort) {
+ // System property format: "rtpMinPort/rtpMaxPort"
+ final String propertyValue = rtpMinPort + "/" + rtpMaxPort;
+ Log.v(LOG_TAG, "set system property " + RTP_PORTS_PROPERTY_NAME + " : " + propertyValue);
+ SystemProperties.set(RTP_PORTS_PROPERTY_NAME, propertyValue);
+ }
+
+ private void enableCacheSetting(final int cacheMinSize,
+ final int cacheMaxSize, final int keepAliveIntervalSec) {
+ // System property format: "minCacheSizeKB/maxCacheSizeKB/keepAliveIntervalSeconds"
+ final String propertyValue = (cacheMinSize / 1024) + "/" +
+ (cacheMaxSize / 1024) + "/" + keepAliveIntervalSec;
+ Log.v(LOG_TAG, "set system property " + CACHE_PROPERTY_NAME + " : " + propertyValue);
+ SystemProperties.set(CACHE_PROPERTY_NAME, propertyValue);
+ }
+}