Revert "Initial checkin of AOSP Messaging app."
This reverts commit 461a34b466.
Change-Id: Iac4ca77eeaa94989e91dead49a7959c905bd3078
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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.android.messaging.ui.debug;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.messaging.R;
|
||||
import com.android.messaging.ui.BaseBugleActivity;
|
||||
|
||||
/**
|
||||
* Show list of all MmsConfig key/value pairs and allow editing.
|
||||
*/
|
||||
public class DebugMmsConfigActivity extends BaseBugleActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.debug_mmsconfig_activity);
|
||||
}
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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.android.messaging.ui.debug;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.messaging.R;
|
||||
import com.android.messaging.datamodel.data.ParticipantData;
|
||||
import com.android.messaging.sms.MmsConfig;
|
||||
import com.android.messaging.ui.debug.DebugMmsConfigItemView.MmsConfigItemListener;
|
||||
import com.android.messaging.util.OsUtil;
|
||||
import com.android.messaging.util.PhoneUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Show list of all MmsConfig key/value pairs and allow editing.
|
||||
*/
|
||||
public class DebugMmsConfigFragment extends Fragment {
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
|
||||
final Bundle savedInstanceState) {
|
||||
final View fragmentView = inflater.inflate(R.layout.mms_config_debug_fragment, container,
|
||||
false);
|
||||
final ListView listView = (ListView) fragmentView.findViewById(android.R.id.list);
|
||||
final Spinner spinner = (Spinner) fragmentView.findViewById(R.id.sim_selector);
|
||||
final Integer[] subIdArray = getActiveSubIds();
|
||||
ArrayAdapter<Integer> spinnerAdapter = new ArrayAdapter<Integer>(getActivity(),
|
||||
android.R.layout.simple_spinner_item, subIdArray);
|
||||
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
spinner.setAdapter(spinnerAdapter);
|
||||
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
listView.setAdapter(new MmsConfigAdapter(getActivity(), subIdArray[position]));
|
||||
|
||||
final int[] mccmnc = PhoneUtils.get(subIdArray[position]).getMccMnc();
|
||||
// Set the title with the mcc/mnc
|
||||
final TextView title = (TextView) fragmentView.findViewById(R.id.sim_title);
|
||||
title.setText("(" + mccmnc[0] + "/" + mccmnc[1] + ") " +
|
||||
getActivity().getString(R.string.debug_sub_id_spinner_text));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
}
|
||||
});
|
||||
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
public static Integer[] getActiveSubIds() {
|
||||
if (!OsUtil.isAtLeastL_MR1()) {
|
||||
return new Integer[] { ParticipantData.DEFAULT_SELF_SUB_ID };
|
||||
}
|
||||
final List<SubscriptionInfo> subRecords =
|
||||
PhoneUtils.getDefault().toLMr1().getActiveSubscriptionInfoList();
|
||||
if (subRecords == null) {
|
||||
return new Integer[0];
|
||||
}
|
||||
final Integer[] retArray = new Integer[subRecords.size()];
|
||||
for (int i = 0; i < subRecords.size(); i++) {
|
||||
retArray[i] = subRecords.get(i).getSubscriptionId();
|
||||
}
|
||||
return retArray;
|
||||
}
|
||||
|
||||
private class MmsConfigAdapter extends BaseAdapter implements
|
||||
DebugMmsConfigItemView.MmsConfigItemListener {
|
||||
private final LayoutInflater mInflater;
|
||||
private final List<String> mKeys;
|
||||
private final MmsConfig mMmsConfig;
|
||||
|
||||
public MmsConfigAdapter(Context context, int subId) {
|
||||
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mMmsConfig = MmsConfig.get(subId);
|
||||
mKeys = new ArrayList<>(mMmsConfig.keySet());
|
||||
Collections.sort(mKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, final View convertView, final ViewGroup parent) {
|
||||
final DebugMmsConfigItemView view;
|
||||
if (convertView != null && convertView instanceof DebugMmsConfigItemView) {
|
||||
view = (DebugMmsConfigItemView) convertView;
|
||||
} else {
|
||||
view = (DebugMmsConfigItemView) mInflater.inflate(
|
||||
R.layout.debug_mmsconfig_item_view, parent, false);
|
||||
}
|
||||
final String key = mKeys.get(position);
|
||||
view.bind(key,
|
||||
MmsConfig.getKeyType(key),
|
||||
String.valueOf(mMmsConfig.getValue(key)),
|
||||
this);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(String key, String keyType, String value) {
|
||||
mMmsConfig.update(key, value, keyType);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mKeys.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return mKeys.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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.android.messaging.ui.debug;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnShowListener;
|
||||
import android.text.InputType;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.messaging.R;
|
||||
import com.android.messaging.sms.MmsConfig;
|
||||
import com.android.messaging.util.LogUtil;
|
||||
|
||||
public class DebugMmsConfigItemView extends LinearLayout implements OnClickListener,
|
||||
OnCheckedChangeListener, DialogInterface.OnClickListener {
|
||||
|
||||
public interface MmsConfigItemListener {
|
||||
void onValueChanged(String key, String keyType, String value);
|
||||
}
|
||||
|
||||
private TextView mTitle;
|
||||
private TextView mTextValue;
|
||||
private Switch mSwitch;
|
||||
private String mKey;
|
||||
private String mKeyType;
|
||||
private MmsConfigItemListener mListener;
|
||||
private EditText mEditText;
|
||||
|
||||
public DebugMmsConfigItemView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate () {
|
||||
mTitle = (TextView) findViewById(R.id.title);
|
||||
mTextValue = (TextView) findViewById(R.id.text_value);
|
||||
mSwitch = (Switch) findViewById(R.id.switch_button);
|
||||
setOnClickListener(this);
|
||||
mSwitch.setOnCheckedChangeListener(this);
|
||||
}
|
||||
|
||||
public void bind(final String key, final String keyType, final String value,
|
||||
final MmsConfigItemListener listener) {
|
||||
mListener = listener;
|
||||
mKey = key;
|
||||
mKeyType = keyType;
|
||||
mTitle.setText(key);
|
||||
|
||||
switch (keyType) {
|
||||
case MmsConfig.KEY_TYPE_BOOL:
|
||||
mSwitch.setVisibility(View.VISIBLE);
|
||||
mTextValue.setVisibility(View.GONE);
|
||||
mSwitch.setChecked(Boolean.valueOf(value));
|
||||
break;
|
||||
case MmsConfig.KEY_TYPE_STRING:
|
||||
case MmsConfig.KEY_TYPE_INT:
|
||||
mTextValue.setVisibility(View.VISIBLE);
|
||||
mSwitch.setVisibility(View.GONE);
|
||||
mTextValue.setText(value);
|
||||
break;
|
||||
default:
|
||||
mTextValue.setVisibility(View.GONE);
|
||||
mSwitch.setVisibility(View.GONE);
|
||||
LogUtil.e(LogUtil.BUGLE_TAG, "Unexpected keytype: " + keyType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
mListener.onValueChanged(mKey, mKeyType, String.valueOf(isChecked));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (MmsConfig.KEY_TYPE_BOOL.equals(mKeyType)) {
|
||||
return;
|
||||
}
|
||||
final Context context = getContext();
|
||||
mEditText = new EditText(context);
|
||||
mEditText.setText(mTextValue.getText());
|
||||
mEditText.setFocusable(true);
|
||||
if (MmsConfig.KEY_TYPE_INT.equals(mKeyType)) {
|
||||
mEditText.setInputType(InputType.TYPE_CLASS_PHONE);
|
||||
} else {
|
||||
mEditText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||
}
|
||||
final AlertDialog dialog = new AlertDialog.Builder(context)
|
||||
.setTitle(mKey)
|
||||
.setView(mEditText)
|
||||
.setPositiveButton(android.R.string.ok, this)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
dialog.setOnShowListener(new OnShowListener() {
|
||||
@Override
|
||||
public void onShow(DialogInterface dialog) {
|
||||
mEditText.requestFocus();
|
||||
mEditText.selectAll();
|
||||
((InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE))
|
||||
.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mListener.onValueChanged(mKey, mKeyType, mEditText.getText().toString());
|
||||
}
|
||||
}
|
||||
@@ -1,171 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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.android.messaging.ui.debug;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.telephony.SmsMessage;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.messaging.R;
|
||||
import com.android.messaging.datamodel.action.ReceiveMmsMessageAction;
|
||||
import com.android.messaging.datamodel.data.ParticipantData;
|
||||
import com.android.messaging.receiver.SmsReceiver;
|
||||
import com.android.messaging.sms.MmsUtils;
|
||||
import com.android.messaging.util.DebugUtils;
|
||||
import com.android.messaging.util.LogUtil;
|
||||
|
||||
/**
|
||||
* Class that displays UI for choosing SMS/MMS dump files for debugging
|
||||
*/
|
||||
public class DebugSmsMmsFromDumpFileDialogFragment extends DialogFragment {
|
||||
public static final String APPLICATION_OCTET_STREAM = "application/octet-stream";
|
||||
public static final String KEY_DUMP_FILES = "dump_files";
|
||||
public static final String KEY_ACTION = "action";
|
||||
|
||||
public static final String ACTION_LOAD = "load";
|
||||
public static final String ACTION_EMAIL = "email";
|
||||
|
||||
private String[] mDumpFiles;
|
||||
private String mAction;
|
||||
|
||||
public static DebugSmsMmsFromDumpFileDialogFragment newInstance(final String[] dumpFiles,
|
||||
final String action) {
|
||||
final DebugSmsMmsFromDumpFileDialogFragment frag =
|
||||
new DebugSmsMmsFromDumpFileDialogFragment();
|
||||
final Bundle args = new Bundle();
|
||||
args.putSerializable(KEY_DUMP_FILES, dumpFiles);
|
||||
args.putString(KEY_ACTION, action);
|
||||
frag.setArguments(args);
|
||||
return frag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(final Bundle savedInstanceState) {
|
||||
final Bundle args = getArguments();
|
||||
mDumpFiles = (String[]) args.getSerializable(KEY_DUMP_FILES);
|
||||
mAction = args.getString(KEY_ACTION);
|
||||
|
||||
final LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
final View layout = inflater.inflate(
|
||||
R.layout.debug_sms_mms_from_dump_file_dialog, null/*root*/);
|
||||
final ListView list = (ListView) layout.findViewById(R.id.dump_file_list);
|
||||
list.setAdapter(new DumpFileListAdapter(getActivity(), mDumpFiles));
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
final Resources resources = getResources();
|
||||
if (ACTION_LOAD.equals(mAction)) {
|
||||
builder.setTitle(resources.getString(
|
||||
R.string.load_sms_mms_from_dump_file_dialog_title));
|
||||
} else if (ACTION_EMAIL.equals(mAction)) {
|
||||
builder.setTitle(resources.getString(
|
||||
R.string.email_sms_mms_from_dump_file_dialog_title));
|
||||
}
|
||||
builder.setView(layout);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
private class DumpFileListAdapter extends ArrayAdapter<String> {
|
||||
public DumpFileListAdapter(final Context context, final String[] dumpFiles) {
|
||||
super(context, R.layout.sms_mms_dump_file_list_item, dumpFiles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, final View view, final ViewGroup parent) {
|
||||
TextView actionItemView;
|
||||
if (view == null || !(view instanceof TextView)) {
|
||||
final LayoutInflater inflater = LayoutInflater.from(getContext());
|
||||
actionItemView = (TextView) inflater.inflate(
|
||||
R.layout.sms_mms_dump_file_list_item, parent, false);
|
||||
} else {
|
||||
actionItemView = (TextView) view;
|
||||
}
|
||||
|
||||
final String file = getItem(position);
|
||||
actionItemView.setText(file);
|
||||
actionItemView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View view) {
|
||||
dismiss();
|
||||
if (ACTION_LOAD.equals(mAction)) {
|
||||
receiveFromDumpFile(file);
|
||||
} else if (ACTION_EMAIL.equals(mAction)) {
|
||||
emailDumpFile(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
return actionItemView;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load MMS/SMS from the dump file
|
||||
*/
|
||||
private void receiveFromDumpFile(final String dumpFileName) {
|
||||
if (dumpFileName.startsWith(MmsUtils.SMS_DUMP_PREFIX)) {
|
||||
final SmsMessage[] messages = DebugUtils.retreiveSmsFromDumpFile(dumpFileName);
|
||||
if (messages != null) {
|
||||
SmsReceiver.deliverSmsMessages(getActivity(), ParticipantData.DEFAULT_SELF_SUB_ID,
|
||||
0, messages);
|
||||
} else {
|
||||
LogUtil.e(LogUtil.BUGLE_TAG,
|
||||
"receiveFromDumpFile: invalid sms dump file " + dumpFileName);
|
||||
}
|
||||
} else if (dumpFileName.startsWith(MmsUtils.MMS_DUMP_PREFIX)) {
|
||||
final byte[] data = MmsUtils.createDebugNotificationInd(dumpFileName);
|
||||
if (data != null) {
|
||||
final ReceiveMmsMessageAction action = new ReceiveMmsMessageAction(
|
||||
ParticipantData.DEFAULT_SELF_SUB_ID, data);
|
||||
action.start();
|
||||
} else {
|
||||
LogUtil.e(LogUtil.BUGLE_TAG,
|
||||
"receiveFromDumpFile: invalid mms dump file " + dumpFileName);
|
||||
}
|
||||
} else {
|
||||
LogUtil.e(LogUtil.BUGLE_TAG,
|
||||
"receiveFromDumpFile: invalid dump file name " + dumpFileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch email app to send the dump file
|
||||
*/
|
||||
private void emailDumpFile(final String file) {
|
||||
final Resources resources = getResources();
|
||||
final String fileLocation = "file://"
|
||||
+ Environment.getExternalStorageDirectory() + "/" + file;
|
||||
final Intent sharingIntent = new Intent(Intent.ACTION_SEND);
|
||||
sharingIntent.setType(APPLICATION_OCTET_STREAM);
|
||||
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(fileLocation));
|
||||
sharingIntent.putExtra(Intent.EXTRA_SUBJECT,
|
||||
resources.getString(R.string.email_sms_mms_dump_file_subject));
|
||||
getActivity().startActivity(Intent.createChooser(sharingIntent,
|
||||
resources.getString(R.string.email_sms_mms_dump_file_chooser_title)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user