Subject: [PATCH] add recovery password dialog
---
.../Settings/res/layout/PwdDialog.xml | 32 +++++++++++++
.../Settings/res/values/strings_hi.xml | 3 ++
.../com/android/tv/settings/MainFragment.java | 1 +
.../device/storage/ResetActivity.java | 47 ++++++++++++++++++-
4 files changed, 82 insertions(+), 1 deletion(-)
create mode 100755 apps/TvSettings/Settings/res/layout/PwdDialog.xml
diff --git a/apps/TvSettings/Settings/res/layout/PwdDialog.xml b/apps/TvSettings/Settings/res/layout/PwdDialog.xml
new file mode 100755
index 00000000..cb3f29ce
--- /dev/null
+++ b/apps/TvSettings/Settings/res/layout/PwdDialog.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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
+
+ www.apache.org/licenses/LI…
+
+ 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.
+-->
+<RelativeLayout xmlns:android="schemas.android.com/apk/res/and…"
+ android:id="@+id/pwdDialog"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <EditText
+ android:id="@+id/pwd_edit"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="21dp"
+ android:layout_marginEnd="24dp"
+ android:layout_marginTop="20dp"
+ android:minHeight="48dp"
+ android:inputType="textPassword"
+ android:singleLine="true" />
+
+</RelativeLayout>
diff --git a/apps/TvSettings/Settings/res/values/strings_hi.xml b/apps/TvSettings/Settings/res/values/strings_hi.xml
index 85300c57..72edee52 100755
--- a/apps/TvSettings/Settings/res/values/strings_hi.xml
+++ b/apps/TvSettings/Settings/res/values/strings_hi.xml
@@ -443,5 +443,8 @@
<string name="device_rotation_90">90</string>
<string name="device_rotation_180">180</string>
<string name="device_rotation_270">270</string>
+
+ <string name="dialog_pwd_tips">\u0020\u0020\u0020\u0020 Please Input Your Password !</string>
+ <string name="pwd_error">Password Error!</string>
</resources>
diff --git a/apps/TvSettings/Settings/src/com/android/tv/settings/MainFragment.java b/apps/TvSettings/Settings/src/com/android/tv/settings/MainFragment.java
index b2a4e67d..2db920cd 100755
--- a/apps/TvSettings/Settings/src/com/android/tv/settings/MainFragment.java
+++ b/apps/TvSettings/Settings/src/com/android/tv/settings/MainFragment.java
@@ -240,6 +240,7 @@ public class MainFragment extends PreferenceControllerFragment implements
accountsPref.setVisible(false);
}
}
+ findPreference(KEY_APPLICATIONS).setVisible(false);
Preference accessoryPreference = findPreference(KEY_ACCESSORIES);
if (accessoryPreference != null) {
accessoryPreference.setVisible(false);
diff --git a/apps/TvSettings/Settings/src/com/android/tv/settings/device/storage/ResetActivity.java b/apps/TvSettings/Settings/src/com/android/tv/settings/device/storage/ResetActivity.java
index d989b082..15f883f2 100644
--- a/apps/TvSettings/Settings/src/com/android/tv/settings/device/storage/ResetActivity.java
+++ b/apps/TvSettings/Settings/src/com/android/tv/settings/device/storage/ResetActivity.java
@@ -19,6 +19,15 @@ package com.android.tv.settings.device.storage;
import android.annotation.Nullable;
import android.app.Activity;
import android.app.ActivityManager;
+import android.app.AlertDialog;
+import android.view.View;
+import android.widget.Toast;
+import android.widget.EditText;
+import android.view.LayoutInflater;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnCancelListener;
+import android.content.DialogInterface.OnClickListener;
+import android.content.DialogInterface.OnKeyListener;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
@@ -34,6 +43,7 @@ import java.util.List;
public class ResetActivity extends Activity {
private static final String TAG = "ResetActivity";
+ private static final String PWSSORD = "88888888";
/**
* Support for shutdown-after-reset. If our launch intent has a true value for
@@ -47,7 +57,42 @@ public class ResetActivity extends Activity {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
- GuidedStepFragment.addAsRoot(this, ResetFragment.newInstance(), android.R.id.content);
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ //builder.setMessage(R.string.dialog_summary_virtual_screen);
+ //builder.setMessage("setMessage");
+ builder.setTitle(R.string.dialog_pwd_tips);
+ View view = LayoutInflater.from(this).inflate(R.layout.PwdDialog, null);
+ builder.setView(view);
+ final EditText password = (EditText)view.findViewById(R.id.pwd_edit);
+
+ builder.setPositiveButton(R.string.sure, new OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ String passwd = password.getText().toString().trim();
+ if(PWSSORD.equals(passwd)) {
+ GuidedStepFragment.addAsRoot(ResetActivity.this, ResetFragment.newInstance(), android.R.id.content);
+ } else {
+ Toast.makeText(ResetActivity.this, getString(R.string.pwd_error), Toast.LENGTH_SHORT).show();
+ ResetActivity.this.finish();
+ }
+ }
+ });
+ builder.setNegativeButton(R.string.cancel, null);
+ /* builder.setOnDismissListener(
+ new DialogInterface.OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ ResetActivity.this.finish();
+ }
+ });
+ */
+ AlertDialog alertDialog = builder.create();
+ alertDialog.show();
+
+ //alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).requestFocus();
+ password.requestFocus();
+
+
+
}
}
-- diff --git a/apps/PackageInstaller/src/com/android/packageinstaller/InstallStaging.java b/apps/PackageInstaller/src/com/android/packageinstaller/InstallStaging.java
index f543971a..83eb7ba3 100644
--- a/apps/PackageInstaller/src/com/android/packageinstaller/InstallStaging.java
+++ b/apps/PackageInstaller/src/com/android/packageinstaller/InstallStaging.java
@@ -56,6 +56,14 @@ public class InstallStaging extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.install_staging);
+ String uriPath = getIntent().getData().toString();
+ if(uriPath != null) {
+ Log.w(LOG_TAG, "aaaaa apk path from "+uriPath);
+ if(uriPath.contains("/storage/sd")) {
+ setResult(RESULT_CANCELED);
+ finish();
+ }
+ }
if (savedInstanceState != null) {
mStagedFile = new File(savedInstanceState.getString(STAGED_FILE));