Merge branch 'master' into honeycomb-release
This commit is contained in:
@@ -457,7 +457,7 @@
|
|||||||
<!-- Provide direct entry into manage apps showing running services. -->
|
<!-- Provide direct entry into manage apps showing running services. -->
|
||||||
<activity-alias android:name=".RunningServices"
|
<activity-alias android:name=".RunningServices"
|
||||||
android:label="@string/runningservices_settings_title"
|
android:label="@string/runningservices_settings_title"
|
||||||
android:targetActivity=".applications.ManageApplications">
|
android:targetActivity="Settings">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
@@ -470,7 +470,7 @@
|
|||||||
<!-- Provide direct entry into manage apps showing running services. -->
|
<!-- Provide direct entry into manage apps showing running services. -->
|
||||||
<activity-alias android:name=".applications.StorageUse"
|
<activity-alias android:name=".applications.StorageUse"
|
||||||
android:label="@string/storageuse_settings_title"
|
android:label="@string/storageuse_settings_title"
|
||||||
android:targetActivity=".applications.ManageApplications">
|
android:targetActivity="Settings">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
@@ -480,11 +480,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity-alias>
|
</activity-alias>
|
||||||
|
|
||||||
<activity android:name=".applications.RunningServiceDetails"
|
|
||||||
android:theme="@android:style/Theme.NoTitleBar"
|
|
||||||
android:label="@string/runningservicedetails_settings_title">
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity-alias android:name="SecuritySettings"
|
<activity-alias android:name="SecuritySettings"
|
||||||
android:label="@string/location_security_settings_title"
|
android:label="@string/location_security_settings_title"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
@@ -686,15 +681,17 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="DevelopmentSettings"
|
<activity-alias android:name="DevelopmentSettings"
|
||||||
android:label="@string/development_settings_title">
|
android:label="@string/development_settings_title"
|
||||||
|
android:targetActivity="Settings"
|
||||||
|
android:clearTaskOnLaunch="true"
|
||||||
|
>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<action android:name="com.android.settings.APPLICATION_DEVELOPMENT_SETTINGS" />
|
<action android:name="com.android.settings.APPLICATION_DEVELOPMENT_SETTINGS" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity-alias>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -999,14 +999,6 @@
|
|||||||
<!-- Wi-Fi Advanced Settings --> <skip />
|
<!-- Wi-Fi Advanced Settings --> <skip />
|
||||||
<!-- Wi-Fi settings screen, advanced, settings section. This is a header shown above advanced wifi settings. -->
|
<!-- Wi-Fi settings screen, advanced, settings section. This is a header shown above advanced wifi settings. -->
|
||||||
<string name="wifi_advanced_titlebar">Advanced</string>
|
<string name="wifi_advanced_titlebar">Advanced</string>
|
||||||
<!-- Wi-Fi settings screen, setting title for choosing the number of channels to be used -->
|
|
||||||
<string name="wifi_setting_num_channels_title">Regulatory domain</string>
|
|
||||||
<!-- Wi-Fi settings screen, setting summary for choosing the number of channels to be used -->
|
|
||||||
<string name="wifi_setting_num_channels_summary">Set the number of channels to use</string>
|
|
||||||
<!-- Wi-Fi settings screen, generic error message when the regulatory domain could not be set. -->
|
|
||||||
<string name="wifi_setting_num_channels_error">There was a problem setting the regulatory domain.</string>
|
|
||||||
<!-- Wi-Fi settings screen, label to be appended to the count in displaying the list of valid channel counts -->
|
|
||||||
<string name="wifi_setting_num_channels_channel_phrase"><xliff:g id="num_channels">%1$d</xliff:g> channels</string>
|
|
||||||
<!-- Wi-Fi settings screen, setting title for setting the wifi sleep policy -->
|
<!-- Wi-Fi settings screen, setting title for setting the wifi sleep policy -->
|
||||||
<string name="wifi_setting_sleep_policy_title">Wi-Fi sleep policy</string>
|
<string name="wifi_setting_sleep_policy_title">Wi-Fi sleep policy</string>
|
||||||
<!-- Wi-Fi settings screen, setting summary for setting the wifi sleep policy -->
|
<!-- Wi-Fi settings screen, setting summary for setting the wifi sleep policy -->
|
||||||
|
|||||||
@@ -44,25 +44,24 @@
|
|||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:fragment="com.android.settings.applications.ManageApplications"
|
android:fragment="com.android.settings.applications.ManageApplications"
|
||||||
android:title="@string/manageapplications_settings_title"
|
android:title="@string/manageapplications_settings_title"
|
||||||
android:summary="@string/manageapplications_settings_summary">
|
android:summary="@string/manageapplications_settings_summary">
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
|
android:fragment="com.android.settings.applications.ManageApplications"
|
||||||
android:title="@string/runningservices_settings_title"
|
android:title="@string/runningservices_settings_title"
|
||||||
android:summary="@string/runningservices_settings_summary">
|
android:summary="@string/runningservices_settings_summary">
|
||||||
<intent android:action="android.intent.action.MAIN"
|
<extra android:name="classname" android:value="com.android.settings.RunningServices" />
|
||||||
android:targetPackage="com.android.settings"
|
|
||||||
android:targetClass="com.android.settings.RunningServices" />
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
|
android:fragment="com.android.settings.applications.ManageApplications"
|
||||||
android:title="@string/storageuse_settings_title"
|
android:title="@string/storageuse_settings_title"
|
||||||
android:summary="@string/storageuse_settings_summary">
|
android:summary="@string/storageuse_settings_summary">
|
||||||
<intent android:action="android.intent.action.MAIN"
|
<extra android:name="classname"
|
||||||
android:targetPackage="com.android.settings"
|
android:value="com.android.settings.applications.StorageUse" />
|
||||||
android:targetClass="com.android.settings.applications.StorageUse" />
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
|
|||||||
@@ -17,13 +17,6 @@
|
|||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:title="@string/wifi_advanced_titlebar">
|
android:title="@string/wifi_advanced_titlebar">
|
||||||
|
|
||||||
<ListPreference
|
|
||||||
android:key="num_channels"
|
|
||||||
android:title="@string/wifi_setting_num_channels_title"
|
|
||||||
android:summary="@string/wifi_setting_num_channels_summary"
|
|
||||||
android:persistent="false"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="sleep_policy"
|
android:key="sleep_policy"
|
||||||
android:title="@string/wifi_setting_sleep_policy_title"
|
android:title="@string/wifi_setting_sleep_policy_title"
|
||||||
|
|||||||
@@ -18,21 +18,20 @@ package com.android.settings;
|
|||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Displays preferences for application developers.
|
* Displays preferences for application developers.
|
||||||
*/
|
*/
|
||||||
public class DevelopmentSettings extends PreferenceActivity
|
public class DevelopmentSettings extends PreferenceFragment
|
||||||
implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
|
implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
|
||||||
|
|
||||||
private static final String ENABLE_ADB = "enable_adb";
|
private static final String ENABLE_ADB = "enable_adb";
|
||||||
@@ -49,7 +48,7 @@ public class DevelopmentSettings extends PreferenceActivity
|
|||||||
private Dialog mOkDialog;
|
private Dialog mOkDialog;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.development_prefs);
|
addPreferencesFromResource(R.xml.development_prefs);
|
||||||
@@ -60,14 +59,15 @@ public class DevelopmentSettings extends PreferenceActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
mEnableAdb.setChecked(Settings.Secure.getInt(getContentResolver(),
|
final ContentResolver cr = getActivity().getContentResolver();
|
||||||
|
mEnableAdb.setChecked(Settings.Secure.getInt(cr,
|
||||||
Settings.Secure.ADB_ENABLED, 0) != 0);
|
Settings.Secure.ADB_ENABLED, 0) != 0);
|
||||||
mKeepScreenOn.setChecked(Settings.System.getInt(getContentResolver(),
|
mKeepScreenOn.setChecked(Settings.System.getInt(cr,
|
||||||
Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0) != 0);
|
Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0) != 0);
|
||||||
mAllowMockLocation.setChecked(Settings.Secure.getInt(getContentResolver(),
|
mAllowMockLocation.setChecked(Settings.Secure.getInt(cr,
|
||||||
Settings.Secure.ALLOW_MOCK_LOCATION, 0) != 0);
|
Settings.Secure.ALLOW_MOCK_LOCATION, 0) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,8 +82,8 @@ public class DevelopmentSettings extends PreferenceActivity
|
|||||||
if (mEnableAdb.isChecked()) {
|
if (mEnableAdb.isChecked()) {
|
||||||
mOkClicked = false;
|
mOkClicked = false;
|
||||||
if (mOkDialog != null) dismissDialog();
|
if (mOkDialog != null) dismissDialog();
|
||||||
mOkDialog = new AlertDialog.Builder(this).setMessage(
|
mOkDialog = new AlertDialog.Builder(getActivity()).setMessage(
|
||||||
getResources().getString(R.string.adb_warning_message))
|
getActivity().getResources().getString(R.string.adb_warning_message))
|
||||||
.setTitle(R.string.adb_warning_title)
|
.setTitle(R.string.adb_warning_title)
|
||||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||||
.setPositiveButton(android.R.string.yes, this)
|
.setPositiveButton(android.R.string.yes, this)
|
||||||
@@ -91,14 +91,17 @@ public class DevelopmentSettings extends PreferenceActivity
|
|||||||
.show();
|
.show();
|
||||||
mOkDialog.setOnDismissListener(this);
|
mOkDialog.setOnDismissListener(this);
|
||||||
} else {
|
} else {
|
||||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.ADB_ENABLED, 0);
|
Settings.Secure.putInt(getActivity().getContentResolver(),
|
||||||
|
Settings.Secure.ADB_ENABLED, 0);
|
||||||
}
|
}
|
||||||
} else if (preference == mKeepScreenOn) {
|
} else if (preference == mKeepScreenOn) {
|
||||||
Settings.System.putInt(getContentResolver(), Settings.System.STAY_ON_WHILE_PLUGGED_IN,
|
Settings.System.putInt(getActivity().getContentResolver(),
|
||||||
|
Settings.System.STAY_ON_WHILE_PLUGGED_IN,
|
||||||
mKeepScreenOn.isChecked() ?
|
mKeepScreenOn.isChecked() ?
|
||||||
(BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB) : 0);
|
(BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB) : 0);
|
||||||
} else if (preference == mAllowMockLocation) {
|
} else if (preference == mAllowMockLocation) {
|
||||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION,
|
Settings.Secure.putInt(getActivity().getContentResolver(),
|
||||||
|
Settings.Secure.ALLOW_MOCK_LOCATION,
|
||||||
mAllowMockLocation.isChecked() ? 1 : 0);
|
mAllowMockLocation.isChecked() ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +117,8 @@ public class DevelopmentSettings extends PreferenceActivity
|
|||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||||
mOkClicked = true;
|
mOkClicked = true;
|
||||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.ADB_ENABLED, 1);
|
Settings.Secure.putInt(getActivity().getContentResolver(),
|
||||||
|
Settings.Secure.ADB_ENABLED, 1);
|
||||||
} else {
|
} else {
|
||||||
// Reset the toggle
|
// Reset the toggle
|
||||||
mEnableAdb.setChecked(false);
|
mEnableAdb.setChecked(false);
|
||||||
|
|||||||
@@ -56,7 +56,9 @@ public class Settings extends PreferenceActivity {
|
|||||||
String intentClass = intent.getComponent().getClassName();
|
String intentClass = intent.getComponent().getClassName();
|
||||||
if (intentClass.equals(getClass().getName())) return null;
|
if (intentClass.equals(getClass().getName())) return null;
|
||||||
|
|
||||||
if ("com.android.settings.ManageApplications".equals(intentClass)) {
|
if ("com.android.settings.ManageApplications".equals(intentClass)
|
||||||
|
|| "com.android.settings.RunningServices".equals(intentClass)
|
||||||
|
|| "com.android.settings.applications.StorageUse".equals(intentClass)) {
|
||||||
// Old name of manage apps.
|
// Old name of manage apps.
|
||||||
intentClass = com.android.settings.applications.ManageApplications.class.getName();
|
intentClass = com.android.settings.applications.ManageApplications.class.getName();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,9 +40,11 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.preference.PreferenceActivity;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -222,6 +224,10 @@ public class InstalledAppDetails extends Fragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initMoveButton() {
|
private void initMoveButton() {
|
||||||
|
if (Environment.isExternalStorageEmulated()) {
|
||||||
|
mMoveAppButton.setVisibility(View.INVISIBLE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
boolean dataOnly = false;
|
boolean dataOnly = false;
|
||||||
dataOnly = (mPackageInfo == null) && (mAppEntry != null);
|
dataOnly = (mPackageInfo == null) && (mAppEntry != null);
|
||||||
boolean moveDisable = true;
|
boolean moveDisable = true;
|
||||||
@@ -470,13 +476,8 @@ public class InstalledAppDetails extends Fragment
|
|||||||
if(localLOGV) Log.i(TAG, "appChanged="+appChanged);
|
if(localLOGV) Log.i(TAG, "appChanged="+appChanged);
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(ManageApplications.APP_CHG, appChanged);
|
intent.putExtra(ManageApplications.APP_CHG, appChanged);
|
||||||
Fragment target = getTargetFragment();
|
PreferenceActivity pa = (PreferenceActivity)getActivity();
|
||||||
if (target != null) {
|
pa.finishPreferencePanel(this, Activity.RESULT_OK, intent);
|
||||||
target.onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, intent);
|
|
||||||
}
|
|
||||||
if (finish) {
|
|
||||||
getActivity().onBackPressed();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshSizeInfo() {
|
private void refreshSizeInfo() {
|
||||||
|
|||||||
@@ -21,14 +21,11 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.applications.ApplicationsState.AppEntry;
|
import com.android.settings.applications.ApplicationsState.AppEntry;
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.app.TabActivity;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.IPackageManager;
|
import android.content.pm.IPackageManager;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
@@ -38,14 +35,12 @@ import android.preference.PreferenceActivity;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
@@ -57,7 +52,6 @@ import android.widget.Filterable;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
import android.widget.TabWidget;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
|
||||||
@@ -167,6 +161,8 @@ public class ManageApplications extends Fragment implements
|
|||||||
TextView mUsedStorageText;
|
TextView mUsedStorageText;
|
||||||
TextView mFreeStorageText;
|
TextView mFreeStorageText;
|
||||||
|
|
||||||
|
private Menu mOptionsMenu;
|
||||||
|
|
||||||
// These are for keeping track of activity and tab switch state.
|
// These are for keeping track of activity and tab switch state.
|
||||||
private int mCurView;
|
private int mCurView;
|
||||||
private boolean mCreatedRunning;
|
private boolean mCreatedRunning;
|
||||||
@@ -518,11 +514,14 @@ public class ManageApplications extends Fragment implements
|
|||||||
Intent intent = getActivity().getIntent();
|
Intent intent = getActivity().getIntent();
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
String defaultTabTag = TAB_DOWNLOADED;
|
String defaultTabTag = TAB_DOWNLOADED;
|
||||||
if (intent.getComponent().getClassName().equals(
|
String className = getArguments() != null
|
||||||
"com.android.settings.RunningServices")) {
|
? getArguments().getString("classname") : null;
|
||||||
|
if (className == null) {
|
||||||
|
className = intent.getComponent().getClassName();
|
||||||
|
}
|
||||||
|
if (className.equals("com.android.settings.RunningServices")) {
|
||||||
defaultTabTag = TAB_RUNNING;
|
defaultTabTag = TAB_RUNNING;
|
||||||
} else if (intent.getComponent().getClassName().equals(
|
} else if (className.equals("com.android.settings.applications.StorageUse")
|
||||||
"com.android.settings.applications.StorageUse")
|
|
||||||
|| action.equals(Intent.ACTION_MANAGE_PACKAGE_STORAGE)) {
|
|| action.equals(Intent.ACTION_MANAGE_PACKAGE_STORAGE)) {
|
||||||
mSortOrder = SORT_ORDER_SIZE;
|
mSortOrder = SORT_ORDER_SIZE;
|
||||||
mFilterApps = FILTER_APPS_ALL;
|
mFilterApps = FILTER_APPS_ALL;
|
||||||
@@ -577,6 +576,8 @@ public class ManageApplications extends Fragment implements
|
|||||||
mRunningProcessesView = (RunningProcessesView)mRootView.findViewById(
|
mRunningProcessesView = (RunningProcessesView)mRootView.findViewById(
|
||||||
R.id.running_processes);
|
R.id.running_processes);
|
||||||
|
|
||||||
|
mCreatedRunning = mResumedRunning = false;
|
||||||
|
|
||||||
View tabRoot = mInflater.inflate(com.android.internal.R.layout.tab_content, null);
|
View tabRoot = mInflater.inflate(com.android.internal.R.layout.tab_content, null);
|
||||||
mTabHost = (TabHost)tabRoot.findViewById(com.android.internal.R.id.tabhost);
|
mTabHost = (TabHost)tabRoot.findViewById(com.android.internal.R.id.tabhost);
|
||||||
mTabHost.setup();
|
mTabHost.setup();
|
||||||
@@ -589,10 +590,12 @@ public class ManageApplications extends Fragment implements
|
|||||||
.setIndicator(getActivity().getString(R.string.filter_apps_all),
|
.setIndicator(getActivity().getString(R.string.filter_apps_all),
|
||||||
getActivity().getResources().getDrawable(R.drawable.ic_tab_all))
|
getActivity().getResources().getDrawable(R.drawable.ic_tab_all))
|
||||||
.setContent(this));
|
.setContent(this));
|
||||||
tabHost.addTab(tabHost.newTabSpec(TAB_SDCARD)
|
if (!Environment.isExternalStorageEmulated()) {
|
||||||
.setIndicator(getActivity().getString(R.string.filter_apps_onsdcard),
|
tabHost.addTab(tabHost.newTabSpec(TAB_SDCARD)
|
||||||
getActivity().getResources().getDrawable(R.drawable.ic_tab_sdcard))
|
.setIndicator(getActivity().getString(R.string.filter_apps_onsdcard),
|
||||||
.setContent(this));
|
getActivity().getResources().getDrawable(R.drawable.ic_tab_sdcard))
|
||||||
|
.setContent(this));
|
||||||
|
}
|
||||||
tabHost.addTab(tabHost.newTabSpec(TAB_RUNNING)
|
tabHost.addTab(tabHost.newTabSpec(TAB_RUNNING)
|
||||||
.setIndicator(getActivity().getString(R.string.filter_apps_running),
|
.setIndicator(getActivity().getString(R.string.filter_apps_running),
|
||||||
getActivity().getResources().getDrawable(R.drawable.ic_tab_running))
|
getActivity().getResources().getDrawable(R.drawable.ic_tab_running))
|
||||||
@@ -613,6 +616,7 @@ public class ManageApplications extends Fragment implements
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
mActivityResumed = true;
|
mActivityResumed = true;
|
||||||
showCurrentTab();
|
showCurrentTab();
|
||||||
|
updateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -620,8 +624,8 @@ public class ManageApplications extends Fragment implements
|
|||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putInt("sortOrder", mSortOrder);
|
outState.putInt("sortOrder", mSortOrder);
|
||||||
outState.putInt("filterApps", mFilterApps);
|
outState.putInt("filterApps", mFilterApps);
|
||||||
if (mTabHost != null) {
|
if (mDefaultTab != null) {
|
||||||
outState.putString("defautTabTag", mTabHost.getCurrentTabTag());
|
outState.putString("defautTabTag", mDefaultTab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -645,52 +649,63 @@ public class ManageApplications extends Fragment implements
|
|||||||
|
|
||||||
// utility method used to start sub activity
|
// utility method used to start sub activity
|
||||||
private void startApplicationDetailsActivity() {
|
private void startApplicationDetailsActivity() {
|
||||||
// Create intent to start new activity
|
|
||||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
|
||||||
Uri.fromParts("package", mCurrentPkgName, null));
|
|
||||||
// start new fragment to display extended information
|
// start new fragment to display extended information
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(InstalledAppDetails.ARG_PACKAGE_NAME, mCurrentPkgName);
|
args.putString(InstalledAppDetails.ARG_PACKAGE_NAME, mCurrentPkgName);
|
||||||
|
|
||||||
PreferenceActivity pa = (PreferenceActivity)getActivity();
|
PreferenceActivity pa = (PreferenceActivity)getActivity();
|
||||||
if (pa.isMultiPane()) {
|
pa.startPreferencePanel(InstalledAppDetails.class.getName(), args,
|
||||||
Fragment frag = new InstalledAppDetails();
|
R.string.application_info_label, null, this, INSTALLED_APP_DETAILS);
|
||||||
frag.setTargetFragment(this, INSTALLED_APP_DETAILS);
|
|
||||||
frag.setArguments(args);
|
|
||||||
frag.setTargetFragment(this, INSTALLED_APP_DETAILS);
|
|
||||||
pa.startPreferenceFragment(frag, true);
|
|
||||||
} else {
|
|
||||||
pa.startWithFragment(InstalledAppDetails.class.getName(), args);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
Log.i(TAG, "onCreateOptionsMenu in " + this + ": " + menu);
|
||||||
|
mOptionsMenu = menu;
|
||||||
menu.add(0, SORT_ORDER_ALPHA, 1, R.string.sort_order_alpha)
|
menu.add(0, SORT_ORDER_ALPHA, 1, R.string.sort_order_alpha)
|
||||||
.setIcon(android.R.drawable.ic_menu_sort_alphabetically);
|
.setIcon(android.R.drawable.ic_menu_sort_alphabetically)
|
||||||
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
menu.add(0, SORT_ORDER_SIZE, 2, R.string.sort_order_size)
|
menu.add(0, SORT_ORDER_SIZE, 2, R.string.sort_order_size)
|
||||||
.setIcon(android.R.drawable.ic_menu_sort_by_size);
|
.setIcon(android.R.drawable.ic_menu_sort_by_size)
|
||||||
menu.add(0, SHOW_RUNNING_SERVICES, 3, R.string.show_running_services);
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
menu.add(0, SHOW_BACKGROUND_PROCESSES, 3, R.string.show_background_processes);
|
menu.add(0, SHOW_RUNNING_SERVICES, 3, R.string.show_running_services)
|
||||||
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
|
menu.add(0, SHOW_BACKGROUND_PROCESSES, 3, R.string.show_background_processes)
|
||||||
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
|
updateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareOptionsMenu(Menu menu) {
|
public void onPrepareOptionsMenu(Menu menu) {
|
||||||
|
updateOptionsMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyOptionsMenu() {
|
||||||
|
mOptionsMenu = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateOptionsMenu() {
|
||||||
|
if (mOptionsMenu == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The running processes screen doesn't use the mApplicationsAdapter
|
* The running processes screen doesn't use the mApplicationsAdapter
|
||||||
* so bringing up this menu in that case doesn't make any sense.
|
* so bringing up this menu in that case doesn't make any sense.
|
||||||
*/
|
*/
|
||||||
if (mCurView == VIEW_RUNNING) {
|
if (mCurView == VIEW_RUNNING) {
|
||||||
boolean showingBackground = mRunningProcessesView.mAdapter.getShowBackground();
|
boolean showingBackground = mRunningProcessesView != null
|
||||||
menu.findItem(SORT_ORDER_ALPHA).setVisible(false);
|
? mRunningProcessesView.mAdapter.getShowBackground() : false;
|
||||||
menu.findItem(SORT_ORDER_SIZE).setVisible(false);
|
mOptionsMenu.findItem(SORT_ORDER_ALPHA).setVisible(false);
|
||||||
menu.findItem(SHOW_RUNNING_SERVICES).setVisible(showingBackground);
|
mOptionsMenu.findItem(SORT_ORDER_SIZE).setVisible(false);
|
||||||
menu.findItem(SHOW_BACKGROUND_PROCESSES).setVisible(!showingBackground);
|
mOptionsMenu.findItem(SHOW_RUNNING_SERVICES).setVisible(showingBackground);
|
||||||
|
mOptionsMenu.findItem(SHOW_BACKGROUND_PROCESSES).setVisible(!showingBackground);
|
||||||
} else {
|
} else {
|
||||||
menu.findItem(SORT_ORDER_ALPHA).setVisible(mSortOrder != SORT_ORDER_ALPHA);
|
mOptionsMenu.findItem(SORT_ORDER_ALPHA).setVisible(mSortOrder != SORT_ORDER_ALPHA);
|
||||||
menu.findItem(SORT_ORDER_SIZE).setVisible(mSortOrder != SORT_ORDER_SIZE);
|
mOptionsMenu.findItem(SORT_ORDER_SIZE).setVisible(mSortOrder != SORT_ORDER_SIZE);
|
||||||
menu.findItem(SHOW_RUNNING_SERVICES).setVisible(false);
|
mOptionsMenu.findItem(SHOW_RUNNING_SERVICES).setVisible(false);
|
||||||
menu.findItem(SHOW_BACKGROUND_PROCESSES).setVisible(false);
|
mOptionsMenu.findItem(SHOW_BACKGROUND_PROCESSES).setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -707,6 +722,7 @@ public class ManageApplications extends Fragment implements
|
|||||||
} else if (menuId == SHOW_BACKGROUND_PROCESSES) {
|
} else if (menuId == SHOW_BACKGROUND_PROCESSES) {
|
||||||
mRunningProcessesView.mAdapter.setShowBackground(true);
|
mRunningProcessesView.mAdapter.setShowBackground(true);
|
||||||
}
|
}
|
||||||
|
updateOptionsMenu();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -822,7 +838,7 @@ public class ManageApplications extends Fragment implements
|
|||||||
}
|
}
|
||||||
boolean haveData = true;
|
boolean haveData = true;
|
||||||
if (mActivityResumed && !mResumedRunning) {
|
if (mActivityResumed && !mResumedRunning) {
|
||||||
haveData = mRunningProcessesView.doResume(mRunningProcessesAvail);
|
haveData = mRunningProcessesView.doResume(this, mRunningProcessesAvail);
|
||||||
mResumedRunning = true;
|
mResumedRunning = true;
|
||||||
}
|
}
|
||||||
mApplicationsAdapter.pause();
|
mApplicationsAdapter.pause();
|
||||||
@@ -850,7 +866,7 @@ public class ManageApplications extends Fragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showCurrentTab() {
|
public void showCurrentTab() {
|
||||||
String tabId = mTabHost.getCurrentTabTag();
|
String tabId = mDefaultTab = mTabHost.getCurrentTabTag();
|
||||||
int newOption;
|
int newOption;
|
||||||
if (TAB_DOWNLOADED.equalsIgnoreCase(tabId)) {
|
if (TAB_DOWNLOADED.equalsIgnoreCase(tabId)) {
|
||||||
newOption = FILTER_APPS_THIRD_PARTY;
|
newOption = FILTER_APPS_THIRD_PARTY;
|
||||||
@@ -872,6 +888,7 @@ public class ManageApplications extends Fragment implements
|
|||||||
mFilterApps = newOption;
|
mFilterApps = newOption;
|
||||||
selectView(VIEW_LIST);
|
selectView(VIEW_LIST);
|
||||||
updateStorageUsage();
|
updateStorageUsage();
|
||||||
|
updateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTabChanged(String tabId) {
|
public void onTabChanged(String tabId) {
|
||||||
|
|||||||
@@ -20,16 +20,16 @@ import com.android.settings.R;
|
|||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.app.Fragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
|
import android.preference.PreferenceActivity;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -61,6 +61,8 @@ public class RunningProcessesView extends FrameLayout
|
|||||||
|
|
||||||
RunningState mState;
|
RunningState mState;
|
||||||
|
|
||||||
|
Fragment mOwner;
|
||||||
|
|
||||||
Runnable mDataAvail;
|
Runnable mDataAvail;
|
||||||
|
|
||||||
StringBuilder mBuilder = new StringBuilder(128);
|
StringBuilder mBuilder = new StringBuilder(128);
|
||||||
@@ -417,14 +419,22 @@ public class RunningProcessesView extends FrameLayout
|
|||||||
ListView l = (ListView)parent;
|
ListView l = (ListView)parent;
|
||||||
RunningState.MergedItem mi = (RunningState.MergedItem)l.getAdapter().getItem(position);
|
RunningState.MergedItem mi = (RunningState.MergedItem)l.getAdapter().getItem(position);
|
||||||
mCurSelected = mi;
|
mCurSelected = mi;
|
||||||
Intent intent = new Intent();
|
startServiceDetailsActivity(mi);
|
||||||
intent.putExtra(RunningServiceDetails.KEY_UID, mi.mProcess.mUid);
|
|
||||||
intent.putExtra(RunningServiceDetails.KEY_PROCESS, mi.mProcess.mProcessName);
|
|
||||||
intent.putExtra(RunningServiceDetails.KEY_BACKGROUND, mAdapter.mShowBackground);
|
|
||||||
intent.setClass(getContext(), RunningServiceDetails.class);
|
|
||||||
getContext().startActivity(intent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// utility method used to start sub activity
|
||||||
|
private void startServiceDetailsActivity(RunningState.MergedItem mi) {
|
||||||
|
// start new fragment to display extended information
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt(RunningServiceDetails.KEY_UID, mi.mProcess.mUid);
|
||||||
|
args.putString(RunningServiceDetails.KEY_PROCESS, mi.mProcess.mProcessName);
|
||||||
|
args.putBoolean(RunningServiceDetails.KEY_BACKGROUND, mAdapter.mShowBackground);
|
||||||
|
|
||||||
|
PreferenceActivity pa = (PreferenceActivity)mOwner.getActivity();
|
||||||
|
pa.startPreferencePanel(RunningServiceDetails.class.getName(), args,
|
||||||
|
R.string.runningservicedetails_settings_title, null, null, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public void onMovedToScrapHeap(View view) {
|
public void onMovedToScrapHeap(View view) {
|
||||||
mActiveItems.remove(view);
|
mActiveItems.remove(view);
|
||||||
}
|
}
|
||||||
@@ -472,9 +482,11 @@ public class RunningProcessesView extends FrameLayout
|
|||||||
public void doPause() {
|
public void doPause() {
|
||||||
mState.pause();
|
mState.pause();
|
||||||
mDataAvail = null;
|
mDataAvail = null;
|
||||||
|
mOwner = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean doResume(Runnable dataAvail) {
|
public boolean doResume(Fragment owner, Runnable dataAvail) {
|
||||||
|
mOwner = owner;
|
||||||
mState.resume(this);
|
mState.resume(this);
|
||||||
if (mState.hasData()) {
|
if (mState.hasData()) {
|
||||||
// If the state already has its data, then let's populate our
|
// If the state already has its data, then let's populate our
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ package com.android.settings.applications;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.ApplicationErrorReport;
|
import android.app.ApplicationErrorReport;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.app.DialogFragment;
|
||||||
|
import android.app.Fragment;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
@@ -37,7 +38,7 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class RunningServiceDetails extends Activity
|
public class RunningServiceDetails extends Fragment
|
||||||
implements RunningState.OnRefreshUiListener {
|
implements RunningState.OnRefreshUiListener {
|
||||||
static final String TAG = "RunningServicesDetails";
|
static final String TAG = "RunningServicesDetails";
|
||||||
|
|
||||||
@@ -59,6 +60,7 @@ public class RunningServiceDetails extends Activity
|
|||||||
|
|
||||||
RunningState.MergedItem mMergedItem;
|
RunningState.MergedItem mMergedItem;
|
||||||
|
|
||||||
|
View mRootView;
|
||||||
ViewGroup mAllDetails;
|
ViewGroup mAllDetails;
|
||||||
ViewGroup mSnippet;
|
ViewGroup mSnippet;
|
||||||
RunningProcessesView.ActiveItem mSnippetActiveItem;
|
RunningProcessesView.ActiveItem mSnippetActiveItem;
|
||||||
@@ -84,14 +86,11 @@ public class RunningServiceDetails extends Activity
|
|||||||
RunningState.ServiceItem si = mServiceItem;
|
RunningState.ServiceItem si = mServiceItem;
|
||||||
if (!confirmed) {
|
if (!confirmed) {
|
||||||
if ((si.mServiceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) != 0) {
|
if ((si.mServiceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) != 0) {
|
||||||
Bundle args = new Bundle();
|
showConfirmStopDialog(si.mRunningService.service);
|
||||||
args.putParcelable("comp", si.mRunningService.service);
|
|
||||||
removeDialog(DIALOG_CONFIRM_STOP);
|
|
||||||
showDialog(DIALOG_CONFIRM_STOP, args);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stopService(new Intent().setComponent(si.mRunningService.service));
|
getActivity().stopService(new Intent().setComponent(si.mRunningService.service));
|
||||||
if (mMergedItem == null) {
|
if (mMergedItem == null) {
|
||||||
// If this is gone, we are gone.
|
// If this is gone, we are gone.
|
||||||
mState.updateNow();
|
mState.updateNow();
|
||||||
@@ -125,7 +124,7 @@ public class RunningServiceDetails extends Activity
|
|||||||
}
|
}
|
||||||
ComponentName comp = new ComponentName(mServiceItem.mServiceInfo.packageName,
|
ComponentName comp = new ComponentName(mServiceItem.mServiceInfo.packageName,
|
||||||
mServiceItem.mServiceInfo.name);
|
mServiceItem.mServiceInfo.name);
|
||||||
File filename = getFileStreamPath("service_dump.txt");
|
File filename = getActivity().getFileStreamPath("service_dump.txt");
|
||||||
FileOutputStream output = null;
|
FileOutputStream output = null;
|
||||||
try {
|
try {
|
||||||
output = new FileOutputStream(filename);
|
output = new FileOutputStream(filename);
|
||||||
@@ -160,7 +159,7 @@ public class RunningServiceDetails extends Activity
|
|||||||
|
|
||||||
if (mManageIntent != null) {
|
if (mManageIntent != null) {
|
||||||
try {
|
try {
|
||||||
startIntentSender(mManageIntent.getIntentSender(), null,
|
getActivity().startIntentSender(mManageIntent.getIntentSender(), null,
|
||||||
Intent.FLAG_ACTIVITY_NEW_TASK
|
Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
| Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
|
| Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
|
||||||
Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 0);
|
Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 0);
|
||||||
@@ -236,7 +235,7 @@ public class RunningServiceDetails extends Activity
|
|||||||
|
|
||||||
TextView description = (TextView)root.findViewById(R.id.comp_description);
|
TextView description = (TextView)root.findViewById(R.id.comp_description);
|
||||||
if (si != null && si.mServiceInfo.descriptionRes != 0) {
|
if (si != null && si.mServiceInfo.descriptionRes != 0) {
|
||||||
description.setText(getPackageManager().getText(
|
description.setText(getActivity().getPackageManager().getText(
|
||||||
si.mServiceInfo.packageName, si.mServiceInfo.descriptionRes,
|
si.mServiceInfo.packageName, si.mServiceInfo.descriptionRes,
|
||||||
si.mServiceInfo.applicationInfo));
|
si.mServiceInfo.applicationInfo));
|
||||||
} else {
|
} else {
|
||||||
@@ -244,15 +243,15 @@ public class RunningServiceDetails extends Activity
|
|||||||
description.setText(R.string.background_process_stop_description);
|
description.setText(R.string.background_process_stop_description);
|
||||||
} else if (detail.mManageIntent != null) {
|
} else if (detail.mManageIntent != null) {
|
||||||
try {
|
try {
|
||||||
Resources clientr = getPackageManager().getResourcesForApplication(
|
Resources clientr = getActivity().getPackageManager().getResourcesForApplication(
|
||||||
si.mRunningService.clientPackage);
|
si.mRunningService.clientPackage);
|
||||||
String label = clientr.getString(si.mRunningService.clientLabel);
|
String label = clientr.getString(si.mRunningService.clientLabel);
|
||||||
description.setText(getString(R.string.service_manage_description,
|
description.setText(getActivity().getString(R.string.service_manage_description,
|
||||||
label));
|
label));
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
description.setText(getText(si != null
|
description.setText(getActivity().getText(si != null
|
||||||
? R.string.service_stop_description
|
? R.string.service_stop_description
|
||||||
: R.string.heavy_weight_stop_description));
|
: R.string.heavy_weight_stop_description));
|
||||||
}
|
}
|
||||||
@@ -260,18 +259,19 @@ public class RunningServiceDetails extends Activity
|
|||||||
|
|
||||||
detail.mStopButton = (Button)root.findViewById(R.id.left_button);
|
detail.mStopButton = (Button)root.findViewById(R.id.left_button);
|
||||||
detail.mStopButton.setOnClickListener(detail);
|
detail.mStopButton.setOnClickListener(detail);
|
||||||
detail.mStopButton.setText(getText(detail.mManageIntent != null
|
detail.mStopButton.setText(getActivity().getText(detail.mManageIntent != null
|
||||||
? R.string.service_manage : R.string.service_stop));
|
? R.string.service_manage : R.string.service_stop));
|
||||||
|
|
||||||
detail.mReportButton = (Button)root.findViewById(R.id.right_button);
|
detail.mReportButton = (Button)root.findViewById(R.id.right_button);
|
||||||
detail.mReportButton.setOnClickListener(detail);
|
detail.mReportButton.setOnClickListener(detail);
|
||||||
detail.mReportButton.setText(com.android.internal.R.string.report);
|
detail.mReportButton.setText(com.android.internal.R.string.report);
|
||||||
// check if error reporting is enabled in secure settings
|
// check if error reporting is enabled in secure settings
|
||||||
int enabled = Settings.Secure.getInt(getContentResolver(),
|
int enabled = Settings.Secure.getInt(getActivity().getContentResolver(),
|
||||||
Settings.Secure.SEND_ACTION_APP_ERROR, 0);
|
Settings.Secure.SEND_ACTION_APP_ERROR, 0);
|
||||||
if (enabled != 0 && si != null) {
|
if (enabled != 0 && si != null) {
|
||||||
detail.mInstaller = ApplicationErrorReport.getErrorReportReceiver(
|
detail.mInstaller = ApplicationErrorReport.getErrorReportReceiver(
|
||||||
this, si.mServiceInfo.packageName, si.mServiceInfo.applicationInfo.flags);
|
getActivity(), si.mServiceInfo.packageName,
|
||||||
|
si.mServiceInfo.applicationInfo.flags);
|
||||||
detail.mReportButton.setEnabled(detail.mInstaller != null);
|
detail.mReportButton.setEnabled(detail.mInstaller != null);
|
||||||
} else {
|
} else {
|
||||||
detail.mReportButton.setEnabled(false);
|
detail.mReportButton.setEnabled(false);
|
||||||
@@ -312,9 +312,9 @@ public class RunningServiceDetails extends Activity
|
|||||||
textid = R.string.process_provider_in_use_description;
|
textid = R.string.process_provider_in_use_description;
|
||||||
if (rpi.importanceReasonComponent != null) {
|
if (rpi.importanceReasonComponent != null) {
|
||||||
try {
|
try {
|
||||||
ProviderInfo prov = getPackageManager().getProviderInfo(
|
ProviderInfo prov = getActivity().getPackageManager().getProviderInfo(
|
||||||
rpi.importanceReasonComponent, 0);
|
rpi.importanceReasonComponent, 0);
|
||||||
label = RunningState.makeLabel(getPackageManager(),
|
label = RunningState.makeLabel(getActivity().getPackageManager(),
|
||||||
prov.name, prov);
|
prov.name, prov);
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
}
|
}
|
||||||
@@ -324,9 +324,9 @@ public class RunningServiceDetails extends Activity
|
|||||||
textid = R.string.process_service_in_use_description;
|
textid = R.string.process_service_in_use_description;
|
||||||
if (rpi.importanceReasonComponent != null) {
|
if (rpi.importanceReasonComponent != null) {
|
||||||
try {
|
try {
|
||||||
ServiceInfo serv = getPackageManager().getServiceInfo(
|
ServiceInfo serv = getActivity().getPackageManager().getServiceInfo(
|
||||||
rpi.importanceReasonComponent, 0);
|
rpi.importanceReasonComponent, 0);
|
||||||
label = RunningState.makeLabel(getPackageManager(),
|
label = RunningState.makeLabel(getActivity().getPackageManager(),
|
||||||
serv.name, serv);
|
serv.name, serv);
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
}
|
}
|
||||||
@@ -334,7 +334,7 @@ public class RunningServiceDetails extends Activity
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (textid != 0 && label != null) {
|
if (textid != 0 && label != null) {
|
||||||
description.setText(getString(textid, label));
|
description.setText(getActivity().getString(textid, label));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,23 +405,30 @@ public class RunningServiceDetails extends Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void finish() {
|
||||||
|
getActivity().onBackPressed();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
mUid = getIntent().getIntExtra(KEY_UID, 0);
|
mUid = getArguments().getInt(KEY_UID, 0);
|
||||||
mProcessName = getIntent().getStringExtra(KEY_PROCESS);
|
mProcessName = getArguments().getString(KEY_PROCESS);
|
||||||
mShowBackground = getIntent().getBooleanExtra(KEY_BACKGROUND, false);
|
mShowBackground = getArguments().getBoolean(KEY_BACKGROUND, false);
|
||||||
|
|
||||||
mAm = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
|
mAm = (ActivityManager)getActivity().getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
mInflater = (LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
|
||||||
mState = RunningState.getInstance(this);
|
mState = RunningState.getInstance(getActivity());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
View view = mRootView = inflater.inflate(R.layout.running_service_details, null);
|
||||||
|
|
||||||
setContentView(R.layout.running_service_details);
|
mAllDetails = (ViewGroup)view.findViewById(R.id.all_details);
|
||||||
|
mSnippet = (ViewGroup)view.findViewById(R.id.snippet);
|
||||||
mAllDetails = (ViewGroup)findViewById(R.id.all_details);
|
|
||||||
mSnippet = (ViewGroup)findViewById(R.id.snippet);
|
|
||||||
mSnippet.setBackgroundResource(com.android.internal.R.drawable.title_bar_medium);
|
mSnippet.setBackgroundResource(com.android.internal.R.drawable.title_bar_medium);
|
||||||
mSnippet.setPadding(0, mSnippet.getPaddingTop(), 0, mSnippet.getPaddingBottom());
|
mSnippet.setPadding(0, mSnippet.getPaddingTop(), 0, mSnippet.getPaddingBottom());
|
||||||
mSnippetViewHolder = new RunningProcessesView.ViewHolder(mSnippet);
|
mSnippetViewHolder = new RunningProcessesView.ViewHolder(mSnippet);
|
||||||
@@ -429,26 +436,23 @@ public class RunningServiceDetails extends Activity
|
|||||||
// We want to retrieve the data right now, so any active managed
|
// We want to retrieve the data right now, so any active managed
|
||||||
// dialog that gets created can find it.
|
// dialog that gets created can find it.
|
||||||
ensureData();
|
ensureData();
|
||||||
|
|
||||||
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mHaveData = false;
|
mHaveData = false;
|
||||||
mState.pause();
|
mState.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
ensureData();
|
ensureData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
}
|
|
||||||
|
|
||||||
ActiveDetail activeDetailForService(ComponentName comp) {
|
ActiveDetail activeDetailForService(ComponentName comp) {
|
||||||
for (int i=0; i<mActiveDetails.size(); i++) {
|
for (int i=0; i<mActiveDetails.size(); i++) {
|
||||||
ActiveDetail ad = mActiveDetails.get(i);
|
ActiveDetail ad = mActiveDetails.get(i);
|
||||||
@@ -460,34 +464,56 @@ public class RunningServiceDetails extends Activity
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void showConfirmStopDialog(ComponentName comp) {
|
||||||
protected Dialog onCreateDialog(int id, Bundle args) {
|
DialogFragment newFragment = MyAlertDialogFragment.newConfirmStop(
|
||||||
switch (id) {
|
DIALOG_CONFIRM_STOP, comp);
|
||||||
case DIALOG_CONFIRM_STOP: {
|
newFragment.setTargetFragment(this, 0);
|
||||||
final ComponentName comp = (ComponentName)args.getParcelable("comp");
|
newFragment.show(getFragmentManager(), "confirmstop");
|
||||||
if (activeDetailForService(comp) == null) {
|
}
|
||||||
return null;
|
|
||||||
}
|
public static class MyAlertDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
return new AlertDialog.Builder(this)
|
public static MyAlertDialogFragment newConfirmStop(int id, ComponentName comp) {
|
||||||
.setTitle(getString(R.string.runningservicedetails_stop_dlg_title))
|
MyAlertDialogFragment frag = new MyAlertDialogFragment();
|
||||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
Bundle args = new Bundle();
|
||||||
.setMessage(getString(R.string.runningservicedetails_stop_dlg_text))
|
args.putInt("id", id);
|
||||||
.setPositiveButton(R.string.dlg_ok,
|
args.putParcelable("comp", comp);
|
||||||
new DialogInterface.OnClickListener() {
|
frag.setArguments(args);
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
return frag;
|
||||||
ActiveDetail ad = activeDetailForService(comp);
|
}
|
||||||
if (ad != null) {
|
|
||||||
ad.stopActiveService(true);
|
RunningServiceDetails getOwner() {
|
||||||
|
return (RunningServiceDetails)getTargetFragment();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
int id = getArguments().getInt("id");
|
||||||
|
switch (id) {
|
||||||
|
case DIALOG_CONFIRM_STOP: {
|
||||||
|
final ComponentName comp = (ComponentName)getArguments().getParcelable("comp");
|
||||||
|
if (getOwner().activeDetailForService(comp) == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new AlertDialog.Builder(getActivity())
|
||||||
|
.setTitle(getActivity().getString(R.string.runningservicedetails_stop_dlg_title))
|
||||||
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||||
|
.setMessage(getActivity().getString(R.string.runningservicedetails_stop_dlg_text))
|
||||||
|
.setPositiveButton(R.string.dlg_ok,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
ActiveDetail ad = getOwner().activeDetailForService(comp);
|
||||||
|
if (ad != null) {
|
||||||
|
ad.stopActiveService(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
.setNegativeButton(R.string.dlg_cancel, null)
|
||||||
.setNegativeButton(R.string.dlg_cancel, null)
|
.create();
|
||||||
.create();
|
}
|
||||||
}
|
}
|
||||||
|
throw new IllegalArgumentException("unknown id " + id);
|
||||||
default:
|
|
||||||
return super.onCreateDialog(id, args);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,11 +535,10 @@ public class RunningServiceDetails extends Activity
|
|||||||
|
|
||||||
void updateTimes() {
|
void updateTimes() {
|
||||||
if (mSnippetActiveItem != null) {
|
if (mSnippetActiveItem != null) {
|
||||||
mSnippetActiveItem.updateTime(RunningServiceDetails.this, mBuilder);
|
mSnippetActiveItem.updateTime(getActivity(), mBuilder);
|
||||||
}
|
}
|
||||||
for (int i=0; i<mActiveDetails.size(); i++) {
|
for (int i=0; i<mActiveDetails.size(); i++) {
|
||||||
mActiveDetails.get(i).mActiveItem.updateTime(
|
mActiveDetails.get(i).mActiveItem.updateTime(getActivity(), mBuilder);
|
||||||
RunningServiceDetails.this, mBuilder);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,97 +23,173 @@ import android.content.pm.ApplicationInfo;
|
|||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.provider.Settings.SettingNotFoundException;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.inputmethod.InputMethodInfo;
|
import android.view.inputmethod.InputMethodInfo;
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class InputMethodAndSubtypeUtil {
|
public class InputMethodAndSubtypeUtil {
|
||||||
|
|
||||||
private static final TextUtils.SimpleStringSplitter sStringColonSplitter
|
private static final boolean DEBUG = false;
|
||||||
= new TextUtils.SimpleStringSplitter(':');
|
static final String TAG = "InputMethdAndSubtypeUtil";
|
||||||
|
|
||||||
|
private static final char INPUT_METHOD_SEPARATER = ':';
|
||||||
|
private static final char INPUT_METHOD_SUBTYPE_SEPARATER = ';';
|
||||||
|
private static final int NOT_A_SUBTYPE_ID = -1;
|
||||||
|
|
||||||
|
private static final TextUtils.SimpleStringSplitter sStringInputMethodSplitter
|
||||||
|
= new TextUtils.SimpleStringSplitter(INPUT_METHOD_SEPARATER);
|
||||||
|
|
||||||
|
private static final TextUtils.SimpleStringSplitter sStringInputMethodSubtypeSplitter
|
||||||
|
= new TextUtils.SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATER);
|
||||||
|
|
||||||
|
private static boolean isInputMethodSubtypeSelected(ContentResolver resolver) {
|
||||||
|
try {
|
||||||
|
return Settings.Secure.getInt(resolver,
|
||||||
|
Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE) != NOT_A_SUBTYPE_ID;
|
||||||
|
} catch (SettingNotFoundException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void putSelectedInputMethodSubtype(ContentResolver resolver, int hashCode) {
|
||||||
|
Settings.Secure.putInt(resolver, Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE, hashCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Needs to modify InputMethodManageService if you want to change the format of saved string.
|
||||||
|
private static HashMap<String, HashSet<String>> getEnabledInputMethodsAndSubtypeList(
|
||||||
|
ContentResolver resolver) {
|
||||||
|
final String enabledInputMethodsStr = Settings.Secure.getString(
|
||||||
|
resolver, Settings.Secure.ENABLED_INPUT_METHODS);
|
||||||
|
HashMap<String, HashSet<String>> imsList
|
||||||
|
= new HashMap<String, HashSet<String>>();
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "--- Load enabled input methods: " + enabledInputMethodsStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(enabledInputMethodsStr)) {
|
||||||
|
return imsList;
|
||||||
|
}
|
||||||
|
sStringInputMethodSplitter.setString(enabledInputMethodsStr);
|
||||||
|
while (sStringInputMethodSplitter.hasNext()) {
|
||||||
|
String nextImsStr = sStringInputMethodSplitter.next();
|
||||||
|
sStringInputMethodSubtypeSplitter.setString(nextImsStr);
|
||||||
|
if (sStringInputMethodSubtypeSplitter.hasNext()) {
|
||||||
|
HashSet<String> subtypeHashes = new HashSet<String>();
|
||||||
|
// The first element is ime id.
|
||||||
|
String imeId = sStringInputMethodSubtypeSplitter.next();
|
||||||
|
while (sStringInputMethodSubtypeSplitter.hasNext()) {
|
||||||
|
subtypeHashes.add(sStringInputMethodSubtypeSplitter.next());
|
||||||
|
}
|
||||||
|
imsList.put(imeId, subtypeHashes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return imsList;
|
||||||
|
}
|
||||||
|
|
||||||
public static void saveInputMethodSubtypeList(
|
public static void saveInputMethodSubtypeList(
|
||||||
SettingsPreferenceFragment context, ContentResolver resolver,
|
SettingsPreferenceFragment context, ContentResolver resolver,
|
||||||
List<InputMethodInfo> inputMethodProperties,
|
List<InputMethodInfo> inputMethodProperties,
|
||||||
boolean hasHardKeyboard, String lastTickedInputMethodId) {
|
boolean hasHardKeyboard, String lastTickedInputMethodId) {
|
||||||
String lastInputMethodId = Settings.Secure.getString(resolver,
|
String currentInputMethodId = Settings.Secure.getString(resolver,
|
||||||
Settings.Secure.DEFAULT_INPUT_METHOD);
|
Settings.Secure.DEFAULT_INPUT_METHOD);
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
StringBuilder disabledSysImes = new StringBuilder();
|
StringBuilder disabledSysImes = new StringBuilder();
|
||||||
|
InputMethodInfo firstEnabledIMI = null;
|
||||||
|
int firstSubtypeHashCode = NOT_A_SUBTYPE_ID;
|
||||||
|
|
||||||
int firstEnabled = -1;
|
final boolean onlyOneIME = inputMethodProperties.size() == 1;
|
||||||
int N = inputMethodProperties.size();
|
for (InputMethodInfo property : inputMethodProperties) {
|
||||||
for (int i = 0; i < N; ++i) {
|
|
||||||
final InputMethodInfo property = inputMethodProperties.get(i);
|
|
||||||
final String id = property.getId();
|
final String id = property.getId();
|
||||||
CheckBoxPreference pref = (CheckBoxPreference) context.findPreference(id);
|
CheckBoxPreference pref = (CheckBoxPreference) context.findPreference(id);
|
||||||
boolean currentInputMethod = id.equals(lastInputMethodId);
|
boolean isCurrentInputMethod = id.equals(currentInputMethodId);
|
||||||
boolean systemIme = isSystemIme(property);
|
boolean systemIme = isSystemIme(property);
|
||||||
// TODO: Append subtypes by using the separator ";"
|
// TODO: Append subtypes by using the separator ";"
|
||||||
if (((N == 1 || systemIme) && !hasHardKeyboard)
|
if (((onlyOneIME || systemIme) && !hasHardKeyboard)
|
||||||
|| (pref != null && pref.isChecked())) {
|
|| (pref != null && pref.isChecked())) {
|
||||||
if (builder.length() > 0) builder.append(':');
|
if (builder.length() > 0) builder.append(INPUT_METHOD_SEPARATER);
|
||||||
builder.append(id);
|
builder.append(id);
|
||||||
if (firstEnabled < 0) {
|
if (firstEnabledIMI == null) {
|
||||||
firstEnabled = i;
|
firstEnabledIMI = property;
|
||||||
}
|
}
|
||||||
} else if (currentInputMethod) {
|
for (InputMethodSubtype subtype : property.getSubtypes()) {
|
||||||
lastInputMethodId = lastTickedInputMethodId;
|
CheckBoxPreference subtypePref = (CheckBoxPreference) context.findPreference(
|
||||||
|
id + subtype.hashCode());
|
||||||
|
if (subtypePref != null && subtypePref.isChecked()) {
|
||||||
|
builder.append(INPUT_METHOD_SUBTYPE_SEPARATER).append(subtype.hashCode());
|
||||||
|
if (firstSubtypeHashCode == NOT_A_SUBTYPE_ID) {
|
||||||
|
firstSubtypeHashCode = subtype.hashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (isCurrentInputMethod) {
|
||||||
|
// We are processing the current input method, but found that it's not enabled.
|
||||||
|
// This means that the current input method has been uninstalled.
|
||||||
|
// If currentInputMethod is already uninstalled, selects last ticked IME
|
||||||
|
currentInputMethodId = lastTickedInputMethodId;
|
||||||
}
|
}
|
||||||
// If it's a disabled system ime, add it to the disabled list so that it
|
// If it's a disabled system ime, add it to the disabled list so that it
|
||||||
// doesn't get enabled automatically on any changes to the package list
|
// doesn't get enabled automatically on any changes to the package list
|
||||||
if (pref != null && !pref.isChecked() && systemIme && hasHardKeyboard) {
|
if (pref != null && !pref.isChecked() && systemIme && hasHardKeyboard) {
|
||||||
if (disabledSysImes.length() > 0) disabledSysImes.append(":");
|
if (disabledSysImes.length() > 0) disabledSysImes.append(INPUT_METHOD_SEPARATER);
|
||||||
disabledSysImes.append(id);
|
disabledSysImes.append(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the last input method is unset, set it as the first enabled one.
|
// If the last input method is unset, set it as the first enabled one.
|
||||||
if (TextUtils.isEmpty(lastInputMethodId)) {
|
if (TextUtils.isEmpty(currentInputMethodId)) {
|
||||||
if (firstEnabled >= 0) {
|
if (firstEnabledIMI != null) {
|
||||||
lastInputMethodId = inputMethodProperties.get(firstEnabled).getId();
|
currentInputMethodId = firstEnabledIMI.getId();
|
||||||
} else {
|
} else {
|
||||||
lastInputMethodId = null;
|
currentInputMethodId = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "--- Save enabled inputmethod settings. :" + builder.toString());
|
||||||
|
Log.d(TAG, "--- Save disable system inputmethod settings. :"
|
||||||
|
+ disabledSysImes.toString());
|
||||||
|
Log.d(TAG, "--- Save default inputmethod settings. :" + currentInputMethodId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// redefines SelectedSubtype when all subtypes are unchecked or there is no subtype
|
||||||
|
// selected.
|
||||||
|
if (firstSubtypeHashCode == NOT_A_SUBTYPE_ID || !isInputMethodSubtypeSelected(resolver)) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "--- Set inputmethod subtype because it's not defined."
|
||||||
|
+ firstSubtypeHashCode);
|
||||||
|
}
|
||||||
|
putSelectedInputMethodSubtype(resolver, firstSubtypeHashCode);
|
||||||
|
}
|
||||||
|
|
||||||
Settings.Secure.putString(resolver,
|
Settings.Secure.putString(resolver,
|
||||||
Settings.Secure.ENABLED_INPUT_METHODS, builder.toString());
|
Settings.Secure.ENABLED_INPUT_METHODS, builder.toString());
|
||||||
Settings.Secure.putString(resolver,
|
Settings.Secure.putString(resolver,
|
||||||
Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS, disabledSysImes.toString());
|
Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS, disabledSysImes.toString());
|
||||||
Settings.Secure.putString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD,
|
Settings.Secure.putString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD,
|
||||||
lastInputMethodId != null ? lastInputMethodId : "");
|
currentInputMethodId != null ? currentInputMethodId : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadInputMethodSubtypeList(
|
public static void loadInputMethodSubtypeList(
|
||||||
SettingsPreferenceFragment context, ContentResolver resolver,
|
SettingsPreferenceFragment context, ContentResolver resolver,
|
||||||
List<InputMethodInfo> inputMethodProperties) {
|
List<InputMethodInfo> inputMethodProperties) {
|
||||||
final HashSet<String> enabled = new HashSet<String>();
|
HashMap<String, HashSet<String>> enabledSubtypes =
|
||||||
String enabledStr = Settings.Secure.getString(resolver,
|
getEnabledInputMethodsAndSubtypeList(resolver);
|
||||||
Settings.Secure.ENABLED_INPUT_METHODS);
|
|
||||||
if (enabledStr != null) {
|
|
||||||
final TextUtils.SimpleStringSplitter splitter = sStringColonSplitter;
|
|
||||||
splitter.setString(enabledStr);
|
|
||||||
while (splitter.hasNext()) {
|
|
||||||
enabled.add(splitter.next());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the statuses of the Check Boxes.
|
for (InputMethodInfo property : inputMethodProperties) {
|
||||||
int N = inputMethodProperties.size();
|
final String id = property.getId();
|
||||||
// TODO: Use iterator.
|
CheckBoxPreference pref = (CheckBoxPreference) context.findPreference(id);
|
||||||
for (int i = 0; i < N; ++i) {
|
|
||||||
final String id = inputMethodProperties.get(i).getId();
|
|
||||||
CheckBoxPreference pref = (CheckBoxPreference) context.findPreference(
|
|
||||||
inputMethodProperties.get(i).getId());
|
|
||||||
if (pref != null) {
|
if (pref != null) {
|
||||||
boolean isEnabled = enabled.contains(id);
|
boolean isEnabled = enabledSubtypes.containsKey(id);
|
||||||
pref.setChecked(isEnabled);
|
pref.setChecked(isEnabled);
|
||||||
setSubtypesPreferenceEnabled(context, inputMethodProperties, id, isEnabled);
|
setSubtypesPreferenceEnabled(context, inputMethodProperties, id, isEnabled);
|
||||||
|
updateSubtypesPreferenceChecked(context, inputMethodProperties, enabledSubtypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,17 +197,41 @@ public class InputMethodAndSubtypeUtil {
|
|||||||
public static void setSubtypesPreferenceEnabled(SettingsPreferenceFragment context,
|
public static void setSubtypesPreferenceEnabled(SettingsPreferenceFragment context,
|
||||||
List<InputMethodInfo> inputMethodProperties, String id, boolean enabled) {
|
List<InputMethodInfo> inputMethodProperties, String id, boolean enabled) {
|
||||||
PreferenceScreen preferenceScreen = context.getPreferenceScreen();
|
PreferenceScreen preferenceScreen = context.getPreferenceScreen();
|
||||||
final int N = inputMethodProperties.size();
|
for (InputMethodInfo imi : inputMethodProperties) {
|
||||||
// TODO: Use iterator.
|
|
||||||
for (int i = 0; i < N; i++) {
|
|
||||||
InputMethodInfo imi = inputMethodProperties.get(i);
|
|
||||||
if (id.equals(imi.getId())) {
|
if (id.equals(imi.getId())) {
|
||||||
for (InputMethodSubtype subtype: imi.getSubtypes()) {
|
for (InputMethodSubtype subtype : imi.getSubtypes()) {
|
||||||
preferenceScreen.findPreference(id + subtype.hashCode()).setEnabled(enabled);
|
CheckBoxPreference pref = (CheckBoxPreference) preferenceScreen.findPreference(
|
||||||
|
id + subtype.hashCode());
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setEnabled(enabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void updateSubtypesPreferenceChecked(SettingsPreferenceFragment context,
|
||||||
|
List<InputMethodInfo> inputMethodProperties,
|
||||||
|
HashMap<String, HashSet<String>> enabledSubtypes) {
|
||||||
|
PreferenceScreen preferenceScreen = context.getPreferenceScreen();
|
||||||
|
for (InputMethodInfo imi : inputMethodProperties) {
|
||||||
|
String id = imi.getId();
|
||||||
|
HashSet<String> enabledSubtypesSet = enabledSubtypes.get(id);
|
||||||
|
for (InputMethodSubtype subtype : imi.getSubtypes()) {
|
||||||
|
String hashCode = String.valueOf(subtype.hashCode());
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "--- Set checked state: " + "id" + ", " + hashCode + ", "
|
||||||
|
+ enabledSubtypesSet.contains(hashCode));
|
||||||
|
}
|
||||||
|
CheckBoxPreference pref = (CheckBoxPreference) preferenceScreen.findPreference(
|
||||||
|
id + hashCode);
|
||||||
|
if (pref != null) {
|
||||||
|
pref.setChecked(enabledSubtypesSet.contains(hashCode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isSystemIme(InputMethodInfo property) {
|
public static boolean isSystemIme(InputMethodInfo property) {
|
||||||
return (property.getServiceInfo().applicationInfo.flags
|
return (property.getServiceInfo().applicationInfo.flags
|
||||||
& ApplicationInfo.FLAG_SYSTEM) != 0;
|
& ApplicationInfo.FLAG_SYSTEM) != 0;
|
||||||
|
|||||||
@@ -35,12 +35,8 @@ public class AdvancedSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
private static final String KEY_MAC_ADDRESS = "mac_address";
|
private static final String KEY_MAC_ADDRESS = "mac_address";
|
||||||
private static final String KEY_CURRENT_IP_ADDRESS = "current_ip_address";
|
private static final String KEY_CURRENT_IP_ADDRESS = "current_ip_address";
|
||||||
private static final String KEY_NUM_CHANNELS = "num_channels";
|
|
||||||
private static final String KEY_SLEEP_POLICY = "sleep_policy";
|
private static final String KEY_SLEEP_POLICY = "sleep_policy";
|
||||||
|
|
||||||
//Tracks ro.debuggable (1 on userdebug builds)
|
|
||||||
private static int DEBUGGABLE;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -50,77 +46,16 @@ public class AdvancedSettings extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
DEBUGGABLE = SystemProperties.getInt("ro.debuggable", 0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove user control of regulatory domain
|
|
||||||
* channel count settings in non userdebug builds
|
|
||||||
*/
|
|
||||||
if (DEBUGGABLE == 1) {
|
|
||||||
/*
|
|
||||||
* Fix the Run-time IllegalStateException that ListPreference requires an entries
|
|
||||||
* array and an entryValues array, this exception occurs when user open/close the
|
|
||||||
* slider in the Regulatory domain dialog.
|
|
||||||
*/
|
|
||||||
initNumChannelsPreference();
|
|
||||||
} else {
|
|
||||||
Preference chanPref = findPreference(KEY_NUM_CHANNELS);
|
|
||||||
if (chanPref != null) {
|
|
||||||
getPreferenceScreen().removePreference(chanPref);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove user control of regulatory domain
|
|
||||||
* channel count settings in non userdebug builds
|
|
||||||
*/
|
|
||||||
if (DEBUGGABLE == 1) {
|
|
||||||
initNumChannelsPreference();
|
|
||||||
}
|
|
||||||
initSleepPolicyPreference();
|
initSleepPolicyPreference();
|
||||||
refreshWifiInfo();
|
refreshWifiInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initNumChannelsPreference() {
|
|
||||||
ListPreference pref = (ListPreference) findPreference(KEY_NUM_CHANNELS);
|
|
||||||
pref.setOnPreferenceChangeListener(this);
|
|
||||||
|
|
||||||
WifiManager wifiManager = (WifiManager) getSystemService(Activity.WIFI_SERVICE);
|
|
||||||
/*
|
|
||||||
* Generate the list of valid channel counts to show in the ListPreference.
|
|
||||||
* The values are numerical, so the only text to be localized is the
|
|
||||||
* "channel_word" resource.
|
|
||||||
*/
|
|
||||||
int[] validChannelCounts = wifiManager.getValidChannelCounts();
|
|
||||||
if (validChannelCounts == null) {
|
|
||||||
Toast.makeText(getActivity(), R.string.wifi_setting_num_channels_error,
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
pref.setEnabled(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String[] entries = new String[validChannelCounts.length];
|
|
||||||
String[] entryValues = new String[validChannelCounts.length];
|
|
||||||
|
|
||||||
for (int i = 0; i < validChannelCounts.length; i++) {
|
|
||||||
entryValues[i] = String.valueOf(validChannelCounts[i]);
|
|
||||||
entries[i] = getActivity().getString(R.string.wifi_setting_num_channels_channel_phrase,
|
|
||||||
validChannelCounts[i]);
|
|
||||||
}
|
|
||||||
pref.setEntries(entries);
|
|
||||||
pref.setEntryValues(entryValues);
|
|
||||||
pref.setEnabled(true);
|
|
||||||
int numChannels = wifiManager.getNumAllowedChannels();
|
|
||||||
if (numChannels >= 0) {
|
|
||||||
pref.setValue(String.valueOf(numChannels));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initSleepPolicyPreference() {
|
private void initSleepPolicyPreference() {
|
||||||
ListPreference pref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
|
ListPreference pref = (ListPreference) findPreference(KEY_SLEEP_POLICY);
|
||||||
pref.setOnPreferenceChangeListener(this);
|
pref.setOnPreferenceChangeListener(this);
|
||||||
@@ -133,21 +68,7 @@ public class AdvancedSettings extends SettingsPreferenceFragment
|
|||||||
String key = preference.getKey();
|
String key = preference.getKey();
|
||||||
if (key == null) return true;
|
if (key == null) return true;
|
||||||
|
|
||||||
if (key.equals(KEY_NUM_CHANNELS)) {
|
if (key.equals(KEY_SLEEP_POLICY)) {
|
||||||
try {
|
|
||||||
int numChannels = Integer.parseInt((String) newValue);
|
|
||||||
WifiManager wifiManager = (WifiManager) getSystemService(Activity.WIFI_SERVICE);
|
|
||||||
if (!wifiManager.setNumAllowedChannels(numChannels, true)) {
|
|
||||||
Toast.makeText(getActivity(), R.string.wifi_setting_num_channels_error,
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
Toast.makeText(getActivity(), R.string.wifi_setting_num_channels_error,
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (key.equals(KEY_SLEEP_POLICY)) {
|
|
||||||
try {
|
try {
|
||||||
Settings.System.putInt(getContentResolver(),
|
Settings.System.putInt(getContentResolver(),
|
||||||
Settings.System.WIFI_SLEEP_POLICY, Integer.parseInt(((String) newValue)));
|
Settings.System.WIFI_SLEEP_POLICY, Integer.parseInt(((String) newValue)));
|
||||||
@@ -157,7 +78,7 @@ public class AdvancedSettings extends SettingsPreferenceFragment
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +88,7 @@ public class AdvancedSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
Preference wifiMacAddressPref = findPreference(KEY_MAC_ADDRESS);
|
Preference wifiMacAddressPref = findPreference(KEY_MAC_ADDRESS);
|
||||||
String macAddress = wifiInfo == null ? null : wifiInfo.getMacAddress();
|
String macAddress = wifiInfo == null ? null : wifiInfo.getMacAddress();
|
||||||
wifiMacAddressPref.setSummary(!TextUtils.isEmpty(macAddress) ? macAddress
|
wifiMacAddressPref.setSummary(!TextUtils.isEmpty(macAddress) ? macAddress
|
||||||
: getActivity().getString(R.string.status_unavailable));
|
: getActivity().getString(R.string.status_unavailable));
|
||||||
|
|
||||||
Preference wifiIpAddressPref = findPreference(KEY_CURRENT_IP_ADDRESS);
|
Preference wifiIpAddressPref = findPreference(KEY_CURRENT_IP_ADDRESS);
|
||||||
|
|||||||
Reference in New Issue
Block a user