Merge lp:~humpolec-team/humpolec/add-updateservice into lp:humpolec

Proposed by Michał Karnicki on 2014-03-20
Status: Work in progress
Proposed branch: lp:~humpolec-team/humpolec/add-updateservice
Merge into: lp:humpolec
Diff against target: 490 lines (+277/-28)
14 files modified
AndroidManifest.xml (+29/-16)
project.properties (+1/-1)
res/layout/activity_update.xml (+7/-0)
res/layout/fragment_update.xml (+13/-0)
res/menu/update.xml (+11/-0)
res/values-w820dp/dimens.xml (+10/-0)
res/values/ids.xml (+23/-0)
res/values/strings.xml (+5/-4)
src/com/canonical/dualboot/service/UpdateService.java (+109/-0)
src/com/canonical/ubuntu/installer/NumberPickerDialog.java (+0/-5)
src/com/canonical/ubuntu/installer/TextPickerDialog.java (+0/-1)
src/com/canonical/ubuntu/installer/UbuntuInstallService.java (+5/-0)
src/com/canonical/ubuntu/installer/UpdateActivity.java (+64/-0)
src/com/canonical/ubuntu/installer/Utils.java (+0/-1)
To merge this branch: bzr merge lp:~humpolec-team/humpolec/add-updateservice
Reviewer Review Type Date Requested Status
The Humpolec team 2014-03-20 Pending
Review via email: mp+211965@code.launchpad.net

Commit message

Add UpdateService stub.

Description of the change

Add UpdateService stub.
Minor clean-up (sorry about some noise, Eclipse being smart).

To post a comment you must log in.

Unmerged revisions

61. By Michał Karnicki on 2014-03-20

Add UpdateService stub. Minor clean-up.

60. By Ondrej Kubik on 2014-03-05

Bumping up version for release

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'AndroidManifest.xml'
2--- AndroidManifest.xml 2014-03-05 15:35:14 +0000
3+++ AndroidManifest.xml 2014-03-20 15:01:59 +0000
4@@ -7,13 +7,14 @@
5 <uses-sdk
6 android:minSdkVersion="17"
7 android:targetSdkVersion="18" />
8+
9 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
10- <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
11- <uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
12- <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
13+ <uses-permission android:name="android.permission.GET_ACCOUNTS" />
14+ <uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
15+ <uses-permission android:name="android.permission.WRITE_SETTINGS" />
16 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
17- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
18- <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
19+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
20+ <uses-permission android:name="android.permission.READ_PHONE_STATE" />
21 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
22 <uses-permission android:name="android.permission.BLUETOOTH" />
23 <uses-permission android:name="android.permission.INTERNET" />
24@@ -21,8 +22,8 @@
25 <uses-permission android:name="android.permission.RECORD_AUDIO" />
26 <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
27 <uses-permission android:name="android.permission.ACCESS_CACHE_FILESYSTEM" />
28- <uses-permission android:name="android.permission.REBOOT"/>
29- <uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
30+ <uses-permission android:name="android.permission.REBOOT" />
31+ <uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
32
33 <application
34 android:allowBackup="true"
35@@ -31,9 +32,9 @@
36 android:screenOrientation="portrait"
37 android:theme="@android:style/Theme.Holo" >
38 <activity
39- android:name=".InstallActivity"
40- android:screenOrientation="portrait"
41- android:label="@string/app_name" >
42+ android:name="com.canonical.ubuntu.installer.InstallActivity"
43+ android:label="@string/app_name"
44+ android:screenOrientation="portrait" >
45 <intent-filter>
46 <action android:name="android.intent.action.MAIN" />
47
48@@ -41,12 +42,23 @@
49 </intent-filter>
50 </activity>
51 <activity
52- android:name=".LaunchActivity"
53- android:screenOrientation="portrait"
54- android:label="@string/app_name">
55- </activity>
56-
57- <service android:name="com.canonical.ubuntu.installer.UbuntuInstallService">
58+ android:name="com.canonical.ubuntu.installer.LaunchActivity"
59+ android:label="@string/app_name"
60+ android:screenOrientation="portrait" >
61+ </activity>
62+
63+ <activity
64+ android:name="com.canonical.ubuntu.installer.UpdateActivity"
65+ android:label="@string/title_activity_update" >
66+ </activity>
67+
68+ <service android:name="com.canonical.ubuntu.installer.UbuntuInstallService" >
69+ <intent-filter>
70+ <action android:name="com.canonical.dualboot.ACTION_CHECK_UPDATE" />
71+ </intent-filter>
72+ </service>
73+
74+ <service android:name="com.canonical.ubuntu.installer.UbuntuInstallService" >
75 <intent-filter>
76 <action android:name="com.canonical.ubuntuinstaller.UbuntuInstallService.GET_CHANNEL_LIST" />
77 <action android:name="com.canonical.ubuntuinstaller.UbuntuInstallService.DOWNLOAD_RELEASE" />
78@@ -65,6 +77,7 @@
79 <action android:name="com.canonical.ubuntuinstaller.UbuntuInstallService.IS_UBUNTU_UPGRADABLE" />
80 </intent-filter>
81 </service>
82+
83 </application>
84
85 </manifest>
86
87=== modified file 'project.properties'
88--- project.properties 2013-12-12 02:02:35 +0000
89+++ project.properties 2014-03-20 15:01:59 +0000
90@@ -11,4 +11,4 @@
91 #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
92
93 # Project target.
94-target=Google Inc.:Google APIs:19
95+target=android-19
96
97=== added directory 'res/drawable-ldpi'
98=== added file 'res/drawable-xhdpi/ic_stat_notify_ubuntu.png'
99Binary files res/drawable-xhdpi/ic_stat_notify_ubuntu.png 1970-01-01 00:00:00 +0000 and res/drawable-xhdpi/ic_stat_notify_ubuntu.png 2014-03-20 15:01:59 +0000 differ
100=== added file 'res/layout/activity_update.xml'
101--- res/layout/activity_update.xml 1970-01-01 00:00:00 +0000
102+++ res/layout/activity_update.xml 2014-03-20 15:01:59 +0000
103@@ -0,0 +1,7 @@
104+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
105+ xmlns:tools="http://schemas.android.com/tools"
106+ android:id="@+id/container"
107+ android:layout_width="match_parent"
108+ android:layout_height="match_parent"
109+ tools:context="com.canonical.ubuntu.installer.UpdateActivity"
110+ tools:ignore="MergeRootFrame" />
111
112=== added file 'res/layout/fragment_update.xml'
113--- res/layout/fragment_update.xml 1970-01-01 00:00:00 +0000
114+++ res/layout/fragment_update.xml 2014-03-20 15:01:59 +0000
115@@ -0,0 +1,13 @@
116+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
117+ xmlns:tools="http://schemas.android.com/tools"
118+ android:layout_width="match_parent"
119+ android:layout_height="match_parent"
120+ android:paddingBottom="@dimen/activity_vertical_margin"
121+ android:paddingLeft="@dimen/activity_horizontal_margin"
122+ android:paddingRight="@dimen/activity_horizontal_margin"
123+ android:paddingTop="@dimen/activity_vertical_margin"
124+ tools:context="com.canonical.ubuntu.installer.UpdateActivity$PlaceholderFragment" >
125+
126+ <!-- TODO -->
127+
128+</RelativeLayout>
129
130=== added file 'res/menu/update.xml'
131--- res/menu/update.xml 1970-01-01 00:00:00 +0000
132+++ res/menu/update.xml 2014-03-20 15:01:59 +0000
133@@ -0,0 +1,11 @@
134+<menu xmlns:android="http://schemas.android.com/apk/res/android"
135+ xmlns:tools="http://schemas.android.com/tools"
136+ tools:context="com.canonical.ubuntu.installer.UpdateActivity" >
137+
138+ <item
139+ android:id="@+id/action_settings"
140+ android:orderInCategory="100"
141+ android:showAsAction="never"
142+ android:title="@string/action_settings"/>
143+
144+</menu>
145
146=== added directory 'res/values-w820dp'
147=== added file 'res/values-w820dp/dimens.xml'
148--- res/values-w820dp/dimens.xml 1970-01-01 00:00:00 +0000
149+++ res/values-w820dp/dimens.xml 2014-03-20 15:01:59 +0000
150@@ -0,0 +1,10 @@
151+<resources>
152+
153+ <!--
154+ Example customization of dimensions originally defined in res/values/dimens.xml
155+ (such as screen margins) for screens with more than 820dp of available width. This
156+ would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
157+ -->
158+ <dimen name="activity_horizontal_margin">64dp</dimen>
159+
160+</resources>
161
162=== added file 'res/values/ids.xml'
163--- res/values/ids.xml 1970-01-01 00:00:00 +0000
164+++ res/values/ids.xml 2014-03-20 15:01:59 +0000
165@@ -0,0 +1,23 @@
166+<?xml version="1.0" encoding="utf-8"?>
167+<!--
168+/*
169+ * This file is part of Humpolec - Ubuntu dual boot for Android.
170+ * Copyright 2014 Canonical Ltd.
171+ *
172+ * Ubuntu for Android is free software: you can redistribute it and/or modify
173+ * it under the terms of the GNU General Public License as published by
174+ * the Free Software Foundation.
175+ *
176+ * Ubuntu for Android is distributed in the hope that it will be useful,
177+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
178+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.
179+ * See the GNU General Public License for more details.
180+ *
181+ * You should have received a copy of the GNU General Public License
182+ * along with Ubuntu for Android. If not, see <http://www.gnu.org/licenses/>.
183+ */
184+-->
185+
186+<resources>
187+ <item type="id" name="ubuntu_update_notification" />
188+</resources>
189\ No newline at end of file
190
191=== modified file 'res/values/strings.xml'
192--- res/values/strings.xml 2014-01-09 08:54:46 +0000
193+++ res/values/strings.xml 2014-03-20 15:01:59 +0000
194@@ -1,10 +1,11 @@
195 <?xml version="1.0" encoding="utf-8"?>
196 <resources>
197+
198 <string name="yes">Yes</string>
199 <string name="no">No</string>
200 <string name="ok">OK</string>
201
202- <!-- string for InstallActivity -->
203+ <!-- string for InstallActivity -->
204 <string name="app_name">Ubuntu Dual Boot</string>
205 <string name="action_settings">Settings</string>
206 <string name="action_detele_download">Delete download</string>
207@@ -39,10 +40,8 @@
208 <string name="terminal_dump_succ">Dump Terminal successfully to file on sdcard</string>
209 <string name="terminal_dump_fail">Dump Terminal failed to file on sdcard</string>
210 <string name="external_storage_unavailable">External Storage is not available</string>
211-
212 <string name="not_supported_title">Not supported</string>
213 <string name="not_supported_message_fmt">It appears that your device (%s) is not on the supported list of Ubuntu for Phone dual boot installer. Visit <a href="https://wiki.ubuntu.com/Touch/DualBootInstallation">https://wiki.ubuntu.com/Touch/DualBootInstallation</a> to see phones that is supported.</string>
214-
215 <string name="no_network_dialog_title">Network not available</string>
216 <string name="enable_network">Enable WiFi</string>
217
218@@ -56,5 +55,7 @@
219 <string-array name="uninstall_options">
220 <item>Delete user data</item>
221 </string-array>
222+
223+ <string name="title_activity_update">UpdateActivity</string>
224+
225 </resources>
226-
227
228=== added directory 'src/com/canonical/dualboot'
229=== added directory 'src/com/canonical/dualboot/service'
230=== added file 'src/com/canonical/dualboot/service/UpdateService.java'
231--- src/com/canonical/dualboot/service/UpdateService.java 1970-01-01 00:00:00 +0000
232+++ src/com/canonical/dualboot/service/UpdateService.java 2014-03-20 15:01:59 +0000
233@@ -0,0 +1,109 @@
234+/*
235+ * This file is part of Humpolec - Ubuntu dual boot for Android.
236+ * Copyright 2014 Canonical Ltd.
237+ *
238+ * Ubuntu for Android is free software: you can redistribute it and/or modify
239+ * it under the terms of the GNU General Public License as published by
240+ * the Free Software Foundation.
241+ *
242+ * Ubuntu for Android is distributed in the hope that it will be useful,
243+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
244+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.
245+ * See the GNU General Public License for more details.
246+ *
247+ * You should have received a copy of the GNU General Public License
248+ * along with Ubuntu for Android. If not, see <http://www.gnu.org/licenses/>.
249+ */
250+
251+package com.canonical.dualboot.service;
252+
253+import android.app.IntentService;
254+import android.app.Notification;
255+import android.app.NotificationManager;
256+import android.app.PendingIntent;
257+import android.content.Intent;
258+
259+import com.canonical.ubuntu.installer.R;
260+import com.canonical.ubuntu.installer.UpdateActivity;
261+
262+public class UpdateService extends IntentService {
263+ public static final String ACTION_CHECK_UPDATE =
264+ "com.canonical.dualboot.ACTION_CHECK_UPDATE";
265+
266+ private PendingIntent mDownloadUbuntuIntent;
267+ //private PendingIntent mInstallUbuntuIntent;
268+ //private PendingIntent mAndroidUpdateIntent;
269+
270+ private Notification mUbuntuUpdateNotification;
271+ //private Notification mAndroidUpdateNotification;
272+
273+ public UpdateService() {
274+ super(UpdateService.class.getName());
275+
276+
277+ Intent updateActivity = new Intent(this, UpdateActivity.class);
278+ updateActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
279+ mDownloadUbuntuIntent = PendingIntent.getActivity(
280+ this, 0, updateActivity, PendingIntent.FLAG_UPDATE_CURRENT);
281+ }
282+
283+ @Override
284+ protected void onHandleIntent(Intent intent) {
285+ final String action = intent.getAction();
286+ // TODO This should be launched from an alarm.
287+ if (ACTION_CHECK_UPDATE.equals(action)) {
288+ checkForUpdate();
289+ }
290+ }
291+
292+ private void checkForUpdate() {
293+ // TODO Determine available updates based on PreferenceManager.getDefaultSharedPreferences(this);
294+ boolean ubuntuUpdateAvailable = true;
295+ boolean androidUpdateReady = true;
296+
297+ if (ubuntuUpdateAvailable) {
298+ boolean isDownloaded = false;
299+ if (!isDownloaded) {
300+ showDownloadUbuntuUpdateNotification();
301+ } else {
302+ showInstallUbuntuUpdateNotification();
303+ }
304+ }
305+
306+ if (androidUpdateReady) {
307+ showPrepareForAndroidUpdateNotification();
308+ }
309+ }
310+
311+ private void showDownloadUbuntuUpdateNotification() {
312+ // TODO Extract strings.
313+ Notification notification = new Notification.Builder(this)
314+ .setAutoCancel(true)
315+ .setSmallIcon(R.drawable.ic_stat_notify_ubuntu)
316+ .setContentTitle("Ubuntu")
317+ .setContentText("Ubuntu update available")
318+ .setTicker("Ubuntu update available")
319+ .setContentIntent(mDownloadUbuntuIntent)
320+ .build();
321+
322+ NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
323+ nm.notify(R.id.ubuntu_update_notification, notification);
324+ }
325+
326+ private void showInstallUbuntuUpdateNotification() {
327+ // TODO Add show install Ubuntu update notification.
328+ }
329+
330+ private void showPrepareForAndroidUpdateNotification() {
331+ // TODO Add show prepare for Android update notification.
332+ }
333+
334+ @SuppressWarnings("unused")
335+ private synchronized void hideUbuntuNotification() {
336+ if (mUbuntuUpdateNotification != null) {
337+ NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
338+ nm.cancel(R.id.ubuntu_update_notification);
339+ }
340+ mUbuntuUpdateNotification = null;
341+ }
342+}
343\ No newline at end of file
344
345=== modified file 'src/com/canonical/ubuntu/installer/NumberPickerDialog.java'
346--- src/com/canonical/ubuntu/installer/NumberPickerDialog.java 2013-12-13 01:06:14 +0000
347+++ src/com/canonical/ubuntu/installer/NumberPickerDialog.java 2014-03-20 15:01:59 +0000
348@@ -1,19 +1,14 @@
349 package com.canonical.ubuntu.installer;
350
351-import com.canonical.ubuntu.installer.R;
352-
353 import android.app.AlertDialog;
354 import android.content.Context;
355 import android.content.DialogInterface;
356-import android.content.SharedPreferences;
357 import android.content.DialogInterface.OnClickListener;
358 import android.content.res.Resources;
359 import android.os.Bundle;
360 import android.view.LayoutInflater;
361 import android.view.View;
362-import android.widget.CheckBox;
363 import android.widget.NumberPicker;
364-import android.widget.TextView;
365
366 /**
367 * A text picker dialog that prompts the user for to select one of the text options
368
369=== modified file 'src/com/canonical/ubuntu/installer/TextPickerDialog.java'
370--- src/com/canonical/ubuntu/installer/TextPickerDialog.java 2013-12-13 01:06:14 +0000
371+++ src/com/canonical/ubuntu/installer/TextPickerDialog.java 2014-03-20 15:01:59 +0000
372@@ -13,7 +13,6 @@
373 import android.view.View;
374 import android.widget.CheckBox;
375 import android.widget.NumberPicker;
376-import android.widget.TextView;
377
378 /**
379 * A text picker dialog that prompts the user for to select one of the text options
380
381=== modified file 'src/com/canonical/ubuntu/installer/UbuntuInstallService.java'
382--- src/com/canonical/ubuntu/installer/UbuntuInstallService.java 2014-01-06 15:07:12 +0000
383+++ src/com/canonical/ubuntu/installer/UbuntuInstallService.java 2014-03-20 15:01:59 +0000
384@@ -199,6 +199,7 @@
385 };
386
387 class ECancelException extends Exception {
388+ private static final long serialVersionUID = 747982425589853525L;
389 long mDownloadedSize;
390
391 public ECancelException(long downloadedSize){
392@@ -208,6 +209,8 @@
393 };
394
395 class ESumNotMatchException extends Exception {
396+ private static final long serialVersionUID = -1356096284689475876L;
397+
398 public ESumNotMatchException(){
399 super();
400 }
401@@ -218,6 +221,8 @@
402 };
403
404 class EShellExecException extends Exception {
405+ private static final long serialVersionUID = -9010009907016301558L;
406+
407 public EShellExecException(){
408 super();
409 }
410
411=== added file 'src/com/canonical/ubuntu/installer/UpdateActivity.java'
412--- src/com/canonical/ubuntu/installer/UpdateActivity.java 1970-01-01 00:00:00 +0000
413+++ src/com/canonical/ubuntu/installer/UpdateActivity.java 2014-03-20 15:01:59 +0000
414@@ -0,0 +1,64 @@
415+package com.canonical.ubuntu.installer;
416+
417+import android.app.Activity;
418+import android.app.ActionBar;
419+import android.app.Fragment;
420+import android.os.Bundle;
421+import android.view.LayoutInflater;
422+import android.view.Menu;
423+import android.view.MenuItem;
424+import android.view.View;
425+import android.view.ViewGroup;
426+import android.os.Build;
427+
428+public class UpdateActivity extends Activity {
429+
430+ @Override
431+ protected void onCreate(Bundle savedInstanceState) {
432+ super.onCreate(savedInstanceState);
433+ setContentView(R.layout.activity_update);
434+
435+ if (savedInstanceState == null) {
436+ getFragmentManager().beginTransaction()
437+ .add(R.id.container, new PlaceholderFragment()).commit();
438+ }
439+ }
440+
441+ @Override
442+ public boolean onCreateOptionsMenu(Menu menu) {
443+
444+ // Inflate the menu; this adds items to the action bar if it is present.
445+ getMenuInflater().inflate(R.menu.update, menu);
446+ return true;
447+ }
448+
449+ @Override
450+ public boolean onOptionsItemSelected(MenuItem item) {
451+ // Handle action bar item clicks here. The action bar will
452+ // automatically handle clicks on the Home/Up button, so long
453+ // as you specify a parent activity in AndroidManifest.xml.
454+ int id = item.getItemId();
455+ if (id == R.id.action_settings) {
456+ return true;
457+ }
458+ return super.onOptionsItemSelected(item);
459+ }
460+
461+ /**
462+ * A placeholder fragment containing a simple view.
463+ */
464+ public static class PlaceholderFragment extends Fragment {
465+
466+ public PlaceholderFragment() {
467+ }
468+
469+ @Override
470+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
471+ Bundle savedInstanceState) {
472+ View rootView = inflater.inflate(R.layout.fragment_update,
473+ container, false);
474+ return rootView;
475+ }
476+ }
477+
478+}
479
480=== modified file 'src/com/canonical/ubuntu/installer/Utils.java'
481--- src/com/canonical/ubuntu/installer/Utils.java 2014-01-09 08:54:46 +0000
482+++ src/com/canonical/ubuntu/installer/Utils.java 2014-03-20 15:01:59 +0000
483@@ -180,7 +180,6 @@
484 return size;
485 }
486
487- @SuppressWarnings("deprecation")
488 public static long getFreeSpaceInBytes(String fsPath) {
489 StatFs stats = new StatFs(fsPath);
490 // not using getAvailableBytes() for it's not available in android 4.2

Subscribers

People subscribed via source and target branches

to all changes: