1414import android .support .v7 .app .AlertDialog ;
1515import android .support .v7 .app .AppCompatActivity ;
1616import android .util .Log ;
17+ import android .view .LayoutInflater ;
1718import android .view .View ;
1819import android .widget .Button ;
1920import android .widget .TextView ;
@@ -81,7 +82,12 @@ public void run() {
8182 mHandler .post (new Runnable () {
8283 @ Override
8384 public void run () {
84- notifyManualInstallationRequired ();
85+ File externalStorageDirectory =
86+ Environment .getExternalStorageDirectory ();
87+ File targetFile = new File (externalStorageDirectory ,
88+ EXEC_PAYLOAD_NAME );
89+ notifyManualInstallationRequired (
90+ targetFile .getAbsolutePath ());
8591 }
8692 });
8793 } catch (final ManualInstallationException e ) {
@@ -109,9 +115,16 @@ private String getStackTraceString(Exception e) {
109115 return result .toString ();
110116 }
111117
112- private void notifyManualInstallationRequired () {
118+ private void notifyManualInstallationRequired (String fileExternalStorageDirLocation ) {
119+ LayoutInflater inflater = LayoutInflater .from (this );
120+ View manualInstallationView = inflater .inflate
121+ (R .layout .dialog_manual_payload_installation , null );
122+ TextView copyCommandTextView = manualInstallationView .findViewById (R .id .copy_command );
123+ copyCommandTextView .setText (
124+ getString (R .string .copy_command_text , fileExternalStorageDirLocation ));
125+
113126 new AlertDialog .Builder (this )
114- .setView (R . layout . dialog_manual_payload_installation )
127+ .setView (manualInstallationView )
115128 .setTitle (R .string .alert_title )
116129 .setPositiveButton (R .string .ok , new DialogInterface .OnClickListener () {
117130 @ Override
@@ -125,12 +138,13 @@ public void onClick(DialogInterface dialogInterface, int i) {
125138 private void prepareManualInstallation () throws ManualInstallationException {
126139 File execPayloadFile = new File (getFilesDir (), EXEC_PAYLOAD_NAME );
127140 if (execPayloadFile .exists ()) {
128- File targetFile = new File (Environment .getExternalStorageDirectory ().getPath (),
129- EXEC_PAYLOAD_NAME );
130- if (!targetFile .canWrite ()) {
141+ File externalStorageDirectory = Environment .getExternalStorageDirectory ();
142+ if (!externalStorageDirectory .canWrite ()) {
131143 throw new ManualInstallationException (
132144 "Unable to create file on SD card, check SD card permissions!" );
133145 }
146+
147+ File targetFile = new File (externalStorageDirectory , EXEC_PAYLOAD_NAME );
134148 try {
135149 FileUtils .copyFile (execPayloadFile , targetFile );
136150 } catch (IOException e ) {
0 commit comments