Remove references to global proxy APIs

Remove global proxy settings from Apidemos
Remove CorpApp

Bug: 3460938
Change-Id: I2b6889a96341f0e4fad50a9cfaa76db715ecfaa0
This commit is contained in:
Andy Stadler
2011-02-16 10:51:01 -08:00
parent 0f911715e4
commit 5ee9462101
12 changed files with 2 additions and 414 deletions

View File

@@ -44,6 +44,8 @@
#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/CorpApp_intermediates)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************

View File

@@ -247,31 +247,6 @@
</LinearLayout>
<LinearLayout android:orientation="vertical" android:gravity="center_horizontal"
android:layout_width="match_parent" android:layout_height="wrap_content">
<EditText android:id="@+id/proxyhost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/proxyhost_hint">
</EditText>
<EditText android:id="@+id/proxylist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/proxylist_hint">
</EditText>
<Button android:id="@+id/set_proxy"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0"
android:text="@string/set_proxy_label">
</Button>
</LinearLayout>
<!-- Encryption Status Controls -->
<LinearLayout
android:orientation="horizontal"

View File

@@ -612,9 +612,6 @@
<string name="wipe_all_data">Wipe All Data</string>
<string name="timeout_hint">Max screen timeout</string>
<string name="set_timeout_label">Set Timeout</string>
<string name="proxyhost_hint">Global proxyhost:port</string>
<string name="proxylist_hint">No proxy for domain1,domain2</string>
<string name="set_proxy_label">Set Global Proxy</string>
<string name="encryption_enable_label">Enable Encryption</string>
<string name="encryption_disable_label">Disable Encryption</string>

View File

@@ -22,7 +22,6 @@
<reset-password />
<force-lock />
<wipe-data />
<set-global-proxy />
<expire-password />
<encrypted-storage />
</uses-policies>

View File

@@ -43,12 +43,8 @@ import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.text.DateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* Example of a do-nothing admin class. When enabled, it lets you control
@@ -189,10 +185,6 @@ public class DeviceAdminSample extends DeviceAdminReceiver {
private EditText mTimeout;
EditText mProxyHost;
EditText mProxyList;
Button mProxyButton;
private EditText mPasswordExpirationTimeout;
private Button mPasswordExpirationButton;
private TextView mPasswordExpirationStatus;
@@ -400,11 +392,6 @@ public class DeviceAdminSample extends DeviceAdminReceiver {
mTimeoutButton = (Button) findViewById(R.id.set_timeout);
mTimeoutButton.setOnClickListener(mSetTimeoutListener);
mProxyHost = (EditText) findViewById(R.id.proxyhost);
mProxyList = (EditText) findViewById(R.id.proxylist);
mProxyButton = (Button) findViewById(R.id.set_proxy);
mProxyButton.setOnClickListener(mSetProxyListener);
mEnableEncryptionButton = (Button) findViewById(R.id.encryption_enable_button);
mEnableEncryptionButton.setOnClickListener(mEncryptionButtonListener);
mDisableEncryptionButton = (Button) findViewById(R.id.encryption_disable_button);
@@ -788,49 +775,6 @@ public class DeviceAdminSample extends DeviceAdminReceiver {
}
};
private OnClickListener mSetProxyListener = new OnClickListener() {
public void onClick(View v) {
boolean active = mDPM.isAdminActive(mDeviceAdminSample);
String proxySpec = mProxyHost.getText().toString();
String proxyList = mProxyList.getText().toString();
Proxy instProxy;
List<String> exclList;
if ((proxySpec.length() == 0) || (proxySpec == null)) {
instProxy = Proxy.NO_PROXY;
} else {
String[] proxyComponents = proxySpec.split(":");
if (proxyComponents.length != 2) {
Toast.makeText(Controller.this, "Wrong proxy specification.",
Toast.LENGTH_SHORT).show();
return;
}
instProxy = new Proxy(Proxy.Type.HTTP,
new InetSocketAddress(proxyComponents[0],
Integer.parseInt(proxyComponents[1])));
}
if ((proxyList == null) || (proxyList.length() == 0)) {
exclList = null;
} else {
String[] listDoms = proxyList.split(",");
if (listDoms.length == 0) {
Toast.makeText(Controller.this, "Wrong exclusion list format.",
Toast.LENGTH_SHORT).show();
}
exclList = Arrays.asList(listDoms);
}
if (active) {
mDPM.setGlobalProxy(mDeviceAdminSample, instProxy, exclList);
ComponentName proxyAdmin = mDPM.getGlobalProxyAdmin();
if ((proxyAdmin != null) && (proxyAdmin.equals(mDeviceAdminSample))) {
Toast.makeText(Controller.this, "Global Proxy set by device admin.",
Toast.LENGTH_SHORT).show();
}
}
}
};
private OnClickListener mEncryptionButtonListener = new OnClickListener() {
public void onClick(View v) {
int buttonId = v.getId();

View File

@@ -1,17 +0,0 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := samples
# Only compile source java files in this apk.
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := CorpApp
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)
# Use the following include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))

View File

@@ -1,44 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Declare the contents of this Android application. The namespace
attribute brings in the Android platform namespace, and the package
supplies a unique name for the application. When writing your
own application, the package name must be changed from "com.example.*"
to come from a domain that you own or have control over. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.corpapp">
<application android:label="CorporateDeviceAdminDemoApp">
<activity android:name="CorpAppActivity"
android:label="@string/corp_app_activity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<receiver android:name=".app.CorpDeviceAdmin"
android:label="@string/corp_app_admin"
android:description="@string/corp_device_admin_description"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data android:name="android.app.corp_device_admin"
android:resource="@xml/corp_device_admin" />
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@@ -1,36 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical" android:padding="4dip"
android:gravity="center_horizontal"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView android:id="@+id/status_text"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingBottom="4dip"
android:text="@string/corp_app_status_waiting_text"/>
<Button android:id="@+id/set_button"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/corp_app_set_button_text"/>
</LinearLayout>
</ScrollView>

View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<string name="corp_app_title_text">Corporate Demo App</string>
<string name="corp_app_set_button_text">Set Corp Global Proxy</string>
<string name="corp_app_status_success_text">Global Proxy successfully set</string>
<string name="corp_app_status_failed_text">Global Proxy could not be set.</string>
<string name="corp_app_status_waiting_text">Waiting to set Global Proxy...</string>
<string name="corp_app_proxy_name">proxy.corpapp.com:8080</string>
<string name="corp_app_proxy_excl_list">google.com,youtube.com</string>
<string name="corp_app_activity">Sample Corp App Activity</string>
<string name="corp_app_admin">Sample Corp App Device Admin</string>
<string name="corp_device_admin_description">Corporate device admin sample demo</string>
</resources>

View File

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- BEGIN_INCLUDE(meta_data) -->
<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
<uses-policies>
<set-global-proxy />
</uses-policies>
</device-admin>
<!-- END_INCLUDE(meta_data) -->

View File

@@ -1,114 +0,0 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.corpapp;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.Arrays;
import java.util.List;
/**
* A minimal Globl Proxy-setting corp app application.
*/
public class CorpAppActivity extends Activity {
/**
* Called with the activity is first created.
*/
Button mSetButton;
TextView mStatusText;
String mProxyName;
String mProxyExclList;
String mSuccess;
String mFailure;
DevicePolicyManager mDPM;
ActivityManager mAM;
ComponentName mCorpDeviceAdmin;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
mAM = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
mCorpDeviceAdmin = new ComponentName(CorpAppActivity.this, CorpDeviceAdmin.class);
// Set the layout for this activity. You can find it
// in res/layout/corp_app_activity.xml
setContentView(R.layout.corp_app_activity);
mSetButton = (Button)findViewById(R.id.set_button);
mSetButton.setOnClickListener(mSetListener);
mStatusText = (Button)findViewById(R.id.status_text);
boolean active = mDPM.isAdminActive(mCorpDeviceAdmin);
mSetButton.setEnabled(active);
mProxyName = getResources().getString(R.string.corp_app_proxy_name);
mProxyExclList = getResources().getString(R.string.corp_app_proxy_excl_list);
mSuccess = getResources().getString(R.string.corp_app_status_success_text);
mFailure = getResources().getString(R.string.corp_app_status_failed_text);
}
private OnClickListener mSetListener = new OnClickListener() {
public void onClick(View v) {
String[] proxyComponents = mProxyName.split(":");
if (proxyComponents.length != 2) {
Toast.makeText(CorpAppActivity.this, "Wrong proxy specification.",
Toast.LENGTH_SHORT).show();
return;
}
Proxy instProxy = new Proxy(Proxy.Type.HTTP,
new InetSocketAddress(proxyComponents[0],
Integer.parseInt(proxyComponents[1])));
String[] listDoms = mProxyExclList.split(",");
if (listDoms.length == 0) {
Toast.makeText(CorpAppActivity.this, "Wrong exclusion list format.",
Toast.LENGTH_SHORT).show();
}
List<String> exclList = Arrays.asList(listDoms);
boolean active = mDPM.isAdminActive(mCorpDeviceAdmin);
if (active) {
mDPM.setGlobalProxy(mCorpDeviceAdmin, instProxy, exclList);
ComponentName proxyAdmin = mDPM.getGlobalProxyAdmin();
if ((proxyAdmin != null) && (proxyAdmin.equals(mCorpDeviceAdmin))) {
Toast.makeText(CorpAppActivity.this, "Global Proxy set by device admin.",
Toast.LENGTH_SHORT).show();
mStatusText.setText(mSuccess);
} else {
Toast.makeText(CorpAppActivity.this, "Failed to set Global Proxy.",
Toast.LENGTH_SHORT).show();
mStatusText.setText(mFailure);
}
}
}
};
}

View File

@@ -1,64 +0,0 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.corpapp;
import android.app.admin.DeviceAdminReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.widget.Toast;
public class CorpDeviceAdmin extends DeviceAdminReceiver {
static SharedPreferences getSamplePreferences(Context context) {
return context.getSharedPreferences(DeviceAdminReceiver.class.getName(), 0);
}
void showToast(Context context, CharSequence msg) {
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
}
@Override
public void onEnabled(Context context, Intent intent) {
showToast(context, "Sample Corp Device Admin: enabled");
}
@Override
public CharSequence onDisableRequested(Context context, Intent intent) {
return "Sample Corp Device Admin: disable requested";
}
@Override
public void onDisabled(Context context, Intent intent) {
showToast(context, "Sample Corp Device Admin: disabled");
}
@Override
public void onPasswordChanged(Context context, Intent intent) {
showToast(context, "Sample Corp Device Admin: pw changed");
}
@Override
public void onPasswordFailed(Context context, Intent intent) {
showToast(context, "Sample Corp Device Admin: pw failed");
}
@Override
public void onPasswordSucceeded(Context context, Intent intent) {
showToast(context, "Sample Corp Device Admin: pw succeeded");
}
}