packages/apps/TSCalibration2
Revision | 19a2a71e348d42381d9cb781a2dd9cf406e76ce1 (tree) |
---|---|
Zeit | 2010-05-14 17:37:32 |
Autor | Kan-Ru Chen <kanru@0xla...> |
Commiter | Kan-Ru Chen |
[TSCalibration2] Mimic the Launcher to become the first Activity after boot.
Use the trick to mimic the Launcher by listen to the HOME intent, once
the Calibration is done we unregister the startup activity from
package manager. Set the priority at very high value to ensure we are
the first activity.
Change-Id: I528629d5f91b31a31120f5d6f11df16296bcae61
@@ -19,30 +19,23 @@ limitations under the License. | ||
19 | 19 | package="org.zeroxlab.util.tscal" |
20 | 20 | android:sharedUserId="android.uid.system"> |
21 | 21 | <uses-permission android:name="android.permission.SET_ALWAYS_FINISH" /> |
22 | - <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | |
23 | - | |
24 | 22 | <application android:icon="@drawable/icon" android:label="@string/app_name"> |
25 | - | |
26 | 23 | <activity android:name=".TSCalibration" |
27 | 24 | android:label="Calibration" |
25 | + android:launchMode="standard" | |
28 | 26 | android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" |
29 | 27 | android:configChanges="keyboard|keyboardHidden|navigation|orientation"> |
30 | - | |
31 | 28 | <intent-filter> |
32 | 29 | <action android:name="android.intent.action.MAIN" /> |
33 | 30 | <category android:name="android.intent.category.LAUNCHER" /> |
34 | 31 | </intent-filter> |
35 | - | |
36 | 32 | </activity> |
37 | - | |
38 | - <receiver android:name="StartupIntentReceiver" > | |
39 | - | |
40 | - <intent-filter> | |
41 | - <action android:name="android.intent.action.BOOT_COMPLETED" /> | |
33 | + <activity android:name=".TSCalibrationStartup"> | |
34 | + <intent-filter android:priority="100"> | |
35 | + <action android:name="android.intent.action.MAIN" /> | |
42 | 36 | <category android:name="android.intent.category.HOME" /> |
37 | + <category android:name="android.intent.category.DEFAULT" /> | |
43 | 38 | </intent-filter> |
44 | - | |
45 | - </receiver> | |
46 | - | |
39 | + </activity> | |
47 | 40 | </application> |
48 | 41 | </manifest> |
@@ -60,7 +60,8 @@ public class TSCalibration extends Activity { | ||
60 | 60 | { |
61 | 61 | if (mTSCalibrationView.isFinished()) { |
62 | 62 | mTSCalibrationView.dumpCalData(FILE); |
63 | - this.finish(); | |
63 | + setResult(0); | |
64 | + finish(); | |
64 | 65 | } else { |
65 | 66 | setContentView(mTSCalibrationView); |
66 | 67 | } |
@@ -15,24 +15,37 @@ | ||
15 | 15 | */ |
16 | 16 | package org.zeroxlab.util.tscal; |
17 | 17 | |
18 | -import android.content.BroadcastReceiver; | |
18 | +import android.app.Activity; | |
19 | +import android.content.ComponentName; | |
19 | 20 | import android.content.Context; |
20 | 21 | import android.content.Intent; |
21 | -import android.util.Log; | |
22 | +import android.content.pm.PackageManager; | |
23 | +import android.os.Bundle; | |
22 | 24 | |
23 | 25 | import java.io.File; |
24 | 26 | |
25 | -// Added to allow for automatic startup | |
26 | -public class StartupIntentReceiver extends BroadcastReceiver { | |
27 | +public class TSCalibrationStartup extends Activity { | |
27 | 28 | |
28 | 29 | private static String cal_path = "/data/misc/tscal/pointercal"; |
29 | 30 | |
30 | - @Override public void onReceive(Context context, Intent intent) { | |
31 | + | |
32 | + @Override | |
33 | + public void onCreate(Bundle savedInstanceState) { | |
34 | + super.onCreate(savedInstanceState); | |
31 | 35 | File calFile = new File(cal_path); |
32 | 36 | if (!calFile.exists()) { |
33 | - Intent starterIntent = new Intent(context, TSCalibration.class); | |
34 | - starterIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
35 | - context.startActivity(starterIntent); | |
37 | + Intent starterIntent = new Intent(this, TSCalibration.class); | |
38 | + startActivityForResult(starterIntent, 0); | |
36 | 39 | } |
37 | 40 | } |
41 | + | |
42 | + @Override | |
43 | + protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
44 | + super.onActivityResult(requestCode, resultCode, data); | |
45 | + // remove this activity from the package manager. | |
46 | + PackageManager pm = getPackageManager(); | |
47 | + ComponentName name = new ComponentName(this, TSCalibrationStartup.class); | |
48 | + pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); | |
49 | + finish(); | |
50 | + } | |
38 | 51 | } |