diff -urN Original_4.4.4_r1/packages/apps/a1/AndroidManifest.xml AndroidSource/packages/apps/a1/AndroidManifest.xml
--- Original_4.4.4_r1/packages/apps/a1/AndroidManifest.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/AndroidManifest.xml 2015-11-25 17:26:36.000000000 +0900
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -urN Original_4.4.4_r1/packages/apps/a1/Android.mk AndroidSource/packages/apps/a1/Android.mk
--- Original_4.4.4_r1/packages/apps/a1/Android.mk 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/Android.mk 2015-11-25 17:27:50.000000000 +0900
@@ -0,0 +1,18 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := a1
+LOCAL_CERTIFICATE := platform
+LOCAL_PRIVILEGED_MODULE := true
+
+include $(BUILD_PACKAGE)
+
+include $(call all-makefiles-under, $(LOCAL_PATH))
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/a1/Android.mk~ AndroidSource/packages/apps/a1/Android.mk~
--- Original_4.4.4_r1/packages/apps/a1/Android.mk~ 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/Android.mk~ 2015-01-09 00:26:12.000000000 +0900
@@ -0,0 +1,18 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := TestApp
+LOCAL_CERTIFICATE := platform
+LOCAL_PRIVILEGED_MODULE := true
+
+include $(BUILD_PACKAGE)
+
+include $(call all-makefiles-under, $(LOCAL_PATH))
+
+
+
+
Binary files Original_4.4.4_r1/packages/apps/a1/bin/a1.apk and AndroidSource/packages/apps/a1/bin/a1.apk differ
diff -urN Original_4.4.4_r1/packages/apps/a1/bin/AndroidManifest.xml AndroidSource/packages/apps/a1/bin/AndroidManifest.xml
--- Original_4.4.4_r1/packages/apps/a1/bin/AndroidManifest.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/bin/AndroidManifest.xml 2015-11-25 17:26:36.000000000 +0900
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Binary files Original_4.4.4_r1/packages/apps/a1/bin/classes/com/example/a1/BuildConfig.class and AndroidSource/packages/apps/a1/bin/classes/com/example/a1/BuildConfig.class differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/classes/com/example/a1/R$attr.class and AndroidSource/packages/apps/a1/bin/classes/com/example/a1/R$attr.class differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/classes/com/example/a1/R.class and AndroidSource/packages/apps/a1/bin/classes/com/example/a1/R.class differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/classes/com/example/a1/R$dimen.class and AndroidSource/packages/apps/a1/bin/classes/com/example/a1/R$dimen.class differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/classes/com/example/a1/R$drawable.class and AndroidSource/packages/apps/a1/bin/classes/com/example/a1/R$drawable.class differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/classes/com/example/a1/R$id.class and AndroidSource/packages/apps/a1/bin/classes/com/example/a1/R$id.class differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/classes/com/example/a1/R$layout.class and AndroidSource/packages/apps/a1/bin/classes/com/example/a1/R$layout.class differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/classes/com/example/a1/R$menu.class and AndroidSource/packages/apps/a1/bin/classes/com/example/a1/R$menu.class differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/classes/com/example/a1/R$string.class and AndroidSource/packages/apps/a1/bin/classes/com/example/a1/R$string.class differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/classes/com/example/a1/R$style.class and AndroidSource/packages/apps/a1/bin/classes/com/example/a1/R$style.class differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/classes/com/example/aa/MainActivity.class and AndroidSource/packages/apps/a1/bin/classes/com/example/aa/MainActivity.class differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/classes/com/example/aa/StartMyServiceAtBootReceiver.class and AndroidSource/packages/apps/a1/bin/classes/com/example/aa/StartMyServiceAtBootReceiver.class differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/classes.dex and AndroidSource/packages/apps/a1/bin/classes.dex differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/dexedLibs/android-support-v4-662f517e02939eb28de50a62c54df090.jar and AndroidSource/packages/apps/a1/bin/dexedLibs/android-support-v4-662f517e02939eb28de50a62c54df090.jar differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/dexedLibs/android-support-v4-664e038797163c322951976646a5b761.jar and AndroidSource/packages/apps/a1/bin/dexedLibs/android-support-v4-664e038797163c322951976646a5b761.jar differ
diff -urN Original_4.4.4_r1/packages/apps/a1/bin/jarlist.cache AndroidSource/packages/apps/a1/bin/jarlist.cache
--- Original_4.4.4_r1/packages/apps/a1/bin/jarlist.cache 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/bin/jarlist.cache 2015-11-25 14:28:46.000000000 +0900
@@ -0,0 +1,3 @@
+# cache for current jar dependency. DO NOT EDIT.
+# format is
+# Encoding is UTF-8
Binary files Original_4.4.4_r1/packages/apps/a1/bin/res/crunch/drawable-hdpi/ic_launcher.png and AndroidSource/packages/apps/a1/bin/res/crunch/drawable-hdpi/ic_launcher.png differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/res/crunch/drawable-mdpi/ic_launcher.png and AndroidSource/packages/apps/a1/bin/res/crunch/drawable-mdpi/ic_launcher.png differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/res/crunch/drawable-xhdpi/ic_launcher.png and AndroidSource/packages/apps/a1/bin/res/crunch/drawable-xhdpi/ic_launcher.png differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/res/crunch/drawable-xxhdpi/ic_launcher.png and AndroidSource/packages/apps/a1/bin/res/crunch/drawable-xxhdpi/ic_launcher.png differ
Binary files Original_4.4.4_r1/packages/apps/a1/bin/resources.ap_ and AndroidSource/packages/apps/a1/bin/resources.ap_ differ
diff -urN Original_4.4.4_r1/packages/apps/a1/.classpath AndroidSource/packages/apps/a1/.classpath
--- Original_4.4.4_r1/packages/apps/a1/.classpath 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/.classpath 2015-05-12 12:44:40.000000000 +0900
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/a1/gen/com/example/a1/BuildConfig.java AndroidSource/packages/apps/a1/gen/com/example/a1/BuildConfig.java
--- Original_4.4.4_r1/packages/apps/a1/gen/com/example/a1/BuildConfig.java 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/gen/com/example/a1/BuildConfig.java 2015-11-25 14:28:52.000000000 +0900
@@ -0,0 +1,6 @@
+/** Automatically generated file. DO NOT MODIFY */
+package com.example.a1;
+
+public final class BuildConfig {
+ public final static boolean DEBUG = true;
+}
\ No newline at end of file
diff -urN Original_4.4.4_r1/packages/apps/a1/gen/com/example/a1/R.java AndroidSource/packages/apps/a1/gen/com/example/a1/R.java
--- Original_4.4.4_r1/packages/apps/a1/gen/com/example/a1/R.java 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/gen/com/example/a1/R.java 2015-11-25 17:26:36.000000000 +0900
@@ -0,0 +1,71 @@
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package com.example.a1;
+
+public final class R {
+ public static final class attr {
+ }
+ public static final class dimen {
+ /** Default screen margins, per the Android Design guidelines.
+
+ Example customization of dimensions originally defined in res/values/dimens.xml
+ (such as screen margins) for screens with more than 820dp of available width. This
+ would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
+
+ */
+ public static final int activity_horizontal_margin=0x7f040000;
+ public static final int activity_vertical_margin=0x7f040001;
+ }
+ public static final class drawable {
+ public static final int ic_launcher=0x7f020000;
+ }
+ public static final class id {
+ public static final int action_settings=0x7f080002;
+ public static final int button1=0x7f080001;
+ public static final int textView1=0x7f080000;
+ }
+ public static final class layout {
+ public static final int activity_main=0x7f030000;
+ }
+ public static final class menu {
+ public static final int main=0x7f070000;
+ }
+ public static final class string {
+ public static final int action_settings=0x7f050002;
+ public static final int app_name=0x7f050000;
+ public static final int hello_world=0x7f050001;
+ }
+ public static final class style {
+ /**
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+
+
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+
+
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+
+ API 11 theme customizations can go here.
+
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+
+ API 14 theme customizations can go here.
+ */
+ public static final int AppBaseTheme=0x7f060000;
+ /** Application theme.
+ All customizations that are NOT specific to a particular API-level can go here.
+ */
+ public static final int AppTheme=0x7f060001;
+ }
+}
Binary files Original_4.4.4_r1/packages/apps/a1/ic_launcher-web.png and AndroidSource/packages/apps/a1/ic_launcher-web.png differ
Binary files Original_4.4.4_r1/packages/apps/a1/libs/android-support-v4.jar and AndroidSource/packages/apps/a1/libs/android-support-v4.jar differ
diff -urN Original_4.4.4_r1/packages/apps/a1/proguard-project.txt AndroidSource/packages/apps/a1/proguard-project.txt
--- Original_4.4.4_r1/packages/apps/a1/proguard-project.txt 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/proguard-project.txt 2015-05-12 12:44:38.000000000 +0900
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff -urN Original_4.4.4_r1/packages/apps/a1/.project AndroidSource/packages/apps/a1/.project
--- Original_4.4.4_r1/packages/apps/a1/.project 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/.project 2015-05-12 12:44:38.000000000 +0900
@@ -0,0 +1,33 @@
+
+
+ a1
+
+
+
+
+
+ com.android.ide.eclipse.adt.ResourceManagerBuilder
+
+
+
+
+ com.android.ide.eclipse.adt.PreCompilerBuilder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ com.android.ide.eclipse.adt.ApkBuilder
+
+
+
+
+
+ com.android.ide.eclipse.adt.AndroidNature
+ org.eclipse.jdt.core.javanature
+
+
diff -urN Original_4.4.4_r1/packages/apps/a1/project.properties AndroidSource/packages/apps/a1/project.properties
--- Original_4.4.4_r1/packages/apps/a1/project.properties 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/project.properties 2015-05-12 12:44:40.000000000 +0900
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-19
Binary files Original_4.4.4_r1/packages/apps/a1/res/drawable-hdpi/ic_launcher.png and AndroidSource/packages/apps/a1/res/drawable-hdpi/ic_launcher.png differ
Binary files Original_4.4.4_r1/packages/apps/a1/res/drawable-mdpi/ic_launcher.png and AndroidSource/packages/apps/a1/res/drawable-mdpi/ic_launcher.png differ
Binary files Original_4.4.4_r1/packages/apps/a1/res/drawable-xhdpi/ic_launcher.png and AndroidSource/packages/apps/a1/res/drawable-xhdpi/ic_launcher.png differ
Binary files Original_4.4.4_r1/packages/apps/a1/res/drawable-xxhdpi/ic_launcher.png and AndroidSource/packages/apps/a1/res/drawable-xxhdpi/ic_launcher.png differ
diff -urN Original_4.4.4_r1/packages/apps/a1/res/layout/activity_main.xml AndroidSource/packages/apps/a1/res/layout/activity_main.xml
--- Original_4.4.4_r1/packages/apps/a1/res/layout/activity_main.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/res/layout/activity_main.xml 2015-11-25 18:04:22.000000000 +0900
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/a1/res/layout/activity_main.xml~ AndroidSource/packages/apps/a1/res/layout/activity_main.xml~
--- Original_4.4.4_r1/packages/apps/a1/res/layout/activity_main.xml~ 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/res/layout/activity_main.xml~ 2015-05-12 16:37:16.000000000 +0900
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -urN Original_4.4.4_r1/packages/apps/a1/res/menu/main.xml AndroidSource/packages/apps/a1/res/menu/main.xml
--- Original_4.4.4_r1/packages/apps/a1/res/menu/main.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/res/menu/main.xml 2015-05-12 12:44:40.000000000 +0900
@@ -0,0 +1,11 @@
+
diff -urN Original_4.4.4_r1/packages/apps/a1/res/values/dimens.xml AndroidSource/packages/apps/a1/res/values/dimens.xml
--- Original_4.4.4_r1/packages/apps/a1/res/values/dimens.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/res/values/dimens.xml 2015-05-12 12:44:40.000000000 +0900
@@ -0,0 +1,7 @@
+
+
+
+ 16dp
+ 16dp
+
+
diff -urN Original_4.4.4_r1/packages/apps/a1/res/values/strings.xml AndroidSource/packages/apps/a1/res/values/strings.xml
--- Original_4.4.4_r1/packages/apps/a1/res/values/strings.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/res/values/strings.xml 2015-05-12 12:44:40.000000000 +0900
@@ -0,0 +1,8 @@
+
+
+
+ a1
+ Hello world!
+ Settings
+
+
diff -urN Original_4.4.4_r1/packages/apps/a1/res/values/styles.xml AndroidSource/packages/apps/a1/res/values/styles.xml
--- Original_4.4.4_r1/packages/apps/a1/res/values/styles.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/res/values/styles.xml 2015-05-12 12:44:40.000000000 +0900
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/a1/res/values-v11/styles.xml AndroidSource/packages/apps/a1/res/values-v11/styles.xml
--- Original_4.4.4_r1/packages/apps/a1/res/values-v11/styles.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/res/values-v11/styles.xml 2015-05-12 12:44:40.000000000 +0900
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/a1/res/values-v14/styles.xml AndroidSource/packages/apps/a1/res/values-v14/styles.xml
--- Original_4.4.4_r1/packages/apps/a1/res/values-v14/styles.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/res/values-v14/styles.xml 2015-05-12 12:44:40.000000000 +0900
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/a1/res/values-w820dp/dimens.xml AndroidSource/packages/apps/a1/res/values-w820dp/dimens.xml
--- Original_4.4.4_r1/packages/apps/a1/res/values-w820dp/dimens.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/res/values-w820dp/dimens.xml 2015-05-12 12:44:40.000000000 +0900
@@ -0,0 +1,10 @@
+
+
+
+ 64dp
+
+
diff -urN Original_4.4.4_r1/packages/apps/a1/src/com/example/aa/MainActivity.java AndroidSource/packages/apps/a1/src/com/example/aa/MainActivity.java
--- Original_4.4.4_r1/packages/apps/a1/src/com/example/aa/MainActivity.java 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/src/com/example/aa/MainActivity.java 2015-11-25 17:24:46.000000000 +0900
@@ -0,0 +1,40 @@
+package com.example.aa;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.util.List;
+
+import com.example.a1.R;
+
+import android.app.Activity;
+import android.app.Service;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.media.MediaCodec;
+import android.media.MediaExtractor;
+import android.media.MediaFormat;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.IBinder;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+
+public class MainActivity extends Service {
+ private final String TAG = "TAG";
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff -urN Original_4.4.4_r1/packages/apps/a1/src/com/example/aa/StartMyServiceAtBootReceiver.java AndroidSource/packages/apps/a1/src/com/example/aa/StartMyServiceAtBootReceiver.java
--- Original_4.4.4_r1/packages/apps/a1/src/com/example/aa/StartMyServiceAtBootReceiver.java 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/src/com/example/aa/StartMyServiceAtBootReceiver.java 2015-11-27 15:24:04.000000000 +0900
@@ -0,0 +1,48 @@
+package com.example.aa;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
+
+import java.util.List;
+
+public class StartMyServiceAtBootReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
+ saveWpaConfig(context, "dcslab5G", "dcslab2014", false);
+ }
+ }
+
+ public static void saveWpaConfig(Context context, String SSID, String Passphrase, boolean Hidden)
+ {
+ WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ if (!wifiManager.isWifiEnabled())
+ wifiManager.setWifiEnabled(true);
+
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ // setup a wifi configuration
+ WifiConfiguration wc = new WifiConfiguration();
+ wc.SSID = "\""+SSID+"\"";
+ wc.preSharedKey = "\""+Passphrase+"\"";
+ wc.status = WifiConfiguration.Status.ENABLED;
+ wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
+ wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
+ wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
+ wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
+ wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
+ wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
+ // connect to and enable the connection
+ int netId = wifiManager.addNetwork(wc);
+ wifiManager.enableNetwork(netId, true);
+ wifiManager.setWifiEnabled(true);
+ }
+}
diff -urN Original_4.4.4_r1/packages/apps/a1/src/com/example/aa/StartMyServiceAtBootReceiver.java~ AndroidSource/packages/apps/a1/src/com/example/aa/StartMyServiceAtBootReceiver.java~
--- Original_4.4.4_r1/packages/apps/a1/src/com/example/aa/StartMyServiceAtBootReceiver.java~ 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/a1/src/com/example/aa/StartMyServiceAtBootReceiver.java~ 2015-11-27 15:23:54.000000000 +0900
@@ -0,0 +1,54 @@
+package com.example.aa;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
+
+import java.util.List;
+
+public class StartMyServiceAtBootReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ saveWpaConfig(context, "dcslab5G", "dcslab2014", false);
+ }
+ }
+
+ public static void saveWpaConfig(Context context, String SSID, String Passphrase, boolean Hidden)
+ {
+ WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ if (!wifiManager.isWifiEnabled())
+ wifiManager.setWifiEnabled(true);
+
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ // setup a wifi configuration
+ WifiConfiguration wc = new WifiConfiguration();
+ wc.SSID = "\""+SSID+"\"";
+ wc.preSharedKey = "\""+Passphrase+"\"";
+ wc.status = WifiConfiguration.Status.ENABLED;
+ wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
+ wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
+ wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
+ wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
+ wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
+ wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
+ // connect to and enable the connection
+ int netId = wifiManager.addNetwork(wc);
+ wifiManager.enableNetwork(netId, true);
+ wifiManager.setWifiEnabled(true);
+ }
+}
diff -urN Original_4.4.4_r1/packages/apps/Settings/AndroidManifest.xml AndroidSource/packages/apps/Settings/AndroidManifest.xml
--- Original_4.4.4_r1/packages/apps/Settings/AndroidManifest.xml 2016-01-29 15:12:43.007488000 +0900
+++ AndroidSource/packages/apps/Settings/AndroidManifest.xml 2016-01-05 18:58:39.000000000 +0900
@@ -261,6 +261,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/Settings/.git/HEAD AndroidSource/packages/apps/Settings/.git/HEAD
--- Original_4.4.4_r1/packages/apps/Settings/.git/HEAD 2016-01-29 15:12:43.003488000 +0900
+++ AndroidSource/packages/apps/Settings/.git/HEAD 1970-01-01 09:00:00.000000000 +0900
@@ -1 +0,0 @@
-dd9d9015b82bd94527c4a906e1db9ff395c86113
Binary files Original_4.4.4_r1/packages/apps/Settings/.git/index and AndroidSource/packages/apps/Settings/.git/index differ
diff -urN Original_4.4.4_r1/packages/apps/Settings/.gitignore AndroidSource/packages/apps/Settings/.gitignore
--- Original_4.4.4_r1/packages/apps/Settings/.gitignore 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/Settings/.gitignore 2016-02-15 18:34:09.000000000 +0900
@@ -0,0 +1 @@
+/bin/
diff -urN Original_4.4.4_r1/packages/apps/Settings/.project AndroidSource/packages/apps/Settings/.project
--- Original_4.4.4_r1/packages/apps/Settings/.project 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/Settings/.project 2016-02-15 13:10:41.000000000 +0900
@@ -0,0 +1,17 @@
+
+
+ Settings
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff -urN Original_4.4.4_r1/packages/apps/Settings/res/layout/collaboroid_dialog_row.xml AndroidSource/packages/apps/Settings/res/layout/collaboroid_dialog_row.xml
--- Original_4.4.4_r1/packages/apps/Settings/res/layout/collaboroid_dialog_row.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/Settings/res/layout/collaboroid_dialog_row.xml 2016-06-21 18:39:22.000000000 +0900
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/Settings/res/layout/collaboroid_dialog.xml AndroidSource/packages/apps/Settings/res/layout/collaboroid_dialog.xml
--- Original_4.4.4_r1/packages/apps/Settings/res/layout/collaboroid_dialog.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/Settings/res/layout/collaboroid_dialog.xml 2016-06-24 12:33:29.000000000 +0900
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/Settings/res/values/strings.xml AndroidSource/packages/apps/Settings/res/values/strings.xml
--- Original_4.4.4_r1/packages/apps/Settings/res/values/strings.xml 2016-01-29 15:12:43.167488000 +0900
+++ AndroidSource/packages/apps/Settings/res/values/strings.xml 2016-06-24 12:32:56.000000000 +0900
@@ -1384,7 +1384,27 @@
Automatic setup (WPS)
To complete setup, your tablet needs access to Wi\u2011Fi. After setup, you can switch between mobile data and Wi\u2011Fi.
+
+
+
+ CollaboRoid
+ CollaboRoid
+
+ CollaboRoid settings
+ No Remote Device...
+
+ Refresh
+ Start Collaboration
+
+ Resource
+ Ask
+ Request
+ Allow
+
+ Submit
+ Cancel
+
Show advanced options
diff -urN Original_4.4.4_r1/packages/apps/Settings/res/values/styles.xml AndroidSource/packages/apps/Settings/res/values/styles.xml
--- Original_4.4.4_r1/packages/apps/Settings/res/values/styles.xml 2016-01-29 15:12:43.167488000 +0900
+++ AndroidSource/packages/apps/Settings/res/values/styles.xml 2016-01-18 14:39:37.000000000 +0900
@@ -248,4 +248,27 @@
+
+
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/Settings/res/xml/collaboroid_settings.xml AndroidSource/packages/apps/Settings/res/xml/collaboroid_settings.xml
--- Original_4.4.4_r1/packages/apps/Settings/res/xml/collaboroid_settings.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/Settings/res/xml/collaboroid_settings.xml 2016-01-05 18:44:40.000000000 +0900
@@ -0,0 +1,20 @@
+
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/Settings/res/xml/settings_headers.xml AndroidSource/packages/apps/Settings/res/xml/settings_headers.xml
--- Original_4.4.4_r1/packages/apps/Settings/res/xml/settings_headers.xml 2016-01-29 15:12:43.171488000 +0900
+++ AndroidSource/packages/apps/Settings/res/xml/settings_headers.xml 2016-01-05 19:32:36.000000000 +0900
@@ -28,6 +28,13 @@
android:fragment="com.android.settings.wifi.WifiSettings"
android:title="@string/wifi_settings_title"
android:icon="@drawable/ic_settings_wireless" />
+
+
+
askedResources = new HashMap();
+ private HashMap allowedResources = new HashMap();
+
+ private CheckBox[] resourceCheckBoxes = new CheckBox[Device.RESOURCE_TYPE_SIZE];
+ private int[][] resources = new int[2][Device.RESOURCE_TYPE_SIZE];
+
+ private View mView;
+ //private WifiConfigController mController;
+
+ public CollaboRoidDialog(Context context, DialogInterface.OnClickListener listener,
+ RemoteDevice remoteDevice, boolean edit) {
+ super(context);
+ mEdit = edit;
+ mListener = listener;
+ mRemoteDevice = remoteDevice;
+ }
+
+ public CollaboRoidDialog(Context context, DialogInterface.OnClickListener listener,
+ RemoteDevice remoteDevice) {
+ super(context);
+ mEdit = false;
+ mListener = listener;
+ mRemoteDevice = remoteDevice;
+ }
+
+ /*@Override
+ public WifiConfigController getController() {
+ return mController;
+ }*/
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ //mView = getLayoutInflater().inflate(R.layout.collaboroid_dialog, null);
+ mView = getLayoutInflater().inflate(R.layout.collaboroid_dialog, null);
+ setView(mView);
+ setInverseBackgroundForced(true);
+ //mController = new WifiConfigController(this, mView, mRemoteDevice, mEdit);
+ super.onCreate(savedInstanceState);
+
+ ViewGroup group = (ViewGroup) mView.findViewById(R.id.info);
+
+ Log.d(TAG, mRemoteDevice.name + " - " + mRemoteDevice.description);
+
+ for(int resource : mRemoteDevice.resources)
+ addRow(group, resource, mRemoteDevice.askedResources[resource]==1, mRemoteDevice.allowedResources[resource]==1);
+ }
+
+ private void addRow(ViewGroup group, int resource, Boolean isAsked, Boolean isAllowed)
+ {
+ View row = this.getLayoutInflater().inflate(R.layout.collaboroid_dialog_row, group, false);
+
+ ((TextView) row.findViewById(R.id.name)).setText(Device.ResourceNames[resource]);
+
+ CheckBox cb = (CheckBox) row.findViewById(R.id.checkbox_ask);
+ cb.setChecked(isAsked);
+ cb.setTag(resource);
+ cb.setOnCheckedChangeListener(new OnCheckedChangeListener()
+ {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
+ {
+ // TODO Auto-generated method stub
+ String msg = buttonView.getText().toString();
+
+ askedResources.put(msg, isChecked);
+
+ resources[0][Integer.parseInt(buttonView.getTag().toString())] = isChecked?1:0;
+
+ Log.d(TAG, buttonView.getTag() + " - " + isChecked);
+ }
+ });
+ resourceCheckBoxes[resource] = cb;
+
+ /*CheckBox cb2 = (CheckBox) row.findViewById(R.id.checkbox_allow);
+ cb2.setChecked(isAllowed);
+ cb2.setTag(resource);
+ cb2.setOnCheckedChangeListener(new OnCheckedChangeListener()
+ {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
+ {
+ // TODO Auto-generated method stub
+
+ String msg = buttonView.getText().toString();
+
+ allowedResources.put(msg, isChecked);
+
+ resources[1][Integer.parseInt(buttonView.getTag().toString())] = isChecked?1:0;
+
+ Log.d(TAG, buttonView.getTag() + " - " + isChecked);
+ }
+ });*/
+
+ group.addView(row);
+
+ askedResources.put(Device.ResourceNames[resource], true);
+ //allowedResources.put(Device.ResourceNames[resource], true);
+ }
+
+ public int[] getAskedResources()
+ {
+ for(int i=0; i selectedRemoteDevices = new ArrayList();
+
+
+
+ public CollaboRoidSettings() {
+ super(DISALLOW_CONFIG_WIFI);
+ mFilter = new IntentFilter();
+ mFilter.addAction(CollaboRoidManager.COLLABOROID_STATE_CHANGED_ACTION);
+
+ mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ // TODO Auto-generated method stub
+ if(intent.getIntExtra(CollaboRoidManager.EXTRA_COLLABOROID_STATE, CollaboRoidManager.COLLABOROID_STATE_UNKNOWN)
+ == CollaboRoidManager.COLLABOROID_STATE_DISABLED)
+ setOffMessage();
+ }
+ };
+ }
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ // Set this flag early, as it's needed by getHelpResource(), which is called by super
+
+ Log.d(TAG, "onCreate");
+ super.onCreate(icicle);
+ }
+
+ @Override
+ public View onCreateView(final LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+
+ Log.d(TAG, "onCreateView");
+
+ return super.onCreateView(inflater, container, savedInstanceState);
+
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ final Activity activity = getActivity();
+ mDeviceManager = (DeviceManager) getSystemService(Context.DEVICE_MANAGEMENT_SERVICE);
+ mRemoteManager = (RemoteServiceManager) getSystemService(Context.REMOTE_SERVICE);
+
+ //final Intent intent = activity.getIntent();
+ addPreferencesFromResource(R.xml.collaboroid_settings);
+
+ actionBarSwitch = new Switch(activity);
+
+ if (activity instanceof PreferenceActivity) {
+ PreferenceActivity preferenceActivity = (PreferenceActivity) activity;
+ if (preferenceActivity.onIsHidingHeaders() || !preferenceActivity.onIsMultiPane()) {
+ final int padding = activity.getResources().getDimensionPixelSize(
+ R.dimen.action_bar_switch_padding);
+ actionBarSwitch.setPaddingRelative(0, 0, padding, 0);
+ activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
+ ActionBar.DISPLAY_SHOW_CUSTOM);
+ activity.getActionBar().setCustomView(actionBarSwitch, new ActionBar.LayoutParams(
+ ActionBar.LayoutParams.WRAP_CONTENT,
+ ActionBar.LayoutParams.WRAP_CONTENT,
+ Gravity.CENTER_VERTICAL | Gravity.END));
+ }
+ }
+
+ mCollaboRoidEnabler = new CollaboRoidEnabler(activity, actionBarSwitch);
+
+ mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
+ getListView().setEmptyView(mEmptyView);
+
+ registerForContextMenu(getListView());
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ if(mCollaboRoidEnabler != null)
+ {
+ mCollaboRoidEnabler.resume();
+ }
+ getActivity().registerReceiver(mReceiver, mFilter);
+ updateRemoteDevices();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ if(mCollaboRoidEnabler != null)
+ {
+ mCollaboRoidEnabler.pause();
+ }
+ getActivity().unregisterReceiver(mReceiver);
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ TypedArray ta = getActivity().getTheme().obtainStyledAttributes(
+ new int[] {R.attr.ic_menu_add, R.attr.ic_wps});
+
+ menu.add(Menu.NONE, MENU_REFRESH_ID, 0, R.string.collaboroid_menu_refresh)
+ //.setIcon(ta.getDrawable(1))
+ .setEnabled(true)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ menu.add(Menu.NONE, MENU_START_ID, 0, R.string.collaboroid_menu_start)
+ //.setIcon(ta.getDrawable(0))
+ .setEnabled(true)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
+ /*menu.add(Menu.NONE, 2, 0, R.string.wifi_menu_scan)
+ // .setIcon(R.drawable.ic_menu_scan_network)
+ .setEnabled(true)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);*/
+ ta.recycle();
+
+ super.onCreateOptionsMenu(menu, inflater);
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+
+
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // If the user is not allowed to configure wifi, do not handle menu selections.
+ // if (isRestrictedAndNotPinProtected()) return false;
+
+ Log.d(TAG, "onOptionItemSelected: " + item.getItemId());
+ if(item.getItemId() == MENU_REFRESH_ID)
+ {
+ updateRemoteDevices();
+ mRemoteManager.testOperation();
+ }
+ else if(item.getItemId() == MENU_START_ID)
+ {
+ //mDeviceManager.constructCluster(remoteDevicesToDevices(selectedRemoteDevices));
+ mDeviceManager.askResources(remoteDevicesToDevices(selectedRemoteDevices));
+ mRemoteManager.startServer();
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+
+ public List remoteDevicesToDevices(List remoteDevices)
+ {
+ List devices = new ArrayList();
+
+ for(RemoteDevice rd : remoteDevices)
+ devices.add(rd.getDevice());
+
+ return devices;
+ }
+
+ @Override
+ public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo info) {
+
+ }
+
+ @Override
+ public boolean onContextItemSelected(MenuItem item) {
+ Log.d(TAG, "onContextItemSelected: " + item.getItemId());
+
+ return super.onContextItemSelected(item);
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
+
+ //here!!
+ if (preference instanceof RemoteDevice)
+ {
+ if(((CheckBoxPreference)preference).isChecked())
+ {
+ selectedRemoteDevices.add((RemoteDevice)preference);
+ mSelectedRemoteDevice = (RemoteDevice) preference;
+ showDialog(mSelectedRemoteDevice);
+ }
+ else
+ selectedRemoteDevices.remove(preference);
+ }
+ else
+ return super.onPreferenceTreeClick(screen, preference);
+
+ return true;
+ }
+
+ private void showDialog(RemoteDevice remoteDevice)
+ {
+ if (mDialog != null)
+ {
+ //removeDialog(REMOTE_DEVICE_DIALOG_ID);
+ mDialog = null;
+ }
+
+ // Save the access point and edit mode
+ mDlgRemoteDevice = remoteDevice;
+ //mDlgEdit = edit;
+
+ showDialog(REMOTE_DEVICE_DIALOG_ID);
+ }
+
+
+ @Override
+ public Dialog onCreateDialog(int dialogId) {
+
+
+ switch (dialogId)
+ {
+ case REMOTE_DEVICE_DIALOG_ID:
+ RemoteDevice rd = mDlgRemoteDevice; // For manual launch
+ Log.d(TAG, "onCreateDialog: " + rd.name);
+
+ // null exception !!!!!!!!!!!!!!!!!!!!!!!!
+
+ /*if (rd == null)
+ { // For re-launch from saved state
+ if (mAccessPointSavedState != null)
+ {
+ ap = new AccessPoint(getActivity(), mAccessPointSavedState);
+ // For repeated orientation changes
+ mDlgRemoteDevice = ap;
+ // Reset the saved access point data
+ mAccessPointSavedState = null;
+ }
+ }*/
+ // If it's still null, fine, it's for Add Network
+ //mSelectedAccessPoint = ap;
+
+ mDialog = new CollaboRoidDialog(getActivity(), this, rd);
+ mDialog.setSubmitButton(getActivity().getString(R.string.collaboroid_submit));
+ mDialog.setCancelButton(getActivity().getString(R.string.collaboroid_cancel));
+ mDialog.setTitle(rd.name);
+ return mDialog;
+ }
+
+ return super.onCreateDialog(dialogId);
+ }
+
+
+ @Override
+ public void onClick(DialogInterface dialogInterface, int button) {
+ /*if (button == WifiDialog.BUTTON_FORGET && mSelectedAccessPoint != null) {
+ forget();
+ } else if (button == WifiDialog.BUTTON_SUBMIT) {
+ if (mDialog != null) {
+ submit(mDialog.getController());
+ }
+ }*/
+
+ Log.d(TAG, "onClick: " + button);
+ if (button == CollaboRoidDialog.BUTTON_SUBMIT)
+ {
+ if (mDialog != null)
+ {
+ submit(mDialog);
+ }
+ }
+ }
+
+ void submit(CollaboRoidDialog dialog)
+ {
+ mSelectedRemoteDevice.setAllowedResources(dialog.getAllowedResources());
+ mSelectedRemoteDevice.setAskedResources(dialog.getAskedResources());
+
+ /*int[] resources = dialog.getAllowedResources();
+ for(int i=0; i<7; i++)
+ Log.d(TAG, "allow: " + resources[i]);
+
+ int[] resources2 = dialog.getAskedResources();
+ for(int i=0; i<7; i++)
+ Log.d(TAG, "ask: " + resources2[i]);
+
+ Log.d(TAG, "TEST:" + resources2.toString());*/
+
+
+ }
+
+ @Override
+ protected int getHelpResource() {
+
+ return R.string.help_url_wifi;
+ }
+
+ private void updateRemoteDevices()
+ {
+ // Safeguard from some delayed event handling
+ if (getActivity() == null)
+ return;
+
+ final Collection remoteDevices = findRemoteDevices();
+ getPreferenceScreen().removeAll();
+
+ /*ArrayList resources = new ArrayList();
+ resources.add("Touch");
+ resources.add("Key");
+ resources.add("Sensor");
+ resources.add("Location");
+ resources.add("Audio");
+ resources.add("Video");
+
+ RemoteDevice rd = new RemoteDevice(getActivity(), "JAKE", "21%", resources);
+ getPreferenceScreen().addPreference(rd);
+
+ rd = new RemoteDevice(getActivity(), "SAM", "45%", resources);
+ getPreferenceScreen().addPreference(rd);*/
+
+ /*if (remoteDevices.size() == 0)
+ {
+ addMessagePreference(R.string.collaboroid_empty_list);
+ }
+ else*/
+
+ if(mDeviceManager.getNumofConfiguredDevices() > 0)
+ {
+ for (RemoteDevice remoteDevice : remoteDevices)
+ {
+ Device rd = mDeviceManager.getDevice(remoteDevice.name);
+ if(rd != null)
+ {
+ remoteDevice.setAskedResources(rd.askedResources);
+ remoteDevice.setAllowedResources(rd.allowedResources);
+ remoteDevice.setChecked(true);
+ }
+
+ getPreferenceScreen().addPreference(remoteDevice);
+ }
+ }
+ else
+ for (RemoteDevice remoteDevice : remoteDevices)
+ {
+ getPreferenceScreen().addPreference(remoteDevice);
+ }
+ }
+
+ private void setOffMessage()
+ {
+ if (mEmptyView != null) {
+ mEmptyView.setText(R.string.collaboroid_empty_list);
+ }
+ getPreferenceScreen().removeAll();
+ }
+
+
+ private void addMessagePreference(int messageId)
+ {
+ if (mEmptyView != null)
+ mEmptyView.setText(messageId);
+ getPreferenceScreen().removeAll();
+ }
+
+ List findRemoteDevices()
+ {
+ List devices = mDeviceManager.getDeviceList(1);
+ ArrayList remoteDevices = new ArrayList();
+
+ // need to be modified
+ ArrayList resources = new ArrayList();
+
+ resources.add(Device.RESOURCE_TYPE_TOUCH);
+ resources.add(Device.RESOURCE_TYPE_KEY);
+ resources.add(Device.RESOURCE_TYPE_SENSOR);
+ resources.add(Device.RESOURCE_TYPE_LOCATION);
+ resources.add(Device.RESOURCE_TYPE_VIDEO);
+ resources.add(Device.RESOURCE_TYPE_AUDIO);
+ resources.add(Device.RESOURCE_TYPE_VIBRATOR);
+
+
+ for(Device device : devices)
+ {
+ RemoteDevice remoteDevice = new RemoteDevice(getActivity(), device, resources);
+ remoteDevices.add(remoteDevice);
+ Log.d(TAG, device.toString());
+ }
+
+ return remoteDevices;
+ }
+
+ /**
+ * Used as the outer frame of all setup wizard pages that need to adjust their margins based
+ * on the total size of the available display. (e.g. side margins set to 10% of total width.)
+ */
+ public static class ProportionalOuterFrame extends RelativeLayout {
+ public ProportionalOuterFrame(Context context) {
+ super(context);
+ }
+ public ProportionalOuterFrame(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+ public ProportionalOuterFrame(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ /**
+ * Set our margins and title area height proportionally to the available display size
+ */
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
+ int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
+ final Resources resources = getContext().getResources();
+ float titleHeight = resources.getFraction(R.dimen.setup_title_height, 1, 1);
+ float sideMargin = resources.getFraction(R.dimen.setup_border_width, 1, 1);
+ int bottom = resources.getDimensionPixelSize(R.dimen.setup_margin_bottom);
+ setPaddingRelative(
+ (int) (parentWidth * sideMargin),
+ 0,
+ (int) (parentWidth * sideMargin),
+ bottom);
+ View title = findViewById(R.id.title_area);
+ if (title != null) {
+ title.setMinimumHeight((int) (parentHeight * titleHeight));
+ }
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+ }
+
+}
diff -urN Original_4.4.4_r1/packages/apps/Settings/src/com/android/settings/collaboroid/RemoteDevice.java AndroidSource/packages/apps/Settings/src/com/android/settings/collaboroid/RemoteDevice.java
--- Original_4.4.4_r1/packages/apps/Settings/src/com/android/settings/collaboroid/RemoteDevice.java 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/Settings/src/com/android/settings/collaboroid/RemoteDevice.java 2016-06-20 21:00:58.000000000 +0900
@@ -0,0 +1,106 @@
+package com.android.settings.collaboroid;
+
+import java.util.ArrayList;
+
+import android.content.Context;
+import android.preference.CheckBoxPreference;
+import android.service.devicemanager.Device;
+
+public class RemoteDevice extends CheckBoxPreference
+{
+ Device device;
+
+ String name;
+ String description;
+
+ ArrayList resources;
+
+ int[] askedResources;
+ int[] allowedResources;
+
+ public RemoteDevice(Context context)
+ {
+ super(context);
+ // TODO Auto-generated constructor stub
+ //setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
+ refresh();
+ }
+
+ public RemoteDevice(Context context, String name, String des, ArrayList resources)
+ {
+ super(context);
+ // TODO Auto-generated constructor stub
+ //setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
+ this.name = name;
+ description = des;
+ this.resources = resources;
+ askedResources = new int[Device.RESOURCE_TYPE_SIZE];
+ allowedResources = new int[Device.RESOURCE_TYPE_SIZE];
+
+ refresh();
+ }
+
+ public RemoteDevice(Context context, Device device, ArrayList resources)
+ {
+ super(context);
+ // TODO Auto-generated constructor stub
+ //setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
+ this.device = device;
+ this.name = device.deviceName;
+ description = device.idleCpu;
+ this.resources = resources;
+ askedResources = new int[Device.RESOURCE_TYPE_SIZE];
+ allowedResources = new int[Device.RESOURCE_TYPE_SIZE];
+
+ refresh();
+ }
+
+ private void refresh()
+ {
+ setTitle(name);
+ setSummary(description);
+ }
+
+ public void setAllowedResources(int[] resources)
+ {
+ allowedResources = resources;
+ device.setAllowedResources(resources);
+ }
+
+ public void setAskedResources(int[] resources)
+ {
+ askedResources = resources;
+ device.setAskedResources(resources);
+ }
+
+ public int[] getAllowedResources()
+ {
+ return allowedResources;
+ }
+
+ public int[] getAskedResources()
+ {
+ return askedResources;
+ }
+
+ public String toString()
+ {
+ String str, allowed="", asked="";
+
+ for(int resource : askedResources)
+ asked += (resource + " ");
+
+ for(int resource : allowedResources)
+ allowed += (resource + " ");
+
+ str = "name: " + name + " description: " + description + " resources: " + resources.toString() +
+ "\nask: " + asked + "\nallowed: " + allowed;
+
+ return str;
+ }
+
+ public Device getDevice()
+ {
+ return device;
+ }
+}
diff -urN Original_4.4.4_r1/packages/apps/Settings/src/com/android/settings/Settings.java AndroidSource/packages/apps/Settings/src/com/android/settings/Settings.java
--- Original_4.4.4_r1/packages/apps/Settings/src/com/android/settings/Settings.java 2016-01-29 15:12:43.179488000 +0900
+++ AndroidSource/packages/apps/Settings/src/com/android/settings/Settings.java 2016-01-13 12:21:58.000000000 +0900
@@ -71,6 +71,8 @@
import com.android.settings.applications.ProcessStatsUi;
import com.android.settings.bluetooth.BluetoothEnabler;
import com.android.settings.bluetooth.BluetoothSettings;
+import com.android.settings.collaboroid.CollaboRoidEnabler;
+import com.android.settings.collaboroid.CollaboRoidSettings;
import com.android.settings.deviceinfo.Memory;
import com.android.settings.deviceinfo.UsbSettings;
import com.android.settings.fuelgauge.PowerUsageSummary;
@@ -136,6 +138,7 @@
private int[] SETTINGS_FOR_RESTRICTED = {
R.id.wireless_section,
R.id.wifi_settings,
+ R.id.collaboroid_settings,
R.id.bluetooth_settings,
R.id.data_usage_settings,
R.id.wireless_settings,
@@ -309,6 +312,7 @@
private static final String[] ENTRY_FRAGMENTS = {
WirelessSettings.class.getName(),
WifiSettings.class.getName(),
+ CollaboRoidSettings.class.getName(),
AdvancedWifiSettings.class.getName(),
BluetoothSettings.class.getName(),
TetherSettings.class.getName(),
@@ -505,6 +509,7 @@
// uiOptions for fragments also defined as activities in manifest.
if (WifiSettings.class.getName().equals(fragmentName) ||
WifiP2pSettings.class.getName().equals(fragmentName) ||
+ CollaboRoidSettings.class.getName().equals(fragmentName) ||
BluetoothSettings.class.getName().equals(fragmentName) ||
DreamSettings.class.getName().equals(fragmentName) ||
LocationSettings.class.getName().equals(fragmentName) ||
@@ -779,6 +784,7 @@
private static final int HEADER_TYPE_COUNT = HEADER_TYPE_BUTTON + 1;
private final WifiEnabler mWifiEnabler;
+ private final CollaboRoidEnabler mCollaboRoidEnabler;
private final BluetoothEnabler mBluetoothEnabler;
private AuthenticatorHelper mAuthHelper;
private DevicePolicyManager mDevicePolicyManager;
@@ -797,7 +803,7 @@
static int getHeaderType(Header header) {
if (header.fragment == null && header.intent == null) {
return HEADER_TYPE_CATEGORY;
- } else if (header.id == R.id.wifi_settings || header.id == R.id.bluetooth_settings) {
+ } else if (header.id == R.id.wifi_settings || header.id == R.id.collaboroid_settings || header.id == R.id.bluetooth_settings) {
return HEADER_TYPE_SWITCH;
} else if (header.id == R.id.security_settings) {
return HEADER_TYPE_BUTTON;
@@ -842,6 +848,7 @@
// Temp Switches provided as placeholder until the adapter replaces these with actual
// Switches inflated from their layouts. Must be done before adapter is set in super
mWifiEnabler = new WifiEnabler(context, new Switch(context));
+ mCollaboRoidEnabler = new CollaboRoidEnabler(context, new Switch(context));
mBluetoothEnabler = new BluetoothEnabler(context, new Switch(context));
mDevicePolicyManager = dpm;
}
@@ -912,7 +919,12 @@
// Would need a different treatment if the main menu had more switches
if (header.id == R.id.wifi_settings) {
mWifiEnabler.setSwitch(holder.switch_);
- } else {
+ }
+ else if(header.id == R.id.collaboroid_settings)
+ {
+ mCollaboRoidEnabler.setSwitch(holder.switch_);
+ }
+ else {
mBluetoothEnabler.setSwitch(holder.switch_);
}
updateCommonHeaderView(header, holder);
@@ -986,11 +998,13 @@
public void resume() {
mWifiEnabler.resume();
+ mCollaboRoidEnabler.resume();
mBluetoothEnabler.resume();
}
public void pause() {
mWifiEnabler.pause();
+ mCollaboRoidEnabler.pause();
mBluetoothEnabler.pause();
}
}
diff -urN Original_4.4.4_r1/packages/apps/Settings/src/com/android/settings/wifi/WifiSettings.java AndroidSource/packages/apps/Settings/src/com/android/settings/wifi/WifiSettings.java
--- Original_4.4.4_r1/packages/apps/Settings/src/com/android/settings/wifi/WifiSettings.java 2016-01-29 15:12:43.191488000 +0900
+++ AndroidSource/packages/apps/Settings/src/com/android/settings/wifi/WifiSettings.java 2016-01-12 13:46:51.000000000 +0900
@@ -83,1047 +83,1300 @@
/**
* Two types of UI are provided here.
- *
+ *
* The first is for "usual Settings", appearing as any other Setup fragment.
- *
- * The second is for Setup Wizard, with a simplified interface that hides the action bar
- * and menus.
+ *
+ * The second is for Setup Wizard, with a simplified interface that hides the
+ * action bar and menus.
*/
-public class WifiSettings extends RestrictedSettingsFragment
- implements DialogInterface.OnClickListener {
- private static final String TAG = "WifiSettings";
- private static final int MENU_ID_WPS_PBC = Menu.FIRST;
- private static final int MENU_ID_WPS_PIN = Menu.FIRST + 1;
- private static final int MENU_ID_P2P = Menu.FIRST + 2;
- private static final int MENU_ID_ADD_NETWORK = Menu.FIRST + 3;
- private static final int MENU_ID_ADVANCED = Menu.FIRST + 4;
- private static final int MENU_ID_SCAN = Menu.FIRST + 5;
- private static final int MENU_ID_CONNECT = Menu.FIRST + 6;
- private static final int MENU_ID_FORGET = Menu.FIRST + 7;
- private static final int MENU_ID_MODIFY = Menu.FIRST + 8;
-
- private static final int WIFI_DIALOG_ID = 1;
- private static final int WPS_PBC_DIALOG_ID = 2;
- private static final int WPS_PIN_DIALOG_ID = 3;
- private static final int WIFI_SKIPPED_DIALOG_ID = 4;
- private static final int WIFI_AND_MOBILE_SKIPPED_DIALOG_ID = 5;
-
- // Combo scans can take 5-6s to complete - set to 10s.
- private static final int WIFI_RESCAN_INTERVAL_MS = 10 * 1000;
-
- // Instance state keys
- private static final String SAVE_DIALOG_EDIT_MODE = "edit_mode";
- private static final String SAVE_DIALOG_ACCESS_POINT_STATE = "wifi_ap_state";
-
- // Activity result when pressing the Skip button
- private static final int RESULT_SKIP = Activity.RESULT_FIRST_USER;
-
- private final IntentFilter mFilter;
- private final BroadcastReceiver mReceiver;
- private final Scanner mScanner;
-
- private WifiManager mWifiManager;
- private WifiManager.ActionListener mConnectListener;
- private WifiManager.ActionListener mSaveListener;
- private WifiManager.ActionListener mForgetListener;
- private boolean mP2pSupported;
-
- private WifiEnabler mWifiEnabler;
- // An access point being editted is stored here.
- private AccessPoint mSelectedAccessPoint;
-
- private DetailedState mLastState;
- private WifiInfo mLastInfo;
-
- private final AtomicBoolean mConnected = new AtomicBoolean(false);
-
- private WifiDialog mDialog;
-
- private TextView mEmptyView;
-
- /* Used in Wifi Setup context */
-
- // this boolean extra specifies whether to disable the Next button when not connected
- private static final String EXTRA_ENABLE_NEXT_ON_CONNECT = "wifi_enable_next_on_connect";
-
- // this boolean extra specifies whether to auto finish when connection is established
- private static final String EXTRA_AUTO_FINISH_ON_CONNECT = "wifi_auto_finish_on_connect";
-
- // this boolean extra shows a custom button that we can control
- protected static final String EXTRA_SHOW_CUSTOM_BUTTON = "wifi_show_custom_button";
-
- // show a text regarding data charges when wifi connection is required during setup wizard
- protected static final String EXTRA_SHOW_WIFI_REQUIRED_INFO = "wifi_show_wifi_required_info";
-
- // this boolean extra is set if we are being invoked by the Setup Wizard
- private static final String EXTRA_IS_FIRST_RUN = "firstRun";
-
- // should Next button only be enabled when we have a connection?
- private boolean mEnableNextOnConnection;
-
- // should activity finish once we have a connection?
- private boolean mAutoFinishOnConnection;
-
- // Save the dialog details
- private boolean mDlgEdit;
- private AccessPoint mDlgAccessPoint;
- private Bundle mAccessPointSavedState;
-
- // the action bar uses a different set of controls for Setup Wizard
- private boolean mSetupWizardMode;
-
- /* End of "used in Wifi Setup context" */
-
- public WifiSettings() {
- super(DISALLOW_CONFIG_WIFI);
- mFilter = new IntentFilter();
- mFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
- mFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
- mFilter.addAction(WifiManager.NETWORK_IDS_CHANGED_ACTION);
- mFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
- mFilter.addAction(WifiManager.CONFIGURED_NETWORKS_CHANGED_ACTION);
- mFilter.addAction(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION);
- mFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
- mFilter.addAction(WifiManager.RSSI_CHANGED_ACTION);
-
- mReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- handleEvent(context, intent);
- }
- };
-
- mScanner = new Scanner();
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- // Set this flag early, as it's needed by getHelpResource(), which is called by super
- mSetupWizardMode = getActivity().getIntent().getBooleanExtra(EXTRA_IS_FIRST_RUN, false);
-
- super.onCreate(icicle);
- }
-
- @Override
- public View onCreateView(final LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- if (mSetupWizardMode) {
- View view = inflater.inflate(R.layout.setup_preference, container, false);
- View other = view.findViewById(R.id.other_network);
- other.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mWifiManager.isWifiEnabled()) {
- onAddNetworkPressed();
- }
- }
- });
- final ImageButton b = (ImageButton) view.findViewById(R.id.more);
- if (b != null) {
- b.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mWifiManager.isWifiEnabled()) {
- PopupMenu pm = new PopupMenu(inflater.getContext(), b);
- pm.inflate(R.menu.wifi_setup);
- pm.setOnMenuItemClickListener(new OnMenuItemClickListener() {
- @Override
- public boolean onMenuItemClick(MenuItem item) {
- if (R.id.wifi_wps == item.getItemId()) {
- showDialog(WPS_PBC_DIALOG_ID);
- return true;
- }
- return false;
- }
- });
- pm.show();
- }
- }
- });
- }
-
- Intent intent = getActivity().getIntent();
- if (intent.getBooleanExtra(EXTRA_SHOW_CUSTOM_BUTTON, false)) {
- view.findViewById(R.id.button_bar).setVisibility(View.VISIBLE);
- view.findViewById(R.id.back_button).setVisibility(View.INVISIBLE);
- view.findViewById(R.id.skip_button).setVisibility(View.INVISIBLE);
- view.findViewById(R.id.next_button).setVisibility(View.INVISIBLE);
-
- Button customButton = (Button) view.findViewById(R.id.custom_button);
- customButton.setVisibility(View.VISIBLE);
- customButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- boolean isConnected = false;
- Activity activity = getActivity();
- final ConnectivityManager connectivity = (ConnectivityManager)
- activity.getSystemService(Context.CONNECTIVITY_SERVICE);
- if (connectivity != null) {
- final NetworkInfo info = connectivity.getActiveNetworkInfo();
- isConnected = (info != null) && info.isConnected();
- }
- if (isConnected) {
- // Warn of possible data charges
- showDialog(WIFI_SKIPPED_DIALOG_ID);
- } else {
- // Warn of lack of updates
- showDialog(WIFI_AND_MOBILE_SKIPPED_DIALOG_ID);
- }
- }
- });
- }
-
- if (intent.getBooleanExtra(EXTRA_SHOW_WIFI_REQUIRED_INFO, false)) {
- view.findViewById(R.id.wifi_required_info).setVisibility(View.VISIBLE);
- }
-
- return view;
- } else {
- return super.onCreateView(inflater, container, savedInstanceState);
- }
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- mP2pSupported = getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_DIRECT);
- mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
-
- mConnectListener = new WifiManager.ActionListener() {
- @Override
- public void onSuccess() {
- }
- @Override
- public void onFailure(int reason) {
- Activity activity = getActivity();
- if (activity != null) {
- Toast.makeText(activity,
- R.string.wifi_failed_connect_message,
- Toast.LENGTH_SHORT).show();
- }
- }
- };
-
- mSaveListener = new WifiManager.ActionListener() {
- @Override
- public void onSuccess() {
- }
- @Override
- public void onFailure(int reason) {
- Activity activity = getActivity();
- if (activity != null) {
- Toast.makeText(activity,
- R.string.wifi_failed_save_message,
- Toast.LENGTH_SHORT).show();
- }
- }
- };
-
- mForgetListener = new WifiManager.ActionListener() {
- @Override
- public void onSuccess() {
- }
- @Override
- public void onFailure(int reason) {
- Activity activity = getActivity();
- if (activity != null) {
- Toast.makeText(activity,
- R.string.wifi_failed_forget_message,
- Toast.LENGTH_SHORT).show();
- }
- }
- };
-
- if (savedInstanceState != null
- && savedInstanceState.containsKey(SAVE_DIALOG_ACCESS_POINT_STATE)) {
- mDlgEdit = savedInstanceState.getBoolean(SAVE_DIALOG_EDIT_MODE);
- mAccessPointSavedState = savedInstanceState.getBundle(SAVE_DIALOG_ACCESS_POINT_STATE);
- }
-
- final Activity activity = getActivity();
- final Intent intent = activity.getIntent();
-
- // first if we're supposed to finish once we have a connection
- mAutoFinishOnConnection = intent.getBooleanExtra(EXTRA_AUTO_FINISH_ON_CONNECT, false);
-
- if (mAutoFinishOnConnection) {
- // Hide the next button
- if (hasNextButton()) {
- getNextButton().setVisibility(View.GONE);
- }
-
- final ConnectivityManager connectivity = (ConnectivityManager)
- activity.getSystemService(Context.CONNECTIVITY_SERVICE);
- if (connectivity != null
- && connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected()) {
- activity.setResult(Activity.RESULT_OK);
- activity.finish();
- return;
- }
- }
-
- // if we're supposed to enable/disable the Next button based on our current connection
- // state, start it off in the right state
- mEnableNextOnConnection = intent.getBooleanExtra(EXTRA_ENABLE_NEXT_ON_CONNECT, false);
-
- if (mEnableNextOnConnection) {
- if (hasNextButton()) {
- final ConnectivityManager connectivity = (ConnectivityManager)
- activity.getSystemService(Context.CONNECTIVITY_SERVICE);
- if (connectivity != null) {
- NetworkInfo info = connectivity.getNetworkInfo(
- ConnectivityManager.TYPE_WIFI);
- changeNextButtonState(info.isConnected());
- }
- }
- }
-
- addPreferencesFromResource(R.xml.wifi_settings);
-
- if (mSetupWizardMode) {
- getView().setSystemUiVisibility(
-// View.STATUS_BAR_DISABLE_BACK |
- View.STATUS_BAR_DISABLE_HOME |
- View.STATUS_BAR_DISABLE_RECENT |
- View.STATUS_BAR_DISABLE_NOTIFICATION_ALERTS |
- View.STATUS_BAR_DISABLE_CLOCK);
- }
-
- // On/off switch is hidden for Setup Wizard
- if (!mSetupWizardMode) {
- Switch actionBarSwitch = new Switch(activity);
-
- if (activity instanceof PreferenceActivity) {
- PreferenceActivity preferenceActivity = (PreferenceActivity) activity;
- if (preferenceActivity.onIsHidingHeaders() || !preferenceActivity.onIsMultiPane()) {
- final int padding = activity.getResources().getDimensionPixelSize(
- R.dimen.action_bar_switch_padding);
- actionBarSwitch.setPaddingRelative(0, 0, padding, 0);
- activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
- ActionBar.DISPLAY_SHOW_CUSTOM);
- activity.getActionBar().setCustomView(actionBarSwitch, new ActionBar.LayoutParams(
- ActionBar.LayoutParams.WRAP_CONTENT,
- ActionBar.LayoutParams.WRAP_CONTENT,
- Gravity.CENTER_VERTICAL | Gravity.END));
- }
- }
-
- mWifiEnabler = new WifiEnabler(activity, actionBarSwitch);
- }
-
- mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
- getListView().setEmptyView(mEmptyView);
-
- if (!mSetupWizardMode) {
- registerForContextMenu(getListView());
- }
- setHasOptionsMenu(true);
- }
-
- @Override
- public void onResume() {
- super.onResume();
- if (mWifiEnabler != null) {
- mWifiEnabler.resume();
- }
-
- getActivity().registerReceiver(mReceiver, mFilter);
- updateAccessPoints();
- }
-
- @Override
- public void onPause() {
- super.onPause();
- if (mWifiEnabler != null) {
- mWifiEnabler.pause();
- }
- getActivity().unregisterReceiver(mReceiver);
- mScanner.pause();
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- // If the user is not allowed to configure wifi, do not show the menu.
- if (isRestrictedAndNotPinProtected()) return;
-
- final boolean wifiIsEnabled = mWifiManager.isWifiEnabled();
- TypedArray ta = getActivity().getTheme().obtainStyledAttributes(
- new int[] {R.attr.ic_menu_add, R.attr.ic_wps});
- if (mSetupWizardMode) {
- menu.add(Menu.NONE, MENU_ID_WPS_PBC, 0, R.string.wifi_menu_wps_pbc)
- .setIcon(ta.getDrawable(1))
- .setEnabled(wifiIsEnabled)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
- menu.add(Menu.NONE, MENU_ID_ADD_NETWORK, 0, R.string.wifi_add_network)
- .setEnabled(wifiIsEnabled)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
- } else {
- menu.add(Menu.NONE, MENU_ID_WPS_PBC, 0, R.string.wifi_menu_wps_pbc)
- .setIcon(ta.getDrawable(1))
- .setEnabled(wifiIsEnabled)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
- menu.add(Menu.NONE, MENU_ID_ADD_NETWORK, 0, R.string.wifi_add_network)
- .setIcon(ta.getDrawable(0))
- .setEnabled(wifiIsEnabled)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
- menu.add(Menu.NONE, MENU_ID_SCAN, 0, R.string.wifi_menu_scan)
- //.setIcon(R.drawable.ic_menu_scan_network)
- .setEnabled(wifiIsEnabled)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
- menu.add(Menu.NONE, MENU_ID_WPS_PIN, 0, R.string.wifi_menu_wps_pin)
- .setEnabled(wifiIsEnabled)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
- if (mP2pSupported) {
- menu.add(Menu.NONE, MENU_ID_P2P, 0, R.string.wifi_menu_p2p)
- .setEnabled(wifiIsEnabled)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
- }
- menu.add(Menu.NONE, MENU_ID_ADVANCED, 0, R.string.wifi_menu_advanced)
- //.setIcon(android.R.drawable.ic_menu_manage)
- .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
- }
- ta.recycle();
- super.onCreateOptionsMenu(menu, inflater);
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
-
- // If the dialog is showing, save its state.
- if (mDialog != null && mDialog.isShowing()) {
- outState.putBoolean(SAVE_DIALOG_EDIT_MODE, mDlgEdit);
- if (mDlgAccessPoint != null) {
- mAccessPointSavedState = new Bundle();
- mDlgAccessPoint.saveWifiState(mAccessPointSavedState);
- outState.putBundle(SAVE_DIALOG_ACCESS_POINT_STATE, mAccessPointSavedState);
- }
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // If the user is not allowed to configure wifi, do not handle menu selections.
- if (isRestrictedAndNotPinProtected()) return false;
-
- switch (item.getItemId()) {
- case MENU_ID_WPS_PBC:
- showDialog(WPS_PBC_DIALOG_ID);
- return true;
- case MENU_ID_P2P:
- if (getActivity() instanceof PreferenceActivity) {
- ((PreferenceActivity) getActivity()).startPreferencePanel(
- WifiP2pSettings.class.getCanonicalName(),
- null,
- R.string.wifi_p2p_settings_title, null,
- this, 0);
- } else {
- startFragment(this, WifiP2pSettings.class.getCanonicalName(), -1, null);
- }
- return true;
- case MENU_ID_WPS_PIN:
- showDialog(WPS_PIN_DIALOG_ID);
- return true;
- case MENU_ID_SCAN:
- if (mWifiManager.isWifiEnabled()) {
- mScanner.forceScan();
- }
- return true;
- case MENU_ID_ADD_NETWORK:
- if (mWifiManager.isWifiEnabled()) {
- onAddNetworkPressed();
- }
- return true;
- case MENU_ID_ADVANCED:
- if (getActivity() instanceof PreferenceActivity) {
- ((PreferenceActivity) getActivity()).startPreferencePanel(
- AdvancedWifiSettings.class.getCanonicalName(),
- null,
- R.string.wifi_advanced_titlebar, null,
- this, 0);
- } else {
- startFragment(this, AdvancedWifiSettings.class.getCanonicalName(), -1, null);
- }
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo info) {
- if (info instanceof AdapterContextMenuInfo) {
- Preference preference = (Preference) getListView().getItemAtPosition(
- ((AdapterContextMenuInfo) info).position);
-
- if (preference instanceof AccessPoint) {
- mSelectedAccessPoint = (AccessPoint) preference;
- menu.setHeaderTitle(mSelectedAccessPoint.ssid);
- if (mSelectedAccessPoint.getLevel() != -1
- && mSelectedAccessPoint.getState() == null) {
- menu.add(Menu.NONE, MENU_ID_CONNECT, 0, R.string.wifi_menu_connect);
- }
- if (mSelectedAccessPoint.networkId != INVALID_NETWORK_ID) {
- menu.add(Menu.NONE, MENU_ID_FORGET, 0, R.string.wifi_menu_forget);
- menu.add(Menu.NONE, MENU_ID_MODIFY, 0, R.string.wifi_menu_modify);
- }
- }
- }
- }
-
- @Override
- public boolean onContextItemSelected(MenuItem item) {
- if (mSelectedAccessPoint == null) {
- return super.onContextItemSelected(item);
- }
- switch (item.getItemId()) {
- case MENU_ID_CONNECT: {
- if (mSelectedAccessPoint.networkId != INVALID_NETWORK_ID) {
- mWifiManager.connect(mSelectedAccessPoint.networkId,
- mConnectListener);
- } else if (mSelectedAccessPoint.security == AccessPoint.SECURITY_NONE) {
- /** Bypass dialog for unsecured networks */
- mSelectedAccessPoint.generateOpenNetworkConfig();
- mWifiManager.connect(mSelectedAccessPoint.getConfig(),
- mConnectListener);
- } else {
- showDialog(mSelectedAccessPoint, true);
- }
- return true;
- }
- case MENU_ID_FORGET: {
- mWifiManager.forget(mSelectedAccessPoint.networkId, mForgetListener);
- return true;
- }
- case MENU_ID_MODIFY: {
- showDialog(mSelectedAccessPoint, true);
- return true;
- }
- }
- return super.onContextItemSelected(item);
- }
-
- @Override
- public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
- if (preference instanceof AccessPoint) {
- mSelectedAccessPoint = (AccessPoint) preference;
- /** Bypass dialog for unsecured, unsaved networks */
- if (mSelectedAccessPoint.security == AccessPoint.SECURITY_NONE &&
- mSelectedAccessPoint.networkId == INVALID_NETWORK_ID) {
- mSelectedAccessPoint.generateOpenNetworkConfig();
- mWifiManager.connect(mSelectedAccessPoint.getConfig(), mConnectListener);
- } else {
- showDialog(mSelectedAccessPoint, false);
- }
- } else {
- return super.onPreferenceTreeClick(screen, preference);
- }
- return true;
- }
-
- private void showDialog(AccessPoint accessPoint, boolean edit) {
- if (mDialog != null) {
- removeDialog(WIFI_DIALOG_ID);
- mDialog = null;
- }
-
- // Save the access point and edit mode
- mDlgAccessPoint = accessPoint;
- mDlgEdit = edit;
-
- showDialog(WIFI_DIALOG_ID);
- }
-
- @Override
- public Dialog onCreateDialog(int dialogId) {
- switch (dialogId) {
- case WIFI_DIALOG_ID:
- AccessPoint ap = mDlgAccessPoint; // For manual launch
- if (ap == null) { // For re-launch from saved state
- if (mAccessPointSavedState != null) {
- ap = new AccessPoint(getActivity(), mAccessPointSavedState);
- // For repeated orientation changes
- mDlgAccessPoint = ap;
- // Reset the saved access point data
- mAccessPointSavedState = null;
- }
- }
- // If it's still null, fine, it's for Add Network
- mSelectedAccessPoint = ap;
- mDialog = new WifiDialog(getActivity(), this, ap, mDlgEdit);
- return mDialog;
- case WPS_PBC_DIALOG_ID:
- return new WpsDialog(getActivity(), WpsInfo.PBC);
- case WPS_PIN_DIALOG_ID:
- return new WpsDialog(getActivity(), WpsInfo.DISPLAY);
- case WIFI_SKIPPED_DIALOG_ID:
- return new AlertDialog.Builder(getActivity())
- .setMessage(R.string.wifi_skipped_message)
- .setCancelable(false)
- .setNegativeButton(R.string.wifi_skip_anyway,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- getActivity().setResult(RESULT_SKIP);
- getActivity().finish();
- }
- })
- .setPositiveButton(R.string.wifi_dont_skip,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- }
- })
- .create();
- case WIFI_AND_MOBILE_SKIPPED_DIALOG_ID:
- return new AlertDialog.Builder(getActivity())
- .setMessage(R.string.wifi_and_mobile_skipped_message)
- .setCancelable(false)
- .setNegativeButton(R.string.wifi_skip_anyway,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- getActivity().setResult(RESULT_SKIP);
- getActivity().finish();
- }
- })
- .setPositiveButton(R.string.wifi_dont_skip,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- }
- })
- .create();
-
- }
- return super.onCreateDialog(dialogId);
- }
-
- /**
- * Shows the latest access points available with supplimental information like
- * the strength of network and the security for it.
- */
- private void updateAccessPoints() {
- // Safeguard from some delayed event handling
- if (getActivity() == null) return;
-
- if (isRestrictedAndNotPinProtected()) {
- addMessagePreference(R.string.wifi_empty_list_user_restricted);
- return;
- }
- final int wifiState = mWifiManager.getWifiState();
-
- switch (wifiState) {
- case WifiManager.WIFI_STATE_ENABLED:
- // AccessPoints are automatically sorted with TreeSet.
- final Collection accessPoints = constructAccessPoints();
- getPreferenceScreen().removeAll();
- if(accessPoints.size() == 0) {
- addMessagePreference(R.string.wifi_empty_list_wifi_on);
- }
- for (AccessPoint accessPoint : accessPoints) {
- getPreferenceScreen().addPreference(accessPoint);
- }
- break;
-
- case WifiManager.WIFI_STATE_ENABLING:
- getPreferenceScreen().removeAll();
- break;
-
- case WifiManager.WIFI_STATE_DISABLING:
- addMessagePreference(R.string.wifi_stopping);
- break;
-
- case WifiManager.WIFI_STATE_DISABLED:
- setOffMessage();
- break;
- }
- }
-
- private void setOffMessage() {
- if (mEmptyView != null) {
- mEmptyView.setText(R.string.wifi_empty_list_wifi_off);
- if (Settings.Global.getInt(getActivity().getContentResolver(),
- Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1) {
- mEmptyView.append("\n\n");
- int resId;
- if (Settings.Secure.isLocationProviderEnabled(getActivity().getContentResolver(),
- LocationManager.NETWORK_PROVIDER)) {
- resId = R.string.wifi_scan_notify_text_location_on;
- } else {
- resId = R.string.wifi_scan_notify_text_location_off;
- }
- CharSequence charSeq = getText(resId);
- mEmptyView.append(charSeq);
- }
- }
- getPreferenceScreen().removeAll();
- }
-
- private void addMessagePreference(int messageId) {
- if (mEmptyView != null) mEmptyView.setText(messageId);
- getPreferenceScreen().removeAll();
- }
-
- /** Returns sorted list of access points */
- private List constructAccessPoints() {
- ArrayList accessPoints = new ArrayList();
- /** Lookup table to more quickly update AccessPoints by only considering objects with the
- * correct SSID. Maps SSID -> List of AccessPoints with the given SSID. */
- Multimap apMap = new Multimap();
-
- final List configs = mWifiManager.getConfiguredNetworks();
- if (configs != null) {
- for (WifiConfiguration config : configs) {
- AccessPoint accessPoint = new AccessPoint(getActivity(), config);
- accessPoint.update(mLastInfo, mLastState);
- accessPoints.add(accessPoint);
- apMap.put(accessPoint.ssid, accessPoint);
- }
- }
-
- final List results = mWifiManager.getScanResults();
- if (results != null) {
- for (ScanResult result : results) {
- // Ignore hidden and ad-hoc networks.
- if (result.SSID == null || result.SSID.length() == 0 ||
- result.capabilities.contains("[IBSS]")) {
- continue;
- }
-
- boolean found = false;
- for (AccessPoint accessPoint : apMap.getAll(result.SSID)) {
- if (accessPoint.update(result))
- found = true;
- }
- if (!found) {
- AccessPoint accessPoint = new AccessPoint(getActivity(), result);
- accessPoints.add(accessPoint);
- apMap.put(accessPoint.ssid, accessPoint);
- }
- }
- }
-
- // Pre-sort accessPoints to speed preference insertion
- Collections.sort(accessPoints);
- return accessPoints;
- }
-
- /** A restricted multimap for use in constructAccessPoints */
- private class Multimap {
- private final HashMap> store = new HashMap>();
- /** retrieve a non-null list of values with key K */
- List getAll(K key) {
- List values = store.get(key);
- return values != null ? values : Collections.emptyList();
- }
-
- void put(K key, V val) {
- List curVals = store.get(key);
- if (curVals == null) {
- curVals = new ArrayList(3);
- store.put(key, curVals);
- }
- curVals.add(val);
- }
- }
-
- private void handleEvent(Context context, Intent intent) {
- String action = intent.getAction();
- if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
- updateWifiState(intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
- WifiManager.WIFI_STATE_UNKNOWN));
- } else if (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION.equals(action) ||
- WifiManager.CONFIGURED_NETWORKS_CHANGED_ACTION.equals(action) ||
- WifiManager.LINK_CONFIGURATION_CHANGED_ACTION.equals(action)) {
- updateAccessPoints();
- } else if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION.equals(action)) {
- //Ignore supplicant state changes when network is connected
- //TODO: we should deprecate SUPPLICANT_STATE_CHANGED_ACTION and
- //introduce a broadcast that combines the supplicant and network
- //network state change events so the apps dont have to worry about
- //ignoring supplicant state change when network is connected
- //to get more fine grained information.
- SupplicantState state = (SupplicantState) intent.getParcelableExtra(
- WifiManager.EXTRA_NEW_STATE);
- if (!mConnected.get() && SupplicantState.isHandshakeState(state)) {
- updateConnectionState(WifiInfo.getDetailedStateOf(state));
- } else {
- // During a connect, we may have the supplicant
- // state change affect the detailed network state.
- // Make sure a lost connection is updated as well.
- updateConnectionState(null);
- }
- } else if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) {
- NetworkInfo info = (NetworkInfo) intent.getParcelableExtra(
- WifiManager.EXTRA_NETWORK_INFO);
- mConnected.set(info.isConnected());
- changeNextButtonState(info.isConnected());
- updateAccessPoints();
- updateConnectionState(info.getDetailedState());
- if (mAutoFinishOnConnection && info.isConnected()) {
- Activity activity = getActivity();
- if (activity != null) {
- activity.setResult(Activity.RESULT_OK);
- activity.finish();
- }
- return;
- }
- } else if (WifiManager.RSSI_CHANGED_ACTION.equals(action)) {
- updateConnectionState(null);
- }
- }
-
- private void updateConnectionState(DetailedState state) {
- /* sticky broadcasts can call this when wifi is disabled */
- if (!mWifiManager.isWifiEnabled()) {
- mScanner.pause();
- return;
- }
-
- if (state == DetailedState.OBTAINING_IPADDR) {
- mScanner.pause();
- } else {
- mScanner.resume();
- }
-
- mLastInfo = mWifiManager.getConnectionInfo();
- if (state != null) {
- mLastState = state;
- }
-
- for (int i = getPreferenceScreen().getPreferenceCount() - 1; i >= 0; --i) {
- // Maybe there's a WifiConfigPreference
- Preference preference = getPreferenceScreen().getPreference(i);
- if (preference instanceof AccessPoint) {
- final AccessPoint accessPoint = (AccessPoint) preference;
- accessPoint.update(mLastInfo, mLastState);
- }
- }
- }
-
- private void updateWifiState(int state) {
- Activity activity = getActivity();
- if (activity != null) {
- activity.invalidateOptionsMenu();
- }
-
- switch (state) {
- case WifiManager.WIFI_STATE_ENABLED:
- mScanner.resume();
- return; // not break, to avoid the call to pause() below
-
- case WifiManager.WIFI_STATE_ENABLING:
- addMessagePreference(R.string.wifi_starting);
- break;
-
- case WifiManager.WIFI_STATE_DISABLED:
- setOffMessage();
- break;
- }
-
- mLastInfo = null;
- mLastState = null;
- mScanner.pause();
- }
-
- private class Scanner extends Handler {
- private int mRetry = 0;
-
- void resume() {
- if (!hasMessages(0)) {
- sendEmptyMessage(0);
- }
- }
-
- void forceScan() {
- removeMessages(0);
- sendEmptyMessage(0);
- }
-
- void pause() {
- mRetry = 0;
- removeMessages(0);
- }
-
- @Override
- public void handleMessage(Message message) {
- if (mWifiManager.startScan()) {
- mRetry = 0;
- } else if (++mRetry >= 3) {
- mRetry = 0;
- Activity activity = getActivity();
- if (activity != null) {
- Toast.makeText(activity, R.string.wifi_fail_to_scan,
- Toast.LENGTH_LONG).show();
- }
- return;
- }
- sendEmptyMessageDelayed(0, WIFI_RESCAN_INTERVAL_MS);
- }
- }
-
- /**
- * Renames/replaces "Next" button when appropriate. "Next" button usually exists in
- * Wifi setup screens, not in usual wifi settings screen.
- *
- * @param connected true when the device is connected to a wifi network.
- */
- private void changeNextButtonState(boolean connected) {
- if (mEnableNextOnConnection && hasNextButton()) {
- getNextButton().setEnabled(connected);
- }
- }
-
- @Override
- public void onClick(DialogInterface dialogInterface, int button) {
- if (button == WifiDialog.BUTTON_FORGET && mSelectedAccessPoint != null) {
- forget();
- } else if (button == WifiDialog.BUTTON_SUBMIT) {
- if (mDialog != null) {
- submit(mDialog.getController());
- }
- }
- }
-
- /* package */ void submit(WifiConfigController configController) {
-
- final WifiConfiguration config = configController.getConfig();
-
- if (config == null) {
- if (mSelectedAccessPoint != null
- && mSelectedAccessPoint.networkId != INVALID_NETWORK_ID) {
- mWifiManager.connect(mSelectedAccessPoint.networkId,
- mConnectListener);
- }
- } else if (config.networkId != INVALID_NETWORK_ID) {
- if (mSelectedAccessPoint != null) {
- mWifiManager.save(config, mSaveListener);
- }
- } else {
- if (configController.isEdit()) {
- mWifiManager.save(config, mSaveListener);
- } else {
- mWifiManager.connect(config, mConnectListener);
- }
- }
-
- if (mWifiManager.isWifiEnabled()) {
- mScanner.resume();
- }
- updateAccessPoints();
- }
-
- /* package */ void forget() {
- if (mSelectedAccessPoint.networkId == INVALID_NETWORK_ID) {
- // Should not happen, but a monkey seems to triger it
- Log.e(TAG, "Failed to forget invalid network " + mSelectedAccessPoint.getConfig());
- return;
- }
-
- mWifiManager.forget(mSelectedAccessPoint.networkId, mForgetListener);
-
- if (mWifiManager.isWifiEnabled()) {
- mScanner.resume();
- }
- updateAccessPoints();
-
- // We need to rename/replace "Next" button in wifi setup context.
- changeNextButtonState(false);
- }
-
- /**
- * Refreshes acccess points and ask Wifi module to scan networks again.
- */
- /* package */ void refreshAccessPoints() {
- if (mWifiManager.isWifiEnabled()) {
- mScanner.resume();
- }
-
- getPreferenceScreen().removeAll();
- }
-
- /**
- * Called when "add network" button is pressed.
- */
- /* package */ void onAddNetworkPressed() {
- // No exact access point is selected.
- mSelectedAccessPoint = null;
- showDialog(null, true);
- }
-
- /* package */ int getAccessPointsCount() {
- final boolean wifiIsEnabled = mWifiManager.isWifiEnabled();
- if (wifiIsEnabled) {
- return getPreferenceScreen().getPreferenceCount();
- } else {
- return 0;
- }
- }
-
- /**
- * Requests wifi module to pause wifi scan. May be ignored when the module is disabled.
- */
- /* package */ void pauseWifiScan() {
- if (mWifiManager.isWifiEnabled()) {
- mScanner.pause();
- }
- }
-
- /**
- * Requests wifi module to resume wifi scan. May be ignored when the module is disabled.
- */
- /* package */ void resumeWifiScan() {
- if (mWifiManager.isWifiEnabled()) {
- mScanner.resume();
- }
- }
-
- @Override
- protected int getHelpResource() {
- if (mSetupWizardMode) {
- return 0;
- }
- return R.string.help_url_wifi;
- }
-
- /**
- * Used as the outer frame of all setup wizard pages that need to adjust their margins based
- * on the total size of the available display. (e.g. side margins set to 10% of total width.)
- */
- public static class ProportionalOuterFrame extends RelativeLayout {
- public ProportionalOuterFrame(Context context) {
- super(context);
- }
- public ProportionalOuterFrame(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
- public ProportionalOuterFrame(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- /**
- * Set our margins and title area height proportionally to the available display size
- */
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
- int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
- final Resources resources = getContext().getResources();
- float titleHeight = resources.getFraction(R.dimen.setup_title_height, 1, 1);
- float sideMargin = resources.getFraction(R.dimen.setup_border_width, 1, 1);
- int bottom = resources.getDimensionPixelSize(R.dimen.setup_margin_bottom);
- setPaddingRelative(
- (int) (parentWidth * sideMargin),
- 0,
- (int) (parentWidth * sideMargin),
- bottom);
- View title = findViewById(R.id.title_area);
- if (title != null) {
- title.setMinimumHeight((int) (parentHeight * titleHeight));
- }
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- }
- }
+public class WifiSettings extends RestrictedSettingsFragment implements
+ DialogInterface.OnClickListener
+{
+ private static final String TAG = "WifiSettings";
+ private static final int MENU_ID_WPS_PBC = Menu.FIRST;
+ private static final int MENU_ID_WPS_PIN = Menu.FIRST + 1;
+ private static final int MENU_ID_P2P = Menu.FIRST + 2;
+ private static final int MENU_ID_ADD_NETWORK = Menu.FIRST + 3;
+ private static final int MENU_ID_ADVANCED = Menu.FIRST + 4;
+ private static final int MENU_ID_SCAN = Menu.FIRST + 5;
+ private static final int MENU_ID_CONNECT = Menu.FIRST + 6;
+ private static final int MENU_ID_FORGET = Menu.FIRST + 7;
+ private static final int MENU_ID_MODIFY = Menu.FIRST + 8;
+
+ private static final int WIFI_DIALOG_ID = 1;
+ private static final int WPS_PBC_DIALOG_ID = 2;
+ private static final int WPS_PIN_DIALOG_ID = 3;
+ private static final int WIFI_SKIPPED_DIALOG_ID = 4;
+ private static final int WIFI_AND_MOBILE_SKIPPED_DIALOG_ID = 5;
+
+ // Combo scans can take 5-6s to complete - set to 10s.
+ private static final int WIFI_RESCAN_INTERVAL_MS = 10 * 1000;
+
+ // Instance state keys
+ private static final String SAVE_DIALOG_EDIT_MODE = "edit_mode";
+ private static final String SAVE_DIALOG_ACCESS_POINT_STATE = "wifi_ap_state";
+
+ // Activity result when pressing the Skip button
+ private static final int RESULT_SKIP = Activity.RESULT_FIRST_USER;
+
+ private final IntentFilter mFilter;
+ private final BroadcastReceiver mReceiver;
+ private final Scanner mScanner;
+
+ private WifiManager mWifiManager;
+ private WifiManager.ActionListener mConnectListener;
+ private WifiManager.ActionListener mSaveListener;
+ private WifiManager.ActionListener mForgetListener;
+ private boolean mP2pSupported;
+
+ private WifiEnabler mWifiEnabler;
+ // An access point being editted is stored here.
+ private AccessPoint mSelectedAccessPoint;
+
+ private DetailedState mLastState;
+ private WifiInfo mLastInfo;
+
+ private final AtomicBoolean mConnected = new AtomicBoolean(false);
+
+ private WifiDialog mDialog;
+
+ private TextView mEmptyView;
+
+ /* Used in Wifi Setup context */
+
+ // this boolean extra specifies whether to disable the Next button when not
+ // connected
+ private static final String EXTRA_ENABLE_NEXT_ON_CONNECT = "wifi_enable_next_on_connect";
+
+ // this boolean extra specifies whether to auto finish when connection is
+ // established
+ private static final String EXTRA_AUTO_FINISH_ON_CONNECT = "wifi_auto_finish_on_connect";
+
+ // this boolean extra shows a custom button that we can control
+ protected static final String EXTRA_SHOW_CUSTOM_BUTTON = "wifi_show_custom_button";
+
+ // show a text regarding data charges when wifi connection is required
+ // during setup wizard
+ protected static final String EXTRA_SHOW_WIFI_REQUIRED_INFO = "wifi_show_wifi_required_info";
+
+ // this boolean extra is set if we are being invoked by the Setup Wizard
+ private static final String EXTRA_IS_FIRST_RUN = "firstRun";
+
+ // should Next button only be enabled when we have a connection?
+ private boolean mEnableNextOnConnection;
+
+ // should activity finish once we have a connection?
+ private boolean mAutoFinishOnConnection;
+
+ // Save the dialog details
+ private boolean mDlgEdit;
+ private AccessPoint mDlgAccessPoint;
+ private Bundle mAccessPointSavedState;
+
+ // the action bar uses a different set of controls for Setup Wizard
+ private boolean mSetupWizardMode;
+
+ /* End of "used in Wifi Setup context" */
+
+ public WifiSettings()
+ {
+ super(DISALLOW_CONFIG_WIFI);
+ mFilter = new IntentFilter();
+ mFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
+ mFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
+ mFilter.addAction(WifiManager.NETWORK_IDS_CHANGED_ACTION);
+ mFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
+ mFilter.addAction(WifiManager.CONFIGURED_NETWORKS_CHANGED_ACTION);
+ mFilter.addAction(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION);
+ mFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
+ mFilter.addAction(WifiManager.RSSI_CHANGED_ACTION);
+
+ mReceiver = new BroadcastReceiver()
+ {
+ @Override
+ public void onReceive(Context context, Intent intent)
+ {
+ handleEvent(context, intent);
+ }
+ };
+
+ mScanner = new Scanner();
+ }
+
+ @Override
+ public void onCreate(Bundle icicle)
+ {
+ // Set this flag early, as it's needed by getHelpResource(), which is
+ // called by super
+ mSetupWizardMode = getActivity().getIntent().getBooleanExtra(
+ EXTRA_IS_FIRST_RUN, false);
+
+ super.onCreate(icicle);
+ }
+
+ @Override
+ public View onCreateView(final LayoutInflater inflater,
+ ViewGroup container, Bundle savedInstanceState)
+ {
+ if (mSetupWizardMode)
+ {
+ View view = inflater.inflate(R.layout.setup_preference, container,
+ false);
+ View other = view.findViewById(R.id.other_network);
+ other.setOnClickListener(new OnClickListener()
+ {
+ @Override
+ public void onClick(View v)
+ {
+ if (mWifiManager.isWifiEnabled())
+ {
+ onAddNetworkPressed();
+ }
+ }
+ });
+ final ImageButton b = (ImageButton) view.findViewById(R.id.more);
+ if (b != null)
+ {
+ b.setOnClickListener(new OnClickListener()
+ {
+ @Override
+ public void onClick(View v)
+ {
+ if (mWifiManager.isWifiEnabled())
+ {
+ PopupMenu pm = new PopupMenu(inflater.getContext(),
+ b);
+ pm.inflate(R.menu.wifi_setup);
+ pm.setOnMenuItemClickListener(new OnMenuItemClickListener()
+ {
+ @Override
+ public boolean onMenuItemClick(MenuItem item)
+ {
+ if (R.id.wifi_wps == item.getItemId())
+ {
+ Log.d(TAG, "imagebutton: " + item.getItemId());
+ showDialog(WPS_PBC_DIALOG_ID);
+ return true;
+ }
+ return false;
+ }
+ });
+ pm.show();
+ }
+ }
+ });
+ }
+
+ Intent intent = getActivity().getIntent();
+ if (intent.getBooleanExtra(EXTRA_SHOW_CUSTOM_BUTTON, false))
+ {
+ view.findViewById(R.id.button_bar).setVisibility(View.VISIBLE);
+ view.findViewById(R.id.back_button).setVisibility(
+ View.INVISIBLE);
+ view.findViewById(R.id.skip_button).setVisibility(
+ View.INVISIBLE);
+ view.findViewById(R.id.next_button).setVisibility(
+ View.INVISIBLE);
+
+ Button customButton = (Button) view
+ .findViewById(R.id.custom_button);
+ customButton.setVisibility(View.VISIBLE);
+ customButton.setOnClickListener(new OnClickListener()
+ {
+ @Override
+ public void onClick(View v)
+ {
+ boolean isConnected = false;
+ Activity activity = getActivity();
+ final ConnectivityManager connectivity = (ConnectivityManager) activity
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (connectivity != null)
+ {
+ final NetworkInfo info = connectivity
+ .getActiveNetworkInfo();
+ isConnected = (info != null) && info.isConnected();
+ }
+ if (isConnected)
+ {
+ // Warn of possible data charges
+ showDialog(WIFI_SKIPPED_DIALOG_ID);
+ } else
+ {
+ // Warn of lack of updates
+ showDialog(WIFI_AND_MOBILE_SKIPPED_DIALOG_ID);
+ }
+ }
+ });
+ }
+
+ if (intent.getBooleanExtra(EXTRA_SHOW_WIFI_REQUIRED_INFO, false))
+ {
+ view.findViewById(R.id.wifi_required_info).setVisibility(
+ View.VISIBLE);
+ }
+
+ return view;
+ } else
+ {
+ return super.onCreateView(inflater, container, savedInstanceState);
+ }
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState)
+ {
+ super.onActivityCreated(savedInstanceState);
+
+ mP2pSupported = getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_WIFI_DIRECT);
+ mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
+
+ mConnectListener = new WifiManager.ActionListener()
+ {
+ @Override
+ public void onSuccess()
+ {
+ }
+
+ @Override
+ public void onFailure(int reason)
+ {
+ Activity activity = getActivity();
+ if (activity != null)
+ {
+ Toast.makeText(activity,
+ R.string.wifi_failed_connect_message,
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ };
+
+ mSaveListener = new WifiManager.ActionListener()
+ {
+ @Override
+ public void onSuccess()
+ {
+ }
+
+ @Override
+ public void onFailure(int reason)
+ {
+ Activity activity = getActivity();
+ if (activity != null)
+ {
+ Toast.makeText(activity, R.string.wifi_failed_save_message,
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ };
+
+ mForgetListener = new WifiManager.ActionListener()
+ {
+ @Override
+ public void onSuccess()
+ {
+ }
+
+ @Override
+ public void onFailure(int reason)
+ {
+ Activity activity = getActivity();
+ if (activity != null)
+ {
+ Toast.makeText(activity,
+ R.string.wifi_failed_forget_message,
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ };
+
+ if (savedInstanceState != null
+ && savedInstanceState
+ .containsKey(SAVE_DIALOG_ACCESS_POINT_STATE))
+ {
+ mDlgEdit = savedInstanceState.getBoolean(SAVE_DIALOG_EDIT_MODE);
+ mAccessPointSavedState = savedInstanceState
+ .getBundle(SAVE_DIALOG_ACCESS_POINT_STATE);
+ }
+
+ final Activity activity = getActivity();
+ final Intent intent = activity.getIntent();
+
+ // first if we're supposed to finish once we have a connection
+ mAutoFinishOnConnection = intent.getBooleanExtra(
+ EXTRA_AUTO_FINISH_ON_CONNECT, false);
+
+ if (mAutoFinishOnConnection)
+ {
+ // Hide the next button
+ if (hasNextButton())
+ {
+ getNextButton().setVisibility(View.GONE);
+ }
+
+ final ConnectivityManager connectivity = (ConnectivityManager) activity
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (connectivity != null
+ && connectivity.getNetworkInfo(
+ ConnectivityManager.TYPE_WIFI).isConnected())
+ {
+ activity.setResult(Activity.RESULT_OK);
+ activity.finish();
+ return;
+ }
+ }
+
+ // if we're supposed to enable/disable the Next button based on our
+ // current connection
+ // state, start it off in the right state
+ mEnableNextOnConnection = intent.getBooleanExtra(
+ EXTRA_ENABLE_NEXT_ON_CONNECT, false);
+
+ if (mEnableNextOnConnection)
+ {
+ if (hasNextButton())
+ {
+ final ConnectivityManager connectivity = (ConnectivityManager) activity
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (connectivity != null)
+ {
+ NetworkInfo info = connectivity
+ .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
+ changeNextButtonState(info.isConnected());
+ }
+ }
+ }
+
+ addPreferencesFromResource(R.xml.wifi_settings);
+
+ if (mSetupWizardMode)
+ {
+ getView().setSystemUiVisibility(
+ // View.STATUS_BAR_DISABLE_BACK |
+ View.STATUS_BAR_DISABLE_HOME
+ | View.STATUS_BAR_DISABLE_RECENT
+ | View.STATUS_BAR_DISABLE_NOTIFICATION_ALERTS
+ | View.STATUS_BAR_DISABLE_CLOCK);
+ }
+
+ // On/off switch is hidden for Setup Wizard
+ if (!mSetupWizardMode)
+ {
+ Switch actionBarSwitch = new Switch(activity);
+
+ if (activity instanceof PreferenceActivity)
+ {
+ PreferenceActivity preferenceActivity = (PreferenceActivity) activity;
+ if (preferenceActivity.onIsHidingHeaders()
+ || !preferenceActivity.onIsMultiPane())
+ {
+ final int padding = activity.getResources()
+ .getDimensionPixelSize(
+ R.dimen.action_bar_switch_padding);
+ actionBarSwitch.setPaddingRelative(0, 0, padding, 0);
+ activity.getActionBar().setDisplayOptions(
+ ActionBar.DISPLAY_SHOW_CUSTOM,
+ ActionBar.DISPLAY_SHOW_CUSTOM);
+ activity.getActionBar().setCustomView(
+ actionBarSwitch,
+ new ActionBar.LayoutParams(
+ ActionBar.LayoutParams.WRAP_CONTENT,
+ ActionBar.LayoutParams.WRAP_CONTENT,
+ Gravity.CENTER_VERTICAL | Gravity.END));
+ }
+ }
+
+ mWifiEnabler = new WifiEnabler(activity, actionBarSwitch);
+ }
+
+ mEmptyView = (TextView) getView().findViewById(android.R.id.empty);
+ getListView().setEmptyView(mEmptyView);
+
+ if (!mSetupWizardMode)
+ {
+ registerForContextMenu(getListView());
+ }
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public void onResume()
+ {
+ super.onResume();
+ if (mWifiEnabler != null)
+ {
+ mWifiEnabler.resume();
+ }
+
+ getActivity().registerReceiver(mReceiver, mFilter);
+ updateAccessPoints();
+ }
+
+ @Override
+ public void onPause()
+ {
+ super.onPause();
+ if (mWifiEnabler != null)
+ {
+ mWifiEnabler.pause();
+ }
+ getActivity().unregisterReceiver(mReceiver);
+ mScanner.pause();
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
+ {
+ // If the user is not allowed to configure wifi, do not show the menu.
+ if (isRestrictedAndNotPinProtected())
+ return;
+
+ final boolean wifiIsEnabled = mWifiManager.isWifiEnabled();
+ TypedArray ta = getActivity().getTheme().obtainStyledAttributes(
+ new int[] { R.attr.ic_menu_add, R.attr.ic_wps });
+ if (mSetupWizardMode)
+ {
+ menu.add(Menu.NONE, MENU_ID_WPS_PBC, 0, R.string.wifi_menu_wps_pbc)
+ .setIcon(ta.getDrawable(1)).setEnabled(wifiIsEnabled)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
+ menu.add(Menu.NONE, MENU_ID_ADD_NETWORK, 0,
+ R.string.wifi_add_network).setEnabled(wifiIsEnabled)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
+ } else
+ {
+ menu.add(Menu.NONE, MENU_ID_WPS_PBC, 0, R.string.wifi_menu_wps_pbc)
+ .setIcon(ta.getDrawable(1)).setEnabled(wifiIsEnabled)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ menu.add(Menu.NONE, MENU_ID_ADD_NETWORK, 0,
+ R.string.wifi_add_network).setIcon(ta.getDrawable(0))
+ .setEnabled(wifiIsEnabled)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ menu.add(Menu.NONE, MENU_ID_SCAN, 0, R.string.wifi_menu_scan)
+ // .setIcon(R.drawable.ic_menu_scan_network)
+ .setEnabled(wifiIsEnabled)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
+ menu.add(Menu.NONE, MENU_ID_WPS_PIN, 0, R.string.wifi_menu_wps_pin)
+ .setEnabled(wifiIsEnabled)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
+ if (mP2pSupported)
+ {
+ menu.add(Menu.NONE, MENU_ID_P2P, 0, R.string.wifi_menu_p2p)
+ .setEnabled(wifiIsEnabled)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
+ }
+ menu.add(Menu.NONE, MENU_ID_ADVANCED, 0,
+ R.string.wifi_menu_advanced)
+ // .setIcon(android.R.drawable.ic_menu_manage)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
+ }
+ ta.recycle();
+ super.onCreateOptionsMenu(menu, inflater);
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState)
+ {
+ super.onSaveInstanceState(outState);
+
+ // If the dialog is showing, save its state.
+ if (mDialog != null && mDialog.isShowing())
+ {
+ outState.putBoolean(SAVE_DIALOG_EDIT_MODE, mDlgEdit);
+ if (mDlgAccessPoint != null)
+ {
+ mAccessPointSavedState = new Bundle();
+ mDlgAccessPoint.saveWifiState(mAccessPointSavedState);
+ outState.putBundle(SAVE_DIALOG_ACCESS_POINT_STATE,
+ mAccessPointSavedState);
+ }
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ // If the user is not allowed to configure wifi, do not handle menu
+ // selections.
+ if (isRestrictedAndNotPinProtected())
+ return false;
+ Log.d(TAG, "onOptionItemSelected" + item.getItemId());
+ switch (item.getItemId())
+ {
+ case MENU_ID_WPS_PBC:
+ showDialog(WPS_PBC_DIALOG_ID);
+ return true;
+ case MENU_ID_P2P:
+ if (getActivity() instanceof PreferenceActivity)
+ {
+ ((PreferenceActivity) getActivity()).startPreferencePanel(
+ WifiP2pSettings.class.getCanonicalName(), null,
+ R.string.wifi_p2p_settings_title, null, this, 0);
+ } else
+ {
+ startFragment(this, WifiP2pSettings.class.getCanonicalName(),
+ -1, null);
+ }
+ return true;
+ case MENU_ID_WPS_PIN:
+ showDialog(WPS_PIN_DIALOG_ID);
+ return true;
+ case MENU_ID_SCAN:
+ if (mWifiManager.isWifiEnabled())
+ {
+ mScanner.forceScan();
+ }
+ return true;
+ case MENU_ID_ADD_NETWORK:
+ if (mWifiManager.isWifiEnabled())
+ {
+ onAddNetworkPressed();
+ }
+ return true;
+ case MENU_ID_ADVANCED:
+ if (getActivity() instanceof PreferenceActivity)
+ {
+ ((PreferenceActivity) getActivity()).startPreferencePanel(
+ AdvancedWifiSettings.class.getCanonicalName(), null,
+ R.string.wifi_advanced_titlebar, null, this, 0);
+ } else
+ {
+ startFragment(this,
+ AdvancedWifiSettings.class.getCanonicalName(), -1, null);
+ }
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ public void onCreateContextMenu(ContextMenu menu, View view,
+ ContextMenuInfo info)
+ {
+ if (info instanceof AdapterContextMenuInfo)
+ {
+ Preference preference = (Preference) getListView()
+ .getItemAtPosition(((AdapterContextMenuInfo) info).position);
+
+ if (preference instanceof AccessPoint)
+ {
+ mSelectedAccessPoint = (AccessPoint) preference;
+ menu.setHeaderTitle(mSelectedAccessPoint.ssid);
+ menu.setHeaderTitle("TEST");
+ if (mSelectedAccessPoint.getLevel() != -1
+ && mSelectedAccessPoint.getState() == null)
+ {
+ menu.add(Menu.NONE, MENU_ID_CONNECT, 0,
+ R.string.wifi_menu_connect);
+ }
+ if (mSelectedAccessPoint.networkId != INVALID_NETWORK_ID)
+ {
+ menu.add(Menu.NONE, MENU_ID_FORGET, 0,
+ R.string.wifi_menu_forget);
+ menu.add(Menu.NONE, MENU_ID_MODIFY, 0,
+ R.string.wifi_menu_modify);
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean onContextItemSelected(MenuItem item)
+ {
+ if (mSelectedAccessPoint == null)
+ {
+ return super.onContextItemSelected(item);
+ }
+ Log.d(TAG, "onContextItemSelected" + item.getItemId());
+ switch (item.getItemId())
+ {
+ case MENU_ID_CONNECT:
+ {
+ if (mSelectedAccessPoint.networkId != INVALID_NETWORK_ID)
+ {
+ mWifiManager.connect(mSelectedAccessPoint.networkId,
+ mConnectListener);
+ } else if (mSelectedAccessPoint.security == AccessPoint.SECURITY_NONE)
+ {
+ /** Bypass dialog for unsecured networks */
+ mSelectedAccessPoint.generateOpenNetworkConfig();
+ mWifiManager.connect(mSelectedAccessPoint.getConfig(),
+ mConnectListener);
+ } else
+ {
+ showDialog(mSelectedAccessPoint, true);
+ }
+ return true;
+ }
+ case MENU_ID_FORGET:
+ {
+ mWifiManager
+ .forget(mSelectedAccessPoint.networkId, mForgetListener);
+ return true;
+ }
+ case MENU_ID_MODIFY:
+ {
+ showDialog(mSelectedAccessPoint, true);
+ return true;
+ }
+ }
+ return super.onContextItemSelected(item);
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen screen,
+ Preference preference)
+ {
+ if (preference instanceof AccessPoint)
+ {
+ mSelectedAccessPoint = (AccessPoint) preference;
+ Log.d(TAG, mSelectedAccessPoint.ssid);
+ /** Bypass dialog for unsecured, unsaved networks */
+ if (mSelectedAccessPoint.security == AccessPoint.SECURITY_NONE
+ && mSelectedAccessPoint.networkId == INVALID_NETWORK_ID)
+ {
+ mSelectedAccessPoint.generateOpenNetworkConfig();
+ mWifiManager.connect(mSelectedAccessPoint.getConfig(),
+ mConnectListener);
+ } else
+ {
+ showDialog(mSelectedAccessPoint, false);
+ }
+ } else
+ {
+ return super.onPreferenceTreeClick(screen, preference);
+ }
+ return true;
+ }
+
+ private void showDialog(AccessPoint accessPoint, boolean edit)
+ {
+ if (mDialog != null)
+ {
+ removeDialog(WIFI_DIALOG_ID);
+ mDialog = null;
+ }
+
+ // Save the access point and edit mode
+ mDlgAccessPoint = accessPoint;
+ mDlgEdit = edit;
+
+ showDialog(WIFI_DIALOG_ID);
+ }
+
+ @Override
+ public Dialog onCreateDialog(int dialogId)
+ {
+ Log.d(TAG, "onCreateDialog" + dialogId);
+ switch (dialogId)
+ {
+ case WIFI_DIALOG_ID:
+ AccessPoint ap = mDlgAccessPoint; // For manual launch
+ if (ap == null)
+ { // For re-launch from saved state
+ if (mAccessPointSavedState != null)
+ {
+ ap = new AccessPoint(getActivity(), mAccessPointSavedState);
+ // For repeated orientation changes
+ mDlgAccessPoint = ap;
+ // Reset the saved access point data
+ mAccessPointSavedState = null;
+ }
+ }
+ // If it's still null, fine, it's for Add Network
+ mSelectedAccessPoint = ap;
+ mDialog = new WifiDialog(getActivity(), this, ap, mDlgEdit);
+ return mDialog;
+ case WPS_PBC_DIALOG_ID:
+ return new WpsDialog(getActivity(), WpsInfo.PBC);
+ case WPS_PIN_DIALOG_ID:
+ return new WpsDialog(getActivity(), WpsInfo.DISPLAY);
+ case WIFI_SKIPPED_DIALOG_ID:
+ return new AlertDialog.Builder(getActivity())
+ .setMessage(R.string.wifi_skipped_message)
+ .setCancelable(false)
+ .setNegativeButton(R.string.wifi_skip_anyway,
+ new DialogInterface.OnClickListener()
+ {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int id)
+ {
+ getActivity().setResult(RESULT_SKIP);
+ getActivity().finish();
+ }
+ })
+ .setPositiveButton(R.string.wifi_dont_skip,
+ new DialogInterface.OnClickListener()
+ {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int id)
+ {
+ }
+ }).create();
+ case WIFI_AND_MOBILE_SKIPPED_DIALOG_ID:
+ return new AlertDialog.Builder(getActivity())
+ .setMessage(R.string.wifi_and_mobile_skipped_message)
+ .setCancelable(false)
+ .setNegativeButton(R.string.wifi_skip_anyway,
+ new DialogInterface.OnClickListener()
+ {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int id)
+ {
+ getActivity().setResult(RESULT_SKIP);
+ getActivity().finish();
+ }
+ })
+ .setPositiveButton(R.string.wifi_dont_skip,
+ new DialogInterface.OnClickListener()
+ {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int id)
+ {
+ }
+ }).create();
+
+ }
+ return super.onCreateDialog(dialogId);
+ }
+
+ /**
+ * Shows the latest access points available with supplimental information
+ * like the strength of network and the security for it.
+ */
+ private void updateAccessPoints()
+ {
+ // Safeguard from some delayed event handling
+ if (getActivity() == null)
+ return;
+
+ if (isRestrictedAndNotPinProtected())
+ {
+ addMessagePreference(R.string.wifi_empty_list_user_restricted);
+ return;
+ }
+ final int wifiState = mWifiManager.getWifiState();
+
+ switch (wifiState)
+ {
+ case WifiManager.WIFI_STATE_ENABLED:
+ // AccessPoints are automatically sorted with TreeSet.
+ final Collection accessPoints = constructAccessPoints();
+ getPreferenceScreen().removeAll();
+ if (accessPoints.size() == 0)
+ {
+ addMessagePreference(R.string.wifi_empty_list_wifi_on);
+ }
+ for (AccessPoint accessPoint : accessPoints)
+ {
+ getPreferenceScreen().addPreference(accessPoint);
+ }
+ break;
+
+ case WifiManager.WIFI_STATE_ENABLING:
+ getPreferenceScreen().removeAll();
+ break;
+
+ case WifiManager.WIFI_STATE_DISABLING:
+ addMessagePreference(R.string.wifi_stopping);
+ break;
+
+ case WifiManager.WIFI_STATE_DISABLED:
+ setOffMessage();
+ break;
+ }
+ }
+
+ private void setOffMessage()
+ {
+ if (mEmptyView != null)
+ {
+ mEmptyView.setText(R.string.wifi_empty_list_wifi_off);
+ if (Settings.Global.getInt(getActivity().getContentResolver(),
+ Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1)
+ {
+ mEmptyView.append("\n\n");
+ int resId;
+ if (Settings.Secure
+ .isLocationProviderEnabled(getActivity()
+ .getContentResolver(),
+ LocationManager.NETWORK_PROVIDER))
+ {
+ resId = R.string.wifi_scan_notify_text_location_on;
+ } else
+ {
+ resId = R.string.wifi_scan_notify_text_location_off;
+ }
+ CharSequence charSeq = getText(resId);
+ mEmptyView.append(charSeq);
+ }
+ }
+ getPreferenceScreen().removeAll();
+ }
+
+ private void addMessagePreference(int messageId)
+ {
+ if (mEmptyView != null)
+ mEmptyView.setText(messageId);
+ getPreferenceScreen().removeAll();
+ }
+
+ /** Returns sorted list of access points */
+ private List constructAccessPoints()
+ {
+ ArrayList accessPoints = new ArrayList();
+ /**
+ * Lookup table to more quickly update AccessPoints by only considering
+ * objects with the correct SSID. Maps SSID -> List of AccessPoints with
+ * the given SSID.
+ */
+ Multimap apMap = new Multimap();
+
+ final List configs = mWifiManager
+ .getConfiguredNetworks();
+ if (configs != null)
+ {
+ for (WifiConfiguration config : configs)
+ {
+ AccessPoint accessPoint = new AccessPoint(getActivity(), config);
+ accessPoint.update(mLastInfo, mLastState);
+ accessPoints.add(accessPoint);
+ apMap.put(accessPoint.ssid, accessPoint);
+ }
+ }
+
+ final List results = mWifiManager.getScanResults();
+ if (results != null)
+ {
+ for (ScanResult result : results)
+ {
+ // Ignore hidden and ad-hoc networks.
+ if (result.SSID == null || result.SSID.length() == 0
+ || result.capabilities.contains("[IBSS]"))
+ {
+ continue;
+ }
+
+ boolean found = false;
+ for (AccessPoint accessPoint : apMap.getAll(result.SSID))
+ {
+ if (accessPoint.update(result))
+ found = true;
+ }
+ if (!found)
+ {
+ AccessPoint accessPoint = new AccessPoint(getActivity(),
+ result);
+ accessPoints.add(accessPoint);
+ apMap.put(accessPoint.ssid, accessPoint);
+ }
+ }
+ }
+
+ // Pre-sort accessPoints to speed preference insertion
+ Collections.sort(accessPoints);
+ return accessPoints;
+ }
+
+ /** A restricted multimap for use in constructAccessPoints */
+ private class Multimap
+ {
+ private final HashMap> store = new HashMap>();
+
+ /** retrieve a non-null list of values with key K */
+ List getAll(K key)
+ {
+ List values = store.get(key);
+ return values != null ? values : Collections. emptyList();
+ }
+
+ void put(K key, V val)
+ {
+ List curVals = store.get(key);
+ if (curVals == null)
+ {
+ curVals = new ArrayList(3);
+ store.put(key, curVals);
+ }
+ curVals.add(val);
+ }
+ }
+
+ private void handleEvent(Context context, Intent intent)
+ {
+ String action = intent.getAction();
+ if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action))
+ {
+ updateWifiState(intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
+ WifiManager.WIFI_STATE_UNKNOWN));
+ } else if (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION.equals(action)
+ || WifiManager.CONFIGURED_NETWORKS_CHANGED_ACTION
+ .equals(action)
+ || WifiManager.LINK_CONFIGURATION_CHANGED_ACTION.equals(action))
+ {
+ updateAccessPoints();
+ } else if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION.equals(action))
+ {
+ // Ignore supplicant state changes when network is connected
+ // TODO: we should deprecate SUPPLICANT_STATE_CHANGED_ACTION and
+ // introduce a broadcast that combines the supplicant and network
+ // network state change events so the apps dont have to worry about
+ // ignoring supplicant state change when network is connected
+ // to get more fine grained information.
+ SupplicantState state = (SupplicantState) intent
+ .getParcelableExtra(WifiManager.EXTRA_NEW_STATE);
+ if (!mConnected.get() && SupplicantState.isHandshakeState(state))
+ {
+ updateConnectionState(WifiInfo.getDetailedStateOf(state));
+ } else
+ {
+ // During a connect, we may have the supplicant
+ // state change affect the detailed network state.
+ // Make sure a lost connection is updated as well.
+ updateConnectionState(null);
+ }
+ } else if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action))
+ {
+ NetworkInfo info = (NetworkInfo) intent
+ .getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
+ mConnected.set(info.isConnected());
+ changeNextButtonState(info.isConnected());
+ updateAccessPoints();
+ updateConnectionState(info.getDetailedState());
+ if (mAutoFinishOnConnection && info.isConnected())
+ {
+ Activity activity = getActivity();
+ if (activity != null)
+ {
+ activity.setResult(Activity.RESULT_OK);
+ activity.finish();
+ }
+ return;
+ }
+ } else if (WifiManager.RSSI_CHANGED_ACTION.equals(action))
+ {
+ updateConnectionState(null);
+ }
+ }
+
+ private void updateConnectionState(DetailedState state)
+ {
+ /* sticky broadcasts can call this when wifi is disabled */
+ if (!mWifiManager.isWifiEnabled())
+ {
+ mScanner.pause();
+ return;
+ }
+
+ if (state == DetailedState.OBTAINING_IPADDR)
+ {
+ mScanner.pause();
+ } else
+ {
+ mScanner.resume();
+ }
+
+ mLastInfo = mWifiManager.getConnectionInfo();
+ if (state != null)
+ {
+ mLastState = state;
+ }
+
+ for (int i = getPreferenceScreen().getPreferenceCount() - 1; i >= 0; --i)
+ {
+ // Maybe there's a WifiConfigPreference
+ Preference preference = getPreferenceScreen().getPreference(i);
+ if (preference instanceof AccessPoint)
+ {
+ final AccessPoint accessPoint = (AccessPoint) preference;
+ accessPoint.update(mLastInfo, mLastState);
+ }
+ }
+ }
+
+ private void updateWifiState(int state)
+ {
+ Activity activity = getActivity();
+ if (activity != null)
+ {
+ activity.invalidateOptionsMenu();
+ }
+
+ switch (state)
+ {
+ case WifiManager.WIFI_STATE_ENABLED:
+ mScanner.resume();
+ return; // not break, to avoid the call to pause() below
+
+ case WifiManager.WIFI_STATE_ENABLING:
+ addMessagePreference(R.string.wifi_starting);
+ break;
+
+ case WifiManager.WIFI_STATE_DISABLED:
+ setOffMessage();
+ break;
+ }
+
+ mLastInfo = null;
+ mLastState = null;
+ mScanner.pause();
+ }
+
+ private class Scanner extends Handler
+ {
+ private int mRetry = 0;
+
+ void resume()
+ {
+ if (!hasMessages(0))
+ {
+ sendEmptyMessage(0);
+ }
+ }
+
+ void forceScan()
+ {
+ removeMessages(0);
+ sendEmptyMessage(0);
+ }
+
+ void pause()
+ {
+ mRetry = 0;
+ removeMessages(0);
+ }
+
+ @Override
+ public void handleMessage(Message message)
+ {
+ if (mWifiManager.startScan())
+ {
+ mRetry = 0;
+ } else if (++mRetry >= 3)
+ {
+ mRetry = 0;
+ Activity activity = getActivity();
+ if (activity != null)
+ {
+ Toast.makeText(activity, R.string.wifi_fail_to_scan,
+ Toast.LENGTH_LONG).show();
+ }
+ return;
+ }
+ sendEmptyMessageDelayed(0, WIFI_RESCAN_INTERVAL_MS);
+ }
+ }
+
+ /**
+ * Renames/replaces "Next" button when appropriate. "Next" button usually
+ * exists in Wifi setup screens, not in usual wifi settings screen.
+ *
+ * @param connected
+ * true when the device is connected to a wifi network.
+ */
+ private void changeNextButtonState(boolean connected)
+ {
+ if (mEnableNextOnConnection && hasNextButton())
+ {
+ getNextButton().setEnabled(connected);
+ }
+ }
+
+ @Override
+ public void onClick(DialogInterface dialogInterface, int button)
+ {
+ Log.d(TAG, "onClick : " + button);
+ if (button == WifiDialog.BUTTON_FORGET && mSelectedAccessPoint != null)
+ {
+ forget();
+ } else if (button == WifiDialog.BUTTON_SUBMIT)
+ {
+ if (mDialog != null)
+ {
+ submit(mDialog.getController());
+ }
+ }
+ }
+
+ /* package */void submit(WifiConfigController configController)
+ {
+
+ final WifiConfiguration config = configController.getConfig();
+
+ if (config == null)
+ {
+ if (mSelectedAccessPoint != null
+ && mSelectedAccessPoint.networkId != INVALID_NETWORK_ID)
+ {
+ mWifiManager.connect(mSelectedAccessPoint.networkId,
+ mConnectListener);
+ }
+ } else if (config.networkId != INVALID_NETWORK_ID)
+ {
+ if (mSelectedAccessPoint != null)
+ {
+ mWifiManager.save(config, mSaveListener);
+ }
+ } else
+ {
+ if (configController.isEdit())
+ {
+ mWifiManager.save(config, mSaveListener);
+ } else
+ {
+ mWifiManager.connect(config, mConnectListener);
+ }
+ }
+
+ if (mWifiManager.isWifiEnabled())
+ {
+ mScanner.resume();
+ }
+ updateAccessPoints();
+ }
+
+ /* package */void forget()
+ {
+ if (mSelectedAccessPoint.networkId == INVALID_NETWORK_ID)
+ {
+ // Should not happen, but a monkey seems to triger it
+ Log.e(TAG, "Failed to forget invalid network "
+ + mSelectedAccessPoint.getConfig());
+ return;
+ }
+
+ mWifiManager.forget(mSelectedAccessPoint.networkId, mForgetListener);
+
+ if (mWifiManager.isWifiEnabled())
+ {
+ mScanner.resume();
+ }
+ updateAccessPoints();
+
+ // We need to rename/replace "Next" button in wifi setup context.
+ changeNextButtonState(false);
+ }
+
+ /**
+ * Refreshes acccess points and ask Wifi module to scan networks again.
+ */
+ /* package */void refreshAccessPoints()
+ {
+ if (mWifiManager.isWifiEnabled())
+ {
+ mScanner.resume();
+ }
+
+ getPreferenceScreen().removeAll();
+ }
+
+ /**
+ * Called when "add network" button is pressed.
+ */
+ /* package */void onAddNetworkPressed()
+ {
+ // No exact access point is selected.
+ mSelectedAccessPoint = null;
+ showDialog(null, true);
+ }
+
+ /* package */int getAccessPointsCount()
+ {
+ final boolean wifiIsEnabled = mWifiManager.isWifiEnabled();
+ if (wifiIsEnabled)
+ {
+ return getPreferenceScreen().getPreferenceCount();
+ } else
+ {
+ return 0;
+ }
+ }
+
+ /**
+ * Requests wifi module to pause wifi scan. May be ignored when the module
+ * is disabled.
+ */
+ /* package */void pauseWifiScan()
+ {
+ if (mWifiManager.isWifiEnabled())
+ {
+ mScanner.pause();
+ }
+ }
+
+ /**
+ * Requests wifi module to resume wifi scan. May be ignored when the module
+ * is disabled.
+ */
+ /* package */void resumeWifiScan()
+ {
+ if (mWifiManager.isWifiEnabled())
+ {
+ mScanner.resume();
+ }
+ }
+
+ @Override
+ protected int getHelpResource()
+ {
+ if (mSetupWizardMode)
+ {
+ return 0;
+ }
+ return R.string.help_url_wifi;
+ }
+
+ /**
+ * Used as the outer frame of all setup wizard pages that need to adjust
+ * their margins based on the total size of the available display. (e.g.
+ * side margins set to 10% of total width.)
+ */
+ public static class ProportionalOuterFrame extends RelativeLayout
+ {
+ public ProportionalOuterFrame(Context context)
+ {
+ super(context);
+ }
+
+ public ProportionalOuterFrame(Context context, AttributeSet attrs)
+ {
+ super(context, attrs);
+ }
+
+ public ProportionalOuterFrame(Context context, AttributeSet attrs,
+ int defStyle)
+ {
+ super(context, attrs, defStyle);
+ }
+
+ /**
+ * Set our margins and title area height proportionally to the available
+ * display size
+ */
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
+ {
+ int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
+ int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
+ final Resources resources = getContext().getResources();
+ float titleHeight = resources.getFraction(
+ R.dimen.setup_title_height, 1, 1);
+ float sideMargin = resources.getFraction(
+ R.dimen.setup_border_width, 1, 1);
+ int bottom = resources
+ .getDimensionPixelSize(R.dimen.setup_margin_bottom);
+ setPaddingRelative((int) (parentWidth * sideMargin), 0,
+ (int) (parentWidth * sideMargin), bottom);
+ View title = findViewById(R.id.title_area);
+ if (title != null)
+ {
+ title.setMinimumHeight((int) (parentHeight * titleHeight));
+ }
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+ }
}
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/AndroidManifest.xml AndroidSource/packages/apps/SurfaceProvider/AndroidManifest.xml
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/AndroidManifest.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/AndroidManifest.xml 2016-01-22 20:41:44.000000000 +0900
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/Android.mk AndroidSource/packages/apps/SurfaceProvider/Android.mk
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/Android.mk 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/Android.mk 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,18 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := SurfaceProvider
+LOCAL_CERTIFICATE := platform
+LOCAL_PRIVILEGED_MODULE := true
+
+include $(BUILD_PACKAGE)
+
+include $(call all-makefiles-under, $(LOCAL_PATH))
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/Android.mk~ AndroidSource/packages/apps/SurfaceProvider/Android.mk~
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/Android.mk~ 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/Android.mk~ 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,18 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := TestApp
+LOCAL_CERTIFICATE := platform
+LOCAL_PRIVILEGED_MODULE := true
+
+include $(BUILD_PACKAGE)
+
+include $(call all-makefiles-under, $(LOCAL_PATH))
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/AndroidManifest.xml AndroidSource/packages/apps/SurfaceProvider/bin/AndroidManifest.xml
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/AndroidManifest.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/bin/AndroidManifest.xml 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/BuildConfig.class and AndroidSource/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/BuildConfig.class differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$attr.class and AndroidSource/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$attr.class differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R.class and AndroidSource/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R.class differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$dimen.class and AndroidSource/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$dimen.class differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$drawable.class and AndroidSource/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$drawable.class differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$id.class and AndroidSource/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$id.class differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$layout.class and AndroidSource/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$layout.class differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$menu.class and AndroidSource/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$menu.class differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$string.class and AndroidSource/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$string.class differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$style.class and AndroidSource/packages/apps/SurfaceProvider/bin/classes/com/example/surfaceprovider/R$style.class differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/classes/com/remote/surfaceprovider/SurfaceProvider.class and AndroidSource/packages/apps/SurfaceProvider/bin/classes/com/remote/surfaceprovider/SurfaceProvider.class differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/classes/com/remote/surfaceprovider/SurfaceProvider$mVideoPlayer.class and AndroidSource/packages/apps/SurfaceProvider/bin/classes/com/remote/surfaceprovider/SurfaceProvider$mVideoPlayer.class differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/classes/com/remote/surfaceprovider/vData.class and AndroidSource/packages/apps/SurfaceProvider/bin/classes/com/remote/surfaceprovider/vData.class differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/classes.dex and AndroidSource/packages/apps/SurfaceProvider/bin/classes.dex differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/dexedLibs/android-support-v4-e4e268e2fdaef81c9e05705fd1efab0a.jar and AndroidSource/packages/apps/SurfaceProvider/bin/dexedLibs/android-support-v4-e4e268e2fdaef81c9e05705fd1efab0a.jar differ
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/jarlist.cache AndroidSource/packages/apps/SurfaceProvider/bin/jarlist.cache
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/jarlist.cache 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/bin/jarlist.cache 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,3 @@
+# cache for current jar dependency. DO NOT EDIT.
+# format is
+# Encoding is UTF-8
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/res/crunch/drawable-hdpi/ic_launcher.png and AndroidSource/packages/apps/SurfaceProvider/bin/res/crunch/drawable-hdpi/ic_launcher.png differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/res/crunch/drawable-mdpi/ic_launcher.png and AndroidSource/packages/apps/SurfaceProvider/bin/res/crunch/drawable-mdpi/ic_launcher.png differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/res/crunch/drawable-xhdpi/ic_launcher.png and AndroidSource/packages/apps/SurfaceProvider/bin/res/crunch/drawable-xhdpi/ic_launcher.png differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/res/crunch/drawable-xxhdpi/ic_launcher.png and AndroidSource/packages/apps/SurfaceProvider/bin/res/crunch/drawable-xxhdpi/ic_launcher.png differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/resources.ap_ and AndroidSource/packages/apps/SurfaceProvider/bin/resources.ap_ differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/bin/SurfaceProvider.apk and AndroidSource/packages/apps/SurfaceProvider/bin/SurfaceProvider.apk differ
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/.classpath AndroidSource/packages/apps/SurfaceProvider/.classpath
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/.classpath 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/.classpath 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/gen/com/example/surfaceprovider/BuildConfig.java AndroidSource/packages/apps/SurfaceProvider/gen/com/example/surfaceprovider/BuildConfig.java
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/gen/com/example/surfaceprovider/BuildConfig.java 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/gen/com/example/surfaceprovider/BuildConfig.java 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,6 @@
+/** Automatically generated file. DO NOT MODIFY */
+package com.example.surfaceprovider;
+
+public final class BuildConfig {
+ public final static boolean DEBUG = true;
+}
\ No newline at end of file
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/gen/com/example/surfaceprovider/R.java AndroidSource/packages/apps/SurfaceProvider/gen/com/example/surfaceprovider/R.java
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/gen/com/example/surfaceprovider/R.java 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/gen/com/example/surfaceprovider/R.java 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,69 @@
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package com.example.surfaceprovider;
+
+public final class R {
+ public static final class attr {
+ }
+ public static final class dimen {
+ /** Default screen margins, per the Android Design guidelines.
+
+ Example customization of dimensions originally defined in res/values/dimens.xml
+ (such as screen margins) for screens with more than 820dp of available width. This
+ would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
+
+ */
+ public static final int activity_horizontal_margin=0x7f040000;
+ public static final int activity_vertical_margin=0x7f040001;
+ }
+ public static final class drawable {
+ public static final int ic_launcher=0x7f020000;
+ }
+ public static final class id {
+ public static final int action_settings=0x7f080000;
+ }
+ public static final class layout {
+ public static final int activity_surface_giver=0x7f030000;
+ }
+ public static final class menu {
+ public static final int surface_giver=0x7f070000;
+ }
+ public static final class string {
+ public static final int action_settings=0x7f050002;
+ public static final int app_name=0x7f050000;
+ public static final int hello_world=0x7f050001;
+ }
+ public static final class style {
+ /**
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+
+
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+
+
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+
+ API 11 theme customizations can go here.
+
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+
+ API 14 theme customizations can go here.
+ */
+ public static final int AppBaseTheme=0x7f060000;
+ /** Application theme.
+ All customizations that are NOT specific to a particular API-level can go here.
+ */
+ public static final int AppTheme=0x7f060001;
+ }
+}
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/ic_launcher-web.png and AndroidSource/packages/apps/SurfaceProvider/ic_launcher-web.png differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/libs/android-support-v4.jar and AndroidSource/packages/apps/SurfaceProvider/libs/android-support-v4.jar differ
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/proguard-project.txt AndroidSource/packages/apps/SurfaceProvider/proguard-project.txt
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/proguard-project.txt 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/proguard-project.txt 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/.project AndroidSource/packages/apps/SurfaceProvider/.project
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/.project 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/.project 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,33 @@
+
+
+ SurfaceProvider
+
+
+
+
+
+ com.android.ide.eclipse.adt.ResourceManagerBuilder
+
+
+
+
+ com.android.ide.eclipse.adt.PreCompilerBuilder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ com.android.ide.eclipse.adt.ApkBuilder
+
+
+
+
+
+ com.android.ide.eclipse.adt.AndroidNature
+ org.eclipse.jdt.core.javanature
+
+
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/project.properties AndroidSource/packages/apps/SurfaceProvider/project.properties
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/project.properties 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/project.properties 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-19
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/res/drawable-hdpi/ic_launcher.png and AndroidSource/packages/apps/SurfaceProvider/res/drawable-hdpi/ic_launcher.png differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/res/drawable-mdpi/ic_launcher.png and AndroidSource/packages/apps/SurfaceProvider/res/drawable-mdpi/ic_launcher.png differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/res/drawable-xhdpi/ic_launcher.png and AndroidSource/packages/apps/SurfaceProvider/res/drawable-xhdpi/ic_launcher.png differ
Binary files Original_4.4.4_r1/packages/apps/SurfaceProvider/res/drawable-xxhdpi/ic_launcher.png and AndroidSource/packages/apps/SurfaceProvider/res/drawable-xxhdpi/ic_launcher.png differ
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/res/layout/activity_surface_giver.xml AndroidSource/packages/apps/SurfaceProvider/res/layout/activity_surface_giver.xml
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/res/layout/activity_surface_giver.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/res/layout/activity_surface_giver.xml 2015-11-24 23:38:42.000000000 +0900
@@ -0,0 +1,18 @@
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/res/layout/activity_surface_giver.xml~ AndroidSource/packages/apps/SurfaceProvider/res/layout/activity_surface_giver.xml~
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/res/layout/activity_surface_giver.xml~ 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/res/layout/activity_surface_giver.xml~ 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,16 @@
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/res/menu/surface_giver.xml AndroidSource/packages/apps/SurfaceProvider/res/menu/surface_giver.xml
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/res/menu/surface_giver.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/res/menu/surface_giver.xml 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,11 @@
+
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/res/values/dimens.xml AndroidSource/packages/apps/SurfaceProvider/res/values/dimens.xml
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/res/values/dimens.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/res/values/dimens.xml 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,7 @@
+
+
+
+ 16dp
+ 16dp
+
+
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/res/values/strings.xml AndroidSource/packages/apps/SurfaceProvider/res/values/strings.xml
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/res/values/strings.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/res/values/strings.xml 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,8 @@
+
+
+
+ SurfaceProvider
+ Hello world!
+ Settings
+
+
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/res/values/styles.xml AndroidSource/packages/apps/SurfaceProvider/res/values/styles.xml
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/res/values/styles.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/res/values/styles.xml 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/res/values-v11/styles.xml AndroidSource/packages/apps/SurfaceProvider/res/values-v11/styles.xml
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/res/values-v11/styles.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/res/values-v11/styles.xml 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/res/values-v14/styles.xml AndroidSource/packages/apps/SurfaceProvider/res/values-v14/styles.xml
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/res/values-v14/styles.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/res/values-v14/styles.xml 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/res/values-w820dp/dimens.xml AndroidSource/packages/apps/SurfaceProvider/res/values-w820dp/dimens.xml
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/res/values-w820dp/dimens.xml 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/res/values-w820dp/dimens.xml 2015-10-27 11:41:12.000000000 +0900
@@ -0,0 +1,10 @@
+
+
+
+ 64dp
+
+
diff -urN Original_4.4.4_r1/packages/apps/SurfaceProvider/src/com/remote/surfaceprovider/SurfaceProvider.java AndroidSource/packages/apps/SurfaceProvider/src/com/remote/surfaceprovider/SurfaceProvider.java
--- Original_4.4.4_r1/packages/apps/SurfaceProvider/src/com/remote/surfaceprovider/SurfaceProvider.java 1970-01-01 09:00:00.000000000 +0900
+++ AndroidSource/packages/apps/SurfaceProvider/src/com/remote/surfaceprovider/SurfaceProvider.java 2016-09-27 17:43:56.629147730 +0900
@@ -0,0 +1,1203 @@
+
+package com.remote.surfaceprovider;
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.nio.ByteBuffer;
+
+import android.service.remote.IRemoteService;
+import android.service.remote.SdPackage;
+
+import com.example.surfaceprovider.R;
+
+import android.service.remote.vData;
+import android.app.Activity;
+import android.app.KeyguardManager;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.media.AudioFormat;
+import android.media.AudioManager;
+import android.media.AudioTrack;
+import android.media.MediaCodec;
+import android.media.MediaCodecInfo;
+import android.media.MediaFormat;
+import android.media.MediaCodec.BufferInfo;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.PowerManager;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.MotionEvent;
+import android.view.Surface;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+import android.view.View;
+import android.view.View.OnTouchListener;
+import android.view.ViewGroup.LayoutParams;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.ImageView;
+
+public class SurfaceProvider extends Activity implements SurfaceHolder.Callback {
+ // private String serverIP = "192.168.0.26";
+ private String serverIP = "";
+ public int vport = 30000;
+ private String TAG = "SurfaceProvider";
+ SurfaceHolder mHolder;
+ SurfaceView surfaceView;
+ ImageView imageView;
+
+ public long aSync = 0, vSync = 0;
+ public String mode = "";
+
+ public class mVideoPlayerAsync extends AsyncTask